From 5a4ddb52a2a32aadd2e9f44cf783d876106fbb96 Mon Sep 17 00:00:00 2001 From: wraitii Date: Sun, 15 Mar 2015 12:00:28 +0000 Subject: [PATCH] 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. --- .../public/gui/session/selection_details.js | 21 ++++++++++++++++++- .../single_details_area.xml | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/binaries/data/mods/public/gui/session/selection_details.js b/binaries/data/mods/public/gui/session/selection_details.js index 482682ec88..c85ae48b69 100644 --- a/binaries/data/mods/public/gui/session/selection_details.js +++ b/binaries/data/mods/public/gui/session/selection_details.js @@ -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") { diff --git a/binaries/data/mods/public/gui/session/selection_panels_middle/single_details_area.xml b/binaries/data/mods/public/gui/session/selection_panels_middle/single_details_area.xml index 9c4efd5e0a..990956525e 100644 --- a/binaries/data/mods/public/gui/session/selection_panels_middle/single_details_area.xml +++ b/binaries/data/mods/public/gui/session/selection_panels_middle/single_details_area.xml @@ -12,7 +12,7 @@ Health: - +