Mod selector: "start mods" saves the configuration.

Differential Revision: https://code.wildfiregames.com/D3992
This was SVN commit r25573.
This commit is contained in:
wraitii 2021-05-26 13:27:43 +00:00
parent 8f4b3dfb16
commit bce26e905f
2 changed files with 11 additions and 17 deletions

View File

@ -147,8 +147,8 @@ function initGUIButtons(data)
let hasPreviousPage = !data || data.cancelbutton; let hasPreviousPage = !data || data.cancelbutton;
Engine.GetGUIObjectByName("cancelButton").hidden = !hasPreviousPage; Engine.GetGUIObjectByName("cancelButton").hidden = !hasPreviousPage;
Engine.GetGUIObjectByName("quitButton").hidden = hasPreviousPage; Engine.GetGUIObjectByName("quitButton").hidden = hasPreviousPage;
Engine.GetGUIObjectByName("startModsButton").hidden = !hasPreviousPage; // Turn 'save' off, it will be enabled on any change.
Engine.GetGUIObjectByName("startButton").hidden = hasPreviousPage; Engine.GetGUIObjectByName("saveConfigurationButton").enabled = false;
Engine.GetGUIObjectByName("toggleModButton").caption = translateWithContext("mod activation", "Enable"); Engine.GetGUIObjectByName("toggleModButton").caption = translateWithContext("mod activation", "Enable");
} }
@ -157,11 +157,13 @@ function saveMods()
sortEnabledMods(); sortEnabledMods();
Engine.ConfigDB_CreateValue("user", "mod.enabledmods", ["mod"].concat(g_ModsEnabled).join(" ")); Engine.ConfigDB_CreateValue("user", "mod.enabledmods", ["mod"].concat(g_ModsEnabled).join(" "));
Engine.ConfigDB_WriteFile("user", "config/user.cfg"); Engine.ConfigDB_WriteFile("user", "config/user.cfg");
Engine.GetGUIObjectByName("saveConfigurationButton").enabled = false;
} }
function startMods() function startMods()
{ {
sortEnabledMods(); saveMods();
if (!Engine.SetModsAndRestartEngine(["mod"].concat(g_ModsEnabled))) if (!Engine.SetModsAndRestartEngine(["mod"].concat(g_ModsEnabled)))
Engine.GetGUIObjectByName("message").caption = coloredText(translate('Dependencies not met'), g_ColorDependenciesNotMet); Engine.GetGUIObjectByName("message").caption = coloredText(translate('Dependencies not met'), g_ColorDependenciesNotMet);
} }
@ -235,6 +237,8 @@ function enableMod()
reloadDisabledMods(); reloadDisabledMods();
recomputeCompatibility(); recomputeCompatibility();
Engine.GetGUIObjectByName("saveConfigurationButton").enabled = true;
if (pos >= g_ModsDisabledFiltered.length) if (pos >= g_ModsDisabledFiltered.length)
--pos; --pos;
@ -275,6 +279,8 @@ function disableMod()
--i; --i;
} }
Engine.GetGUIObjectByName("saveConfigurationButton").enabled = true;
recomputeCompatibility(true); recomputeCompatibility(true);
displayModLists(); displayModLists();
Engine.GetGUIObjectByName("message").caption = ""; Engine.GetGUIObjectByName("message").caption = "";
@ -457,16 +463,9 @@ function selectedMod(listObjectName)
'[color="' + g_ColorNoModSelected + '"]' + translate("No mod has been selected.") + '[/color]'; '[color="' + g_ColorNoModSelected + '"]' + translate("No mod has been selected.") + '[/color]';
if (!g_ModsEnabled.length) if (!g_ModsEnabled.length)
{
if (!Engine.GetGUIObjectByName("startButton").hidden)
Engine.GetGUIObjectByName("message").caption = coloredText(translate('Enable at least 0ad mod and save configuration'), g_ColorDependenciesNotMet);
else
Engine.GetGUIObjectByName("message").caption = coloredText(translate('Enable at least 0ad mod'), g_ColorDependenciesNotMet); Engine.GetGUIObjectByName("message").caption = coloredText(translate('Enable at least 0ad mod'), g_ColorDependenciesNotMet);
}
if (!Engine.GetGUIObjectByName("startButton").hidden) if (!Engine.GetGUIObjectByName("startButton").hidden)
Engine.GetGUIObjectByName("startButton").enabled = g_ModsEnabled.length > 0; Engine.GetGUIObjectByName("startButton").enabled = g_ModsEnabled.length > 0;
if (!Engine.GetGUIObjectByName("startModsButton").hidden)
Engine.GetGUIObjectByName("startModsButton").enabled = g_ModsEnabled.length > 0;
} }

View File

@ -212,13 +212,8 @@
<action on="Press">saveMods();</action> <action on="Press">saveMods();</action>
</object> </object>
<object name="startModsButton" type="button" style="ModernButtonRed" size="100%-196 100%-44 100%-16 100%-16">
<translatableAttribute id="caption">Start Mods</translatableAttribute>
<action on="Press">startMods();</action>
</object>
<object name="startButton" type="button" style="ModernButtonRed" size="100%-196 100%-44 100%-16 100%-16"> <object name="startButton" type="button" style="ModernButtonRed" size="100%-196 100%-44 100%-16 100%-16">
<translatableAttribute id="caption">Start</translatableAttribute> <translatableAttribute id="caption">Save and Restart</translatableAttribute>
<action on="Press">startMods();</action> <action on="Press">startMods();</action>
</object> </object>
</object> </object>