forked from 0ad/0ad
Change the tooltip for number of builders to give more useful information and add one on the healthbar of foundations.
This was SVN commit r16429.
This commit is contained in:
parent
5d6f95321d
commit
5a4ddb52a2
@ -65,6 +65,16 @@ function displaySingle(entState, template)
|
|||||||
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
|
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
|
||||||
unitHealthBar.size = healthSize;
|
unitHealthBar.size = healthSize;
|
||||||
|
|
||||||
|
if (entState.foundation && entState.visibility == "visible" && entState.foundation.numBuilders !== 0)
|
||||||
|
{
|
||||||
|
// logic comes from Foundation component.
|
||||||
|
var speed = Math.pow(entState.foundation.numBuilders, 0.7);
|
||||||
|
var timeLeft = (1.0 - entState.foundation.progress / 100.0) * template.cost.time;
|
||||||
|
Engine.GetGUIObjectByName("health").tooltip = sprintf(translate("This foundation will be completed in %(numb)s seconds."), { numb : Math.ceil(timeLeft/speed) });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Engine.GetGUIObjectByName("health").tooltip = "";
|
||||||
|
|
||||||
Engine.GetGUIObjectByName("healthStats").caption = sprintf(translate("%(hitpoints)s / %(maxHitpoints)s"), {
|
Engine.GetGUIObjectByName("healthStats").caption = sprintf(translate("%(hitpoints)s / %(maxHitpoints)s"), {
|
||||||
hitpoints: Math.ceil(entState.hitpoints),
|
hitpoints: Math.ceil(entState.hitpoints),
|
||||||
maxHitpoints: entState.maxHitpoints
|
maxHitpoints: entState.maxHitpoints
|
||||||
@ -170,7 +180,16 @@ function displaySingle(entState, template)
|
|||||||
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false;
|
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false;
|
||||||
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png";
|
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png";
|
||||||
Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " ";
|
Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " ";
|
||||||
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf(translate("Number of builders.\nTasking another to this foundation would speed construction up by %(numb)s%%"), { numb : Math.round((Math.pow((entState.foundation.numBuilders+1)/entState.foundation.numBuilders, 0.7) - 1.0)*100) });
|
if (entState.foundation.numBuilders !== 0)
|
||||||
|
{
|
||||||
|
var speedup = Math.pow((entState.foundation.numBuilders+1)/entState.foundation.numBuilders, 0.7);
|
||||||
|
var timeLeft = (1.0 - entState.foundation.progress / 100.0) * template.cost.time;
|
||||||
|
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf(translate("Number of builders.\nTasking another to this foundation would speed construction up by %(numb)s seconds."), { numb : Math.ceil(timeLeft - timeLeft/speedup) });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Number of builders.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints) && entState.visibility == "visible")
|
else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints) && entState.visibility == "visible")
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<translatableAttribute id="tooltip">Health:</translatableAttribute>
|
<translatableAttribute id="tooltip">Health:</translatableAttribute>
|
||||||
</object>
|
</object>
|
||||||
<object size="0 0 100% 16" name="healthStats" type="text" style="StatsTextRight" ghost="true"/>
|
<object size="0 0 100% 16" name="healthStats" type="text" style="StatsTextRight" ghost="true"/>
|
||||||
<object size="1 16 100% 23" name="health" type="image">
|
<object size="1 16 100% 23" name="health" type="image" tooltip_style="sessionToolTip">
|
||||||
<object type="image" sprite="barBorder" ghost="true" size="-1 -1 100%+1 100%+1"/>
|
<object type="image" sprite="barBorder" ghost="true" size="-1 -1 100%+1 100%+1"/>
|
||||||
<object type="image" sprite="healthBackground" ghost="true"/>
|
<object type="image" sprite="healthBackground" ghost="true"/>
|
||||||
<object type="image" sprite="healthForeground" ghost="true" name="healthBar"/>
|
<object type="image" sprite="healthForeground" ghost="true" name="healthBar"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user