From 3f297eb5c09790276bd88c56f2ab9b7d8f33fc8e Mon Sep 17 00:00:00 2001 From: PiKeyAr Date: Tue, 3 Dec 2024 13:41:22 +0900 Subject: [PATCH] More specific error messages when settings files are missing --- SADXModLoader/config.cpp | 18 ++++++++++++++++-- SADXModLoader/config.h | 2 +- SADXModLoader/dllmain.cpp | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/SADXModLoader/config.cpp b/SADXModLoader/config.cpp index f01a7cee..b811edf9 100644 --- a/SADXModLoader/config.cpp +++ b/SADXModLoader/config.cpp @@ -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); } @@ -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); diff --git a/SADXModLoader/config.h b/SADXModLoader/config.h index c4b6bd98..bf57c305 100644 --- a/SADXModLoader/config.h +++ b/SADXModLoader/config.h @@ -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); diff --git a/SADXModLoader/dllmain.cpp b/SADXModLoader/dllmain.cpp index 2cbc0e78..b1876554 100644 --- a/SADXModLoader/dllmain.cpp +++ b/SADXModLoader/dllmain.cpp @@ -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) {