From a26535d02339df39377dee551ee41fc134f2ba36 Mon Sep 17 00:00:00 2001 From: wraitii Date: Thu, 20 May 2021 17:11:26 +0000 Subject: [PATCH] Fix mistake in 3bcf360107 which stopped the incompatible mods page from showing. I didn't quite understand what was supposed to happen here. This makes things work as before. While at it, fix a conversion bug & do some more tweaks. Differential Revision: https://code.wildfiregames.com/D3990 This was SVN commit r25475. --- binaries/data/mods/mod/gui/modmod/modmod.js | 4 ++-- source/ps/GameSetup/GameSetup.cpp | 11 +++-------- source/ps/Mod.cpp | 6 ++---- source/ps/Mod.h | 6 ++++-- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/binaries/data/mods/mod/gui/modmod/modmod.js b/binaries/data/mods/mod/gui/modmod/modmod.js index 6da87d70ea..6eb1d2f65c 100644 --- a/binaries/data/mods/mod/gui/modmod/modmod.js +++ b/binaries/data/mods/mod/gui/modmod/modmod.js @@ -118,7 +118,7 @@ function getMod(folder) function loadEnabledMods() { if (g_HasIncompatibleMods) - g_ModsEnabled = Engine.GetFailedMods().filter(folder => folder != "mod"); + g_ModsEnabled = Engine.GetIncompatibleMods().filter(folder => folder != "mod"); else g_ModsEnabled = Engine.GetEnabledMods().filter(folder => !!g_Mods[folder]); g_ModsDisabled = Object.keys(g_Mods).filter(folder => g_ModsEnabled.indexOf(folder) == -1); @@ -446,7 +446,7 @@ function selectedMod(listObjectName) toggleModButton.caption = isPickedDisabledList ? translateWithContext("mod activation", "Enable") : translateWithContext("mod activation", "Disable"); - toggleModButton.enabled = isPickedDisabledList ? isModSelected && g_ModsCompatibility[listObject.list[listObject.selected]] : isModSelected; + toggleModButton.enabled = isPickedDisabledList ? isModSelected && g_ModsCompatibility[listObject.list[listObject.selected]] || false : isModSelected; Engine.GetGUIObjectByName("enabledModUp").enabled = isModSelected && listObjectName == "modsEnabledList" && !areFilters(); Engine.GetGUIObjectByName("enabledModDown").enabled = isModSelected && listObjectName == "modsEnabledList" && !areFilters(); diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index c1c9899fc5..467dd99823 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -906,14 +906,9 @@ bool Init(const CmdLineArgs& args, int flags) LOGERROR("Trying to start with incompatible mods: %s.", boost::algorithm::join(g_Mods.GetIncompatibleMods(), ", ")); return false; } - LOGWARNING("Invalid mods specified, starting with default mods."); - g_Mods.EnableDefaultMods(modInterface); - } - // Sanity check. - if (!g_Mods.GetIncompatibleMods().empty()) - { - LOGERROR("Trying to start with incompatible mods: %s.", boost::algorithm::join(g_Mods.GetIncompatibleMods(), ", ")); - return false; + // Disable all mods but "mod", we want to use the JS fallback code. + // TODO: it'd be nicer if the control flow was more obvious here. + g_Mods.SwitchToModSelector(modInterface); } } MountMods(Paths(args), g_Mods.GetEnabledMods()); diff --git a/source/ps/Mod.cpp b/source/ps/Mod.cpp index afe9b83c77..a1e4644ce5 100644 --- a/source/ps/Mod.cpp +++ b/source/ps/Mod.cpp @@ -159,11 +159,9 @@ const std::vector& Mod::GetIncompatibleMods() const return m_IncompatibleMods; } -void Mod::EnableDefaultMods(const ScriptInterface& scriptInterface) +void Mod::SwitchToModSelector(const ScriptInterface& scriptInterface) { - m_IncompatibleMods.clear(); - m_ModsLoaded.clear(); - m_ModsLoaded.insert(m_ModsLoaded.begin(), "mod"); + m_ModsLoaded = { "mod" }; CacheEnabledModVersions(scriptInterface); } diff --git a/source/ps/Mod.h b/source/ps/Mod.h index f0ec266053..4b6704f4bc 100644 --- a/source/ps/Mod.h +++ b/source/ps/Mod.h @@ -37,9 +37,11 @@ public: const std::vector& GetIncompatibleMods() const; /** - * Enable the default mods. De-activates any non-default mod currently enabled. + * Enables the mod selector only, leaving incompatible mods as-is. + * This is used, in combination with the JS code, to show the user + * a clear interface in case of incompatible mods. */ - void EnableDefaultMods(const ScriptInterface& scriptInterface); + void SwitchToModSelector(const ScriptInterface& scriptInterface); /** * Enables specified mods (& mods required by the engine).