Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_details.js
function layoutSelectionSingle() | function layoutSelectionSingle() | ||||
{ | { | ||||
Engine.GetGUIObjectByName("detailsAreaSingle").hidden = false; | Engine.GetGUIObjectByName("detailsAreaSingle").hidden = false; | ||||
Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = true; | Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = true; | ||||
} | } | ||||
function layoutSelectionMultiple() | function layoutSelectionMultiple() | ||||
{ | { | ||||
Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = false; | Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = false; | ||||
Engine.GetGUIObjectByName("detailsAreaSingle").hidden = true; | Engine.GetGUIObjectByName("detailsAreaSingle").hidden = true; | ||||
} | } | ||||
function getResourceTypeDisplayName(resourceType) | |||||
{ | |||||
return resourceNameFirstWord( | |||||
resourceType.generic == "treasure" ? | |||||
resourceType.specific : | |||||
resourceType.generic); | |||||
} | |||||
// Updates the health bar of garrisoned units | // Updates the health bar of garrisoned units | ||||
Stan: Could remove the englobing function and use this call in relevant places? | |||||
function updateGarrisonHealthBar(entState, selection) | function updateGarrisonHealthBar(entState, selection) | ||||
{ | { | ||||
if (!entState.garrisonHolder) | if (!entState.garrisonHolder) | ||||
return; | return; | ||||
// Summing up the Health of every single unit | // Summing up the Health of every single unit | ||||
let totalGarrisonHealth = 0; | let totalGarrisonHealth = 0; | ||||
let maxGarrisonHealth = 0; | let maxGarrisonHealth = 0; | ||||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | if (entState.resourceSupply) | ||||
let unitResourceBar = Engine.GetGUIObjectByName("resourceBar"); | let unitResourceBar = Engine.GetGUIObjectByName("resourceBar"); | ||||
let resourceSize = unitResourceBar.size; | let resourceSize = unitResourceBar.size; | ||||
resourceSize.rright = entState.resourceSupply.isInfinite ? 100 : | resourceSize.rright = entState.resourceSupply.isInfinite ? 100 : | ||||
100 * Math.max(0, Math.min(1, +entState.resourceSupply.amount / +entState.resourceSupply.max)); | 100 * Math.max(0, Math.min(1, +entState.resourceSupply.amount / +entState.resourceSupply.max)); | ||||
unitResourceBar.size = resourceSize; | unitResourceBar.size = resourceSize; | ||||
Engine.GetGUIObjectByName("resourceLabel").caption = sprintf(translate("%(resource)s:"), { | Engine.GetGUIObjectByName("resourceLabel").caption = sprintf(translate("%(resource)s:"), { | ||||
"resource": getResourceTypeDisplayName(entState.resourceSupply.type) | "resource": resourceNameFirstWord(entState.resourceSupply.type.generic) | ||||
}); | }); | ||||
Engine.GetGUIObjectByName("resourceStats").caption = resources; | Engine.GetGUIObjectByName("resourceStats").caption = resources; | ||||
} | } | ||||
let resourceCarryingIcon = Engine.GetGUIObjectByName("resourceCarryingIcon"); | let resourceCarryingIcon = Engine.GetGUIObjectByName("resourceCarryingIcon"); | ||||
let resourceCarryingText = Engine.GetGUIObjectByName("resourceCarryingText"); | let resourceCarryingText = Engine.GetGUIObjectByName("resourceCarryingText"); | ||||
resourceCarryingIcon.hidden = false; | resourceCarryingIcon.hidden = false; | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | function displaySingle(entState) | ||||
if (genericName) | if (genericName) | ||||
iconTooltips.push("[font=\"sans-bold-16\"]" + genericName + "[/font]"); | iconTooltips.push("[font=\"sans-bold-16\"]" + genericName + "[/font]"); | ||||
iconTooltips = iconTooltips.concat([ | iconTooltips = iconTooltips.concat([ | ||||
getVisibleEntityClassesFormatted, | getVisibleEntityClassesFormatted, | ||||
getAurasTooltip, | getAurasTooltip, | ||||
getEntityTooltip, | getEntityTooltip, | ||||
getTreasureTooltip, | |||||
showTemplateViewerOnRightClickTooltip | showTemplateViewerOnRightClickTooltip | ||||
].map(func => func(template))); | ].map(func => func(template))); | ||||
Engine.GetGUIObjectByName("iconBorder").tooltip = iconTooltips.filter(tip => tip).join("\n"); | Engine.GetGUIObjectByName("iconBorder").tooltip = iconTooltips.filter(tip => tip).join("\n"); | ||||
Engine.GetGUIObjectByName("detailsAreaSingle").hidden = false; | Engine.GetGUIObjectByName("detailsAreaSingle").hidden = false; | ||||
Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = true; | Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 214 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Could remove the englobing function and use this call in relevant places?