diff --git a/binaries/data/mods/public/gui/common/tooltips.js b/binaries/data/mods/public/gui/common/tooltips.js index 1a8c4b5b39..5ba2c77456 100644 --- a/binaries/data/mods/public/gui/common/tooltips.js +++ b/binaries/data/mods/public/gui/common/tooltips.js @@ -1,4 +1,4 @@ -const g_CostDisplayNames = { +const g_CostDisplayIcons = { "food": '[icon="iconFood"]', "wood": '[icon="iconWood"]', "stone": '[icon="iconStone"]', @@ -258,10 +258,10 @@ function getBuildRateTooltip(rate) * Translates a cost component identifier as they are used internally * (e.g. "population", "food", etc.) to proper display names. */ -function getCostComponentDisplayName(costComponentName) +function getCostComponentDisplayIcon(costComponentName) { - if (costComponentName in g_CostDisplayNames) - return g_CostDisplayNames[costComponentName]; + if (costComponentName in g_CostDisplayIcons) + return g_CostDisplayIcons[costComponentName]; warn(sprintf("The specified cost component, ā€˜%(component)s’, is not currently supported.", { "component": costComponentName })); return ""; @@ -292,10 +292,10 @@ function getEntityCostComponentsTooltipString(template, trainNum, entity) let costs = []; - for (let type in g_CostDisplayNames) + for (let type in g_CostDisplayIcons) if (totalCosts[type]) costs.push(sprintf(translate("%(component)s %(cost)s"), { - "component": getCostComponentDisplayName(type), + "component": getCostComponentDisplayIcon(type), "cost": totalCosts[type] })); @@ -353,7 +353,7 @@ function getWallPieceTooltip(wallTypes) // Translation: This string is part of the resources cost string on // the tooltip for wall structures. out.push(sprintf(translate("%(resourceIcon)s %(minimum)s to %(resourceIcon)s %(maximum)s"), { - "resourceIcon": getCostComponentDisplayName(resource), + "resourceIcon": getCostComponentDisplayIcon(resource), "minimum": resourceMin, "maximum": resourceMax })); @@ -415,7 +415,7 @@ function getNeededResourcesTooltip(resources) let formatted = []; for (let resource in resources) formatted.push(sprintf(translate("%(component)s %(cost)s"), { - "component": '[font="sans-12"]' + getCostComponentDisplayName(resource) + '[/font]', + "component": '[font="sans-12"]' + getCostComponentDisplayIcon(resource) + '[/font]', "cost": resources[resource] })); diff --git a/binaries/data/mods/public/gui/session/selection_details.js b/binaries/data/mods/public/gui/session/selection_details.js index e1913b7855..7948042fe3 100644 --- a/binaries/data/mods/public/gui/session/selection_details.js +++ b/binaries/data/mods/public/gui/session/selection_details.js @@ -338,6 +338,7 @@ function displayMultiple(selection) let maxCapturePoints = 0; let capturePoints = (new Array(g_MaxPlayers + 1)).fill(0); let playerID = 0; + let totalResourcesCarried = {}; for (let i = 0; i < selection.length; ++i) { @@ -355,6 +356,12 @@ function displayMultiple(selection) maxCapturePoints += entState.maxCapturePoints; capturePoints = entState.capturePoints.map((v, i) => v + capturePoints[i]); } + + if (entState.resourceCarrying && entState.resourceCarrying.length) + { + let carrying = entState.resourceCarrying[0]; + totalResourcesCarried[carrying.type] = (totalResourcesCarried[carrying.type] || 0) + carrying.amount; + } } Engine.GetGUIObjectByName("healthMultiple").hidden = averageHealth <= 0; @@ -404,7 +411,11 @@ function displayMultiple(selection) }); } - Engine.GetGUIObjectByName("numberOfUnits").caption = selection.length; + let numberOfUnits = Engine.GetGUIObjectByName("numberOfUnits"); + numberOfUnits.caption = selection.length; + numberOfUnits.tooltip = Object.keys(totalResourcesCarried).map(res => + getCostComponentDisplayIcon(res) + totalResourcesCarried[res] + ).join(" "); // Unhide Details Area Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = false; diff --git a/binaries/data/mods/public/gui/session/selection_panels.js b/binaries/data/mods/public/gui/session/selection_panels.js index 5a410b008b..9b910804d6 100644 --- a/binaries/data/mods/public/gui/session/selection_panels.js +++ b/binaries/data/mods/public/gui/session/selection_panels.js @@ -737,7 +737,7 @@ g_SelectionPanels.Queue = { { tooltip += "\n[color=\"red\"]" + translate("Insufficient population capacity:") + "\n[/color]"; tooltip += sprintf(translate("%(population)s %(neededSlots)s"), { - "population": getCostComponentDisplayName("population"), + "population": getCostComponentDisplayIcon("population"), "neededSlots": data.item.neededSlots }); } @@ -977,23 +977,12 @@ g_SelectionPanels.Selection = { }, "setTooltip": function(data) { + let tooltip = data.name; if (data.carried) - { - var str = data.name + "\n"; - var ress = ["food", "wood", "stone", "metal"]; - for (var i = 0; i < 4; ++i) - { - if (data.carried[ress[i]]) - { - str += getCostComponentDisplayName(ress[i]) + data.carried[ress[i]]; - if (i !== 3) - str += " "; - } - } - data.button.tooltip = str; - } - else - data.button.tooltip = data.name; + tooltip += "\n" + Object.keys(data.carried).map(res => + getCostComponentDisplayIcon(res) + data.carried[res] + ).join(" "); + data.button.tooltip = tooltip; }, "setCountDisplay": function(data) { diff --git a/binaries/data/mods/public/gui/session/selection_panels_middle/multiple_details_area.xml b/binaries/data/mods/public/gui/session/selection_panels_middle/multiple_details_area.xml index 525c30fdd6..373e1a7090 100644 --- a/binaries/data/mods/public/gui/session/selection_panels_middle/multiple_details_area.xml +++ b/binaries/data/mods/public/gui/session/selection_panels_middle/multiple_details_area.xml @@ -19,7 +19,7 @@ - + diff --git a/binaries/data/mods/public/gui/structree/draw.js b/binaries/data/mods/public/gui/structree/draw.js index 1e655b4f6e..05d7f02ab0 100644 --- a/binaries/data/mods/public/gui/structree/draw.js +++ b/binaries/data/mods/public/gui/structree/draw.js @@ -366,7 +366,7 @@ function assembleTooltip(template) let rates = []; for (let type in template.gather) rates.push(sprintf(translate("%(resourceIcon)s %(rate)s"), { - "resourceIcon": getCostComponentDisplayName(type), + "resourceIcon": getCostComponentDisplayIcon(type), "rate": template.gather[type] }));