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:
wraitii 2015-03-15 12:00:28 +00:00
parent 5d6f95321d
commit 5a4ddb52a2
2 changed files with 21 additions and 2 deletions

View File

@ -65,6 +65,16 @@ function displaySingle(entState, template)
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
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"), {
hitpoints: Math.ceil(entState.hitpoints),
maxHitpoints: entState.maxHitpoints
@ -170,7 +180,16 @@ function displaySingle(entState, template)
Engine.GetGUIObjectByName("resourceCarryingText").hidden = false;
Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png";
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")
{

View File

@ -12,7 +12,7 @@
<translatableAttribute id="tooltip">Health:</translatableAttribute>
</object>
<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="healthBackground" ghost="true"/>
<object type="image" sprite="healthForeground" ghost="true" name="healthBar"/>