1
0
forked from 0ad/0ad

Adjust resourceCarryingText position and small cleanup

Differential Revision: https://code.wildfiregames.com/D1376
This was SVN commit r21505.
This commit is contained in:
temple 2018-03-11 17:27:07 +00:00
parent 78e34ea143
commit 6c3f93a33d
2 changed files with 25 additions and 31 deletions

View File

@ -206,68 +206,62 @@ function displaySingle(entState)
} }
let resourceCarryingIcon = Engine.GetGUIObjectByName("resourceCarryingIcon");
let resourceCarryingText = Engine.GetGUIObjectByName("resourceCarryingText");
resourceCarryingIcon.hidden = false;
resourceCarryingText.hidden = false;
// Resource carrying // Resource carrying
if (entState.resourceCarrying && entState.resourceCarrying.length) if (entState.resourceCarrying && entState.resourceCarrying.length)
{ {
// We should only be carrying one resource type at once, so just display the first // We should only be carrying one resource type at once, so just display the first
let carried = entState.resourceCarrying[0]; let carried = entState.resourceCarrying[0];
resourceCarryingIcon.sprite = "stretched:session/icons/resources/" + carried.type + ".png";
Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; resourceCarryingText.caption = sprintf(translate("%(amount)s / %(max)s"), { "amount": carried.amount, "max": carried.max });
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; resourceCarryingIcon.tooltip = "";
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/" + carried.type + ".png";
Engine.GetGUIObjectByName("resourceCarryingText").caption = sprintf(translate("%(amount)s / %(max)s"), { "amount": carried.amount, "max": carried.max });
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = "";
} }
// Use the same indicators for traders // Use the same indicators for traders
else if (entState.trader && entState.trader.goods.amount) else if (entState.trader && entState.trader.goods.amount)
{ {
Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; resourceCarryingIcon.sprite = "stretched:session/icons/resources/" + entState.trader.goods.type + ".png";
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false;
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/" + entState.trader.goods.type + ".png";
let totalGain = entState.trader.goods.amount.traderGain; let totalGain = entState.trader.goods.amount.traderGain;
if (entState.trader.goods.amount.market1Gain) if (entState.trader.goods.amount.market1Gain)
totalGain += entState.trader.goods.amount.market1Gain; totalGain += entState.trader.goods.amount.market1Gain;
if (entState.trader.goods.amount.market2Gain) if (entState.trader.goods.amount.market2Gain)
totalGain += entState.trader.goods.amount.market2Gain; totalGain += entState.trader.goods.amount.market2Gain;
Engine.GetGUIObjectByName("resourceCarryingText").caption = totalGain; resourceCarryingText.caption = totalGain;
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf(translate("Gain: %(gain)s"), { resourceCarryingIcon.tooltip = sprintf(translate("Gain: %(gain)s"), {
"gain": getTradingTooltip(entState.trader.goods.amount) "gain": getTradingTooltip(entState.trader.goods.amount)
}); });
} }
// And for number of workers // And for number of workers
else if (entState.foundation) else if (entState.foundation)
{ {
Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; resourceCarryingIcon.sprite = "stretched:session/icons/repair.png";
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; resourceCarryingIcon.tooltip = getBuildTimeTooltip(entState);
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; resourceCarryingText.caption = entState.foundation.numBuilders ?
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = getBuildTimeTooltip(entState); Engine.FormatMillisecondsIntoDateStringGMT(entState.foundation.buildTime.timeRemaining * 1000, translateWithContext("countdown format", "m:ss")) : "";
Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders ?
Engine.FormatMillisecondsIntoDateStringGMT(entState.foundation.buildTime.timeRemaining * 1000, translateWithContext("countdown format", "m:ss")) + " " : "";
} }
else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints)) else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints))
{ {
Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; resourceCarryingIcon.sprite = "stretched:session/icons/repair.png";
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; resourceCarryingText.caption = sprintf(translate("%(amount)s / %(max)s"), {
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png";
Engine.GetGUIObjectByName("resourceCarryingText").caption = sprintf(translate("%(amount)s / %(max)s"), {
"amount": entState.resourceSupply.numGatherers, "amount": entState.resourceSupply.numGatherers,
"max": entState.resourceSupply.maxGatherers "max": entState.resourceSupply.maxGatherers
}) + " "; });
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Current/max gatherers"); Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Current/max gatherers");
} }
else if (entState.repairable && entState.needsRepair) else if (entState.repairable && entState.needsRepair)
{ {
Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; resourceCarryingIcon.sprite = "stretched:session/icons/repair.png";
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; resourceCarryingIcon.tooltip = getRepairTimeTooltip(entState);
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; resourceCarryingText.caption = entState.repairable.numBuilders ?
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = getRepairTimeTooltip(entState); Engine.FormatMillisecondsIntoDateStringGMT(entState.repairable.buildTime.timeRemaining * 1000, translateWithContext("countdown format", "m:ss")) : "";
Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.repairable.numBuilders ?
Engine.FormatMillisecondsIntoDateStringGMT(entState.repairable.buildTime.timeRemaining * 1000, translateWithContext("countdown format", "m:ss")) + " " : "";
} }
else else
{ {
Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = true; resourceCarryingIcon.hidden = true;
Engine.GetGUIObjectByName("resourceCarryingText").hidden = true; resourceCarryingText.hidden = true;
} }
Engine.GetGUIObjectByName("specific").caption = specificName; Engine.GetGUIObjectByName("specific").caption = specificName;

View File

@ -62,7 +62,7 @@
<!-- Resource carrying icon/counter --> <!-- Resource carrying icon/counter -->
<!-- Used also for number of gatherers/builders --> <!-- Used also for number of gatherers/builders -->
<object size="100%-98 -2 100%-28 34" type="text" name="resourceCarryingText" style="CarryingTextRight"/> <object size="100%-98 -2 100%-36 34" type="text" name="resourceCarryingText" style="CarryingTextRight"/>
<object size="100%-36 -2 100% 34" type="image" name="resourceCarryingIcon" tooltip_style="sessionToolTip"/> <object size="100%-36 -2 100% 34" type="image" name="resourceCarryingIcon" tooltip_style="sessionToolTip"/>
</object> </object>