Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mm DDD support #981

Merged
merged 15 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions OpenKh.Research.Panacea/OpenKH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
L"/kh2",
L"/recom",
L"/bbs",
L"/ddd",
L"/kh3d",
};
void OpenKH::Initialize()
{
Expand Down Expand Up @@ -177,18 +177,18 @@
FILE* f = fopen("panacea_settings.txt", "w");
char buf[MAX_PATH];
memset(buf, 0, MAX_PATH);
WideCharToMultiByte(CP_UTF8, 0, &m_ModPath.front(), m_ModPath.size(), buf, MAX_PATH, nullptr, nullptr);

Check warning on line 180 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
fprintf(f, "mod_path=%s\n", buf);
if (!m_ExtractPath.empty())
{
memset(buf, 0, MAX_PATH);
WideCharToMultiByte(CP_UTF8, 0, &m_ExtractPath.front(), m_ExtractPath.size(), buf, MAX_PATH, nullptr, nullptr);

Check warning on line 185 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
fprintf(f, "extract_path=%s\n", buf);
}
if (!m_DevPath.empty())
{
memset(buf, 0, MAX_PATH);
WideCharToMultiByte(CP_UTF8, 0, &m_DevPath.front(), m_DevPath.size(), buf, MAX_PATH, nullptr, nullptr);

Check warning on line 191 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
fprintf(f, "dev_path=%s\n", buf);
}
if (m_ShowConsole)
Expand Down Expand Up @@ -267,17 +267,17 @@

if (!strncmp(key, "mod_path", sizeof(buf)) && strnlen(value, sizeof(buf)) > 0)
{
m_ModPath.resize(MultiByteToWideChar(CP_UTF8, 0, value, strlen(value), nullptr, 0));

Check warning on line 270 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
MultiByteToWideChar(CP_UTF8, 0, value, strlen(value), &m_ModPath.front(), m_ModPath.size());

Check warning on line 271 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 271 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
}
else if (!strncmp(key, "dev_path", sizeof(buf)) && strnlen(value, sizeof(buf)) > 0)
{
m_DevPath.resize(MultiByteToWideChar(CP_UTF8, 0, value, strlen(value), nullptr, 0));

Check warning on line 275 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
MultiByteToWideChar(CP_UTF8, 0, value, strlen(value), &m_DevPath.front(), m_DevPath.size());

Check warning on line 276 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data

Check warning on line 276 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
}
else if (!strncmp(key, "extract_path", sizeof(buf)) && strnlen(value, sizeof(buf)) > 0)
{
m_ExtractPath.resize(MultiByteToWideChar(CP_UTF8, 0, value, strlen(value), nullptr, 0));

Check warning on line 280 in OpenKh.Research.Panacea/OpenKH.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
MultiByteToWideChar(CP_UTF8, 0, value, strlen(value), &m_ExtractPath.front(), m_ExtractPath.size());
}
else if (!strncmp(key, "show_console", sizeof(buf)))
Expand All @@ -288,7 +288,7 @@
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;
Expand Down
34 changes: 34 additions & 0 deletions OpenKh.Tools.ModsManager/Services/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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");

Expand All @@ -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);

Expand Down Expand Up @@ -123,6 +127,8 @@ public static ICollection<string> 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];
}
Expand All @@ -140,6 +146,9 @@ public static ICollection<string> EnabledMods
case "Recom":
File.WriteAllLines(EnabledModsPathRECOM, value);
break;
case "kh3d":
File.WriteAllLines(EnabledModsPathKH3D, value);
break;
default:
File.WriteAllLines(EnabledModsPathKH2, value);
break;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down
149 changes: 122 additions & 27 deletions OpenKh.Tools.ModsManager/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ public class MainViewModel : BaseNotifyPropertyChanged, IChangeModEnableState
"kh2",
"kh1",
"bbs",
"Recom"
"Recom",
"kh3d"
};
private int _wizardVersionNumber = 1;
private string[] executable = new string[]
{
"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;

Expand Down Expand Up @@ -226,6 +228,9 @@ public int GametoLaunch
case "Recom":
launchExecutable = 3;
return 3;
case "kh3d":
launchExecutable = 4;
return 4;
default:
launchExecutable = 0;
return 0;
Expand All @@ -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";
Expand Down Expand Up @@ -446,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,
Expand All @@ -459,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;
Expand All @@ -475,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;
Expand Down Expand Up @@ -585,38 +606,112 @@ private Task RunGame()
isPcsx2 = true;
break;
case 2:
if (ConfigurationService.IsEGSVersion)
{
if (ConfigurationService.PanaceaInstalled)
{
File.AppendAllText(Path.Combine(ConfigurationService.PcReleaseLocation, "panacea_settings.txt"), "\nquick_launch=" + _launchGame);
if (ConfigurationService.IsEGSVersion && !(_launchGame == "kh3d"))
{
if (ConfigurationService.PcReleaseLocation != null)
{
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,
};
}
else
{
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")
{
if (ConfigurationService.PcReleaseLocationKH3D != null)
{
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,
};
}
else
{
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;
}
processStartInfo = new ProcessStartInfo
{
FileName = "com.epicgames.launcher://apps/4158b699dd70447a981fee752d970a3e%3A5aac304f0e8948268ddfd404334dbdc7%3A68c214c58f694ae88c2dab6f209b43e4?action=launch&silent=true",
UseShellExecute = true,
};
}
else
{
processStartInfo = new ProcessStartInfo
{
FileName = Path.Combine(ConfigurationService.PcReleaseLocation, executable[launchExecutable]),
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();
try
{
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;
}
catch
{
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);
}
Process.Start(processStartInfo);
CloseAllWindows();
return Task.CompletedTask;
return Task.CompletedTask;
default:
return Task.CompletedTask;
}
Expand Down
Loading
Loading