Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/reference/common/ReferencePage.js
- This file was added.
/** | |||||
* This class contains code common to the Structure Tree, Template Viewer, and any other "Reference Page" that may be added in the future. | |||||
*/ | |||||
class ReferencePage | |||||
{ | |||||
/* This class possesses static fields. Unfortunately, the version of | |||||
* SpiderMonkey we're using does not support the syntax to add them | |||||
* within the body of the class. Also, as class definitions are not | |||||
* hoisted, they are defined at the bottom of this file. | |||||
elexis: "gaia" could be this.DefaultCiv, string is reused in multiple places too. Even across multiple… | |||||
*/ | |||||
Done Inline Actions/* This class possesses static fields. Unfortunately, the version of * SpiderMonkey we're using does not support the syntax to add them * within the body of the class. Also, as class definitions are not * hoisted, they are defined at the bottom of this file. */ This refers to StatsFunctions? ReferencePage.prototype.StatsFunctions = [func1, func2, ...]; doesnt work? elexis: ```
/* This class possesses static fields. Unfortunately, the version of
* SpiderMonkey… | |||||
constructor() | |||||
{ | |||||
this.activeCiv = "gaia"; | |||||
this.civData = loadCivData(true, false); | |||||
this.Loader = new Loader(); | |||||
this.Lister = new Lister(this.Loader); | |||||
this.Parser = new Parser(this.Loader); | |||||
this.currentTemplateLists = {}; | |||||
} | |||||
setActiveCiv(civCode) | |||||
{ | |||||
if (civCode == "gaia") | |||||
return; | |||||
this.activeCiv = civCode; | |||||
this.currentTemplateLists = this.Lister.compileTemplateLists(this.activeCiv, this.civData); | |||||
this.Parser.deriveModifications(this.activeCiv); | |||||
this.Parser.derivePhaseList(this.currentTemplateLists.techs.keys(), this.activeCiv); | |||||
} | |||||
/** | |||||
* Concatanates the return values of the array of passed functions. | |||||
* | |||||
* @param {object} template | |||||
* @param {array} textFunctions | |||||
* @param {string} joiner | |||||
* @return {string} The built text. | |||||
*/ | |||||
static buildText(template, textFunctions=[], joiner="\n") | |||||
{ | |||||
return textFunctions.map(func => func(template)).filter(tip => tip).join(joiner); | |||||
} | |||||
} | |||||
/** | |||||
* List of functions that get the statistics of any template or entity, | |||||
* formatted in such a way as to appear in a tooltip. | |||||
* | |||||
* The functions listed are defined in gui/common/tooltips.js | |||||
*/ | |||||
Object.defineProperty(ReferencePage, 'StatsFunctions', { value: [ | |||||
getHealthTooltip, | |||||
getHealerTooltip, | |||||
getAttackTooltip, | |||||
getSplashDamageTooltip, | |||||
getArmorTooltip, | |||||
getGarrisonTooltip, | |||||
getProjectilesTooltip, | |||||
getSpeedTooltip, | |||||
getGatherTooltip, | |||||
getResourceSupplyTooltip, | |||||
getPopulationBonusTooltip, | |||||
getResourceTrickleTooltip, | |||||
getLootTooltip | |||||
]}); |
Wildfire Games · Phabricator
"gaia" could be this.DefaultCiv, string is reused in multiple places too. Even across multiple classes if I see correctly, which might make it a bit indirect to refer to with a single reference however.