Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/mod/gui/modmod/modmod.js
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Name of the mods installed by the ModInstaller. | * Name of the mods installed by the ModInstaller. | ||||
*/ | */ | ||||
var g_InstalledMods; | var g_InstalledMods; | ||||
var g_ColorNoModSelected = "255 255 100"; | var g_ColorNoModSelected = "255 255 100"; | ||||
var g_ColorDependenciesMet = "100 255 100"; | var g_ColorDependenciesMet = "100 255 100"; | ||||
var g_ColorDependenciesNotMet = "255 100 100"; | var g_ColorDependenciesNotMet = "255 100 100"; | ||||
Silier: hmm, somehow i made this irrelevant, one can ask for failed mods directly, however in case of… | |||||
function init(data, hotloadData) | function init(data, hotloadData) | ||||
{ | { | ||||
g_InstalledMods = data && data.installedMods || hotloadData && hotloadData.installedMods || []; | g_InstalledMods = data && data.installedMods || hotloadData && hotloadData.installedMods || []; | ||||
initMods(); | initMods(); | ||||
initGUIButtons(data); | initGUIButtons(data); | ||||
} | } | ||||
Show All 13 Lines | |||||
function loadMods() | function loadMods() | ||||
{ | { | ||||
g_Mods = Engine.GetAvailableMods(); | g_Mods = Engine.GetAvailableMods(); | ||||
deepfreeze(g_Mods); | deepfreeze(g_Mods); | ||||
} | } | ||||
function loadEnabledMods() | function loadEnabledMods() | ||||
{ | { | ||||
g_ModsEnabled = Engine.ConfigDB_GetValue("user", "mod.enabledmods").split(/\s+/).filter(folder => !!g_Mods[folder]); | g_ModsEnabled = Engine.GetEnabledMods().filter(folder => !!g_Mods[folder]); | ||||
g_ModsDisabled = Object.keys(g_Mods).filter(folder => g_ModsEnabled.indexOf(folder) == -1); | g_ModsDisabled = Object.keys(g_Mods).filter(folder => g_ModsEnabled.indexOf(folder) == -1); | ||||
g_ModsEnabledFiltered = g_ModsEnabled; | g_ModsEnabledFiltered = g_ModsEnabled; | ||||
g_ModsDisabledFiltered = g_ModsDisabled; | g_ModsDisabledFiltered = g_ModsDisabled; | ||||
} | } | ||||
function validateMods() | function validateMods() | ||||
{ | { | ||||
for (let folder in g_Mods) | for (let folder in g_Mods) | ||||
validateMod(folder, g_Mods[folder], true); | validateMod(folder, g_Mods[folder], true); | ||||
} | } | ||||
function initGUIFilters() | function initGUIFilters() | ||||
{ | { | ||||
Engine.GetGUIObjectByName("negateFilter").checked = false; | Engine.GetGUIObjectByName("negateFilter").checked = false; | ||||
displayModLists(); | displayModLists(); | ||||
} | } | ||||
function initGUIButtons(data) | function initGUIButtons(data) | ||||
{ | { | ||||
// Either get back to the previous page or quit if there is no previous page | // Either get back to the previous page or quit if there is no previous page | ||||
let cancelButton = !data || data.cancelbutton; | let hasPreviousPage = !data || data.cancelbutton; | ||||
Done Inline Actionsrename to something general Silier: rename to something general | |||||
Engine.GetGUIObjectByName("cancelButton").hidden = !cancelButton; | Engine.GetGUIObjectByName("cancelButton").hidden = !hasPreviousPage; | ||||
Engine.GetGUIObjectByName("quitButton").hidden = cancelButton; | Engine.GetGUIObjectByName("quitButton").hidden = hasPreviousPage; | ||||
Engine.GetGUIObjectByName("startModsButton").hidden = !hasPreviousPage; | |||||
Engine.GetGUIObjectByName("startButton").hidden = hasPreviousPage; | |||||
Engine.GetGUIObjectByName("toggleModButton").caption = translateWithContext("mod activation", "Enable"); | Engine.GetGUIObjectByName("toggleModButton").caption = translateWithContext("mod activation", "Enable"); | ||||
} | } | ||||
function saveMods() | 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"); | ||||
} | } | ||||
function startMods() | function startMods() | ||||
{ | { | ||||
sortEnabledMods(); | sortEnabledMods(); | ||||
Engine.SetMods(["mod"].concat(g_ModsEnabled)); | if (!g_ModsEnabled.length) | ||||
Engine.RestartEngine(); | { | ||||
Engine.GetGUIObjectByName("message").caption = coloredText(translate('Enable at least one mod'), g_ColorDependenciesNotMet); | |||||
return; | |||||
} | |||||
if (!Engine.SetModsAndRestartEngine(["mod"].concat(g_ModsEnabled))) | |||||
Done Inline Actionsset mod in c++ as we require it to be able to show at least mod page and we hide it from available mods anyway so no one can mess up this line Silier: set mod in c++ as we require it to be able to show at least mod page and we hide it from… | |||||
Engine.GetGUIObjectByName("message").caption = coloredText(translate('Dependencies not met'), g_ColorDependenciesNotMet); | |||||
} | } | ||||
function displayModLists() | function displayModLists() | ||||
{ | { | ||||
g_ModsEnabledFiltered = displayModList("modsEnabledList", g_ModsEnabled); | g_ModsEnabledFiltered = displayModList("modsEnabledList", g_ModsEnabled); | ||||
g_ModsDisabledFiltered = displayModList("modsDisabledList", g_ModsDisabled); | g_ModsDisabledFiltered = displayModList("modsDisabledList", g_ModsDisabled); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
hmm, somehow i made this irrelevant, one can ask for failed mods directly, however in case of not visual starts it would be good to know which one exactly caused it, so irrelevant just in js