Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/reference/structree/draw.js
/** | /** | ||||
* Functions used to collate the contents of a tooltip. | |||||
*/ | |||||
var g_StructreeTooltipFunctions = [ | |||||
getEntityNamesFormatted, | |||||
getEntityCostTooltip, | |||||
getEntityTooltip, | |||||
getAurasTooltip | |||||
].concat(g_StatsFunctions); | |||||
/** | |||||
* Draw the structree | * Draw the structree | ||||
* | * | ||||
* (Actually resizes and changes visibility of elements, and populates text) | * (Actually resizes and changes visibility of elements, and populates text) | ||||
*/ | */ | ||||
function draw() | function draw() | ||||
{ | { | ||||
// Set basic state (positioning of elements mainly), but only once | // Set basic state (positioning of elements mainly), but only once | ||||
if (!Object.keys(g_DrawLimits).length) | if (!Object.keys(g_DrawLimits).length) | ||||
Show All 29 Lines | for (let stru of g_BuildList[g_SelectedCiv][pha]) | ||||
let c = 0; | let c = 0; | ||||
let rowCounts = []; | let rowCounts = []; | ||||
stru = g_ParsedData.structures[stru]; | stru = g_ParsedData.structures[stru]; | ||||
Engine.GetGUIObjectByName("phase["+i+"]_struct["+s+"]_icon").sprite = | Engine.GetGUIObjectByName("phase["+i+"]_struct["+s+"]_icon").sprite = | ||||
"stretched:session/portraits/"+stru.icon; | "stretched:session/portraits/"+stru.icon; | ||||
Engine.GetGUIObjectByName("phase["+i+"]_struct["+s+"]_icon").tooltip = | Engine.GetGUIObjectByName("phase["+i+"]_struct["+s+"]_icon").tooltip = | ||||
buildText(stru, g_TooltipFunctions); | compileTooltip(stru); | ||||
Engine.GetGUIObjectByName("phase["+i+"]_struct["+s+"]_name").caption = | Engine.GetGUIObjectByName("phase["+i+"]_struct["+s+"]_name").caption = | ||||
translate(stru.name.specific); | translate(stru.name.specific); | ||||
setViewerOnPress("phase["+i+"]_struct["+s+"]_icon", stru.name.internal); | |||||
thisEle.hidden = false; | thisEle.hidden = false; | ||||
for (let r in g_DrawLimits[pha].prodQuant) | for (let r in g_DrawLimits[pha].prodQuant) | ||||
{ | { | ||||
let p = 0; | let p = 0; | ||||
r = +r; // force int | r = +r; // force int | ||||
let prod_pha = phaseList[phaseList.indexOf(pha) + r]; | let prod_pha = phaseList[phaseList.indexOf(pha) + r]; | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | for (let trainer of g_TrainList[g_SelectedCiv]) | ||||
if (thisEle === undefined) | if (thisEle === undefined) | ||||
{ | { | ||||
error("\""+g_SelectedCiv+"\" has more unit trainers than can be supported by the current GUI layout"); | error("\""+g_SelectedCiv+"\" has more unit trainers than can be supported by the current GUI layout"); | ||||
break; | break; | ||||
} | } | ||||
trainer = g_ParsedData.units[trainer]; | trainer = g_ParsedData.units[trainer]; | ||||
Engine.GetGUIObjectByName("trainer["+t+"]_icon").sprite = "stretched:session/portraits/"+trainer.icon; | Engine.GetGUIObjectByName("trainer["+t+"]_icon").sprite = "stretched:session/portraits/"+trainer.icon; | ||||
Engine.GetGUIObjectByName("trainer["+t+"]_icon").tooltip = buildText(trainer, g_TooltipFunctions); | Engine.GetGUIObjectByName("trainer["+t+"]_icon").tooltip = compileTooltip(trainer); | ||||
Engine.GetGUIObjectByName("trainer["+t+"]_name").caption = translate(trainer.name.specific); | Engine.GetGUIObjectByName("trainer["+t+"]_name").caption = translate(trainer.name.specific); | ||||
setViewerOnPress("trainer["+t+"]_icon", trainer.name.internal); | |||||
thisEle.hidden = false; | thisEle.hidden = false; | ||||
let p = 0; | let p = 0; | ||||
if (trainer.production) | if (trainer.production) | ||||
for (let prodType in trainer.production) | for (let prodType in trainer.production) | ||||
for (let prod of trainer.production[prodType]) | for (let prod of trainer.production[prodType]) | ||||
{ | { | ||||
switch (prodType) | switch (prodType) | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | function drawProdIcon(phase, parentID, rowID, iconID, template) | ||||
if (prodEle === undefined) | if (prodEle === undefined) | ||||
{ | { | ||||
error("The " + (phase === null ? "trainer units" : "structures") + " of \"" + g_SelectedCiv + | error("The " + (phase === null ? "trainer units" : "structures") + " of \"" + g_SelectedCiv + | ||||
"\" have more production icons than can be supported by the current GUI layout"); | "\" have more production icons than can be supported by the current GUI layout"); | ||||
return false; | return false; | ||||
} | } | ||||
prodEle.sprite = "stretched:session/portraits/"+template.icon; | prodEle.sprite = "stretched:session/portraits/"+template.icon; | ||||
prodEle.tooltip = buildText(template, g_TooltipFunctions); | prodEle.tooltip = compileTooltip(template); | ||||
prodEle.hidden = false; | prodEle.hidden = false; | ||||
setViewerOnPress(prodEle.name, template.name.internal); | |||||
return true; | return true; | ||||
} | } | ||||
function compileTooltip(template) | |||||
{ | |||||
return buildText(template, g_StructreeTooltipFunctions) + "\n" + templateViewerOnClickMessage(false); | |||||
} | |||||
/** | /** | ||||
* Calculate row position offset (accounting for different number of prod rows per phase). | * Calculate row position offset (accounting for different number of prod rows per phase). | ||||
* | * | ||||
* @param {number} idx | * @param {number} idx | ||||
* @return {number} | * @return {number} | ||||
*/ | */ | ||||
function getPositionOffset(idx) | function getPositionOffset(idx) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator