Skip to content

Commit

Permalink
Synchronize methods to load game config
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Jan 2, 2023
1 parent 9048b9b commit 481a46e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private async void StartLoadedRoutine(object sender, RoutedEventArgs e)
{
try
{
GameDirPath = NormalizePath(await LoadGameConfig());
GameDirPath = NormalizePath(LoadGameConfig());

GetCurrentGameState();

Expand Down Expand Up @@ -685,7 +685,7 @@ private async void InstallGameDialog(object sender, RoutedEventArgs e)
catch (TaskCanceledException)
{
LogWriteLine($"Installation cancelled for game {CurrentConfigV2.ZoneFullname}");
}
}
catch (OperationCanceledException)
{
LogWriteLine($"Installation cancelled for game {CurrentConfigV2.ZoneFullname}");
Expand Down Expand Up @@ -1016,7 +1016,7 @@ private async void StartGame(object sender, RoutedEventArgs e)
Process proc = new Process();
proc.StartInfo.FileName = Path.Combine(NormalizePath(gameIni.Profile["launcher"]["game_install_path"].ToString()), CurrentConfigV2.GameExecutableName);
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Arguments = await GetLaunchArguments();
proc.StartInfo.Arguments = GetLaunchArguments();
LogWriteLine($"Running game with parameters:\r\n{proc.StartInfo.Arguments}");
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(NormalizePath(gameIni.Profile["launcher"]["game_install_path"].ToString()));
proc.StartInfo.Verb = "runas";
Expand Down
4 changes: 2 additions & 2 deletions Hi3Helper.Core/Classes/Shared/Region/Config/GameConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -600,15 +600,15 @@ public static string ConvertByteToString(byte value)

#region LaunchArgumentBuilder

public static async Task<string> GetLaunchArguments()
public static string GetLaunchArguments()
{
StringBuilder parameter = new StringBuilder();

if (IsRegKeyExist)
{
if (!(CurrentConfigV2.IsGenshin ?? false))
{
await Task.Run(CheckExistingGameSettings);
CheckExistingGameSettings();

if (GetGameConfigValue("FullscreenExclusive").ToBool())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Hi3Helper.Data;
using System;
using System.IO;
using System.Threading.Tasks;
using static Hi3Helper.Data.ConverterTool;
using static Hi3Helper.Logger;
using static Hi3Helper.Shared.Region.GameConfig;
Expand Down Expand Up @@ -33,7 +32,7 @@ public static void PrepareGameConfig()
BuildGameIniConfig();
}

public static async Task<string> LoadGameConfig()
public static string LoadGameConfig()
{
try
{
Expand All @@ -44,7 +43,7 @@ public static async Task<string> LoadGameConfig()
gameIni.Config.Load(gameIni.ConfigPath);

if (Directory.Exists(GamePath))
await Task.Run(CheckExistingGameSettings);
CheckExistingGameSettings();

return GamePath;
}
Expand Down

0 comments on commit 481a46e

Please sign in to comment.