Changeset View
Standalone View
binaries/data/mods/public/gui/reference/viewer/viewer.js
- This file was added.
/** | |||||
* Holder for the template file being displayed | |||||
*/ | |||||
elexis: Short comments would be nice to help people who read the file for the first time (or didn't… | |||||
Done Inline Actions. elexis: . | |||||
var g_Template = {}; | |||||
/** | |||||
* Holder for the template lists generated by compileTemplateLists() | |||||
*/ | |||||
var g_TemplateLists = {}; | |||||
Done Inline Actions-1 space elexis: -1 space
That null isn't needed, is it? Afaik it will either be `undefined` in case someone… | |||||
/** | |||||
* Most templates in simulation/templates/other/ can be safely treated as structures. | |||||
* The templates with filenames that start with the following are the odd ones out. | |||||
*/ | |||||
var g_OtherPathOddities = new Map([ | |||||
["other/special_treasure", "resource"], // Sea-based treasures are in `other/` instead of `gaia/` with the rest of the treasures. | |||||
Done Inline Actionsmodification of variables should be done in a function, can do it on init or a function called on init elexis: modification of variables should be done in a function, can do it on init or a function called… | |||||
["other/catafalque", "unit"] // Catafalques are units. | |||||
]); | |||||
Not Done Inline Actions(In D877 it was discussed whether to rename those directories. Meh, a mess, whatever xd) elexis: (In D877 it was discussed whether to rename those directories. Meh, a mess, whatever xd) | |||||
Done Inline ActionsRelics were moved. I still regret not having spent the time on @Nescio's treasure sorting patch! elexis: Relics were moved.
I still regret not having spent the time on @Nescio's treasure sorting… | |||||
Done Inline ActionsMoved all treasure to gaia/treasure/ and all ruins to gaia/ruins/, D989 elexis: Moved all treasure to `gaia/treasure/` and all ruins to `gaia/ruins/`, D989 | |||||
/** | |||||
* Override style so we can get a bigger specific name. | |||||
Not Done Inline ActionsCondense to 1 line. List is not well defined (array), but that it's an array is self evident, no need to mention that, just consumes time to read when one could have read [ already. elexis: Condense to 1 line. `List` is not well defined (array), but that it's an array is self evident… | |||||
*/ | |||||
g_TooltipTextFormats.entityNameSpecificBig[0] = '[font="sans-bold-20"]'; | |||||
Not Done Inline Actionss/Info/Tooltip elexis: s/Info/Tooltip | |||||
Not Done Inline ActionsThey're not being used in/as a tooltip, so no. s0600204: They're not being used in/as a tooltip, so no. | |||||
Not Done Inline ActionsI mostly recommended that because about every of the items is a Tooltip function. elexis: I mostly recommended that because about every of the items is a Tooltip function.
Then… | |||||
g_TooltipTextFormats.entityNameSpecificSmall[0] = '[font="sans-bold-16"]'; | |||||
g_TooltipTextFormats.entityNameGeneric[0] = '[font="sans-bold-16"]'; | |||||
Not Done Inline Actions(g_TooltipTextFormats should be changed some day to only save the actual fonts) elexis: (`g_TooltipTextFormats` should be changed some day to only save the actual fonts) | |||||
/** | |||||
* Page initialisation. May also eventually pre-draw/arrange objects. | |||||
* | |||||
* @param {object} data - Contains the civCode and the name of the template to display. | |||||
* @param {string} data.templateName | |||||
* @param {string} [data.civ] | |||||
* @param {*} [data.callback] - If set and loosely equivalent to true, a callback is | |||||
Not Done Inline ActionsThe functions here should all do the same thing, return the entire string, not one to return the caption and the rest the rest of the previous function. I suspect you might want 3 arrays, one for auras, one for techs and one for entities. elexis: The functions here should all do the same thing, return the entire string, not one to return… | |||||
* assumed to be setup ready be called by Engine when this | |||||
* page is closed. | |||||
*/ | |||||
function init(data) | |||||
{ | |||||
if (!data || !data.templateName) | |||||
{ | |||||
error("Viewer: No template provided"); | |||||
closePage(); | |||||
return; | |||||
} | |||||
Done Inline Actions-1 space elexis: -1 space | |||||
data.templateName = data.templateName.slice(data.templateName.lastIndexOf("&")+1); | |||||
Not Done Inline ActionsNot ideal, the callers should pass the thing they want to the functions ideally, but might not be so easy to fix, good enough for now. elexis: Not ideal, the callers should pass the thing they want to the functions ideally, but might not… | |||||
if (data.callback) | |||||
g_CallbackSet = true; | |||||
Done Inline Actions(Where did that & come from? Is that something promotion info from the GUI selection? Perhaps a brief comment. Perhaps a split["&"][foo]?) elexis: (Where did that & come from? Is that something promotion info from the GUI selection? Perhaps a… | |||||
Not Done Inline ActionsI can't remember. I'm sure I added it for a reason, whether it be corpses or mirages or something, but I can't seem to work out what it was for. s0600204: I can't remember. I'm sure I added it for a reason, whether it be corpses or mirages or… | |||||
if (data.civ) | |||||
g_SelectedCiv = data.civ; | |||||
g_Template = loadTemplateFromName(data.templateName); | |||||
if (!g_Template) | |||||
{ | |||||
error("Viewer: unable to recognise or load template (" + data.templateName + ")"); | |||||
closePage(); | |||||
return; | |||||
} | |||||
init_civs(); | |||||
g_TemplateLists = compileTemplateLists(g_SelectedCiv); | |||||
draw(); | |||||
} | |||||
/** | |||||
* Populate the UI elements. | |||||
*/ | |||||
function draw() | |||||
{ | |||||
let iconObject = Engine.GetGUIObjectByName("entityIcon") | |||||
Engine.GetGUIObjectByName("entityName").caption = getEntityNamesFormatted(g_Template); | |||||
Not Done Inline Actions(It's the tech requirements defining which civ can research it, but deriving it from the researcher is ok if that's shorter) elexis: (It's the tech requirements defining which civ can research it, but deriving it from the… | |||||
iconObject.sprite = "stretched:session/portraits/" + g_Template.icon; | |||||
let statsObject = Engine.GetGUIObjectByName("entityStats"); | |||||
let statFunctions = [ | |||||
getEntityCostTooltip | |||||
].concat(g_EntityStatFunctions); | |||||
statsObject.caption = buildText(g_Template, statFunctions); | |||||
Done Inline Actionsunneeded parentheses elexis: unneeded parentheses | |||||
// This is something of a crude hack. Ideally, it would be better to | |||||
// acquire the height of the rendered text from the text object, but | |||||
// that is not currently implemented (needs c++ change) | |||||
let infoObject = Engine.GetGUIObjectByName("entityInfo"); | |||||
let lines = statsObject.caption.split("\n").length; | |||||
Not Done Inline ActionsShould always or never pass the civ per parameter (single source of truth, minimization of possible code paths i.e. https://en.wikipedia.org/wiki/Cyclomatic_complexity). If I recall correctly it was only about the palisade wallset? If so I will try to assassinate that. elexis: Should always or never pass the civ per parameter (single source of truth, minimization of… | |||||
Not Done Inline ActionsAnd modders. Please don't assassinate the modders. s0600204: And modders. Please don't assassinate the modders. | |||||
Not Done Inline ActionsBut we don't want to encourage mods using templates as wrong as the palisades however? elexis: But we don't want to encourage mods using templates as wrong as the palisades however? | |||||
let fontSize = +statsObject.font.substr(statsObject.font.indexOf("-")+1) + 4; | |||||
let infoSize = infoObject.size; | |||||
infoSize.top = Math.max(iconObject.size.bottom, lines * fontSize + statsObject.size.top) + 8; | |||||
infoObject.size = infoSize; | |||||
let infoFunctions = [ | |||||
Done Inline Actions(might want to use != -1. I can also stfu) elexis: (might want to use != -1. I can also stfu) | |||||
getEntityTooltip, | |||||
getHistoryTooltip, | |||||
Not Done Inline ActionsCan also do throw new Error, but I guess this one is more comfortable for debugging elexis: Can also do `throw new Error`, but I guess this one is more comfortable for debugging | |||||
getDescriptionTooltip, | |||||
getAurasTooltip, | |||||
getVisibleEntityClassesFormatted, | |||||
getProducedByList, | |||||
getBuildList, | |||||
Done Inline ActionsWe avoid ticket and phabricator references in the code, add an inline comment or add it to the ticket. The comment is good. elexis: We avoid ticket and phabricator references in the code, add an inline comment or add it to the… | |||||
getTrainList, | |||||
getResearchList, | |||||
getUpgradeList | |||||
Done Inline Actionsfont.split("-")[1]? elexis: `font.split("-")[1]`? | |||||
]; | |||||
infoObject.caption = buildText(g_Template, infoFunctions, "\n\n"); | |||||
if (g_Template.promotion) | |||||
Engine.GetGUIObjectByName("entityRankGlyph").sprite = "stretched:" + getRankGlyph(g_Template.promotion.current_rank); | |||||
Engine.GetGUIObjectByName("entityRankGlyph").hidden = !g_Template.promotion; | |||||
} | |||||
Not Done Inline ActionsWe have updateGUIObjects in session and gamesetup ? draw sounds more that paints pixels onTick. Fits also a bit to GetGUIObjectByName. Dunno about the draw.js filename, could be kept if we don't find anything else. elexis: We have `updateGUIObjects` in session and gamesetup ? `draw` sounds more that paints pixels… | |||||
Done Inline Actionsmove one line lower elexis: move one line lower | |||||
/** | |||||
* Determines the requested template and loads it | |||||
* | |||||
Done Inline Actionslet entityStats = Engine.GetGUIObjectByName("entityStats");, easier to track if GUI objects names are unique elexis: `let entityStats = Engine.GetGUIObjectByName("entityStats");`, easier to track if GUI objects… | |||||
* @param {string} templateName - The template name. If loading a technology, then `tech/` must be prefixed. | |||||
* @return {object} The entity object. | |||||
*/ | |||||
function loadTemplateFromName(templateName) | |||||
{ | |||||
Done Inline ActionsIf infoFunctions and statFunctions were global, then we can edit the list of tooltips without having to look or touch the logic code (separation of logic & data) elexis: If `infoFunctions` and `statFunctions` were global, then we can edit the list of tooltips… | |||||
if (templateName.indexOf("|") != -1) | |||||
templateName = templateName.slice(templateName.indexOf("|")+1); | |||||
Not Done Inline ActionsThere is a revision that implements this: D844. If accepted and merged (along with its prerequisite) this "crude hack", as I describe it, could be replaced with something nicer. In fact, one of the reasons why I've been dragging my heels on this revision is that I was hoping to get that revision in first. s0600204: There is a revision that implements this: D844. If accepted and merged (along with its… | |||||
Done Inline Actionsprefix with TODO so we can identify it more easily elexis: prefix with TODO so we can identify it more easily | |||||
if (g_ParsedData[templateName]) | |||||
return g_ParsedData[templateName]; | |||||
Not Done Inline ActionsWe only have few fonts, expecting that it breaks under some circumstance. Font names should be hardcoded, remain exchangeable and findable with a string-search. But that can be done when dealing with the TODO elexis: We only have few fonts, expecting that it breaks under some circumstance. Font names should be… | |||||
Not Done Inline ActionsNo part of this code block sets the font, it only reads it so it can determine how tall each line should be. But yes, most of this block can be replaced by a call to the function implemented/proposed in D844, which would satisfy the @todo. s0600204: No part of this code block sets the font, it only reads it so it can determine how tall each… | |||||
let template; | |||||
switch (getTypeFromName(templateName)) | |||||
{ | |||||
case "structure": | |||||
Done Inline ActionsIt can return false instead of a string, so it should be '{string|false}` http://usejsdoc.org/tags-returns.html Without having read and understood the entire code, it's not too clear what a type of a template is. It might be easier to just map from directory name to function name instead of directory name -> type of a template -> function name. elexis: It can return `false` instead of a string, so it should be '{string|false}` http://usejsdoc. | |||||
template = loadStructure(templateName); | |||||
break; | |||||
case "unit": | |||||
template = loadUnit(templateName); | |||||
break; | |||||
case "resource": | |||||
template = loadResource(templateName); | |||||
break; | |||||
case "tech": | |||||
template = loadTechnology(templateName.substr(templateName.indexOf("/")+1)); | |||||
Not Done Inline Actions(Not a fan of one function parsing different formats) elexis: (Not a fan of one function parsing different formats) | |||||
Not Done Inline Actions(Nor am I, which is partly why this function is in this file, and not in one of the common js files.) s0600204: (Nor am I, which is partly why this function is in this file, and not in one of the common js… | |||||
break; | |||||
Done Inline ActionsThis is likely to break in the future as it's hidden in the code. elexis: This is likely to break in the future as it's hidden in the code.
While we maybe could move the… | |||||
default: | |||||
Done Inline ActionsMabye templateName = templateName.split(("|")[0]? elexis: Mabye `templateName = templateName.split(("|")[0]`? | |||||
// do nothing (error message is given elsewhere) | |||||
} | |||||
g_ParsedData[templateName] = template; | |||||
return template; | |||||
} | |||||
/** | |||||
* Returns the type of entity created from the provided template. | |||||
* | |||||
* This used by loadTemplateFromName() to know which load function to use, | |||||
* and used by getProducedByList() to pick a suitable label. | |||||
* | |||||
* @param {string} templateName | |||||
* @return {(string|false)} Entity type; "structure", "unit", etc. | |||||
*/ | |||||
function getTypeFromName(templateName) | |||||
{ | |||||
Not Done Inline ActionsAs mentioned in the function comment, this is (or rather, was) a near-identical function to one elsewhere. I say "was" because it was a couple of years ago when this page was originally thrown together. The original function this was based on has been altered/rewritten/improved since then. This "copy" was not. I've marked the remarks as "done" as I cannot mark them as "no longer valid" - I've removed this function override in favour of a different approach to what I want to achieve. And hopefully the new approach is a better one. s0600204: As mentioned in the function comment, this is (or rather, was) a near-identical function to one… | |||||
if (templateName.indexOf("|") > -1) | |||||
templateName = templateName.slice(templateName.indexOf("|")+1); | |||||
let prefix = templateName.slice(0, templateName.indexOf("/")); | |||||
if (prefix == "other") | |||||
{ | |||||
for (let [pathStart, type] of g_OtherPathOddities) | |||||
if (templateName.startsWith(pathStart)) | |||||
Not Done Inline ActionsThe internal property seems like a workaround. That property should be accessible to all places using the globalscripts parsing or none. Could also be done by changing the structure to g_BuildList[civ][templateName], g_BuildList[civ] = { "templateName": ..., "template": ... } or g_BuildList[civ] = [templateName1, ...]` and parsing JIT. But it seems legit that one might want to get the templateName from a parsed template, so why not add it to GetTemplateDataHelper? (Can be done afterwards, since it's present already). At last, I don't know where the tech/ actually comes from, can't find it in templates files nor directories. I had assumed we might be able to use basename elexis: The `internal` property seems like a workaround. That property should be accessible to all… | |||||
return type; | |||||
return "structure"; | |||||
} | |||||
Done Inline Actionsthose parentheses should be translated with placeholder(s) elexis: those parentheses should be translated with placeholder(s) | |||||
let dict = { | |||||
"structures": "structure", | |||||
Done Inline ActionsWould be easier moddable to have these fonts global consts (more like g_ResourceTitleFont = "sans-bold-16" in session.js than these constructs in tooltips.js) - or reuse the tooltip font functions directly as is done below. elexis: Would be easier moddable to have these fonts global consts (more like `g_ResourceTitleFont =… | |||||
"units": "unit", | |||||
Done Inline Actions(!= -1 points the reader towards the fact that `< -1 cannot be returned) elexis: (`!= -1` points the reader towards the fact that `< -1 cannot be returned) | |||||
"gaia": "resource", | |||||
Done Inline ActionsShouldn't we just keep the empty string and throw a warning if the name is unknown? elexis: Shouldn't we just keep the empty string and throw a warning if the name is unknown? | |||||
"tech": "tech" | |||||
}; | |||||
return dict[prefix] || false; | |||||
} | |||||
/** | |||||
Done Inline Actionslet templateFoo = templateName.split("|").pop() maybe? elexis: let templateFoo = templateName.split("|").pop() maybe? | |||||
* @param {object} template | |||||
* @return {string} List of the names of all the buildings/units that build/train/research the selected template. | |||||
*/ | |||||
function getProducedByList(template) | |||||
{ | |||||
Not Done Inline ActionsWe shouldn't figure out after the effect what kind of file we're dealing with, but it should be a choice by the template viewer to first load all aura templates into an aura variable, then all techs into a tech variable and then all entity templates into a templates or entitytemplates variable. Whether an entity is a Unit or Structure should be derived from the template (https://en.wikipedia.org/wiki/Single_source_of_truth pattern). I suspect we don't need the Unit / Structure differentiation if the getBuilderTooltip and getResearcherTooltip functions just return emptystring in case. elexis: We shouldn't figure out after the effect what kind of file we're dealing with, but it should be… | |||||
Not Done Inline Actions
If you mean the functions I think you're referring to, they already do.
Where are you getting that from? The structree/reference-suite code has supported units being able to research techs since rP18218. s0600204: > I suspect we don't need the Unit / Structure differentiation if the getBuilderTooltip and… | |||||
if (g_SelectedCiv == "gaia") | |||||
return ""; | |||||
let builders = []; | |||||
let buildCaption = ""; | |||||
Not Done Inline Actions(Oddity to use a struct here and a switch above. Perhaps it could be merged in a global somehow. But not touching it unless there is a sensational idea works too) elexis: (Oddity to use a struct here and a switch above. Perhaps it could be merged in a global somehow. | |||||
switch (getTypeFromName(template.name.internal)) | |||||
{ | |||||
case "structure": | |||||
if (!g_TemplateLists.structures.has(template.name.internal)) | |||||
// Wall towers and gates are not built directly by anything, | |||||
// thus they won't exist in the Map. | |||||
return ""; | |||||
Not Done Inline Actions(As long as we want that colon to have the same color/font as the rest of the caption, transifex people will have to live with not being able to change the formatting nicely. Still noone complained about this, so not relevant) elexis: (As long as we want that colon to have the same color/font as the rest of the caption… | |||||
builders = g_TemplateLists.structures.get(template.name.internal); | |||||
// Translation: Label before list of the names of units that build the structure selected. | |||||
buildCaption = translate("Built by:"); | |||||
break; | |||||
case "unit": | |||||
builders = g_TemplateLists.units.get(template.name.internal); | |||||
// Translation: Label before list of the names of structures or units that train the unit selected. | |||||
buildCaption = translate("Trained at:"); | |||||
break; | |||||
case "tech": | |||||
Done Inline ActionsThese three strings might need a translation comment so that transifex people know what it meant elexis: These three strings might need a translation comment so that transifex people know what it meant | |||||
Done Inline Actionsprod -> tech? elexis: prod -> tech? | |||||
{ | |||||
let templateName = template.name.internal; | |||||
Done Inline Actionsresearch -> techTemplate or technologyTemplate? elexis: research -> techTemplate or technologyTemplate? | |||||
builders = g_TemplateLists.techs.get(templateName.substr(templateName.indexOf("/")+1)); | |||||
// Translation: Label before list of name of stuctures or units that research the technology selected. | |||||
buildCaption = translate("Researched at:"); | |||||
break; | |||||
} | |||||
default: | |||||
return ""; | |||||
} | |||||
Done Inline Actions(could use .map depending on personal taste) elexis: (could use .map depending on personal taste) | |||||
// This can happen, for example with catafalques which cannot be built/trained. | |||||
Done Inline Actionstranslation comment or context elexis: translation comment or context | |||||
if (!builders) | |||||
return ""; | |||||
Done Inline Actions(Some ", " have translation comments, most don't. Doesn't seem like an issue to add this one) elexis: (Some ", " have translation comments, most don't. Doesn't seem like an issue to add this one) | |||||
let builderText = builders.map(builder => getEntityNames(loadTemplateFromName(builder))); | |||||
// Translation: Label followed by a list of unit/structure names. | |||||
return sprintf(translate("%(listHeader)s %(listOfNames)s"), { | |||||
"listHeader": headerFont(buildCaption), | |||||
// Translation: List separator. | |||||
"listOfNames": bodyFont(builderText.join(translate(", "))) | |||||
}); | |||||
Done Inline Actionscould be inlined if you like elexis: could be inlined if you like | |||||
} | |||||
/** | |||||
* @param {object} template | |||||
* @return {string} List of the names of the buildings the selected unit can build. | |||||
*/ | |||||
function getBuildList(template) | |||||
{ | |||||
if (!template.builder || !template.builder.length) | |||||
return ""; | |||||
Not Done Inline Actions(Can't tell right now, but might be nicer as 3 functions too?) elexis: (Can't tell right now, but might be nicer as 3 functions too?) | |||||
Not Done Inline ActionsTried it. Now tell me if you like the duplicated logic... s0600204: Tried it. Now tell me if you like the duplicated logic... | |||||
Not Done Inline ActionsBarely anything left where we can speak of duplication. The function looks much cleaner to me then the previous getProducedByCaption which would mean I should say thank you :-) elexis: Barely anything left where we can speak of duplication. The function looks much cleaner to me… | |||||
Not Done Inline ActionsOk.
You're welcome. s0600204: Ok.
> which would mean I should say thank you :-)
You're welcome. | |||||
let builds = template.builder.map(prod => getEntityNames(loadStructure(prod))); | |||||
// Translation: Label followed by a list of unit or structure names. | |||||
return sprintf(translate("%(listHeader)s %(listOfNames)s"), { | |||||
Not Done Inline Actions(Perhaps we should make a function from that repeated string some day) elexis: (Perhaps we should make a function from that repeated string some day) | |||||
// Translation: Label before a list of the names of structures the selected unit can construct or build. | |||||
"listHeader": headerFont(translate("Builds:")), | |||||
// Translation: List separator. | |||||
"listOfNames": bodyFont(builds.join(translate(", "))) | |||||
}); | |||||
} | |||||
/** | |||||
* @param {object} template | |||||
Done Inline ActionsThe ones who like that could use elexis: The ones who like that could use
`"listOfNames": template.upgrades.map(upgrade =>… | |||||
* @return {string} List of the names of the technologies the selected structure/unit can research. | |||||
*/ | |||||
function getResearchList(template) | |||||
{ | |||||
if (!template.production || !template.production.technology || !template.production.technology.length) | |||||
return ""; | |||||
let builds = []; | |||||
for (let prod of template.production.technology) | |||||
{ | |||||
let research = loadTechnology(prod); | |||||
if (research.reqs) | |||||
builds.push(getEntityNames(research)); | |||||
} | |||||
// Translation: Label followed by a list of technology names. | |||||
Not Done Inline Actions(I had added those a year ago too, but that template is an object is evident from the first line of the function, so not sure if its worth it. If completeness is a value, we might also add other things for completeness. idc) elexis: (I had added those a year ago too, but that `template` is an object is evident from the first… | |||||
return sprintf(translate("%(listHeader)s %(listOfNames)s"), { | |||||
// Translation: Label before a list of the names of technologies the selected unit or structure can research. | |||||
"listHeader": headerFont(translate("Researches:")), | |||||
// Translation: List separator. | |||||
"listOfNames": bodyFont(builds.join(translate(", "))) | |||||
}); | |||||
} | |||||
/** | |||||
* @param {object} template | |||||
* @return {string} List of the names of the units the selected unit can train. | |||||
*/ | |||||
function getTrainList(template) | |||||
{ | |||||
if (!template.production || !template.production.units || !template.production.units.length) | |||||
return ""; | |||||
let builds = template.production.units.map(prod => getEntityNames(loadUnit(prod))); | |||||
// Translation: Label followed by a list of unit names. | |||||
return sprintf(translate("%(listHeader)s %(listOfNames)s"), { | |||||
// Translation: Label before a list of the names of units the selected unit or structure can train. | |||||
"listHeader": headerFont(translate("Trains:")), | |||||
// Translation: List separator. | |||||
"listOfNames": bodyFont(builds.join(translate(", "))) | |||||
}); | |||||
} | |||||
/** | |||||
* @param {object} template | |||||
* @return {string} List of the names of the buildings/units the selected structure/unit can upgrade to. | |||||
Not Done Inline ActionsNot a string. Again I think reading the first line of the function reveals much more than any description could achieve. elexis: Not a string. Again I think reading the first line of the function reveals much more than any… | |||||
Not Done Inline ActionsUh, the return is a string. Might be an empty string on some occasions, but it still is a string. I realise the name of the function may be misleading, so I've renamed this and the other applicable functions. s0600204: Uh, the return //is// a string. Might be an empty string on some occasions, but it still is a… | |||||
*/ | |||||
function getUpgradeList(template) | |||||
{ | |||||
if (!template.upgrades) | |||||
Done Inline ActionsIf we have a globally consistent naming templateName for strings and template for objects, then we don't need to repeat describing it. elexis: If we have a globally consistent naming `templateName` for strings and `template` for objects… | |||||
return ""; | |||||
let builds = template.upgrades.map(prod => getEntityNames(prod)); | |||||
Not Done Inline Actions(D717 will provide that) elexis: (D717 will provide that) | |||||
Not Done Inline ActionsOh, good. I'm tempted to make this revision require that revision in that case. Tempted, but probably won't. s0600204: Oh, good. I'm tempted to make this revision require that revision in that case. Tempted, but… | |||||
// Translation: Label followed by a list of unit or structure names. | |||||
return sprintf(translate("%(listHeader)s %(listOfNames)s"), { | |||||
// Translation: Label before a list of the names of units or structures the selected unit or structure can be upgradable to. | |||||
"listHeader": headerFont(translate("Upgradable to:")), | |||||
// Translation: List separator. | |||||
"listOfNames": bodyFont(builds.join(translate(", "))) | |||||
}); | |||||
} | |||||
/** | |||||
* Returns the appropriate promotion rank glyph for a given rank | |||||
* | |||||
* TODO: Don't hardcode ranks. | |||||
* | |||||
* @param {string} rank | |||||
* @return {string} Path to the image. | |||||
*/ | |||||
function getRankGlyph(rank) | |||||
{ | |||||
let ranks = [ "Basic", "Advanced", "Elite" ]; | |||||
if (ranks.indexOf(rank) == -1) | |||||
return null; | |||||
return "session/icons/rank" + (ranks.indexOf(rank) + 1) + ".png"; | |||||
} | |||||
Not Done Inline ActionsOh I get it, we have some JSON files to throw at it again :-) elexis: Oh I get it, we have some JSON files to throw at it again :-) | |||||
Done Inline ActionsIf we could get D717 in at some point, or even just the renamed-images part of it, this todo could be dealt with. s0600204: If we could get D717 in at some point, or even just the renamed-images part of it, this todo… |
Short comments would be nice to help people who read the file for the first time (or didn't read them since a long time) to understand what the variables contain and how they are used.