Opened 5 months ago

Closed 4 months ago

#6587 closed enhancement (fixed)

Tooltip issue after modifying a tech for the Macedonian civ bonus

Reported by: Langbart Owned by: marder
Priority: Nice to Have Milestone: Alpha 26
Component: UI & Simulation Keywords:
Cc: Patch: Phab:D4750

Description (last modified by Langbart)

Obelix reported an issue in the forum about a side effect of the new civbonus (mace_storehouse.json) for the Macedonians (added with [26627]).


The tech sets the time to zero

10 "modifications": [
11 {
12 "value": "Researcher/TechCostMultiplier/time",
13 "replace": 0
14 }
15 ],

the tooltip time is checked twice for its existence with an if statement (if(0) equals to false).

720 let totalCosts = multiplyEntityCosts(template, buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch);
721 if (template.cost.time)
722 totalCosts.time = Math.ceil(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", {
723 "entity": entity,
724 "batchSize": buildingsCountToTrainFullBatch > 0 ? fullBatchSize : remainderBatch
725 }) : 1));
727 let costs = [];
728 for (let type of getCostTypes())
729 if (totalCosts[type])
730 costs.push(sprintf(translate("%(component)s %(cost)s"), {

See also comment:3 below for the other issue regarding the correct display of the tooltip in the structure tree for the modified techs.

possible solutions

idea A

rework the JavaScript part for the tooltip. The result would display a time of 0.

  • binaries/data/mods/public/gui/common/tooltips.js

    a b function getEntityCostComponentsTooltipString(template, entity, buildingsCountTo  
    718718    if (!template.cost)
    719719        return [];
    720720    let totalCosts = multiplyEntityCosts(template, buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch);
    721     if (template.cost.time)
     721    if (typeof template.cost.time == "number")
    722722        totalCosts.time = Math.ceil(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", {
    723723            "entity": entity,
    724724            "batchSize": buildingsCountToTrainFullBatch > 0 ? fullBatchSize : remainderBatch
    function getEntityCostComponentsTooltipString(template, entity, buildingsCountTo  
    727727    let costs = [];
    728728    for (let type of getCostTypes())
    729         if (totalCosts[type])
     729        if (typeof totalCosts[type] == "number")
    730730            costs.push(sprintf(translate("%(component)s %(cost)s"), {
    731731                "component": resourceIcon(type),
    732732                "cost": totalCosts[type]

idea B

rework the tech, by doing a multiplication with a low value e.g. 0.01 (similar to the cheat code gift from the gods to get fast actions (fastactions.js). The result would display a time of 1.

  • binaries/data/mods/public/simulation/data/technologies/civbonuses/mace_storehouse.json

    a b  
    44    "description": "The Macedonian economy relied greatly on their vast natural resources.",
    55    "requirements": { "civ": "mace" },
    66    "icon": "wood_axe.png",
    7     "tooltip": "Storehouse technologies −100% research time.",
     7    "tooltip": "Research happens instantly.",
    88    "modifications": [
    9         { "value": "Researcher/TechCostMultiplier/time", "replace": 0 }
     9        { "value": "Researcher/TechCostMultiplier/time", "multiply": 0.01 }
    1010    ],
    1111    "affects": ["Storehouse"]

additional nitpick

(just a point of polish that they could choose to ignore it)

The string Right-click (tooltips.js) should get a color treatment,

1210 // Translation: Appears in a tooltip to indicate that right-clicking the corresponding GUI element will open the Template Details GUI page.
1211 return translate("Right-click to view more information.");

like its being done for the string Click in the getOrderTooltip function (CounterManager.js).

101 return "\n" + sprintf(translate("%(order)s: %(hotkey)s to change order."), {
102 "hotkey": setStringTags("\\[Click]", g_HotkeyTags),
103 "order":

Change History (8)

comment:1 by Stan‘, 5 months ago

Thank you!

comment:2 by Langbart, 5 months ago

... so far this will only solve half of the problem, cos the Structure Tree still shows the wrong value in its tooltip.

comment:3 by Langbart, 5 months ago

  1. the easiest way to solve the second part would be to rework all the storehouse techs (one for the maces and one for all the other civs) and remove the civ bonus. This is not a good solution as there are unnecessarily several slightly different variants of the same technology. Don't like it!
  1. Better to modify the function GetTechnologyDataHelper (globalscripts/Templates.js - Line 574) so it recognises modification as does the GetTemplateDataHelper (globalscripts/Templates.js - Line 159)

comment:4 by Langbart, 5 months ago

Description: modified (diff)
Summary: Dealing with a tooltip of zero time costTooltip issue after modifying a tech for the Macedonian civ bonus

Updating the title to make the issue clearer

comment:5 by s0600204, 5 months ago

The issue with the Structure Tree is that r26015 removed default Researcher/TechCostMultiplier values; and whilst r26192 fixed that for the simulation, a fix was not applied to globalscripts which expects there to be values for each possible resource specified within templates.

This is causing other technology costs to be displayed incorrectly within the Structure Tree, such as those of the Mauryan temple and the Gallic forge.

comment:6 by Stan‘, 4 months ago

Patch: Phab:D4750

comment:7 by Stan, 4 months ago

In 27033:

Add a function to handle custom phase techs, so they do not show as unused.
Fix autostart files being marked as unused.
Fix an issue with the researcher component. Patch by: @marder
Refs Phab:D4750
Refs #6587
Fixes Phab:rP26991

comment:8 by marder, 4 months ago

Owner: set to marder
Resolution: fixed
Status: newclosed

In 27042:

[Fix] Patch globalscripts technology template helper after rP26015 and the ProductionQueue split
Patch by @s0600204.

This lets all technologies show up correctly in-game and in the structure tree again.

accepted by: @marder @Freagarach

Fixes: #6587

Differential Revision:

Note: See TracTickets for help on using tickets.