diff --git a/binaries/data/mods/public/globalscripts/Templates.js b/binaries/data/mods/public/globalscripts/Templates.js
index 9b622db..219f221 100644
a
|
b
|
function GetTemplateDataHelper(template, player, auraTemplates)
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Get information about a technology template. |
| 339 | * |
339 | 340 | * @param template A valid template as obtained by loading the tech JSON file. |
340 | | * @param civ Civilization for which the specific name should be returned. |
341 | 341 | */ |
342 | | function GetTechnologyDataHelper(template, civ) |
| 342 | function GetTechnologyDataHelper(template) |
343 | 343 | { |
344 | 344 | var ret = {}; |
345 | 345 | |
346 | | // Get specific name for this civ or else the generic specific name |
347 | | var specific; |
348 | | if (template.specificName) |
349 | | { |
350 | | if (template.specificName[civ]) |
351 | | specific = template.specificName[civ]; |
352 | | else |
353 | | specific = template.specificName['generic']; |
354 | | } |
355 | | |
356 | 346 | ret.name = { |
357 | | "specific": specific, |
| 347 | "specific": template.specificName || undefined, |
358 | 348 | "generic": template.genericName, |
359 | 349 | }; |
360 | 350 | |
diff --git a/binaries/data/mods/public/gui/common/tooltips.js b/binaries/data/mods/public/gui/common/tooltips.js
index 6cebc6d..c29d0f8 100644
a
|
b
|
function getWallPieceTooltip(wallTypes)
|
412 | 412 | /** |
413 | 413 | * Returns the cost information to display in the specified entity's construction button tooltip. |
414 | 414 | */ |
415 | | function getEntityCostTooltip(template, trainNum, entity) |
| 415 | function getEntityCostTooltip(template, civ, trainNum, entity) |
416 | 416 | { |
417 | 417 | // Entities with a wallset component are proxies for initiating wall placement and as such do not have a cost of |
418 | 418 | // their own; the individual wall pieces within it do. |
… |
… |
function getAurasTooltip(template)
|
538 | 538 | return tooltips.join("\n"); |
539 | 539 | } |
540 | 540 | |
541 | | function getEntityNames(template) |
| 541 | function getCivSpecificEntityName(template, civ) |
542 | 542 | { |
543 | 543 | if (!template.name.specific) |
544 | | return template.name.generic; |
| 544 | return false; |
| 545 | |
| 546 | if (typeof template.name.specific == "string") |
| 547 | if (template.name.specific != template.name.generic) |
| 548 | return template.name.specific; |
| 549 | else |
| 550 | return false; |
| 551 | |
| 552 | if (template.name.specific[civ]) |
| 553 | return template.name.specific[civ]; |
545 | 554 | |
546 | | if (template.name.specific == template.name.generic) |
547 | | return template.name.specific; |
| 555 | if (template.name.specific.generic) |
| 556 | return template.name.specific.generic; |
| 557 | |
| 558 | return false; |
| 559 | } |
| 560 | |
| 561 | function getEntityNames(template, civ) |
| 562 | { |
| 563 | let specific = getCivSpecificEntityName(template, civ); |
| 564 | if (!specific) |
| 565 | return template.name.generic; |
548 | 566 | |
549 | 567 | return sprintf(translate("%(specificName)s (%(genericName)s)"), { |
550 | | "specificName": template.name.specific, |
| 568 | "specificName": specific, |
551 | 569 | "genericName": template.name.generic |
552 | 570 | }); |
553 | 571 | |
554 | 572 | } |
555 | | function getEntityNamesFormatted(template) |
| 573 | function getEntityNamesFormatted(template, civ) |
556 | 574 | { |
557 | | if (!template.name.specific) |
| 575 | let specific = getCivSpecificEntityName(template, civ); |
| 576 | if (!specific) |
558 | 577 | return '[font="sans-bold-16"]' + template.name.generic + "[/font]"; |
559 | 578 | |
560 | 579 | return sprintf(translate("%(specificName)s %(fontStart)s(%(genericName)s)%(fontEnd)s"), { |
561 | 580 | "specificName": |
562 | | '[font="sans-bold-16"]' + template.name.specific[0] + '[/font]' + |
563 | | '[font="sans-bold-12"]' + template.name.specific.slice(1).toUpperCase() + '[/font]', |
| 581 | '[font="sans-bold-16"]' + specific[0] + '[/font]' + |
| 582 | '[font="sans-bold-12"]' + specific.slice(1).toUpperCase() + '[/font]', |
564 | 583 | "genericName": template.name.generic, |
565 | 584 | "fontStart": '[font="sans-bold-16"]', |
566 | 585 | "fontEnd": '[/font]' |
diff --git a/binaries/data/mods/public/gui/session/selection_panels.js b/binaries/data/mods/public/gui/session/selection_panels.js
index fb12b00..1d03334 100644
a
|
b
|
g_SelectionPanels.Construction = {
|
316 | 316 | getGarrisonTooltip, |
317 | 317 | getProjectilesTooltip, |
318 | 318 | getPopulationBonusTooltip |
319 | | ].map(func => func(template)); |
| 319 | ].map(func => func(template, data.playerState.civ)); |
320 | 320 | |
321 | 321 | let limits = getEntityLimitAndCount(data.playerState, data.item); |
322 | 322 | tooltips.push(formatLimitString(limits.entLimit, limits.entCount, limits.entLimitChangers)); |
323 | 323 | |
324 | 324 | if (!technologyEnabled) |
325 | 325 | tooltips.push(sprintf(translate("Requires %(technology)s"), { |
326 | | "technology": getEntityNames(GetTechnologyData(template.requiredTechnology)) |
| 326 | "technology": getEntityNames(GetTechnologyData(template.requiredTechnology), data.playerState.civ) |
327 | 327 | })); |
328 | 328 | |
329 | 329 | tooltips.push(getNeededResourcesTooltip(neededResources)); |
… |
… |
g_SelectionPanels.Garrison = {
|
441 | 441 | |
442 | 442 | let tooltip = canUngarrison || g_IsObserver ? |
443 | 443 | sprintf(translate("Unload %(name)s"), |
444 | | { "name": getEntityNames(template) }) + "\n" + |
| 444 | { "name": getEntityNames(template, data.playerState.civ) }) + "\n" + |
445 | 445 | translate("Single-click to unload 1. Shift-click to unload all of this type.") : |
446 | | getEntityNames(template); |
| 446 | getEntityNames(template, data.playerState.civ); |
447 | 447 | |
448 | 448 | tooltip += "\n" + sprintf(translate("Player: %(playername)s"), { |
449 | 449 | "playername": g_Players[garrisonedUnitOwner].name |
… |
… |
g_SelectionPanels.Queue = {
|
645 | 645 | |
646 | 646 | data.button.onPress = function() { removeFromProductionQueue(data.item.producingEnt, data.item.id); }; |
647 | 647 | |
648 | | let tooltip = getEntityNames(template); |
| 648 | let tooltip = getEntityNames(template, data.playerState.civ); |
649 | 649 | if (data.item.neededSlots) |
650 | 650 | { |
651 | 651 | tooltip += "\n[color=\"red\"]" + translate("Insufficient population capacity:") + "\n[/color]"; |
… |
… |
g_SelectionPanels.Research = {
|
758 | 758 | getEntityNamesFormatted, |
759 | 759 | getEntityTooltip, |
760 | 760 | getEntityCostTooltip |
761 | | ].map(func => func(template)); |
| 761 | ].map(func => func(template, data.playerState.civ)); |
762 | 762 | |
763 | 763 | if (!requirementsPassed) |
764 | 764 | { |
… |
… |
g_SelectionPanels.Selection = {
|
874 | 874 | } |
875 | 875 | } |
876 | 876 | |
877 | | let tooltip = getEntityNames(template); |
| 877 | let tooltip = getEntityNames(template, data.playerState.civ); |
878 | 878 | if (data.carried) |
879 | 879 | tooltip += "\n" + Object.keys(data.carried).map(res => |
880 | 880 | costIcon(res) + data.carried[res] |
… |
… |
g_SelectionPanels.Training = {
|
965 | 965 | let tooltips = [ |
966 | 966 | "[font=\"sans-bold-16\"]" + |
967 | 967 | colorizeHotkey("%(hotkey)s", "session.queueunit." + (data.i + 1)) + |
968 | | "[/font]" + " " + getEntityNamesFormatted(template), |
| 968 | "[/font]" + " " + getEntityNamesFormatted(template, data.playerState.civ), |
969 | 969 | getVisibleEntityClassesFormatted(template), |
970 | 970 | getAurasTooltip(template), |
971 | 971 | getEntityTooltip(template), |
972 | | getEntityCostTooltip(template, trainNum, data.unitEntState.id) |
| 972 | getEntityCostTooltip(template, null, trainNum, data.unitEntState.id) |
973 | 973 | ]; |
974 | 974 | |
975 | 975 | let limits = getEntityLimitAndCount(data.playerState, data.item); |
… |
… |
g_SelectionPanels.Training = {
|
994 | 994 | |
995 | 995 | if (!technologyEnabled) |
996 | 996 | tooltips.push(sprintf(translate("Requires %(technology)s"), { |
997 | | "technology": getEntityNames(GetTechnologyData(template.requiredTechnology)) |
| 997 | "technology": getEntityNames(GetTechnologyData(template.requiredTechnology), data.playerState.civ) |
998 | 998 | })); |
999 | 999 | |
1000 | 1000 | if (neededResources) |
… |
… |
g_SelectionPanels.Upgrade = {
|
1084 | 1084 | tooltip += formatLimitString(limits.entLimit, limits.entCount, limits.entLimitChangers); |
1085 | 1085 | if (!technologyEnabled) |
1086 | 1086 | tooltip += "\n" + sprintf(translate("Requires %(technology)s"), { |
1087 | | "technology": getEntityNames(GetTechnologyData(data.item.requiredTechnology)) |
| 1087 | "technology": getEntityNames(GetTechnologyData(data.item.requiredTechnology), data.playerState.civ) |
1088 | 1088 | }); |
1089 | 1089 | |
1090 | 1090 | tooltip += getNeededResourcesTooltip(neededResources); |
diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js
index d82312e..1e7b74e 100644
a
|
b
|
function updateResearchDisplay()
|
1000 | 1000 | let template = GetTechnologyData(tech); |
1001 | 1001 | let button = Engine.GetGUIObjectByName("researchStartedButton[" + numButtons + "]"); |
1002 | 1002 | button.hidden = false; |
1003 | | button.tooltip = getEntityNames(template); |
| 1003 | button.tooltip = getEntityNames(template, g_Players[g_ViewedPlayer].civ); |
1004 | 1004 | button.onpress = (function(e) { return function() { selectAndMoveTo(e); }; })(researchStarted[tech].researcher); |
1005 | 1005 | |
1006 | 1006 | let icon = "stretched:session/portraits/" + template.icon; |
diff --git a/binaries/data/mods/public/gui/structree/draw.js b/binaries/data/mods/public/gui/structree/draw.js
index 06f1e39..f3544b6 100644
a
|
b
|
function predraw()
|
384 | 384 | */ |
385 | 385 | function assembleTooltip(template) |
386 | 386 | { |
387 | | return g_TooltipFunctions.map(func => func(template)).filter(tip => tip).join("\n"); |
| 387 | return g_TooltipFunctions.map(func => func(template, g_SelectedCiv)).filter(tip => tip).join("\n"); |
388 | 388 | } |
diff --git a/binaries/data/mods/public/gui/structree/structree.js b/binaries/data/mods/public/gui/structree/structree.js
index 65bfd9e..5462c2a 100644
a
|
b
|
function selectCiv(civCode)
|
97 | 97 | let realcode = depath(techcode); |
98 | 98 | |
99 | 99 | if (realcode.slice(0,4) == "pair" || realcode.indexOf("_pair") > -1) |
100 | | techPairs[techcode] = loadTechnologyPair(techcode); |
| 100 | { |
| 101 | if (!techPairs[techcode]) |
| 102 | techPairs[techcode] = loadTechnologyPair(techcode); |
| 103 | } |
101 | 104 | else if (realcode.slice(0,5) == "phase") |
102 | | g_ParsedData.phases[techcode] = loadPhase(techcode); |
| 105 | { |
| 106 | if (!g_ParsedData.phases[techcode]) |
| 107 | g_ParsedData.phases[techcode] = loadPhase(techcode); |
| 108 | } |
103 | 109 | else |
104 | | g_ParsedData.techs[techcode] = loadTechnology(techcode); |
| 110 | if (!g_ParsedData.techs[techcode]) |
| 111 | g_ParsedData.techs[techcode] = loadTechnology(techcode); |
105 | 112 | } |
106 | 113 | |
107 | 114 | // Expand tech pairs |
diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js
index 533c891..1d67aa4 100644
a
|
b
|
GuiInterface.prototype.GetTechnologyData = function(player, name)
|
645 | 645 | } |
646 | 646 | |
647 | 647 | let cmpPlayer = QueryPlayerIDInterface(player, IID_Player); |
648 | | return GetTechnologyDataHelper(template, cmpPlayer.GetCiv()); |
| 648 | return GetTechnologyDataHelper(template); |
649 | 649 | }; |
650 | 650 | |
651 | 651 | GuiInterface.prototype.IsTechnologyResearched = function(player, data) |