Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_details.js
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
// Fills out information that most entities have | // Fills out information that most entities have | ||||
function displaySingle(entState) | function displaySingle(entState) | ||||
{ | { | ||||
// Get general unit and player data | // Get general unit and player data | ||||
let template = GetTemplateData(entState.template); | let template = GetTemplateData(entState.template); | ||||
let specificName = template.name.specific; | let specificName = template.name.specific; | ||||
let genericName = template.name.generic; | let genericName = template.name.generic; | ||||
let primaryName = g_SpecificNamesPrimary ? specificName : genericName; | |||||
let secondaryName; | |||||
if (g_ShowSecondaryNames) | |||||
secondaryName = g_SpecificNamesPrimary ? genericName : specificName; | |||||
// If packed, add that to the generic name (reduces template clutter) | // If packed, add that to the generic name (reduces template clutter) | ||||
if (genericName && template.pack && template.pack.state == "packed") | if (template.pack && template.pack.state == "packed") | ||||
genericName = sprintf(translate("%(genericName)s — Packed"), { "genericName": genericName }); | { | ||||
if (secondaryName && g_ShowSecondaryNames) | |||||
secondaryName = sprintf(translate("%(secondaryName)s — Packed"), { "secondaryName": secondaryName }); | |||||
else | |||||
secondaryName = sprintf(translate("Packed")); | |||||
} | |||||
let playerState = g_Players[entState.player]; | let playerState = g_Players[entState.player]; | ||||
let civName = g_CivData[playerState.civ].Name; | let civName = g_CivData[playerState.civ].Name; | ||||
let civEmblem = g_CivData[playerState.civ].Emblem; | let civEmblem = g_CivData[playerState.civ].Emblem; | ||||
let playerName = playerState.name; | let playerName = playerState.name; | ||||
let playerColor = rgbToGuiColor(g_DisplayedPlayerColors[entState.player], 128); | let playerColor = rgbToGuiColor(g_DisplayedPlayerColors[entState.player], 128); | ||||
▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | else if (entState.repairable && entState.needsRepair) | ||||
resourceCarryingText.caption = entState.repairable.numBuilders ? | resourceCarryingText.caption = entState.repairable.numBuilders ? | ||||
Engine.FormatMillisecondsIntoDateStringGMT(entState.repairable.buildTime.timeRemaining * 1000, translateWithContext("countdown format", "m:ss")) : ""; | Engine.FormatMillisecondsIntoDateStringGMT(entState.repairable.buildTime.timeRemaining * 1000, translateWithContext("countdown format", "m:ss")) : ""; | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
resourceCarryingIcon.hidden = true; | resourceCarryingIcon.hidden = true; | ||||
resourceCarryingText.hidden = true; | resourceCarryingText.hidden = true; | ||||
} | } | ||||
Engine.GetGUIObjectByName("specific").caption = specificName; | |||||
Engine.GetGUIObjectByName("player").caption = playerName; | Engine.GetGUIObjectByName("player").caption = playerName; | ||||
Engine.GetGUIObjectByName("playerColorBackground").sprite = "color:" + playerColor; | Engine.GetGUIObjectByName("playerColorBackground").sprite = "color:" + playerColor; | ||||
Engine.GetGUIObjectByName("generic").caption = genericName == specificName ? "" : | |||||
sprintf(translate("(%(genericName)s)"), { | Engine.GetGUIObjectByName("primary").caption = primaryName; | ||||
"genericName": genericName | Engine.GetGUIObjectByName("secondary").caption = !secondaryName || primaryName == secondaryName ? "" : | ||||
sprintf(translate("(%(secondaryName)s)"), { | |||||
"secondaryName": secondaryName | |||||
}); | }); | ||||
let isGaia = playerState.civ == "gaia"; | let isGaia = playerState.civ == "gaia"; | ||||
Engine.GetGUIObjectByName("playerCivIcon").sprite = isGaia ? "" : "stretched:grayscale:" + civEmblem; | Engine.GetGUIObjectByName("playerCivIcon").sprite = isGaia ? "" : "stretched:grayscale:" + civEmblem; | ||||
Engine.GetGUIObjectByName("player").tooltip = isGaia ? "" : civName; | Engine.GetGUIObjectByName("player").tooltip = isGaia ? "" : civName; | ||||
// TODO: we should require all entities to have icons | // TODO: we should require all entities to have icons | ||||
Engine.GetGUIObjectByName("icon").sprite = template.icon ? ("stretched:session/portraits/" + template.icon) : "BackgroundBlack"; | Engine.GetGUIObjectByName("icon").sprite = template.icon ? ("stretched:session/portraits/" + template.icon) : "BackgroundBlack"; | ||||
Show All 12 Lines | Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = [ | ||||
getGarrisonTooltip, | getGarrisonTooltip, | ||||
getProjectilesTooltip, | getProjectilesTooltip, | ||||
getResourceTrickleTooltip, | getResourceTrickleTooltip, | ||||
getLootTooltip | getLootTooltip | ||||
].map(func => func(entState)).filter(tip => tip).join("\n"); | ].map(func => func(entState)).filter(tip => tip).join("\n"); | ||||
let iconTooltips = []; | let iconTooltips = []; | ||||
if (genericName) | iconTooltips.push(setStringTags(primaryName, g_TooltipTextFormats.namePrimaryBig)); | ||||
iconTooltips.push("[font=\"sans-bold-16\"]" + genericName + "[/font]"); | |||||
iconTooltips = iconTooltips.concat([ | iconTooltips = iconTooltips.concat([ | ||||
getVisibleEntityClassesFormatted, | getVisibleEntityClassesFormatted, | ||||
getAurasTooltip, | getAurasTooltip, | ||||
getEntityTooltip, | getEntityTooltip, | ||||
showTemplateViewerOnRightClickTooltip | showTemplateViewerOnRightClickTooltip | ||||
].map(func => func(template))); | ].map(func => func(template))); | ||||
▲ Show 20 Lines • Show All 206 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator