From 6a7e6ca3430d620dcd65ffdfd5c5caf58357d05e Mon Sep 17 00:00:00 2001 From: Deiz Date: Mon, 27 Aug 2012 07:07:33 +0000 Subject: [PATCH] Clean up entity name formatting; always show generic names in tooltips. This was SVN commit r12535. --- binaries/data/mods/public/gui/session/session.js | 2 +- .../mods/public/gui/session/unit_commands.js | 16 ++++++++-------- .../mods/public/gui/session/utility_functions.js | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js index e1d1bfebea..174937204d 100644 --- a/binaries/data/mods/public/gui/session/session.js +++ b/binaries/data/mods/public/gui/session/session.js @@ -492,7 +492,7 @@ function updateResearchDisplay() var template = GetTechnologyData(tech); var button = getGUIObjectByName("researchStartedButton[" + numButtons + "]"); button.hidden = false; - button.tooltip = getEntityName(template); + button.tooltip = getEntityNames(template); button.onpress = (function(e) { return function() { selectAndMoveTo(e) } })(researchStarted[tech].researcher); var icon = "stretched:session/portraits/" + template.icon; diff --git a/binaries/data/mods/public/gui/session/unit_commands.js b/binaries/data/mods/public/gui/session/unit_commands.js index cfd49755ad..dfb978f828 100644 --- a/binaries/data/mods/public/gui/session/unit_commands.js +++ b/binaries/data/mods/public/gui/session/unit_commands.js @@ -315,14 +315,14 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback) switch (guiName) { case SELECTION: - var name = getEntityNames(template).join(" "); + var name = getEntityNames(template); var tooltip = name; var count = g_Selection.groups.getCount(item); getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 1 ? count : ""); break; case QUEUE: - var tooltip = getEntityName(template); + var tooltip = getEntityNames(template); var progress = Math.round(item.progress*100) + "%"; getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (item.count > 1 ? item.count : ""); @@ -338,7 +338,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback) break; case GARRISON: - var name = getEntityNames(template).join(" "); + var name = getEntityNames(template); var tooltip = "Unload " + name + "\nSingle-click to unload 1. Shift-click to unload all of this type."; var count = garrisonGroups.getCount(item); getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = (count > 1 ? count : ""); @@ -369,7 +369,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback) break; case TRAINING: - var tooltip = getEntityNameWithGenericType(template); + var tooltip = getEntityNamesFormatted(template); if (template.tooltip) tooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]"; @@ -393,7 +393,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback) break; case RESEARCH: - var tooltip = getEntityNameWithGenericType(template); + var tooltip = getEntityNamesFormatted(template); if (template.tooltip) tooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]"; @@ -401,7 +401,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback) if (item.pair) { - var tooltip1 = getEntityNameWithGenericType(template1); + var tooltip1 = getEntityNamesFormatted(template1); if (template1.tooltip) tooltip1 += "\n[font=\"serif-13\"]" + template1.tooltip + "[/font]"; @@ -410,7 +410,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback) break; case CONSTRUCTION: - var tooltip = getEntityNameWithGenericType(template); + var tooltip = getEntityNamesFormatted(template); if (template.tooltip) tooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]"; @@ -567,7 +567,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback) if (guiName != SELECTION && template.requiredTechnology && !Engine.GuiInterfaceCall("IsTechnologyResearched", template.requiredTechnology)) { button.enabled = false; - var techName = getEntityName(GetTechnologyData(template.requiredTechnology)); + var techName = getEntityNames(GetTechnologyData(template.requiredTechnology)); button.tooltip += "\nRequires " + techName; grayscale = "grayscale:"; } diff --git a/binaries/data/mods/public/gui/session/utility_functions.js b/binaries/data/mods/public/gui/session/utility_functions.js index bd52d8255b..d74cd585e6 100644 --- a/binaries/data/mods/public/gui/session/utility_functions.js +++ b/binaries/data/mods/public/gui/session/utility_functions.js @@ -431,12 +431,12 @@ function getEntityNames(template) else if (template.name.generic) names.push(template.name.generic); - return (names.length) ? names : ["???"]; + return (names.length) ? names.join(" ") : "???"; } -function getEntityNameWithGenericType(template) +function getEntityNamesFormatted(template) { - return "[font=\"serif-bold-16\"]" + getEntityNames(template).join(" ") + "[/font]"; + return '[font="serif-bold-16"]' + getEntityNames(template) + "[/font]"; } function getEntityRankedName(entState)