diff --git a/binaries/data/mods/public/gui/common/tooltips.js b/binaries/data/mods/public/gui/common/tooltips.js index c7ed20d779..ad2493ff0b 100644 --- a/binaries/data/mods/public/gui/common/tooltips.js +++ b/binaries/data/mods/public/gui/common/tooltips.js @@ -426,6 +426,21 @@ function getHealerTooltip(template) return healer.join(translate(", ")); } +function getAurasTooltip(template) +{ + if (!template.auras) + return ""; + + var txt = ""; + for (let aura in template.auras) + txt += '\n' + sprintf(translate("%(auralabel)s %(aurainfo)s"), { + auralabel: txtFormats.header[0] + sprintf(translate("%(auraname)s:"), { + auraname: translate(aura) + }) + txtFormats.header[1], + aurainfo: txtFormats.body[0] + translate(template.auras[aura]) + txtFormats.body[1] + }); + return txt; +} function getEntityNames(template) { diff --git a/binaries/data/mods/public/gui/session/selection_details.js b/binaries/data/mods/public/gui/session/selection_details.js index 8da93d622f..73cfdf8848 100644 --- a/binaries/data/mods/public/gui/session/selection_details.js +++ b/binaries/data/mods/public/gui/session/selection_details.js @@ -26,7 +26,7 @@ function displaySingle(entState, template) { // Get general unit and player data var specificName = template.name.specific; - var genericName = template.name.generic != template.name.specific ? template.name.generic : ""; + var genericName = template.name.generic; // If packed, add that to the generic name (reduces template clutter) if (genericName && template.pack && template.pack.state == "packed") genericName = sprintf(translate("%(genericName)s — Packed"), { genericName: genericName }); @@ -40,9 +40,7 @@ function displaySingle(entState, template) // Indicate disconnected players by prefixing their name if (g_Players[entState.player].offline) - { playerName = sprintf(translate("\\[OFFLINE] %(player)s"), { player: playerName }); - } // Rank if (entState.identity && entState.identity.rank && entState.identity.classes) @@ -71,7 +69,8 @@ function displaySingle(entState, template) // 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) }); + var timeToCompletion = Math.ceil(timeLeft/speed); + Engine.GetGUIObjectByName("health").tooltip = sprintf(translatePlural("This foundation will be completed in %(seconds)s second.", "This foundation will be completed in %(seconds)s seconds.", timeToCompletion), { "seconds": timeToCompletion }); } else Engine.GetGUIObjectByName("health").tooltip = ""; @@ -86,8 +85,7 @@ function displaySingle(entState, template) Engine.GetGUIObjectByName("captureSection").hidden = !entState.capturePoints; if (entState.capturePoints) { - let setCaptureBarPart = function(playerID, startSize) - { + let setCaptureBarPart = function(playerID, startSize) { var unitCaptureBar = Engine.GetGUIObjectByName("captureBar["+playerID+"]"); var sizeObj = unitCaptureBar.size; sizeObj.rleft = startSize; @@ -98,7 +96,7 @@ function displaySingle(entState, template) unitCaptureBar.sprite = "color: " + rgbToGuiColor(g_Players[playerID].color, 128); unitCaptureBar.hidden=false; return startSize + size; - } + }; // first handle the owner's points, to keep those points on the left for clarity let size = setCaptureBarPart(entState.player, 0); @@ -107,7 +105,6 @@ function displaySingle(entState, template) if (i != entState.player) size = setCaptureBarPart(i, size); - Engine.GetGUIObjectByName("captureStats").caption = sprintf(translate("%(capturePoints)s / %(maxCapturePoints)s"), { capturePoints: Math.ceil(entState.capturePoints[entState.player]), maxCapturePoints: entState.maxCapturePoints @@ -159,7 +156,6 @@ function displaySingle(entState, template) Engine.GetGUIObjectByName("resourceSection").size = Engine.GetGUIObjectByName("captureSection").size; else Engine.GetGUIObjectByName("resourceSection").size = Engine.GetGUIObjectByName("healthSection").size; - } // Resource carrying @@ -199,12 +195,11 @@ function displaySingle(entState, template) { 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) }); + var timeSpeedup = Math.ceil(timeLeft - timeLeft/speedup); + 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.", timeSpeedup), { "speedup": timeSpeedup }); } else - { Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Number of builders."); - } } else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints) && entState.visibility == "visible") { @@ -225,16 +220,11 @@ function displaySingle(entState, template) Engine.GetGUIObjectByName("player").caption = playerName; Engine.GetGUIObjectByName("playerColorBackground").sprite = "color: " + playerColor; - if (genericName) - { + if (genericName !== specificName) Engine.GetGUIObjectByName("generic").caption = sprintf(translate("(%(genericName)s)"), { genericName: genericName }); - } else - { Engine.GetGUIObjectByName("generic").caption = ""; - } - if ("gaia" != playerState.civ) { Engine.GetGUIObjectByName("playerCivIcon").sprite = "stretched:grayscale:" + civEmblem; @@ -248,14 +238,10 @@ function displaySingle(entState, template) // Icon image if (template.icon) - { Engine.GetGUIObjectByName("icon").sprite = "stretched:session/portraits/" + template.icon; - } else - { // TODO: we should require all entities to have icons, so this case never occurs Engine.GetGUIObjectByName("icon").sprite = "bkFillBlack"; - } var armorString = getArmorTooltip(entState.armour); @@ -281,14 +267,7 @@ function displaySingle(entState, template) } if (template.auras) - { - for (var auraName in template.auras) - { - iconTooltip += "\n[font=\"sans-bold-13\"]" + translate(auraName) + "[/font]"; - if (template.auras[auraName]) - iconTooltip += ": " + translate(template.auras[auraName]); - } - } + iconTooltip += getAurasTooltip(template); if (template.tooltip) iconTooltip += "\n[font=\"sans-13\"]" + template.tooltip + "[/font]"; diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js index 0ea11a1ae4..e59984fee6 100644 --- a/binaries/data/mods/public/gui/session/session.js +++ b/binaries/data/mods/public/gui/session/session.js @@ -624,7 +624,8 @@ function updateHero() tooltip += "\n" + getAttackTooltip(heroState); tooltip += "\n" + getArmorTooltip(heroState.armour); - tooltip += "\n" + template.tooltip; + if (template.tooltip) + tooltip += "\n" + template.tooltip; heroButton.tooltip = tooltip; diff --git a/binaries/data/mods/public/gui/session/session_objects/hero_icon.xml b/binaries/data/mods/public/gui/session/session_objects/hero_icon.xml index efa8f51061..35d7053b36 100644 --- a/binaries/data/mods/public/gui/session/session_objects/hero_icon.xml +++ b/binaries/data/mods/public/gui/session/session_objects/hero_icon.xml @@ -6,7 +6,6 @@ > - Attack and Armor diff --git a/binaries/data/mods/public/gui/structree/draw.js b/binaries/data/mods/public/gui/structree/draw.js index 9cd9991320..cfe2e4a71a 100644 --- a/binaries/data/mods/public/gui/structree/draw.js +++ b/binaries/data/mods/public/gui/structree/draw.js @@ -254,13 +254,7 @@ function assembleTooltip(template) txt += '\n' + txtFormats.body[0] + translate(template.tooltip) + txtFormats.body[1]; if (template.auras) - for (let aura in template.auras) - txt += '\n' + sprintf(translate("%(auralabel)s %(aurainfo)s"), { - auralabel: txtFormats.header[0] + sprintf(translate("%(auraname)s:"), { - auraname: translate(aura) - }) + txtFormats.header[1], - aurainfo: txtFormats.body[0] + translate(template.auras[aura]) + txtFormats.body[1] - }); + txt += getAurasTooltip(template); if (template.health) txt += '\n' + sprintf(translate("%(label)s %(details)s"), {