Skip to content

Commit

Permalink
More specific error messages when settings files are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
PiKeyAr committed Dec 3, 2024
1 parent a07a566 commit 3f297eb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions SADXModLoader/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ std::string LegacyGamePatchList[] =
"XInputFix",
};

void LoadModLoaderSettings(LoaderSettings* loaderSettings, std::wstring appPath)
void LoadModLoaderSettings(LoaderSettings* loaderSettings, std::wstring appPath, std::wstring gamePath)
{
std::wstring profilesPath = appPath + L"SADX\\Profiles.json";

// Warn the player if the profiles file doesn't exist
if (!Exists(profilesPath))
{
MessageBox(nullptr, L"Mod Loader settings could not be read. Please run the Mod Manager, save settings and try again.", L"SADX Mod Loader", MB_ICONWARNING);
std::wstring gamepatherror = L"\nGame path: " + gamePath;
std::wstring appdataerror = L"\nManager data path: " + appPath;
std::wstring profileerror = L"\nThe following file was missing: " + profilesPath;
std::wstring error = L"Mod Loader settings could not be read. Please run the Mod Manager, save settings and try again.\n" + gamepatherror + appdataerror + profileerror;
MessageBox(nullptr, error.c_str(), L"SADX Mod Loader", MB_ICONWARNING);
OnExit(0, 0, 0);
ExitProcess(0);
}
Expand All @@ -66,6 +70,16 @@ void LoadModLoaderSettings(LoaderSettings* loaderSettings, std::wstring appPath)

// Load the current profile
currentProfilePath = appPath + L"SADX\\" + profname_w;
if (!Exists(currentProfilePath))
{
std::wstring gamepatherror = L"\nGame path: " + gamePath;
std::wstring appdataerror = L"\nManager data path: " + appPath;
std::wstring profileerror = L"\nThe following file was missing: " + currentProfilePath;
std::wstring error = L"Mod Loader settings could not be read. Please run the Mod Manager, save settings and try again.\n" + gamepatherror + appdataerror + profileerror;
MessageBox(nullptr, error.c_str(), L"SADX Mod Loader", MB_ICONWARNING);
OnExit(0, 0, 0);
ExitProcess(0);
}
std::ifstream ifs_p(appPath + L"SADX\\" + profname_w);
json json_config = json::parse(ifs_p);
int settingsVersion = json_config.value("SettingsVersion", 0);
Expand Down
2 changes: 1 addition & 1 deletion SADXModLoader/config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

void LoadModLoaderSettings(LoaderSettings* loaderSettings, std::wstring appPath);
void LoadModLoaderSettings(LoaderSettings* loaderSettings, std::wstring appPath, std::wstring gamePath);
unsigned int GetModCount();
std::string GetModName(int index);
bool IsGamePatchEnabled(const char* patchName);
Expand Down
2 changes: 1 addition & 1 deletion SADXModLoader/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ static void __cdecl InitMods()
SetAppPathConfig(exepath);

// Load Mod Loader settings
LoadModLoaderSettings(&loaderSettings, appPath);
LoadModLoaderSettings(&loaderSettings, appPath, exepath);
// Process the main Mod Loader settings.
if (loaderSettings.DebugConsole)
{
Expand Down

0 comments on commit 3f297eb

Please sign in to comment.