Index: binaries/data/mods/public/gui/common/tooltips.js =================================================================== --- binaries/data/mods/public/gui/common/tooltips.js +++ binaries/data/mods/public/gui/common/tooltips.js @@ -380,6 +380,30 @@ }); } +function getBuildTimeTooltip(entState) +{ + if (!entState.foundation.numBuilders) + return sprintf(translatePlural( + "Add a worker to finish the construction in %(second)s second.", + "Add a worker to finish the construction in %(second)s seconds.", + Math.round(entState.buildTime.timeRemainingNew)), + { + "second": Math.round(entState.buildTime.timeRemainingNew) + }); + + return sprintf(translate("%(label)s %(details)s"), { + "label": headerFont(translate("Number of builders:")), + "details": entState.foundation.numBuilders + }) + '\n' + + sprintf(translatePlural( + "Add another worker to speed up the construction by %(second)s second.", + "Add another worker to speed up the construction by %(second)s seconds.", + Math.round(entState.buildTime.timeRemaining - entState.buildTime.timeRemainingNew)), + { + "second": Math.round(entState.buildTime.timeRemaining - entState.buildTime.timeRemainingNew) + }); +} + /** * Multiplies the costs for a template by a given batch size. */ Index: binaries/data/mods/public/gui/session/selection_details.js =================================================================== --- binaries/data/mods/public/gui/session/selection_details.js +++ binaries/data/mods/public/gui/session/selection_details.js @@ -112,15 +112,8 @@ 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 && entState.buildTime) - Engine.GetGUIObjectByName("health").tooltip = sprintf( - translatePlural( - "This foundation will be completed in %(seconds)s second.", - "This foundation will be completed in %(seconds)s seconds.", - Math.ceil(entState.buildTime.timeRemaining)), - { - "seconds": Math.ceil(entState.buildTime.timeRemaining) - }); + if (entState.foundation && entState.visibility == "visible") + Engine.GetGUIObjectByName("health").tooltip = getBuildTimeTooltip(entState); else Engine.GetGUIObjectByName("health").tooltip = ""; @@ -253,18 +246,11 @@ Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; - Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " "; - if (entState.foundation.numBuilders !== 0 && entState.buildTime) - Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf( - translatePlural( - "Number of builders.\nTasking another to this foundation would speed construction up by %(speedup)s second.", - "Number of builders.\nTasking another to this foundation would speed construction up by %(speedup)s seconds.", - Math.ceil(entState.buildTime.timeSpeedup)), - { - "speedup": Math.ceil(entState.buildTime.timeSpeedup) - }); + Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = getBuildTimeTooltip(entState); + if (entState.foundation.numBuilders) + Engine.GetGUIObjectByName("resourceCarryingText").caption = durationToString(entState.buildTime.timeRemaining * 1000) + " "; else - Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Number of builders."); + Engine.GetGUIObjectByName("resourceCarryingText").caption = ""; } else if (entState.repairable && entState.repairable.numBuilders > 0 && entState.visibility == "visible") { Index: binaries/data/mods/public/simulation/components/Foundation.js =================================================================== --- binaries/data/mods/public/simulation/components/Foundation.js +++ binaries/data/mods/public/simulation/components/Foundation.js @@ -173,7 +173,7 @@ let rateNew = (this.totalBuilderRate + 1) * this.CalculateBuildMultiplier(this.GetNumBuilders() + 1); return { "timeRemaining": timeLeft / rate, - "timeSpeedup": timeLeft / rate - timeLeft / rateNew + "timeRemainingNew": timeLeft / rateNew }; }; Index: binaries/data/mods/public/simulation/components/tests/test_Foundation.js =================================================================== --- binaries/data/mods/public/simulation/components/tests/test_Foundation.js +++ binaries/data/mods/public/simulation/components/tests/test_Foundation.js @@ -147,7 +147,7 @@ // Foundation starts with 1 hp, so there's 50 * 99/100 = 49.5 seconds left. TS_ASSERT_UNEVAL_EQUALS(cmpFoundation.GetBuildTime(), { 'timeRemaining': 49.5, - 'timeSpeedup': 49.5 - 49.5 / (2 * twoBuilderMultiplier) + 'timeRemainingNew': 49.5 / (2 * twoBuilderMultiplier) }); cmpFoundation.AddBuilder(11); TS_ASSERT_EQUALS(cmpFoundation.GetNumBuilders(), 2); @@ -155,7 +155,7 @@ TS_ASSERT_EQUALS(cmpFoundation.totalBuilderRate, 2); TS_ASSERT_UNEVAL_EQUALS(cmpFoundation.GetBuildTime(), { 'timeRemaining': 49.5 / (2 * twoBuilderMultiplier), - 'timeSpeedup': 49.5 / (2 * twoBuilderMultiplier) - 49.5 / (3 * threeBuilderMultiplier) + 'timeRemainingNew': 49.5 / (3 * threeBuilderMultiplier) }); cmpFoundation.AddBuilder(11); TS_ASSERT_EQUALS(cmpFoundation.GetNumBuilders(), 2);