Ticket #4099: roundup_wipv1.diff

File roundup_wipv1.diff, 8.4 KB (added by elexis, 8 years ago)
  • binaries/data/mods/public/gui/common/tooltips.js

    function getBuildRateTooltip(template)  
    298298 */
    299299function multiplyEntityCosts(template, trainNum)
    300300{
    301301    let totalCosts = {};
    302302    for (let r in template.cost)
    303         totalCosts[r] = Math.floor(template.cost[r] * trainNum);
     303        totalCosts[r] = Math.round(template.cost[r] * trainNum);
    304304
    305305    return totalCosts;
    306306}
    307307
    308308/**
    function getEntityCostComponentsTooltipS  
    313313    if (!trainNum)
    314314        trainNum = 1;
    315315
    316316    let totalCosts = multiplyEntityCosts(template, trainNum);
    317317    if (template.cost.time)
    318         totalCosts.time = Math.ceil(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", { "entity": entity, "batchSize": trainNum }) : 1));
     318        totalCosts.time = Math.round(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", { "entity": entity, "batchSize": trainNum }) : 1));
    319319
    320320    let costs = [];
    321321    for (let type in template.cost)
    322322        // Population bonus is shown in the tooltip
    323323        if (type != "populationBonus" && totalCosts[type])
    function getWallPieceTooltip(wallTypes)  
    386386        for (let resource in resourceCount)
    387387            // Translation: This string is part of the resources cost string on
    388388            // the tooltip for wall structures.
    389389            out.push(sprintf(translate("%(resourceIcon)s %(minimum)s to %(resourceIcon)s %(maximum)s"), {
    390390                "resourceIcon": costIcon(resource),
    391                 "minimum": Math.min.apply(Math, resourceCount[resource]),
    392                 "maximum": Math.max.apply(Math, resourceCount[resource])
     391                "minimum": Math.round(Math.min(...resourceCount[resource])),
     392                "maximum": Math.round(Math.max(...resourceCount[resource]))
    393393            }));
    394394    else
    395395        for (let i = 0; i < wallTypes.length; ++i)
    396396            out.push(getEntityCostComponentsTooltipString(wallTypes[i]).join(", "));
    397397
  • binaries/data/mods/public/gui/session/selection_details.js

    function updateGarrisionHealthBar(entSta  
    4949        let healthSize = healthBarGarrison.size;
    5050        healthSize.rtop = 100-100*Math.max(0, Math.min(1, totalGarrisionHealth / maxGarrisionHealth));
    5151        healthBarGarrison.size = healthSize;
    5252        healthGarrison.tooltip = sprintf(translate("%(label)s %(current)s / %(max)s"), {
    5353            "label": "[font=\"sans-bold-13\"]" + translate("Hitpoints:") + "[/font]",
    54             "current": Math.ceil(totalGarrisionHealth),
    55             "max": Math.ceil(maxGarrisionHealth)
     54            "current": Math.round(totalGarrisionHealth) || 1,
     55            "max": Math.round(maxGarrisionHealth) || 1
    5656        });
    5757    }
    5858}
    5959
    6060// Fills out information that most entities have
    function displaySingle(entState)  
    106106        if (entState.foundation && entState.visibility == "visible" && entState.foundation.numBuilders !== 0)
    107107        {
    108108            // logic comes from Foundation component.
    109109            let speed = Math.pow(entState.foundation.numBuilders, 0.7);
    110110            let timeLeft = (1.0 - entState.foundation.progress / 100.0) * template.cost.time;
    111             let timeToCompletion = Math.ceil(timeLeft/speed);
     111            let timeToCompletion = Math.round(timeLeft/speed) || 1;
    112112            Engine.GetGUIObjectByName("health").tooltip = sprintf(translatePlural("This foundation will be completed in %(seconds)s second.", "This foundation will be completed in %(seconds)s seconds.", timeToCompletion), { "seconds": timeToCompletion });
    113113        }
    114114        else
    115115            Engine.GetGUIObjectByName("health").tooltip = "";
    116116
    117117        Engine.GetGUIObjectByName("healthStats").caption = sprintf(translate("%(hitpoints)s / %(maxHitpoints)s"), {
    118             "hitpoints": Math.ceil(entState.hitpoints),
    119             "maxHitpoints": Math.ceil(entState.maxHitpoints)
     118            "hitpoints": Math.round(entState.hitpoints) || 1,
     119            "maxHitpoints": Math.round(entState.maxHitpoints) || 1
    120120        });
    121121    }
    122122
    123123    // CapturePoints
    124124    Engine.GetGUIObjectByName("captureSection").hidden = !entState.capturePoints;
    function displaySingle(entState)  
    143143        for (let i in entState.capturePoints)
    144144            if (i != entState.player)
    145145                size = setCaptureBarPart(i, size);
    146146
    147147        Engine.GetGUIObjectByName("captureStats").caption = sprintf(translate("%(capturePoints)s / %(maxCapturePoints)s"), {
    148             "capturePoints": Math.ceil(entState.capturePoints[entState.player]),
    149             "maxCapturePoints": Math.ceil(entState.maxCapturePoints)
     148            "capturePoints": Math.round(entState.capturePoints[entState.player]) || 1,
     149            "maxCapturePoints": Math.round(entState.maxCapturePoints) || 1
    150150        });
    151151    }
    152152
    153153    // Experience
    154154    Engine.GetGUIObjectByName("experience").hidden = !entState.promotion;
    function displaySingle(entState)  
    176176    Engine.GetGUIObjectByName("resourceSection").hidden = !entState.resourceSupply;
    177177    if (entState.resourceSupply)
    178178    {
    179179        let resources = entState.resourceSupply.isInfinite ? translate("∞") :  // Infinity symbol
    180180            sprintf(translate("%(amount)s / %(max)s"), {
    181                 "amount": Math.ceil(+entState.resourceSupply.amount),
     181                "amount": Math.round(+entState.resourceSupply.amount) || 1,
    182182                "max": entState.resourceSupply.max
    183183            });
    184184
    185185        let resourceType = getResourceTypeDisplayName(entState.resourceSupply.type);
    186186
    function displaySingle(entState)  
    234234        Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + "    ";
    235235        if (entState.foundation.numBuilders !== 0)
    236236        {
    237237            let speedup = Math.pow((entState.foundation.numBuilders+1)/entState.foundation.numBuilders, 0.7);
    238238            let timeLeft = (1.0 - entState.foundation.progress / 100.0) * template.cost.time;
    239             let timeSpeedup = Math.ceil(timeLeft - timeLeft/speedup);
     239            let timeSpeedup = Math.round(timeLeft - timeLeft/speedup) || 1;
    240240            Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = sprintf(translatePlural("Number of builders.\nTasking another to this foundation would speed construction up by %(speedup)s second.", "Number of builders.\nTasking another to this foundation would speed construction up by %(speedup)s seconds.", timeSpeedup), { "speedup": timeSpeedup });
    241241        }
    242242        else
    243243            Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = translate("Number of builders.");
    244244    }
    function displayMultiple(selection)  
    353353        healthSize.rtop = 100-100*Math.max(0, Math.min(1, averageHealth / maxHealth));
    354354        unitHealthBar.size = healthSize;
    355355
    356356        Engine.GetGUIObjectByName("healthMultiple").tooltip = sprintf(translate("%(label)s %(current)s / %(max)s"), {
    357357            "label": "[font=\"sans-bold-13\"]" + translate("Hitpoints:") + "[/font]",
    358             "current": Math.ceil(averageHealth),
    359             "max": Math.ceil(maxHealth)
     358            "current": Math.round(averageHealth) || 1,
     359            "max": Math.round(maxHealth) || 1
    360360        });
    361361    }
    362362
    363363    Engine.GetGUIObjectByName("captureMultiple").hidden = maxCapturePoints <= 0;
    364364    if (maxCapturePoints > 0)
    function displayMultiple(selection)  
    385385        // last handle the owner's points, to keep those points on the bottom for clarity
    386386        setCaptureBarPart(playerID, size);
    387387
    388388        Engine.GetGUIObjectByName("captureMultiple").tooltip = sprintf(translate("%(label)s %(current)s / %(max)s"), {
    389389            "label": "[font=\"sans-bold-13\"]" + translate("Capture points:") + "[/font]",
    390             "current": Math.ceil(capturePoints[playerID]),
    391             "max": Math.ceil(maxCapturePoints)
     390            "current": Math.round(capturePoints[playerID]) || 1,
     391            "max": Math.round(maxCapturePoints) || 1
    392392        });
    393393    }
    394394
    395395    let numberOfUnits = Engine.GetGUIObjectByName("numberOfUnits");
    396396    numberOfUnits.caption = selection.length;
  • binaries/data/mods/public/gui/session/session.js

    function createHeroTooltip(heroState, te  
    829829{
    830830    return [
    831831        "[font=\"sans-bold-16\"]" + template.name.specific + "[/font]" + "\n" +
    832832            sprintf(translate("%(label)s %(current)s / %(max)s"), {
    833833                "label": "[font=\"sans-bold-13\"]" + translate("Health:") + "[/font]",
    834                 "current": Math.ceil(heroState.hitpoints),
    835                 "max": Math.ceil(heroState.maxHitpoints)
     834                "current": Math.round(heroState.hitpoints) || 1,
     835                "max": Math.round(heroState.maxHitpoints) || 1
    836836            }),
    837837        getAttackTooltip(heroState),
    838838        getArmorTooltip(heroState),
    839839        getEntityTooltip(heroState)
    840840    ].filter(tip => tip).join("\n");