Skip to content

Commit

Permalink
Automatically save changed settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sabihoshi committed Apr 30, 2021
1 parent 64932c3 commit 5e55ff4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 45 deletions.
5 changes: 0 additions & 5 deletions GenshinLauncher/Bootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Navigation;
using GenshinLauncher.ViewModels;
using Stylet;
Expand All @@ -24,10 +23,6 @@ protected override void Configure()
});
})
);

if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
{
}
}
}
}
35 changes: 8 additions & 27 deletions GenshinLauncher/Config.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
namespace GenshinLauncher {


// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Config {

public Config() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}

private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}

private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
using System.ComponentModel;

namespace GenshinLauncher
{
internal sealed partial class Config
{
protected override void OnPropertyChanged(object sender, PropertyChangedEventArgs e) => Save();
}
}
}
2 changes: 1 addition & 1 deletion GenshinLauncher/GenshinLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<RepositoryUrl>https://github.com/sabihoshi/GenshinLauncher</RepositoryUrl>
<Description>A Genshin Impact launcher with more options in Modern Fluent UI.</Description>
<ApplicationIcon>GenshinImpactIcon.ico</ApplicationIcon>
<Version>1.1.0</Version>
<Version>1.1.0.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
19 changes: 7 additions & 12 deletions GenshinLauncher/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,25 @@ public MainWindowViewModel()

public Resolution Resolution { get; set; }

public string Title { get; } = "Genshin Impact Launcher";

[UserScopedSetting]
public string GenshinLocation { get; set; } =
@"C:\Program Files\Genshin Impact\Genshin Impact Game\GenshinImpact.exe";

public string Title { get; } = "Genshin Impact Launcher";

public async Task<CommandResult> LaunchSelector() =>
await Client.WithArguments("-show-screen-selector")
.ExecuteAsync();

protected override void OnClose()
{
Config.Default.Save();
}
.ExecuteAsync();

public void LaunchGame()
{
var client = Client
.WithArguments(args =>
.WithArguments(args =>
{
args
.Add("-screen-width").Add(Resolution.Width)
.Add("-screen-height").Add(Resolution.Height)
.Add("-screen-fullscreen").Add(Config.Default.Fullscreen ? 1 : 0);
.Add("-screen-width").Add(Resolution.Width)
.Add("-screen-height").Add(Resolution.Height)
.Add("-screen-fullscreen").Add(Config.Default.Fullscreen ? 1 : 0);

if (Config.Default.Borderless)
args.Add("-popupwindow");
Expand Down

0 comments on commit 5e55ff4

Please sign in to comment.