Opened 22 months ago

Last modified 16 months ago

#6587 closed enhancement

Tooltip issue after modifying a tech for the Macedonian civ bonus — at Version 4

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

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]).

issue

The tech sets the time to zero

Line 
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).

Line 
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));
726
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  
    726726
    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"]
    1212}

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,

Line 
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.");
1212}

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

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

Change History (4)

comment:1 by Stan, 22 months ago

Thank you!

comment:2 by Langbart, 22 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, 22 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, 22 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

Note: See TracTickets for help on using tickets.