Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/reference/viewer/viewer.js
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | function init(data) | ||||
g_StatsFunctions = [getEntityCostTooltip].concat(g_StatsFunctions); | g_StatsFunctions = [getEntityCostTooltip].concat(g_StatsFunctions); | ||||
draw(); | draw(); | ||||
} | } | ||||
/** | /** | ||||
* Populate the UI elements. | * Populate the UI elements. | ||||
* | |||||
* @todo (c++ change) Implement and use a function that fetches height of rendered text block from text object. | |||||
*/ | */ | ||||
function draw() | function draw() | ||||
{ | { | ||||
Engine.GetGUIObjectByName("entityName").caption = getEntityNamesFormatted(g_Template); | Engine.GetGUIObjectByName("entityName").caption = getEntityNamesFormatted(g_Template); | ||||
let entityIcon = Engine.GetGUIObjectByName("entityIcon"); | let entityIcon = Engine.GetGUIObjectByName("entityIcon"); | ||||
entityIcon.sprite = "stretched:session/portraits/" + g_Template.icon; | entityIcon.sprite = "stretched:session/portraits/" + g_Template.icon; | ||||
let entityStats = Engine.GetGUIObjectByName("entityStats"); | let entityStats = Engine.GetGUIObjectByName("entityStats"); | ||||
entityStats.caption = buildText(g_Template, g_StatsFunctions); | entityStats.caption = buildText(g_Template, g_StatsFunctions); | ||||
// This is something of a crude hack. See above todo. | |||||
let entityInfo = Engine.GetGUIObjectByName("entityInfo"); | let entityInfo = Engine.GetGUIObjectByName("entityInfo"); | ||||
let lines = entityStats.caption.split("\n").length; | |||||
let fontSize = +entityStats.font.split("-")[1] + 4; | |||||
let infoSize = entityInfo.size; | let infoSize = entityInfo.size; | ||||
infoSize.top = Math.max(entityIcon.size.bottom, lines * fontSize + entityStats.size.top) + 8; | // The magic '8' below provides a gap between the bottom of the icon, and the start of the info text. | ||||
infoSize.top = Math.max(entityIcon.size.bottom + 8, entityStats.size.top + entityStats.getTextSize().height); | |||||
wraitii: The "8" now looks particularly conspicuous. Warrants at least a comment on why it's there. | |||||
entityInfo.size = infoSize; | entityInfo.size = infoSize; | ||||
entityInfo.caption = buildText(g_Template, g_InfoFunctions, "\n\n"); | entityInfo.caption = buildText(g_Template, g_InfoFunctions, "\n\n"); | ||||
if (g_Template.promotion) | if (g_Template.promotion) | ||||
Engine.GetGUIObjectByName("entityRankGlyph").sprite = "stretched:" + g_RankIconPath + g_Template.promotion.current_rank + ".png"; | Engine.GetGUIObjectByName("entityRankGlyph").sprite = "stretched:" + g_RankIconPath + g_Template.promotion.current_rank + ".png"; | ||||
Engine.GetGUIObjectByName("entityRankGlyph").hidden = !g_Template.promotion; | Engine.GetGUIObjectByName("entityRankGlyph").hidden = !g_Template.promotion; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
The "8" now looks particularly conspicuous. Warrants at least a comment on why it's there.