From 38d9b3d69e2f1a12d626e62fd201b71d11a39f78 Mon Sep 17 00:00:00 2001 From: shananas Date: Wed, 17 Jan 2024 13:34:06 -0500 Subject: [PATCH 01/13] Inital KH3D backend support --- .../Services/ConfigurationService.cs | 34 ++++++++++ .../ViewModels/MainViewModel.cs | 43 +++++++++++-- .../ViewModels/SetupWizardViewModel.cs | 62 ++++++++++++++++++- .../Views/MainWindow.xaml | 1 + 4 files changed, 133 insertions(+), 7 deletions(-) diff --git a/OpenKh.Tools.ModsManager/Services/ConfigurationService.cs b/OpenKh.Tools.ModsManager/Services/ConfigurationService.cs index cf528f717..957404c61 100644 --- a/OpenKh.Tools.ModsManager/Services/ConfigurationService.cs +++ b/OpenKh.Tools.ModsManager/Services/ConfigurationService.cs @@ -34,6 +34,7 @@ private class Config public string OpenKhGameEngineLocation { get; internal set; } public string Pcsx2Location { get; internal set; } public string PcReleaseLocation { get; internal set; } + public string PcReleaseLocationKH3D { get; internal set; } public string PcReleaseLanguage { get; internal set; } = "en"; public int RegionId { get; internal set; } public bool PanaceaInstalled { get; internal set; } @@ -70,6 +71,7 @@ public static Config Open(string fileName) private static string EnabledModsPathKH2 = Path.Combine(StoragePath, "mods-KH2.txt"); private static string EnabledModsPathBBS = Path.Combine(StoragePath, "mods-BBS.txt"); private static string EnabledModsPathRECOM = Path.Combine(StoragePath, "mods-ReCoM.txt"); + private static string EnabledModsPathKH3D = Path.Combine(StoragePath, "mods-KH3D.txt"); private static readonly Config _config = Config.Open(ConfigPath); public static string PresetPath = Path.Combine(StoragePath, "presets"); @@ -84,6 +86,8 @@ static ConfigurationService() Directory.CreateDirectory(Path.Combine(modsPath, "bbs")); if (!Directory.Exists(Path.Combine(modsPath, "Recom"))) Directory.CreateDirectory(Path.Combine(modsPath, "Recom")); + if (!Directory.Exists(Path.Combine(modsPath, "kh3d"))) + Directory.CreateDirectory(Path.Combine(modsPath, "kh3d")); if (!Directory.Exists(PresetPath)) Directory.CreateDirectory(PresetPath); @@ -123,6 +127,8 @@ public static ICollection EnabledMods return File.Exists(EnabledModsPathBBS) ? File.ReadAllLines(EnabledModsPathBBS) : new string[0]; case "Recom": return File.Exists(EnabledModsPathRECOM) ? File.ReadAllLines(EnabledModsPathRECOM) : new string[0]; + case "kh3d": + return File.Exists(EnabledModsPathKH3D) ? File.ReadAllLines(EnabledModsPathKH3D) : new string[0]; default: return File.Exists(EnabledModsPathKH2) ? File.ReadAllLines(EnabledModsPathKH2) : new string[0]; } @@ -140,6 +146,9 @@ public static ICollection EnabledMods case "Recom": File.WriteAllLines(EnabledModsPathRECOM, value); break; + case "kh3d": + File.WriteAllLines(EnabledModsPathKH3D, value); + break; default: File.WriteAllLines(EnabledModsPathKH2, value); break; @@ -239,6 +248,15 @@ public static string PcReleaseLocation _config.Save(ConfigPath); } } + public static string PcReleaseLocationKH3D + { + get => _config.PcReleaseLocationKH3D; + set + { + _config.PcReleaseLocationKH3D = value; + _config.Save(ConfigPath); + } + } public static string PcReleaseLanguage { @@ -396,6 +414,22 @@ public static bool Extractrecom _config.Save(ConfigPath); } } + public static bool Extractkh3d + { + get => _config.GamesToExtract.Contains("kh3d"); + set + { + if (value) + { + _config.GamesToExtract.Add("kh3d"); + } + else + { + _config.GamesToExtract.Remove("kh3d"); + } + _config.Save(ConfigPath); + } + } public static string LaunchGame { get => _config.LaunchGame; diff --git a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs index c4762d1de..57af9d119 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs @@ -50,7 +50,8 @@ public class MainViewModel : BaseNotifyPropertyChanged, IChangeModEnableState "kh2", "kh1", "bbs", - "Recom" + "Recom", + "kh3d" }; private int _wizardVersionNumber = 1; private string[] executable = new string[] @@ -58,7 +59,8 @@ public class MainViewModel : BaseNotifyPropertyChanged, IChangeModEnableState "KINGDOM HEARTS II FINAL MIX.exe", "KINGDOM HEARTS FINAL MIX.exe", "KINGDOM HEARTS Birth by Sleep FINAL MIX.exe", - "KINGDOM HEARTS Re_Chain of Memories.exe" + "KINGDOM HEARTS Re_Chain of Memories.exe", + "KINGDOM HEARTS Dream Drop Distance.exe" }; private int launchExecutable = 0; @@ -226,6 +228,9 @@ public int GametoLaunch case "Recom": launchExecutable = 3; return 3; + case "kh3d": + launchExecutable = 4; + return 4; default: launchExecutable = 0; return 0; @@ -252,6 +257,10 @@ public int GametoLaunch _launchGame = "Recom"; ConfigurationService.LaunchGame = "Recom"; break; + case 4: + _launchGame = "kh3d"; + ConfigurationService.LaunchGame = "kh3d"; + break; default: _launchGame = "kh2"; ConfigurationService.LaunchGame = "kh2"; @@ -585,7 +594,7 @@ private Task RunGame() isPcsx2 = true; break; case 2: - if (ConfigurationService.IsEGSVersion) + if (ConfigurationService.IsEGSVersion && !(_launchGame == "kh3d")) { if (ConfigurationService.PanaceaInstalled) { @@ -597,11 +606,33 @@ private Task RunGame() UseShellExecute = true, }; } - else - { + else if (ConfigurationService.IsEGSVersion && _launchGame == "kh3d") + { + if (ConfigurationService.PanaceaInstalled) + { + File.AppendAllText(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "panacea_settings.txt"), "\nquick_launch=" + _launchGame); + } processStartInfo = new ProcessStartInfo { - FileName = Path.Combine(ConfigurationService.PcReleaseLocation, executable[launchExecutable]), + FileName = "com.epicgames.launcher://apps/c8ff067c1c984cd7ab1998e8a9afc8b6%3Aaa743b9f52e84930b0ba1b701951e927%3Ad1a8f7c478d4439b8c60a5808715dc05?action=launch&silent=true", + UseShellExecute = true, + }; + + } + else + { + string filename; + if (!(_launchGame == "kh3d")) + { + filename = Path.Combine(ConfigurationService.PcReleaseLocation, executable[launchExecutable]); + } + else + { + filename = Path.Combine(ConfigurationService.PcReleaseLocationKH3D, executable[launchExecutable]); + } + processStartInfo = new ProcessStartInfo + { + FileName = filename, WorkingDirectory = ConfigurationService.PcReleaseLocation, UseShellExecute = false, }; diff --git a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs index 2ba21e5d2..e6229fe93 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs @@ -241,6 +241,11 @@ public bool Extractrecom get => ConfigurationService.Extractrecom; set => ConfigurationService.Extractrecom = value; } + public bool Extractkh3d + { + get => ConfigurationService.Extractkh3d; + set => ConfigurationService.Extractkh3d = value; + } public bool LuaConfigkh1 { get => LuaScriptPaths.Contains("kh1"); @@ -874,6 +879,13 @@ await Task.Run(() => "third", "fourth" }; + var _nameListkh3d = new string[] + { + "first", + "second", + "third", + "fourth" + }; var _totalFiles = 0; var _procTotalFiles = 0; @@ -911,6 +923,15 @@ await Task.Run(() => var _hedFile = OpenKh.Egs.Hed.Read(_stream); _totalFiles += _hedFile.Count(); } + if (ConfigurationService.Extractkh3d) + { + for (int i = 0; i < 4; i++) + { + using var _stream = new FileStream(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "Image", _pcReleaseLanguage, "kh3d_" + _nameListbbs[i] + ".hed"), System.IO.FileMode.Open); + var _hedFile = OpenKh.Egs.Hed.Read(_stream); + _totalFiles += _hedFile.Count(); + } + } if (ConfigurationService.Extractkh1) { @@ -1067,7 +1088,46 @@ await Task.Run(() => OnPropertyChanged(nameof(ExtractionProgress)); } } - } + } + if (ConfigurationService.Extractkh3d) + { + for (int i = 0; i < 4; i++) + { + var outputDir = Path.Combine(gameDataLocation, "kh3d"); + using var hedStream = File.OpenRead(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "Image", _pcReleaseLanguage, "kh3d_" + _nameListkh3d[i] + ".hed")); + using var img = File.OpenRead(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "Image", _pcReleaseLanguage, "kh3d_" + _nameListkh3d[i] + ".pkg")); + + foreach (var entry in OpenKh.Egs.Hed.Read(hedStream)) + { + var hash = OpenKh.Egs.Helpers.ToString(entry.MD5); + if (!OpenKh.Egs.EgsTools.Names.TryGetValue(hash, out var fileName)) + fileName = $"{hash}.dat"; + + var outputFileName = Path.Combine(outputDir, fileName); + + OpenKh.Egs.EgsTools.CreateDirectoryForFile(outputFileName); + + var hdAsset = new OpenKh.Egs.EgsHdAsset(img.SetPosition(entry.Offset)); + + File.Create(outputFileName).Using(stream => stream.Write(hdAsset.OriginalData)); + + outputFileName = Path.Combine(outputDir, REMASTERED_FILES_FOLDER_NAME, fileName); + + foreach (var asset in hdAsset.Assets) + { + var outputFileNameRemastered = Path.Combine(OpenKh.Egs.EgsTools.GetHDAssetFolder(outputFileName), asset); + OpenKh.Egs.EgsTools.CreateDirectoryForFile(outputFileNameRemastered); + + var assetData = hdAsset.RemasteredAssetsDecompressedData[asset]; + File.Create(outputFileNameRemastered).Using(stream => stream.Write(assetData)); + } + _procTotalFiles++; + + ExtractionProgress = (float)_procTotalFiles / _totalFiles; + OnPropertyChanged(nameof(ExtractionProgress)); + } + } + } System.Windows.Application.Current.Dispatcher.Invoke(() => { IsNotExtracting = true; diff --git a/OpenKh.Tools.ModsManager/Views/MainWindow.xaml b/OpenKh.Tools.ModsManager/Views/MainWindow.xaml index 204a9dd06..5f20bd692 100644 --- a/OpenKh.Tools.ModsManager/Views/MainWindow.xaml +++ b/OpenKh.Tools.ModsManager/Views/MainWindow.xaml @@ -147,6 +147,7 @@ Kingdom Hearts 1 Birth by Sleep Re:Chain of Memories + Dream Drop Distance From 6f41a3489f4a058c8838400a3fbe7d08e4c83f56 Mon Sep 17 00:00:00 2001 From: shananas Date: Fri, 19 Jan 2024 15:03:11 -0500 Subject: [PATCH 02/13] Fix hard crash if processStartInfos FileName variable is null --- .../ViewModels/MainViewModel.cs | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs index 57af9d119..7f63dc433 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs @@ -620,34 +620,37 @@ private Task RunGame() } else - { - string filename; - if (!(_launchGame == "kh3d")) + { + try { - filename = Path.Combine(ConfigurationService.PcReleaseLocation, executable[launchExecutable]); + string filename; + if (!(_launchGame == "kh3d")) + { + filename = Path.Combine(ConfigurationService.PcReleaseLocation, executable[launchExecutable]); + } + else + { + filename = Path.Combine(ConfigurationService.PcReleaseLocationKH3D, executable[launchExecutable]); + } + processStartInfo = new ProcessStartInfo + { + FileName = filename, + WorkingDirectory = ConfigurationService.PcReleaseLocation, + UseShellExecute = false, + }; + Process.Start(processStartInfo); + CloseAllWindows(); + return Task.CompletedTask; } - else + catch { - filename = Path.Combine(ConfigurationService.PcReleaseLocationKH3D, executable[launchExecutable]); - } - processStartInfo = new ProcessStartInfo - { - FileName = filename, - WorkingDirectory = ConfigurationService.PcReleaseLocation, - UseShellExecute = false, - }; - if (processStartInfo == null || !File.Exists(processStartInfo.FileName)) - { - MessageBox.Show( - "Unable to start game. Please make sure your Kingdom Hearts executable is correctly named and in the correct folder.", - "Run error", MessageBoxButton.OK, MessageBoxImage.Error); - CloseAllWindows(); - return Task.CompletedTask; + MessageBox.Show( + "Unable to locate game executable. Please make sure your Kingdom Hearts executable is correctly named and in the correct folder.", + "Run error", MessageBoxButton.OK, MessageBoxImage.Error); + CloseAllWindows(); + return Task.CompletedTask; } - } - Process.Start(processStartInfo); - CloseAllWindows(); - return Task.CompletedTask; + } default: return Task.CompletedTask; } From 22ee0ba288387d114abda42e1917cd8c4d9f5e7d Mon Sep 17 00:00:00 2001 From: shananas Date: Sat, 20 Jan 2024 03:21:31 -0500 Subject: [PATCH 03/13] switch case error fix --- OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs index 7f63dc433..a130ffe9d 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs @@ -650,7 +650,10 @@ private Task RunGame() CloseAllWindows(); return Task.CompletedTask; } - } + } + Process.Start(processStartInfo); + CloseAllWindows(); + return Task.CompletedTask; default: return Task.CompletedTask; } From b4bcd85ee311fb28f7708b467becb50fb753caac Mon Sep 17 00:00:00 2001 From: shananas Date: Sat, 20 Jan 2024 15:43:08 -0500 Subject: [PATCH 04/13] Update panacea to use offcial pkg name od kh3d --- OpenKh.Research.Panacea/OpenKH.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenKh.Research.Panacea/OpenKH.cpp b/OpenKh.Research.Panacea/OpenKH.cpp index f41a98490..82253bf27 100644 --- a/OpenKh.Research.Panacea/OpenKH.cpp +++ b/OpenKh.Research.Panacea/OpenKH.cpp @@ -121,7 +121,7 @@ const std::wstring gamefolders[] = { L"/kh2", L"/recom", L"/bbs", - L"/ddd", + L"/kh3d", }; void OpenKH::Initialize() { @@ -288,7 +288,7 @@ void OpenKH::ReadSettings(const char* filename) parseBool(value, m_EnableCache); else if (!strncmp(key, "quick_launch", sizeof(buf))) { - if (!_stricmp(value, "kh1") || !_stricmp(value, "ddd")) + if (!_stricmp(value, "kh1") || !_stricmp(value, "kh3d")) QuickLaunch = 1; else if (!_stricmp(value, "Recom") || !_stricmp(value, "0.2")) QuickLaunch = 2; From 47fd11f05cb09962b07bbdddd100607952536231 Mon Sep 17 00:00:00 2001 From: shananas Date: Mon, 22 Jan 2024 01:17:38 -0500 Subject: [PATCH 05/13] More DDD stuff --- .../ViewModels/MainViewModel.cs | 62 +++++++++++++------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs index a130ffe9d..782405601 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs @@ -595,45 +595,69 @@ private Task RunGame() break; case 2: if (ConfigurationService.IsEGSVersion && !(_launchGame == "kh3d")) - { - if (ConfigurationService.PanaceaInstalled) - { - File.AppendAllText(Path.Combine(ConfigurationService.PcReleaseLocation, "panacea_settings.txt"), "\nquick_launch=" + _launchGame); + { + if (ConfigurationService.PanaceaInstalled) + { + string panaceaSettings = Path.Combine(ConfigurationService.PcReleaseLocation, "panacea_settings.txt"); + if (!File.Exists(panaceaSettings)) + { + File.WriteAllLines(Path.Combine(ConfigurationService.PcReleaseLocation, "panacea_settings.txt"), + new string[] + { + $"mod_path={ConfigurationService.GameModPath}", + $"show_console={false}", + }); + } + File.AppendAllText(panaceaSettings, "\nquick_launch=" + _launchGame); } - processStartInfo = new ProcessStartInfo - { - FileName = "com.epicgames.launcher://apps/4158b699dd70447a981fee752d970a3e%3A5aac304f0e8948268ddfd404334dbdc7%3A68c214c58f694ae88c2dab6f209b43e4?action=launch&silent=true", - UseShellExecute = true, + processStartInfo = new ProcessStartInfo + { + FileName = "com.epicgames.launcher://apps/4158b699dd70447a981fee752d970a3e%3A5aac304f0e8948268ddfd404334dbdc7%3A68c214c58f694ae88c2dab6f209b43e4?action=launch&silent=true", + UseShellExecute = true, }; } else if (ConfigurationService.IsEGSVersion && _launchGame == "kh3d") { - if (ConfigurationService.PanaceaInstalled) - { - File.AppendAllText(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "panacea_settings.txt"), "\nquick_launch=" + _launchGame); + string panaceaSettings = Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "panacea_settings.txt"); + if (ConfigurationService.PanaceaInstalled) + { + if (!File.Exists(panaceaSettings)) + { + if (Directory.Exists(ConfigurationService.PcReleaseLocationKH3D)) + { + File.WriteAllLines(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "panacea_settings.txt"), + new string[] + { + $"mod_path={ConfigurationService.GameModPath}", + $"show_console={false}", + }); + } + else + File.Create(panaceaSettings); + } + File.AppendAllText(panaceaSettings, "\nquick_launch=" + _launchGame); } - processStartInfo = new ProcessStartInfo - { - FileName = "com.epicgames.launcher://apps/c8ff067c1c984cd7ab1998e8a9afc8b6%3Aaa743b9f52e84930b0ba1b701951e927%3Ad1a8f7c478d4439b8c60a5808715dc05?action=launch&silent=true", - UseShellExecute = true, + processStartInfo = new ProcessStartInfo + { + FileName = "com.epicgames.launcher://apps/c8ff067c1c984cd7ab1998e8a9afc8b6%3Aaa743b9f52e84930b0ba1b701951e927%3Ad1a8f7c478d4439b8c60a5808715dc05?action=launch&silent=true", + UseShellExecute = true, }; - } else - { + { try { string filename; if (!(_launchGame == "kh3d")) { - filename = Path.Combine(ConfigurationService.PcReleaseLocation, executable[launchExecutable]); + filename = Path.Combine(ConfigurationService.PcReleaseLocation, executable[launchExecutable]); } else { filename = Path.Combine(ConfigurationService.PcReleaseLocationKH3D, executable[launchExecutable]); } processStartInfo = new ProcessStartInfo - { + { FileName = filename, WorkingDirectory = ConfigurationService.PcReleaseLocation, UseShellExecute = false, From 151f5812f68036a932683aded6fda15344345377 Mon Sep 17 00:00:00 2001 From: shananas Date: Mon, 22 Jan 2024 20:35:21 -0500 Subject: [PATCH 06/13] DDD UI support --- .../ViewModels/MainViewModel.cs | 92 ++-- .../ViewModels/SetupWizardViewModel.cs | 448 ++++++++++++++---- .../Views/SetupWizardWindow.xaml | 65 ++- .../Views/SetupWizardWindow.xaml.cs | 1 + 4 files changed, 477 insertions(+), 129 deletions(-) diff --git a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs index 782405601..61530a6e4 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs @@ -455,6 +455,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress => ConfigOpenKhGameEngineLocation = ConfigurationService.OpenKhGameEngineLocation, ConfigPcsx2Location = ConfigurationService.Pcsx2Location, ConfigPcReleaseLocation = ConfigurationService.PcReleaseLocation, + ConfigPcReleaseLocationKH3D = ConfigurationService.PcReleaseLocationKH3D, ConfigPcReleaseLanguage = ConfigurationService.PcReleaseLanguage, ConfigRegionId = ConfigurationService.RegionId, ConfigPanaceaInstalled = ConfigurationService.PanaceaInstalled, @@ -468,6 +469,7 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress => ConfigurationService.OpenKhGameEngineLocation = dialog.ConfigOpenKhGameEngineLocation; ConfigurationService.Pcsx2Location = dialog.ConfigPcsx2Location; ConfigurationService.PcReleaseLocation = dialog.ConfigPcReleaseLocation; + ConfigurationService.PcReleaseLocationKH3D = dialog.ConfigPcReleaseLocationKH3D; ConfigurationService.RegionId = dialog.ConfigRegionId; ConfigurationService.PanaceaInstalled = dialog.ConfigPanaceaInstalled; ConfigurationService.IsEGSVersion = dialog.ConfigIsEGSVersion; @@ -484,6 +486,16 @@ await ModsService.InstallMod(name, isZipFile, isLuaFile, progress => $"show_console={false}", }); } + if (ConfigurationService.GameEdition == EpicGamesPC && + Directory.Exists(ConfigurationService.PcReleaseLocationKH3D)) + { + File.WriteAllLines(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "panacea_settings.txt"), + new string[] + { + $"mod_path={ConfigurationService.GameModPath}", + $"show_console={false}", + }); + } if (ConfigurationService.GameEdition == 2) { PC = true; @@ -596,52 +608,74 @@ private Task RunGame() case 2: if (ConfigurationService.IsEGSVersion && !(_launchGame == "kh3d")) { - if (ConfigurationService.PanaceaInstalled) + if (ConfigurationService.PcReleaseLocation != null) { - string panaceaSettings = Path.Combine(ConfigurationService.PcReleaseLocation, "panacea_settings.txt"); - if (!File.Exists(panaceaSettings)) + if (ConfigurationService.PanaceaInstalled) { - File.WriteAllLines(Path.Combine(ConfigurationService.PcReleaseLocation, "panacea_settings.txt"), - new string[] - { + string panaceaSettings = Path.Combine(ConfigurationService.PcReleaseLocation, "panacea_settings.txt"); + if (!File.Exists(panaceaSettings)) + { + File.WriteAllLines(Path.Combine(ConfigurationService.PcReleaseLocation, "panacea_settings.txt"), + new string[] + { $"mod_path={ConfigurationService.GameModPath}", $"show_console={false}", - }); + }); + } + File.AppendAllText(panaceaSettings, "\nquick_launch=" + _launchGame); } - File.AppendAllText(panaceaSettings, "\nquick_launch=" + _launchGame); - } - processStartInfo = new ProcessStartInfo + processStartInfo = new ProcessStartInfo + { + FileName = "com.epicgames.launcher://apps/4158b699dd70447a981fee752d970a3e%3A5aac304f0e8948268ddfd404334dbdc7%3A68c214c58f694ae88c2dab6f209b43e4?action=launch&silent=true", + UseShellExecute = true, + }; + } + else { - FileName = "com.epicgames.launcher://apps/4158b699dd70447a981fee752d970a3e%3A5aac304f0e8948268ddfd404334dbdc7%3A68c214c58f694ae88c2dab6f209b43e4?action=launch&silent=true", - UseShellExecute = true, - }; + MessageBox.Show( + "Unable to locate KINGDOM HEARTS HD 1.5+2.5 ReMIX install. Please re-run the setup wizard and confirm it is correct.", + "Run error", MessageBoxButton.OK, MessageBoxImage.Error); + CloseAllWindows(); + return Task.CompletedTask; + } } else if (ConfigurationService.IsEGSVersion && _launchGame == "kh3d") { - string panaceaSettings = Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "panacea_settings.txt"); - if (ConfigurationService.PanaceaInstalled) + if (ConfigurationService.PcReleaseLocationKH3D != null) { - if (!File.Exists(panaceaSettings)) + string panaceaSettings = Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "panacea_settings.txt"); + if (ConfigurationService.PanaceaInstalled) { - if (Directory.Exists(ConfigurationService.PcReleaseLocationKH3D)) + if (!File.Exists(panaceaSettings)) { - File.WriteAllLines(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "panacea_settings.txt"), - new string[] - { + if (Directory.Exists(ConfigurationService.PcReleaseLocationKH3D)) + { + File.WriteAllLines(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "panacea_settings.txt"), + new string[] + { $"mod_path={ConfigurationService.GameModPath}", $"show_console={false}", - }); + }); + } + else + File.Create(panaceaSettings); } - else - File.Create(panaceaSettings); + File.AppendAllText(panaceaSettings, "\nquick_launch=" + _launchGame); } - File.AppendAllText(panaceaSettings, "\nquick_launch=" + _launchGame); - } - processStartInfo = new ProcessStartInfo + processStartInfo = new ProcessStartInfo + { + FileName = "com.epicgames.launcher://apps/c8ff067c1c984cd7ab1998e8a9afc8b6%3Aaa743b9f52e84930b0ba1b701951e927%3Ad1a8f7c478d4439b8c60a5808715dc05?action=launch&silent=true", + UseShellExecute = true, + }; + } + else { - FileName = "com.epicgames.launcher://apps/c8ff067c1c984cd7ab1998e8a9afc8b6%3Aaa743b9f52e84930b0ba1b701951e927%3Ad1a8f7c478d4439b8c60a5808715dc05?action=launch&silent=true", - UseShellExecute = true, - }; + MessageBox.Show( + "Unable to locate KINGDOM HEARTS HD 2.8 Final Chapter Prologue install. Please re-run the setup wizard and confirm it is correct.", + "Run error", MessageBoxButton.OK, MessageBoxImage.Error); + CloseAllWindows(); + return Task.CompletedTask; + } } else { diff --git a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs index e6229fe93..2aac4d6a6 100644 --- a/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs +++ b/OpenKh.Tools.ModsManager/ViewModels/SetupWizardViewModel.cs @@ -45,6 +45,9 @@ public class SetupWizardViewModel : BaseNotifyPropertyChanged private string _openKhGameEngineLocation; private string _pcsx2Location; private string _pcReleaseLocation; + private string _pcReleaseLocationKH3D; + private string _pcReleasesSelected; + private int _gameCollection = 0; private string _pcReleaseLanguage; private string _gameDataLocation; private bool _isEGSVersion; @@ -133,9 +136,12 @@ public bool IsGameSelected { OpenKHGameEngine => !string.IsNullOrEmpty(OpenKhGameEngineLocation) && File.Exists(OpenKhGameEngineLocation), PCSX2 => !string.IsNullOrEmpty(Pcsx2Location) && File.Exists(Pcsx2Location), - EpicGames => !string.IsNullOrEmpty(PcReleaseLocation) && + EpicGames => (!string.IsNullOrEmpty(PcReleaseLocation) && Directory.Exists(PcReleaseLocation) && - File.Exists(Path.Combine(PcReleaseLocation, "EOSSDK-Win64-Shipping.dll")), + File.Exists(Path.Combine(PcReleaseLocation, "EOSSDK-Win64-Shipping.dll")))|| + (!string.IsNullOrEmpty(PcReleaseLocationKH3D) && + Directory.Exists(PcReleaseLocationKH3D) && + File.Exists(Path.Combine(PcReleaseLocationKH3D, "EOSSDK-Win64-Shipping.dll"))), _ => false, }; } @@ -196,7 +202,12 @@ public string Pcsx2Location } public RelayCommand SelectPcReleaseCommand { get; } - public Visibility PcReleaseConfigVisibility => GameEdition == EpicGames ? Visibility.Visible : Visibility.Collapsed; + public Visibility PcReleaseConfigVisibility => GameEdition == EpicGames ? Visibility.Visible : Visibility.Collapsed; + public Visibility BothPcReleaseSelected => PcReleaseSelections == "both" ? Visibility.Visible : Visibility.Collapsed; + public Visibility PcRelease1525Selected => PcReleaseSelections == "1.5+2.5" ? Visibility.Visible: Visibility.Collapsed; + public Visibility PcRelease28Selected => PcReleaseSelections == "2.8" ? Visibility.Visible : Visibility.Collapsed; + public Visibility InstallForPc1525 => GameCollection == 0 && (PcReleaseSelections == "both" || PcReleaseSelections == "1.5+2.5") ? Visibility.Visible : Visibility.Collapsed; + public Visibility InstallForPc28 => GameCollection == 1 && (PcReleaseSelections == "both" || PcReleaseSelections == "2.8") ? Visibility.Visible :Visibility.Collapsed; public string PcReleaseLocation { get => _pcReleaseLocation; @@ -211,6 +222,70 @@ public string PcReleaseLocation OnPropertyChanged(nameof(IsGameDataFound)); OnPropertyChanged(nameof(LuaBackendFoundVisibility)); OnPropertyChanged(nameof(LuaBackendNotFoundVisibility)); + OnPropertyChanged(nameof(BothPcReleaseSelected)); + OnPropertyChanged(nameof(PcRelease1525Selected)); + OnPropertyChanged(nameof(PcRelease28Selected)); + } + } + + public string PcReleaseSelections + { + get + { + if (Directory.Exists(PcReleaseLocation) && File.Exists(Path.Combine(PcReleaseLocation, "EOSSDK-Win64-Shipping.dll")) && + Directory.Exists(PcReleaseLocationKH3D) && File.Exists(Path.Combine(PcReleaseLocationKH3D, "EOSSDK-Win64-Shipping.dll"))) + { + return _pcReleasesSelected = "both"; + } + else if (Directory.Exists(PcReleaseLocation) && File.Exists(Path.Combine(PcReleaseLocation, "EOSSDK-Win64-Shipping.dll"))) + { + + return _pcReleasesSelected = "1.5+2.5"; + } + else if (Directory.Exists(PcReleaseLocationKH3D) && File.Exists(Path.Combine(PcReleaseLocationKH3D, "EOSSDK-Win64-Shipping.dll"))) + { + + return _pcReleasesSelected = "2.8"; + } + return ""; + } + set { } + } + + public int GameCollection + { + get => _gameCollection; + set + { + _gameCollection = value; + OnPropertyChanged(nameof(InstallForPc1525)); + OnPropertyChanged(nameof(InstallForPc28)); + OnPropertyChanged(nameof(LuaBackendFoundVisibility)); + OnPropertyChanged(nameof(LuaBackendNotFoundVisibility)); + OnPropertyChanged(nameof(IsLastPanaceaVersionInstalled)); + OnPropertyChanged(nameof(PanaceaInstalledVisibility)); + OnPropertyChanged(nameof(PanaceaNotInstalledVisibility)); + } + } + + public RelayCommand SelectPcReleaseKH3DCommand { get; } + public string PcReleaseLocationKH3D + { + get => _pcReleaseLocationKH3D; + set + { + _pcReleaseLocationKH3D = value; + OnPropertyChanged(); + OnPropertyChanged(nameof(IsLastPanaceaVersionInstalled)); + OnPropertyChanged(nameof(PanaceaInstalledVisibility)); + OnPropertyChanged(nameof(PanaceaNotInstalledVisibility)); + OnPropertyChanged(nameof(IsGameSelected)); + OnPropertyChanged(nameof(IsGameDataFound)); + OnPropertyChanged(nameof(LuaBackendFoundVisibility)); + OnPropertyChanged(nameof(LuaBackendNotFoundVisibility)); + OnPropertyChanged(nameof(BothPcReleaseSelected)); + OnPropertyChanged(nameof(PcRelease1525Selected)); + OnPropertyChanged(nameof(PcRelease28Selected)); } } public bool IsEGSVersion @@ -306,6 +381,21 @@ public bool LuaConfigrecom } } } + public bool LuaConfigkh3d + { + get => LuaScriptPaths.Contains("kh3d"); + set + { + if (value) + { + LuaScriptPaths.Add("kh3d"); + } + else + { + LuaScriptPaths.Remove("kh3d"); + } + } + } public bool OverrideGameDataFound { get => _overrideGameDataFound; @@ -353,8 +443,9 @@ public string GameDataLocation public bool IsGameDataFound => (IsNotExtracting && GameService.FolderContainsUniqueFile(GameId, Path.Combine(GameDataLocation, "kh2")) || (GameEdition == EpicGames && (GameService.FolderContainsUniqueFile("kh2", Path.Combine(GameDataLocation, "kh2")) || GameService.FolderContainsUniqueFile("kh1", Path.Combine(GameDataLocation, "kh1")) || - File.Exists(Path.Combine(GameDataLocation, "bbs", "message")) || - File.Exists(Path.Combine(GameDataLocation, "Recom", "SYS"))))|| + Directory.Exists(Path.Combine(GameDataLocation, "bbs", "message")) || + Directory.Exists(Path.Combine(GameDataLocation, "Recom", "SYS"))))|| + Directory.Exists(Path.Combine(GameDataLocation, "kh3d","setdata"))|| OverrideGameDataFound); public Visibility GameDataNotFoundVisibility => !IsGameDataFound ? Visibility.Visible : Visibility.Collapsed; public Visibility GameDataFoundVisibility => IsGameDataFound ? Visibility.Visible : Visibility.Collapsed; @@ -367,12 +458,18 @@ public bool IsLuaBackendInstalled { get { - if (PcReleaseLocation != null) + 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 == 2) + { + return File.Exists(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.dll")) && + File.Exists(Path.Combine(PcReleaseLocationKH3D, "lua54.dll")) && + File.Exists(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.toml")); + } else return false; } @@ -388,13 +485,23 @@ public bool IsLuaBackendInstalled private string PanaceaDestinationLocation => Path.Combine(PcReleaseLocation, "DBGHELP.dll"); private string PanaceaAlternateLocation => Path.Combine(PcReleaseLocation, "version.dll"); private string PanaceaDependenciesLocation => Path.Combine(PcReleaseLocation, "dependencies"); + private string PanaceaDestinationLocationKH3D => Path.Combine(PcReleaseLocationKH3D, "DBGHELP.dll"); + private string PanaceaAlternateLocationKH3D => Path.Combine(PcReleaseLocationKH3D, "version.dll"); + private string PanaceaDependenciesLocationKH3D => Path.Combine(PcReleaseLocationKH3D, "dependencies"); public Visibility PanaceaNotInstalledVisibility => !IsLastPanaceaVersionInstalled ? Visibility.Visible : Visibility.Collapsed; public Visibility PanaceaInstalledVisibility => IsLastPanaceaVersionInstalled ? Visibility.Visible : Visibility.Collapsed; public bool IsLastPanaceaVersionInstalled { get { - if (PcReleaseLocation == null) + if (PcReleaseLocation == null && GameCollection == 0) + { + // Won't be able to find the source location + PanaceaInstalled = false; + return false; + } + + if (PcReleaseLocationKH3D == null && GameCollection == 1) { // Won't be able to find the source location PanaceaInstalled = false; @@ -424,25 +531,44 @@ bool IsEqual(byte[] left, byte[] right) return true; } - if (File.Exists(PanaceaDestinationLocation) && !File.Exists(PanaceaAlternateLocation)) + if (GameCollection == 0 && File.Exists(PanaceaDestinationLocation) && !File.Exists(PanaceaAlternateLocation)) { return IsEqual( CalculateChecksum(PanaceaSourceLocation), CalculateChecksum(PanaceaDestinationLocation)); } - else if (File.Exists(PanaceaAlternateLocation) && !File.Exists(PanaceaDestinationLocation)) + else if (GameCollection == 0 && File.Exists(PanaceaAlternateLocation) && !File.Exists(PanaceaDestinationLocation)) { return IsEqual( CalculateChecksum(PanaceaSourceLocation), CalculateChecksum(PanaceaAlternateLocation)); } - else if (File.Exists(PanaceaDestinationLocation) && File.Exists(PanaceaAlternateLocation)) + else if (GameCollection == 0 && File.Exists(PanaceaDestinationLocation) && File.Exists(PanaceaAlternateLocation)) { return IsEqual(CalculateChecksum(PanaceaSourceLocation), CalculateChecksum(PanaceaDestinationLocation)) || IsEqual(CalculateChecksum(PanaceaSourceLocation), CalculateChecksum(PanaceaAlternateLocation)); } + else if (GameCollection == 1 && File.Exists(PanaceaDestinationLocationKH3D) && !File.Exists(PanaceaAlternateLocationKH3D)) + { + return IsEqual( + CalculateChecksum(PanaceaSourceLocation), + CalculateChecksum(PanaceaDestinationLocationKH3D)); + } + else if (GameCollection == 1 && File.Exists(PanaceaAlternateLocationKH3D) && !File.Exists(PanaceaDestinationLocationKH3D)) + { + return IsEqual( + CalculateChecksum(PanaceaSourceLocation), + CalculateChecksum(PanaceaAlternateLocationKH3D)); + } + else if (GameCollection == 1 && File.Exists(PanaceaDestinationLocationKH3D) && File.Exists(PanaceaAlternateLocationKH3D)) + { + return IsEqual(CalculateChecksum(PanaceaSourceLocation), + CalculateChecksum(PanaceaDestinationLocationKH3D)) || + IsEqual(CalculateChecksum(PanaceaSourceLocation), + CalculateChecksum(PanaceaAlternateLocationKH3D)); + } else { PanaceaInstalled = false; @@ -462,6 +588,8 @@ public SetupWizardViewModel() FileDialog.OnOpen(fileName => Pcsx2Location = fileName, _pcsx2Filter)); SelectPcReleaseCommand = new RelayCommand(_ => FileDialog.OnFolder(path => PcReleaseLocation = path)); + SelectPcReleaseKH3DCommand = new RelayCommand(_ => + FileDialog.OnFolder(path => PcReleaseLocationKH3D = path)); SelectGameDataLocationCommand = new RelayCommand(_ => FileDialog.OnFolder(path => GameDataLocation = path)); ExtractGameDataCommand = new RelayCommand(async _ => @@ -489,60 +617,121 @@ public SetupWizardViewModel() if (File.Exists(PanaceaSourceLocation)) { // Again, do not bother in debug mode - if (!Directory.Exists(PanaceaDependenciesLocation)) - { - Directory.CreateDirectory(PanaceaDependenciesLocation); - } - if (!Convert.ToBoolean(AlternateName)) - { - File.Copy(PanaceaSourceLocation, PanaceaDestinationLocation, true); - File.Delete(PanaceaAlternateLocation); - } - else - { - File.Copy(PanaceaSourceLocation, PanaceaAlternateLocation, true); - File.Delete(PanaceaDestinationLocation); - } - try + if (GameCollection == 0) { - File.Copy(Path.Combine(AppContext.BaseDirectory, "avcodec-vgmstream-59.dll"), Path.Combine(PanaceaDependenciesLocation, "avcodec-vgmstream-59.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "avformat-vgmstream-59.dll"), Path.Combine(PanaceaDependenciesLocation, "avformat-vgmstream-59.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "avutil-vgmstream-57.dll"), Path.Combine(PanaceaDependenciesLocation, "avutil-vgmstream-57.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "bass.dll"), Path.Combine(PanaceaDependenciesLocation, "bass.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "bass_vgmstream.dll"), Path.Combine(PanaceaDependenciesLocation, "bass_vgmstream.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "libatrac9.dll"), Path.Combine(PanaceaDependenciesLocation, "libatrac9.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "libcelt-0061.dll"), Path.Combine(PanaceaDependenciesLocation, "libcelt-0061.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "libcelt-0110.dll"), Path.Combine(PanaceaDependenciesLocation, "libcelt-0110.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "libg719_decode.dll"), Path.Combine(PanaceaDependenciesLocation, "libg719_decode.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "libmpg123-0.dll"), Path.Combine(PanaceaDependenciesLocation, "libmpg123-0.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "libspeex-1.dll"), Path.Combine(PanaceaDependenciesLocation, "libspeex-1.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "libvorbis.dll"), Path.Combine(PanaceaDependenciesLocation, "libvorbis.dll"), true); - File.Copy(Path.Combine(AppContext.BaseDirectory, "swresample-vgmstream-4.dll"), Path.Combine(PanaceaDependenciesLocation, "swresample-vgmstream-4.dll"), true); + if (!Directory.Exists(PanaceaDependenciesLocation)) + { + Directory.CreateDirectory(PanaceaDependenciesLocation); + } + if (!Convert.ToBoolean(AlternateName)) + { + File.Copy(PanaceaSourceLocation, PanaceaDestinationLocation, true); + File.Delete(PanaceaAlternateLocation); + } + else + { + File.Copy(PanaceaSourceLocation, PanaceaAlternateLocation, true); + File.Delete(PanaceaDestinationLocation); + } + try + { + File.Copy(Path.Combine(AppContext.BaseDirectory, "avcodec-vgmstream-59.dll"), Path.Combine(PanaceaDependenciesLocation, "avcodec-vgmstream-59.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "avformat-vgmstream-59.dll"), Path.Combine(PanaceaDependenciesLocation, "avformat-vgmstream-59.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "avutil-vgmstream-57.dll"), Path.Combine(PanaceaDependenciesLocation, "avutil-vgmstream-57.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "bass.dll"), Path.Combine(PanaceaDependenciesLocation, "bass.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "bass_vgmstream.dll"), Path.Combine(PanaceaDependenciesLocation, "bass_vgmstream.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libatrac9.dll"), Path.Combine(PanaceaDependenciesLocation, "libatrac9.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libcelt-0061.dll"), Path.Combine(PanaceaDependenciesLocation, "libcelt-0061.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libcelt-0110.dll"), Path.Combine(PanaceaDependenciesLocation, "libcelt-0110.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libg719_decode.dll"), Path.Combine(PanaceaDependenciesLocation, "libg719_decode.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libmpg123-0.dll"), Path.Combine(PanaceaDependenciesLocation, "libmpg123-0.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libspeex-1.dll"), Path.Combine(PanaceaDependenciesLocation, "libspeex-1.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libvorbis.dll"), Path.Combine(PanaceaDependenciesLocation, "libvorbis.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "swresample-vgmstream-4.dll"), Path.Combine(PanaceaDependenciesLocation, "swresample-vgmstream-4.dll"), true); + } + catch (Exception e) + { + MessageBox.Show( + $"Missing panacea dependencies. Unable to fully install panacea.", + "Extraction error", + MessageBoxButton.OK, + MessageBoxImage.Error); + File.Delete(PanaceaDestinationLocation); + File.Delete(PanaceaAlternateLocation); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "avcodec-vgmstream-59.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "avformat-vgmstream-59.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "avutil-vgmstream-57.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "bass.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "bass_vgmstream.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "libatrac9.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "libcelt-0061.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "libcelt-0110.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "libg719_decode.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "libmpg123-0.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "libspeex-1.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "libvorbis.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocation, "swresample-vgmstream-4.dll")); + PanaceaInstalled = false; + return; + } } - catch (Exception e) + else if (GameCollection == 1) { - MessageBox.Show( - $"Missing panacea dependencies. Unable to fully install panacea.", - "Extraction error", - MessageBoxButton.OK, - MessageBoxImage.Error); - File.Delete(PanaceaDestinationLocation); - File.Delete(PanaceaAlternateLocation); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "avcodec-vgmstream-59.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "avformat-vgmstream-59.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "avutil-vgmstream-57.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "bass.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "bass_vgmstream.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "libatrac9.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "libcelt-0061.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "libcelt-0110.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "libg719_decode.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "libmpg123-0.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "libspeex-1.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "libvorbis.dll")); - File.Delete(Path.Combine(PanaceaDependenciesLocation, "swresample-vgmstream-4.dll")); - PanaceaInstalled = false; - return; + if (!Directory.Exists(PanaceaDependenciesLocationKH3D)) + { + Directory.CreateDirectory(PanaceaDependenciesLocationKH3D); + } + if (!Convert.ToBoolean(AlternateName)) + { + File.Copy(PanaceaSourceLocation, PanaceaDestinationLocationKH3D, true); + File.Delete(PanaceaAlternateLocationKH3D); + } + else + { + File.Copy(PanaceaSourceLocation, PanaceaAlternateLocationKH3D, true); + File.Delete(PanaceaDestinationLocationKH3D); + } + try + { + File.Copy(Path.Combine(AppContext.BaseDirectory, "avcodec-vgmstream-59.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "avcodec-vgmstream-59.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "avformat-vgmstream-59.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "avformat-vgmstream-59.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "avutil-vgmstream-57.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "avutil-vgmstream-57.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "bass.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "bass.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "bass_vgmstream.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "bass_vgmstream.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libatrac9.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "libatrac9.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libcelt-0061.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "libcelt-0061.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libcelt-0110.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "libcelt-0110.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libg719_decode.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "libg719_decode.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libmpg123-0.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "libmpg123-0.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libspeex-1.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "libspeex-1.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "libvorbis.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "libvorbis.dll"), true); + File.Copy(Path.Combine(AppContext.BaseDirectory, "swresample-vgmstream-4.dll"), Path.Combine(PanaceaDependenciesLocationKH3D, "swresample-vgmstream-4.dll"), true); + } + catch (Exception e) + { + MessageBox.Show( + $"Missing panacea dependencies. Unable to fully install panacea.", + "Extraction error", + MessageBoxButton.OK, + MessageBoxImage.Error); + File.Delete(PanaceaDestinationLocation); + File.Delete(PanaceaAlternateLocation); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "avcodec-vgmstream-59.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "avformat-vgmstream-59.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "avutil-vgmstream-57.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "bass.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "bass_vgmstream.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libatrac9.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libcelt-0061.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libcelt-0110.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libg719_decode.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libmpg123-0.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libspeex-1.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libvorbis.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "swresample-vgmstream-4.dll")); + PanaceaInstalled = false; + return; + } } } OnPropertyChanged(nameof(IsLastPanaceaVersionInstalled)); @@ -552,7 +741,7 @@ public SetupWizardViewModel() }); RemovePanaceaCommand = new RelayCommand(_ => { - if (File.Exists(PanaceaDestinationLocation) || File.Exists(PanaceaAlternateLocation)) + if (GameCollection == 0 && File.Exists(PanaceaDestinationLocation) || File.Exists(PanaceaAlternateLocation)) { File.Delete(PanaceaDestinationLocation); File.Delete(PanaceaAlternateLocation); @@ -570,6 +759,24 @@ public SetupWizardViewModel() File.Delete(Path.Combine(PanaceaDependenciesLocation, "libvorbis.dll")); File.Delete(Path.Combine(PanaceaDependenciesLocation, "swresample-vgmstream-4.dll")); } + else if (GameCollection == 1 && File.Exists(PanaceaDestinationLocationKH3D) || File.Exists(PanaceaAlternateLocationKH3D)) + { + File.Delete(PanaceaDestinationLocationKH3D); + File.Delete(PanaceaAlternateLocationKH3D); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "avcodec-vgmstream-59.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "avformat-vgmstream-59.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "avutil-vgmstream-57.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "bass.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "bass_vgmstream.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libatrac9.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libcelt-0061.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libcelt-0110.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libg719_decode.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libmpg123-0.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libspeex-1.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "libvorbis.dll")); + File.Delete(Path.Combine(PanaceaDependenciesLocationKH3D, "swresample-vgmstream-4.dll")); + } OnPropertyChanged(nameof(IsLastPanaceaVersionInstalled)); OnPropertyChanged(nameof(PanaceaInstalledVisibility)); OnPropertyChanged(nameof(PanaceaNotInstalledVisibility)); @@ -600,31 +807,47 @@ public SetupWizardViewModel() File.Delete(DownPath); File.Delete(TempExtractionLocation); } - File.Move(Path.Combine(TempExtractionLocation, "DBGHELP.dll"), Path.Combine(PcReleaseLocation, "LuaBackend.dll"), true); - File.Move(Path.Combine(TempExtractionLocation, "lua54.dll"), Path.Combine(PcReleaseLocation, "lua54.dll"), true); - File.Move(Path.Combine(TempExtractionLocation, "LuaBackend.toml"), Path.Combine(PcReleaseLocation, "LuaBackend.toml"), true); - string config = File.ReadAllText(Path.Combine(PcReleaseLocation, "LuaBackend.toml")).Replace("\\", "/").Replace("\\\\", "/"); - if (LuaScriptPaths.Contains("kh1")) + if (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")) - { - 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")) - { - int index = config.IndexOf("true }", config.IndexOf("[bbs]")) + 6; - config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "bbs/scripts\" , relative = false}").Replace("\\", "/")); + File.Move(Path.Combine(TempExtractionLocation, "DBGHELP.dll"), Path.Combine(PcReleaseLocation, "LuaBackend.dll"), true); + File.Move(Path.Combine(TempExtractionLocation, "lua54.dll"), Path.Combine(PcReleaseLocation, "lua54.dll"), true); + File.Move(Path.Combine(TempExtractionLocation, "LuaBackend.toml"), Path.Combine(PcReleaseLocation, "LuaBackend.toml"), true); + string config = File.ReadAllText(Path.Combine(PcReleaseLocation, "LuaBackend.toml")).Replace("\\", "/").Replace("\\\\", "/"); + if (LuaScriptPaths.Contains("kh1")) + { + 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")) + { + 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")) + { + 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")) + { + int index = config.IndexOf("true }", config.IndexOf("[recom]")) + 6; + config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "Recom/scripts\" , relative = false}").Replace("\\", "/")); + } + File.WriteAllText(Path.Combine(PcReleaseLocation, "LuaBackend.toml"), config); } - if (LuaScriptPaths.Contains("Recom")) + else if (GameCollection ==1) { - int index = config.IndexOf("true }", config.IndexOf("[recom]")) + 6; - config = config.Insert(index, ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "Recom/scripts\" , relative = false}").Replace("\\", "/")); + File.Move(Path.Combine(TempExtractionLocation, "DBGHELP.dll"), Path.Combine(PcReleaseLocationKH3D, "LuaBackend.dll"), true); + File.Move(Path.Combine(TempExtractionLocation, "lua54.dll"), Path.Combine(PcReleaseLocationKH3D, "lua54.dll"), true); + File.Move(Path.Combine(TempExtractionLocation, "LuaBackend.toml"), Path.Combine(PcReleaseLocationKH3D, "LuaBackend.toml"), true); + string config = File.ReadAllText(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.toml")).Replace("\\", "/").Replace("\\\\", "/"); + if (LuaScriptPaths.Contains("kh3d")) + { + 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(PcReleaseLocationKH3D, "LuaBackend.toml"), config); } - File.WriteAllText(Path.Combine(PcReleaseLocation, "LuaBackend.toml"), config); File.Delete(DownPath); Directory.Delete(TempExtractionLocation); OnPropertyChanged(nameof(IsLuaBackendInstalled)); @@ -633,7 +856,7 @@ public SetupWizardViewModel() } else { - if (File.Exists(Path.Combine(PcReleaseLocation, "LuaBackend.toml"))) + if (File.Exists(Path.Combine(PcReleaseLocation, "LuaBackend.toml")) && GameCollection == 0) { string config = File.ReadAllText(Path.Combine(PcReleaseLocation, "LuaBackend.toml")).Replace("\\", "/").Replace("\\\\", "/"); if (LuaScriptPaths.Contains("kh1")) @@ -753,13 +976,58 @@ public SetupWizardViewModel() OnPropertyChanged(nameof(LuaBackendFoundVisibility)); OnPropertyChanged(nameof(LuaBackendNotFoundVisibility)); } + else if(File.Exists(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.toml")) && GameCollection == 1) + { + string config = File.ReadAllText(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.toml")).Replace("\\", "/").Replace("\\\\", "/"); + if (LuaScriptPaths.Contains("kh3d")) + { + if (config.Contains("mod/kh3d/scripts")) + { + var errorMessage = MessageBox.Show($"Your Lua Backend is already configured to run Lua scripts for KH3D from an OpenKH Mod Manager." + + $" Do you want to change Lua Backend to run scripts for KH3D from this version of OpenKH Mod Manager instead?", "Warning", + MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No, MessageBoxOptions.DefaultDesktopOnly); + + switch (errorMessage) + { + case MessageBoxResult.Yes: + { + int index = config.IndexOf("scripts", config.IndexOf("[kh3d]")); + config = config.Remove(index, config.IndexOf("]", index) - index + 1); + config = config.Insert(index, "scripts = [{ path = \"scripts/kh3d/\", relative = true }" + + ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "kh3d/scripts\" , relative = false}]").Replace("\\", "/")); + break; + } + } + } + else + { + int index = config.IndexOf("scripts", config.IndexOf("[kh3d]")); + config = config.Remove(index, config.IndexOf("]", index) - index + 1); + config = config.Insert(index, "scripts = [{ path = \"scripts/kh3d/\", relative = true }" + + ", {path = \"" + Path.Combine(ConfigurationService.GameModPath, "kh3d/scripts\" , relative = false}]").Replace("\\", "/")); + } + } + File.WriteAllText(Path.Combine(PcReleaseLocationKH3D, "LuaBackend.toml"), config); + OnPropertyChanged(nameof(IsLuaBackendInstalled)); + OnPropertyChanged(nameof(LuaBackendFoundVisibility)); + OnPropertyChanged(nameof(LuaBackendNotFoundVisibility)); + } } }); RemoveLuaBackendCommand = new RelayCommand(_ => { - File.Delete(Path.Combine(PcReleaseLocation, "LuaBackend.dll")); - File.Delete(Path.Combine(PcReleaseLocation, "lua54.dll")); - File.Delete(Path.Combine(PcReleaseLocation, "LuaBackend.toml")); + 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)); OnPropertyChanged(nameof(LuaBackendFoundVisibility)); OnPropertyChanged(nameof(LuaBackendNotFoundVisibility)); @@ -927,7 +1195,7 @@ await Task.Run(() => { for (int i = 0; i < 4; i++) { - using var _stream = new FileStream(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "Image", _pcReleaseLanguage, "kh3d_" + _nameListbbs[i] + ".hed"), System.IO.FileMode.Open); + using var _stream = new FileStream(Path.Combine(_pcReleaseLocationKH3D, "Image", _pcReleaseLanguage, "kh3d_" + _nameListbbs[i] + ".hed"), System.IO.FileMode.Open); var _hedFile = OpenKh.Egs.Hed.Read(_stream); _totalFiles += _hedFile.Count(); } @@ -1094,8 +1362,8 @@ await Task.Run(() => for (int i = 0; i < 4; i++) { var outputDir = Path.Combine(gameDataLocation, "kh3d"); - using var hedStream = File.OpenRead(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "Image", _pcReleaseLanguage, "kh3d_" + _nameListkh3d[i] + ".hed")); - using var img = File.OpenRead(Path.Combine(ConfigurationService.PcReleaseLocationKH3D, "Image", _pcReleaseLanguage, "kh3d_" + _nameListkh3d[i] + ".pkg")); + using var hedStream = File.OpenRead(Path.Combine(_pcReleaseLocationKH3D, "Image", _pcReleaseLanguage, "kh3d_" + _nameListkh3d[i] + ".hed")); + using var img = File.OpenRead(Path.Combine(_pcReleaseLocationKH3D, "Image", _pcReleaseLanguage, "kh3d_" + _nameListkh3d[i] + ".pkg")); foreach (var entry in OpenKh.Egs.Hed.Read(hedStream)) { diff --git a/OpenKh.Tools.ModsManager/Views/SetupWizardWindow.xaml b/OpenKh.Tools.ModsManager/Views/SetupWizardWindow.xaml index 050ce6858..b3fff413d 100644 --- a/OpenKh.Tools.ModsManager/Views/SetupWizardWindow.xaml +++ b/OpenKh.Tools.ModsManager/Views/SetupWizardWindow.xaml @@ -9,7 +9,7 @@ mc:Ignorable="d" WindowStartupLocation="CenterScreen" Title="{Binding Title}" d:Title="OpenKH Mods Manager set-up" - Height="425" Width="400" ResizeMode="NoResize"> + Height="480" Width="400" ResizeMode="NoResize"> @@ -84,7 +84,10 @@ NOTE: Only PCSX2 up to 1.6.0 and PCSX2-EX are supported. - Please select the folder location of the PC release + + Mod Manager supports both the 1.5+2.5 collection and KH3D from the 2.8 collection choose the filepath for at least one of the collections. + + Folder location of the PC release of 1.5+2.5 @@ -95,6 +98,17 @@ + Folder location of the PC release of 2.8 + + + + + + + + NOTE: Always be sure to use a supported version as updated might break the compatibility @@ -144,13 +158,31 @@ NextPage="{Binding WizardPageAfterGameData}" IsEnabled="{Binding IsNotExtracting}"> - OpenKh can extract all games in the KH 1.5 2.5 collection. Choose the games you wish to extract. Size values are rounded up. - + + OpenKH can extract all games in the 1.5 + 2.5 collection and KH3D from the 2.8 collection. Check the games below you wish to extract. + If you do not see the game you want to use Mod Manager for please go back to the Game Edition page and make sure you selected the correct filepath. + Size values are rounded up. + + + + + + + + + + + + + + + + Extraction folder location: @@ -172,10 +204,10 @@ - You do not have any extracted data from a supported game. + You do not have any extracted data from a supported game. - You already have extracted data from a supported game. + You already have extracted data from a supported game. @@ -186,9 +218,9 @@ The extraction of the game's data succeded! - - WARNING - If you do not extract a games data only Lua Scripts will function properly. Only check the box below if you will only be installing Lua Scripts in Mods Manager. + + WARNING + If you do not extract a games data only Lua Scripts will function properly. Only check the box below if you will only be installing Lua Scripts in Mods Manager. @@ -230,6 +262,11 @@ PreviousPage="{Binding PageStack.Back}" NextPage="{Binding ElementName=PageLuaBackendInstall}"> + Game Collection + + KINGDOM HEARTS HD 1.5+2.5 ReMIX + KINGDOM HEARTS HD 2.8 Final Chapter Prologue + Panacea allows the PC version of Kingdom Hearts to load the mods you have installed, without modifying the game files. @@ -281,18 +318,26 @@ PreviousPage="{Binding PageStack.Back}" NextPage="{Binding ElementName=PCLaunchOption}"> + Game Collection + + KINGDOM HEARTS HD 1.5+2.5 ReMIX + KINGDOM HEARTS HD 2.8 Final Chapter Prologue + It seems you have not installed Lua Backend for use with Panacea. If you wish to do this press the button below. Also if you wish to have OpenKH configure it so Lua Backend can load scripts installed in Mod Manager check the games below. Lua Backend is installed! for use with Panacea. If you have not already and wish to configure it so it runs scripts from mods installed into OpenKH check the games below and press the configure button. - + + + +