Changeset View
Standalone View
binaries/data/mods/mod/gui/modmod/modmod.js
Show First 20 Lines • Show All 345 Lines • ▼ Show 20 Lines | |||||
function sortEnabledMods() | function sortEnabledMods() | ||||
{ | { | ||||
let dependencies = {}; | let dependencies = {}; | ||||
for (let folder of g_ModsEnabled) | for (let folder of g_ModsEnabled) | ||||
dependencies[folder] = g_Mods[folder].dependencies.map(d => d.split(g_RegExpComparisonOperator)[0]); | dependencies[folder] = g_Mods[folder].dependencies.map(d => d.split(g_RegExpComparisonOperator)[0]); | ||||
g_ModsEnabled.sort((folder1, folder2) => | g_ModsEnabled.sort((folder1, folder2) => | ||||
dependencies[folder1].indexOf(g_Mods[folder2].name) != -1 ? 1 : | dependencies[folder1].indexOf(g_Mods[folder2].name) != -1 ? 1 : | ||||
dependencies[folder2].indexOf(g_Mods[folder1].name) != -1 ? -1 : 0); | dependencies[folder2].indexOf(g_Mods[folder1].name) != -1 ? -1 : 0); | ||||
Stan: Could fix the warning here while at it :) | |||||
Done Inline ActionsGood catch. Imarok: Good catch. | |||||
displayModList("modsEnabledList", g_ModsEnabled); | displayModList("modsEnabledList", g_ModsEnabled); | ||||
} | } | ||||
function selectedMod(listObjectName) | function selectedMod(listObjectName) | ||||
{ | { | ||||
let listObject = Engine.GetGUIObjectByName(listObjectName); | let listObject = Engine.GetGUIObjectByName(listObjectName); | ||||
let otherListObject = Engine.GetGUIObjectByName(listObjectName == "modsDisabledList" ? | let otherListObject = Engine.GetGUIObjectByName(listObjectName == "modsDisabledList" ? | ||||
"modsEnabledList" : "modsDisabledList"); | "modsEnabledList" : "modsDisabledList"); | ||||
if (listObject.selected != -1) | let toggleModButton = Engine.GetGUIObjectByName("toggleModButton"); | ||||
let modSelected = listObject.selected != -1; | |||||
if (modSelected) | |||||
{ | { | ||||
otherListObject.selected = -1; | otherListObject.selected = -1; | ||||
Engine.GetGUIObjectByName("visitWebButton").enabled = true; | |||||
let toggleModButton = Engine.GetGUIObjectByName("toggleModButton"); | |||||
toggleModButton.caption = listObjectName == "modsDisabledList" ? translate("Enable") : translate("Disable"); | |||||
toggleModButton.enabled = true; | |||||
toggleModButton.onPress = listObjectName == "modsDisabledList" ? enableMod : disableMod; | toggleModButton.onPress = listObjectName == "modsDisabledList" ? enableMod : disableMod; | ||||
Engine.GetGUIObjectByName("enabledModUp").enabled = listObjectName == "modsEnabledList"; | |||||
Engine.GetGUIObjectByName("enabledModDown").enabled = listObjectName == "modsEnabledList"; | |||||
} | } | ||||
Not Done Inline ActionsSince there are likely no other Enable/Disable strings in the modselecton screen and since the modselection screen is the only page in the transifex resource, it might work without the context too. But not wrong, good to add it in advance. elexis: Since there are likely no other Enable/Disable strings in the modselecton screen and since the… | |||||
Engine.GetGUIObjectByName("visitWebButton").enabled = modSelected && getSelectedModUrl(); | |||||
toggleModButton.caption = modSelected ? | |||||
(listObjectName == "modsDisabledList" ? | |||||
translateWithContext("mod activation", "Enable") : | |||||
translateWithContext("mod activation", "Disable")) : | |||||
translateWithContext("mod activation", "Enable/Disable"); | |||||
Not Done Inline Actions
elexis: * What is the point of the third string? If it's to inform the user that this button has dual… | |||||
Done Inline ActionsWhat else should the caption of the button be if no mod has been selected? Imarok: What else should the caption of the button be if no mod has been selected? | |||||
Not Done Inline ActionsWhy not just KISS and use "Enable" or "Disable" with the button being disabled if nothing is selected? It's accurate because the user cannot enable or disable if nothing is selected. It's the same behavior with all our other buttons that are disabled conditionally, no? elexis: Why not just KISS and use "Enable" or "Disable" with the button being disabled if nothing is… | |||||
Done Inline Actions
I don't think we have much buttons that show different captions and are sometimes disabled... Imarok: > It's the same behavior with all our other buttons that are disabled conditionally, no?
I… | |||||
Not Done Inline ActionsIt would be the first button that shows a different caption depending on it's enabled property. elexis: It would be the first button that shows a different caption depending on it's enabled property. | |||||
Done Inline ActionsI think it's nicer with the third string, and I mean it doesn't really hurt doing it, right? Imarok: I think it's nicer with the third string, and I mean it doesn't really hurt doing it, right? | |||||
toggleModButton.enabled = modSelected; | |||||
Engine.GetGUIObjectByName("enabledModUp").enabled = modSelected && listObjectName == "modsEnabledList"; | |||||
Engine.GetGUIObjectByName("enabledModDown").enabled = modSelected && listObjectName == "modsEnabledList"; | |||||
Engine.GetGUIObjectByName("globalModDescription").caption = | Engine.GetGUIObjectByName("globalModDescription").caption = | ||||
listObject.list[listObject.selected] ? | listObject.list[listObject.selected] ? | ||||
g_Mods[listObject.list[listObject.selected]].description : | g_Mods[listObject.list[listObject.selected]].description : | ||||
'[color="' + g_ColorNoModSelected + '"]' + translate("No mod has been selected.") + '[/color]'; | '[color="' + g_ColorNoModSelected + '"]' + translate("No mod has been selected.") + '[/color]'; | ||||
} | } | ||||
function visitModWebsite() | |||||
/** | |||||
* @returns {string} The url of the currently selected mod. | |||||
*/ | |||||
function getSelectedModUrl() | |||||
{ | { | ||||
let modsEnabledList = Engine.GetGUIObjectByName("modsEnabledList"); | let modsEnabledList = Engine.GetGUIObjectByName("modsEnabledList"); | ||||
let modsDisabledList = Engine.GetGUIObjectByName("modsDisabledList"); | let modsDisabledList = Engine.GetGUIObjectByName("modsDisabledList"); | ||||
let list = modsEnabledList.selected == -1 ? modsDisabledList : modsEnabledList; | let list = modsEnabledList.selected == -1 ? modsDisabledList : modsEnabledList; | ||||
let folder = list.list_folder[list.selected]; | let folder = list.list_folder[list.selected]; | ||||
let url = folder && g_Mods[folder] && g_Mods[folder].url; | return folder && g_Mods[folder] && g_Mods[folder].url || ""; | ||||
} | |||||
function visitModWebsite() | |||||
{ | |||||
let url = getSelectedModUrl(); | |||||
if (!url) | if (!url) | ||||
return; | return; | ||||
if (!url.startsWith("http://") && !url.startsWith("https://")) | if (!url.startsWith("http://") && !url.startsWith("https://")) | ||||
url = "http://" + url; | url = "http://" + url; | ||||
openURL(url); | openURL(url); | ||||
} | } |
Could fix the warning here while at it :)