From 110821a92c6f2cf2af114d99043d40e15ab9c4dd Mon Sep 17 00:00:00 2001 From: shananas Date: Thu, 16 Jan 2025 17:35:34 -0500 Subject: [PATCH 1/4] Better Detect Install for Steam If the user had a folder with the same name as where 1.5 2.5 or 2.8 were installed it would say it is a valid install even if the folder is empty. this checks that .dll that lets you press the next button exists in that folder first. EGS detect game install seems to be a little more specific and i do not have the EGS version to test so i did not edit that code. --- OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs index c554255bc..6f77a03bf 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs @@ -809,12 +809,12 @@ public SetupWizardViewModel() { string kH1525Path = Path.Combine(commonGamesDirectory, @"KINGDOM HEARTS -HD 1.5+2.5 ReMIX-"); string kH28Path = Path.Combine(commonGamesDirectory, @"KINGDOM HEARTS HD 2.8 Final Chapter Prologue"); - if (Directory.Exists(kH1525Path)) + if (File.Exists(Path.Combine(kH1525Path, "steam_api64.dll"))) { installLocationFoundRemix = true; PcReleaseLocation = kH1525Path; } - if (Directory.Exists(kH28Path)) + if (File.Exists(Path.Combine(kH28Path, "steam_api64.dll"))) { installLocationFound3D = true; PcReleaseLocationKH3D = kH28Path; From dd933123c6c9997dbd8f5aae041973caf42cf1d9 Mon Sep 17 00:00:00 2001 From: shananas Date: Thu, 16 Jan 2025 20:17:45 -0500 Subject: [PATCH 2/4] Detect EGS install also checks for the .dll that lets the user press next --- .../ViewModels/SetupWizardViewModel.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs index 6f77a03bf..784e0d01c 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs @@ -726,12 +726,15 @@ public SetupWizardViewModel() { if (line.Contains("\"InstallLocation\": \"")) { - installLocationFoundRemix = true; int startIndex = line.IndexOf("\": \"") + 4; int endIndex = line.IndexOf("\","); string parsedText = line[startIndex..endIndex]; parsedText = parsedText.Replace("\\\\", "\\"); PcReleaseLocation = parsedText; + if (File.Exists(Path.Combine(PcReleaseLocation, "EOSSDK-Win64-Shipping.dll"))) + { + installLocationFoundRemix = true; + } } } } @@ -741,12 +744,15 @@ public SetupWizardViewModel() { if (line.Contains("\"InstallLocation\": \"")) { - installLocationFound3D = true; int startIndex = line.IndexOf("\": \"") + 4; int endIndex = line.IndexOf("\","); string parsedText = line[startIndex..endIndex]; parsedText = parsedText.Replace("\\\\", "\\"); PcReleaseLocationKH3D = parsedText; + if (File.Exists(Path.Combine(PcReleaseLocationKH3D, "EOSSDK-Win64-Shipping.dll"))) + { + installLocationFound3D = true; + } } } } From caf1f43695ed87f9de61fa6661987b2e92e234bf Mon Sep 17 00:00:00 2001 From: shananas Date: Fri, 17 Jan 2025 05:04:21 -0500 Subject: [PATCH 3/4] remove Lua54.dll since it no longer exists --- OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs index 784e0d01c..c7b7f4a84 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs @@ -527,13 +527,11 @@ public bool IsLuaBackendInstalled if (PcReleaseLocation != null && GameCollection == 0) { return File.Exists(Path.Combine(PcReleaseLocation, "LuaBackend.dll")) && - File.Exists(Path.Combine(PcReleaseLocation, "lua54.dll")) && File.Exists(Path.Combine(PcReleaseLocation, "LuaBackend.toml")); } else if (PcReleaseLocationKH3D != null && GameCollection == 1) { return File.Exists(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.dll")) && - File.Exists(Path.Combine(PcReleaseLocationKH3D, "lua54.dll")) && File.Exists(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.toml")); } else @@ -1063,7 +1061,6 @@ public SetupWizardViewModel() else { File.Move(Path.Combine(TempExtractionLocation, "DBGHELP.dll"), Path.Combine(DestinationCollection, "LuaBackend.dll"), true); - File.Move(Path.Combine(TempExtractionLocation, "lua54.dll"), Path.Combine(DestinationCollection, "lua54.dll"), true); File.Move(Path.Combine(TempExtractionLocation, "LuaBackend.toml"), Path.Combine(DestinationCollection, "LuaBackend.toml"), true); string config = File.ReadAllText(Path.Combine(DestinationCollection, "LuaBackend.toml")).Replace("\\", "/").Replace("\\\\", "/"); if (LuaScriptPaths.Contains("kh1") && GameCollection == 0) @@ -1289,13 +1286,11 @@ public SetupWizardViewModel() if (GameCollection == 0) { File.Delete(Path.Combine(PcReleaseLocation, "LuaBackend.dll")); - File.Delete(Path.Combine(PcReleaseLocation, "lua54.dll")); File.Delete(Path.Combine(PcReleaseLocation, "LuaBackend.toml")); } else if (GameCollection == 1) { File.Delete(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.dll")); - File.Delete(Path.Combine(PcReleaseLocationKH3D, "lua54.dll")); File.Delete(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.toml")); } OnPropertyChanged(nameof(IsLuaBackendInstalled)); From 4e47324ec1e4f96a2813635908c729584f8381fd Mon Sep 17 00:00:00 2001 From: shananas Date: Fri, 17 Jan 2025 05:12:45 -0500 Subject: [PATCH 4/4] Prevent crashing in the event Lua Backend files change again --- .../ViewModels/SetupWizardViewModel.cs | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs index c7b7f4a84..81006e4c6 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs @@ -1060,35 +1060,41 @@ public SetupWizardViewModel() } else { - File.Move(Path.Combine(TempExtractionLocation, "DBGHELP.dll"), Path.Combine(DestinationCollection, "LuaBackend.dll"), true); - File.Move(Path.Combine(TempExtractionLocation, "LuaBackend.toml"), Path.Combine(DestinationCollection, "LuaBackend.toml"), true); - string config = File.ReadAllText(Path.Combine(DestinationCollection, "LuaBackend.toml")).Replace("\\", "/").Replace("\\\\", "/"); - if (LuaScriptPaths.Contains("kh1") && GameCollection == 0) + if(File.Exists((Path.Combine(TempExtractionLocation, "DBGHELP.dll")))) { - int index = config.IndexOf("true }", config.IndexOf("[kh1]")) + 6; - config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "kh1/scripts\" , relative = false}").Replace("\\", "/")); + File.Move(Path.Combine(TempExtractionLocation, "DBGHELP.dll"), Path.Combine(DestinationCollection, "LuaBackend.dll"), true); } - if (LuaScriptPaths.Contains("kh2") && GameCollection == 0) + if (File.Exists(Path.Combine(TempExtractionLocation, "LuaBackend.toml"))) { - int index = config.IndexOf("true }", config.IndexOf("[kh2]")) + 6; - config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "kh2/scripts\" , relative = false}").Replace("\\", "/")); - } - if (LuaScriptPaths.Contains("bbs") && GameCollection == 0) - { - int index = config.IndexOf("true }", config.IndexOf("[bbs]")) + 6; - config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "bbs/scripts\" , relative = false}").Replace("\\", "/")); - } - if (LuaScriptPaths.Contains("Recom") && GameCollection == 0) - { - int index = config.IndexOf("true }", config.IndexOf("[recom]")) + 6; - config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "Recom/scripts\" , relative = false}").Replace("\\", "/")); - } - if (LuaScriptPaths.Contains("kh3d") && GameCollection == 1) - { - int index = config.IndexOf("true }", config.IndexOf("[kh3d]")) + 6; - config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "kh3d/scripts\" , relative = false}").Replace("\\", "/")); + File.Move(Path.Combine(TempExtractionLocation, "LuaBackend.toml"), Path.Combine(DestinationCollection, "LuaBackend.toml"), true); + string config = File.ReadAllText(Path.Combine(DestinationCollection, "LuaBackend.toml")).Replace("\\", "/").Replace("\\\\", "/"); + if (LuaScriptPaths.Contains("kh1") && GameCollection == 0) + { + int index = config.IndexOf("true }", config.IndexOf("[kh1]")) + 6; + config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "kh1/scripts\" , relative = false}").Replace("\\", "/")); + } + if (LuaScriptPaths.Contains("kh2") && GameCollection == 0) + { + int index = config.IndexOf("true }", config.IndexOf("[kh2]")) + 6; + config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "kh2/scripts\" , relative = false}").Replace("\\", "/")); + } + if (LuaScriptPaths.Contains("bbs") && GameCollection == 0) + { + int index = config.IndexOf("true }", config.IndexOf("[bbs]")) + 6; + config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "bbs/scripts\" , relative = false}").Replace("\\", "/")); + } + if (LuaScriptPaths.Contains("Recom") && GameCollection == 0) + { + int index = config.IndexOf("true }", config.IndexOf("[recom]")) + 6; + config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "Recom/scripts\" , relative = false}").Replace("\\", "/")); + } + if (LuaScriptPaths.Contains("kh3d") && GameCollection == 1) + { + int index = config.IndexOf("true }", config.IndexOf("[kh3d]")) + 6; + config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "kh3d/scripts\" , relative = false}").Replace("\\", "/")); + } + File.WriteAllText(Path.Combine(DestinationCollection, "LuaBackend.toml"), config); } - File.WriteAllText(Path.Combine(DestinationCollection, "LuaBackend.toml"), config); File.Delete(DownPath); Directory.Delete(TempExtractionLocation); OnPropertyChanged(nameof(IsLuaBackendInstalled));