Show packing/unpacking time in tooltip

Fixes #8929
This commit is contained in:
eZamux authored and eZamus committed 2026-09-25 14:49:46 +02:00
1 parent a056f0f516
commit 08194a1d56
3 files changed
+17 -3

No files matched your search

@@ -724,6 +724,17 @@ function getBuildTimeTooltip(entState)
return result.join("\n");
}
function getPackingTooltip(packing, time)
{
return sprintf(translate("%(label)s %(details)s"), {
"label": packing ? translate("Pack to Move:") : translate("Unpack to Attack:"),
"details": sprintf(translate("%(icon)s\xa0%(second)s"), {
"icon": resourceIcon("time"),
"second": Math.ceil(time / 1000)
})
});
}
/**
* Multiplies the costs for a template by a given batch size.
*/
@@ -438,6 +438,8 @@ g_SelectionPanels.Pack = {
if (!state.pack)
continue;
checks.packTime = state.pack.time;
if (state.pack.progress == 0)
{
if (state.pack.packed)
@@ -456,7 +458,7 @@ g_SelectionPanels.Pack = {
items.push({
"packing": false,
"packed": false,
"tooltip": translate("Pack"),
"tooltip": getPackingTooltip(true, checks.packTime),
"callback": function() { packUnit(true); }
});
@@ -464,7 +466,7 @@ g_SelectionPanels.Pack = {
items.push({
"packing": false,
"packed": true,
"tooltip": translate("Unpack"),
"tooltip": getPackingTooltip(false, checks.packTime),
"callback": function() { packUnit(false); }
});
@@ -329,7 +329,8 @@ GuiInterface.prototype.GetEntityState = function(player, ent)
if (cmpPack)
ret.pack = {
"packed": cmpPack.IsPacked(),
"progress": cmpPack.GetProgress()
"progress": cmpPack.GetProgress(),
"time": cmpPack.GetPackTime()
};
const cmpPopulation = Engine.QueryInterface(ent, IID_Population);