Changeset View
Standalone View
binaries/data/mods/mod/gui/modmod/modio.js
- This file was added.
let g_Mods = []; | |||||
elexis: I think we have 0 or 1 let in global space currently. I recall you saying in that trigger… | |||||
function init() | |||||
{ | |||||
g_Mods = Engine.ModIoGetMods(); | |||||
generateModsList(g_Mods); | |||||
} | |||||
Done Inline ActionsTODO remove that of course Itms: TODO remove that of course | |||||
function generateModsList(mods) | |||||
{ | |||||
var [keys, names, name_ids, versions, filenames, filesizes, filehash_md5s, downloads] = [[],[],[],[],[],[],[],[]]; | |||||
let i = 0; | |||||
for (let mod of mods) | |||||
Not Done Inline ActionsIs it needed to have this as var if it's assigned to another var below? Itms: Is it needed to have this as `var` if it's assigned to another var below? | |||||
{ | |||||
keys.push(i++); | |||||
names.push(mod.name); | |||||
Not Done Inline ActionsI'd find a C-style loop over i more beautiful but that's just personal taste. Itms: I'd find a C-style loop over `i` more beautiful but that's just personal taste. | |||||
name_ids.push(mod.name_id); | |||||
versions.push(mod.version); | |||||
filenames.push(mod.filename); | |||||
filesizes.push(mod.filesize); | |||||
filehash_md5s.push(mod.filehash_md5); | |||||
downloads.push(mod.binary_url); | |||||
} | |||||
var obj = Engine.GetGUIObjectByName("modsAvailableList"); | |||||
obj.list_name = names; | |||||
Not Done Inline Actionslet modsAvailableList = Engine.GetGUIObjectByName("modsAvailableList"); (having only one name for objects makes things easier) elexis: `let modsAvailableList = Engine.GetGUIObjectByName("modsAvailableList");` (having only one name… | |||||
obj.list_modVersion = versions; | |||||
obj.list_modname_id = name_ids; | |||||
obj.list_modfilename = filenames; | |||||
obj.list_modfilesize = filesizes; | |||||
obj.list_modfilehash_md5 = filehash_md5s; | |||||
Done Inline ActionsIt would be great to have filesizes in human-readable form in the GUI. Itms: It would be great to have filesizes in human-readable form in the GUI. | |||||
obj.list_moddownload = downloads; | |||||
Not Done Inline Actionscan be cut in half with `list_foo = mods.map((mod, i) => mod.property || i) elexis: can be cut in half with `list_foo = mods.map((mod, i) => mod.property || i) | |||||
obj.list = keys; | |||||
} | |||||
function showModDescription() | |||||
{ | |||||
let listObject = Engine.GetGUIObjectByName("modsAvailableList"); | |||||
let desc = "No mod has been selected."; | |||||
if (listObject.selected != -1) | |||||
Not Done Inline Actionstranslate elexis: translate
ternary+inline (<= only assigning a value if it's used doesn't make the reader… | |||||
Not Done Inline ActionsSomething something WIP. Meh. leper: Something something WIP.
Meh. | |||||
Not Done Inline ActionsThis has to be translated. Of course translation of mod summaries would be hard, but the default message should be in my opinion. Actually this message is not shown for me. Itms: This has to be translated. Of course translation of mod summaries would be hard, but the… | |||||
Not Done Inline ActionsIt isn't, given that this function is only called once something is actually selected. Yes, same as other strings shown to the user. You'd be surprised what more recent versions of the mod code than I based this on (you might guess why) consider possible, not that they think about the implications or why other file formats do that another way (which is ugly, and I'd prefer not having that, but that other approach at least works correctly). See comments about chicken and egg issues elsewhere. leper: It isn't, given that this function is only called once something is actually selected. Yes… | |||||
desc = g_Mods[listObject.selected].summary; | |||||
Engine.GetGUIObjectByName("globalModDescription").caption = desc; | |||||
} | |||||
function downloadMod() | |||||
{ | |||||
let listObject = Engine.GetGUIObjectByName("modsAvailableList"); | |||||
if (listObject.selected == -1) | |||||
{ | |||||
warn("Select something first."); | |||||
return; | |||||
Not Done Inline ActionsThe button should be disabled, the warning can stay in case something bad happens (but should be reformulated). Itms: The button should be disabled, the warning can stay in case something bad happens (but should… | |||||
Not Done Inline ActionsTbh this whole page should disappear, at least as a page in and of itself. I guess integrating the retrieved list into the list of _available_ (not disabled, but ask the new mantainers of the mod code) mods would make this a lot nicer. leper: Tbh this whole page should disappear, at least as a page in and of itself. I guess integrating… | |||||
} | |||||
Engine.ModIoDownloadMod(listObject.selected); // TODO in case we support sorting or filtering this should be the keys value. | |||||
// TODO: pass index to engine to download that. We cannot be trusted with anything but an index (and even that just barely). | |||||
Not Done Inline Actionssorting example rP20555 elexis: sorting example rP20555 | |||||
Not Done Inline ActionsEven without sorting or filtering mods should be identified by the mod identifier. elexis: Even without sorting or filtering mods should be identified by the mod identifier. | |||||
Not Done Inline ActionsNope. Broken api with multiple instances of the identifier (or multiple files because whatever). Read the comment about what comments I consider useful here again. leper: Nope. Broken api with multiple instances of the identifier (or multiple files because whatever). | |||||
} | |||||
function closePage() | |||||
{ | |||||
Engine.SwitchGuiPage("page_pregame.xml", {}); | |||||
} |
I think we have 0 or 1 let in global space currently. I recall you saying in that trigger script global scope patch that let in global context will change its meaning with some SM version, but I recall not finding something about it. If there is, we should start using let globally in other files too.