Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/structree/draw.js
Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | for (let prodType in trainer.production) | ||||
} | } | ||||
if (!drawProdIcon(null, t, null, p, prod)) | if (!drawProdIcon(null, t, null, p, prod)) | ||||
break; | break; | ||||
++p; | ++p; | ||||
} | } | ||||
} | } | ||||
hideRemaining("trainer["+t+"]_row", p); | hideRemaining("trainer["+t+"]_row", p); | ||||
let size = thisEle.size; | // Centre the production icons. | ||||
size.right = size.left + Math.max(p*24, defWidth) + 4; | let size = thisEle.getComputedSize(); | ||||
thisEle.size = size; | |||||
let eleWidth = size.right - size.left; | let eleWidth = size.right - size.left; | ||||
let wid = p * 24 - 4; | let wid = p * 24 - 4; | ||||
let phaEle = Engine.GetGUIObjectByName("trainer["+t+"]_row"); | let phaEle = Engine.GetGUIObjectByName("trainer["+t+"]_row"); | ||||
size = phaEle.size; | size = phaEle.size; | ||||
size.left = (eleWidth - wid)/2; | size.left = (eleWidth - wid)/2; | ||||
phaEle.size = size; | phaEle.size = size; | ||||
++t; | ++t; | ||||
} | } | ||||
hideRemaining("trainers", t); | hideRemaining("trainers", t); | ||||
let size = Engine.GetGUIObjectByName("display_tree").size; | if (g_CivData[g_SelectedCiv].relicCart) | ||||
size.right = t > 0 ? -124 : -4; | { | ||||
Engine.GetGUIObjectByName("display_tree").size = size; | let relic = g_CivData[g_SelectedCiv].relicCart; | ||||
Engine.GetGUIObjectByName("relic_icon").sprite = "stretched:session/portraits/"+relic.icon; | |||||
Engine.GetGUIObjectByName("display_trainers").hidden = t == 0; | Engine.GetGUIObjectByName("relic_icon").tooltip = assembleTooltip(relic); | ||||
Engine.GetGUIObjectByName("relic_name").caption = translate(relic.name.specific); | |||||
} | |||||
Engine.GetGUIObjectByName("relic").hidden = !g_CivData[g_SelectedCiv].relicCart; | |||||
} | } | ||||
function drawProdIcon(pha, s, r, p, prod) | function drawProdIcon(pha, s, r, p, prod) | ||||
{ | { | ||||
let prodEle = Engine.GetGUIObjectByName("phase["+pha+"]_struct["+s+"]_row["+r+"]_prod["+p+"]"); | let prodEle = Engine.GetGUIObjectByName("phase["+pha+"]_struct["+s+"]_row["+r+"]_prod["+p+"]"); | ||||
if (pha === null) | if (pha === null) | ||||
prodEle = Engine.GetGUIObjectByName("trainer["+s+"]_prod["+p+"]"); | prodEle = Engine.GetGUIObjectByName("trainer["+s+"]_prod["+p+"]"); | ||||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | function predraw() | ||||
let t = 0; | let t = 0; | ||||
let ele = Engine.GetGUIObjectByName("trainer["+t+"]"); | let ele = Engine.GetGUIObjectByName("trainer["+t+"]"); | ||||
g_DrawLimits.trainer = { | g_DrawLimits.trainer = { | ||||
"trainerQuant": 0, | "trainerQuant": 0, | ||||
"prodQuant": 0 | "prodQuant": 0 | ||||
}; | }; | ||||
let x = 4; | let x = 0; | ||||
do | do | ||||
{ | { | ||||
let p = 0; | let p = 0; | ||||
let prodEle = Engine.GetGUIObjectByName("trainer["+t+"]_prod["+p+"]"); | let prodEle = Engine.GetGUIObjectByName("trainer["+t+"]_prod["+p+"]"); | ||||
do | do | ||||
{ | { | ||||
let prodsize = prodEle.size; | let prodsize = prodEle.size; | ||||
prodsize.left = (initIconSize.right+4) * p; | prodsize.left = (initIconSize.right+4) * p; | ||||
prodsize.right = (initIconSize.right+4) * (p+1) - 4; | prodsize.right = (initIconSize.right+4) * (p+1) - 4; | ||||
prodEle.size = prodsize; | prodEle.size = prodsize; | ||||
p++; | p++; | ||||
prodEle = Engine.GetGUIObjectByName("trainer["+t+"]_prod["+p+"]"); | prodEle = Engine.GetGUIObjectByName("trainer["+t+"]_prod["+p+"]"); | ||||
} while (prodEle !== undefined); | } while (prodEle !== undefined); | ||||
Engine.GetGUIObjectByName("trainer["+t+"]_row").size = "4 100%-24"+" 100%-4 100%"; | Engine.GetGUIObjectByName("trainer["+t+"]_row").size = "4 100%-24 100%-4 100%"; | ||||
g_DrawLimits.trainer.prodQuant = p; | g_DrawLimits.trainer.prodQuant = p; | ||||
let size = ele.size; | let size = ele.size; | ||||
size.top += x; | size.top += x; | ||||
size.bottom += x + 24; | size.bottom += x + 24; | ||||
x += size.bottom - size.top + 8; | x += size.bottom - size.top + 8; | ||||
ele.size = size; | ele.size = size; | ||||
Show All 39 Lines |
Wildfire Games · Phabricator