Opened 22 months ago

Last modified 16 months ago

#6587 closed enhancement

Dealing with a tooltip of zero time cost — at Initial Version

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

Description

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.

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"), {

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 (0)

Note: See TracTickets for help on using tickets.