1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

show exact speeds

This commit is contained in:
EmeraldBlock 2022-05-20 18:19:06 -05:00
parent b9c92d90c1
commit 8f5525eb88
3 changed files with 791 additions and 782 deletions

View File

@ -542,6 +542,15 @@ export function formatSeconds(secs) {
}
}
/**
* Formats a number like 2.51 to "2.51"
* @param {number} speed
* @param {string=} separator The decimal separator for numbers like 50.1 (separator='.')
*/
export function formatNumber(speed, separator = T.global.decimalSeparator) {
return speed.toString().replace(".", separator);
}
/**
* Formats a number like 2.51 to "2.5"
* @param {number} speed
@ -563,7 +572,7 @@ export function formatItemsPerSecond(speed, double = false, separator = T.global
? T.ingame.buildingPlacement.infoTexts.oneItemPerSecond
: T.ingame.buildingPlacement.infoTexts.itemsPerSecond.replace(
"<x>",
round2Digits(speed).toString().replace(".", separator)
speed.toString().replace(".", separator)
)) + (double ? " " + T.ingame.buildingPlacement.infoTexts.itemsPerSecondDouble : "")
);
}

View File

@ -1,5 +1,5 @@
import { globalConfig } from "../../../core/config";
import { formatItemsPerSecond, round2Digits } from "../../../core/utils";
import { formatItemsPerSecond, round4Digits } from "../../../core/utils";
import { Vector } from "../../../core/vector";
import { T } from "../../../translations";
import { Entity } from "../../entity";
@ -69,7 +69,7 @@ export class HUDMinerHighlight extends BaseHUDPart {
parameters.context.fill();
}
const throughput = round2Digits(connectedEntities.length * this.root.hubGoals.getMinerBaseSpeed());
const throughput = round4Digits(connectedEntities.length * this.root.hubGoals.getMinerBaseSpeed());
const maxThroughput = this.root.hubGoals.getBeltBaseSpeed();
@ -84,7 +84,7 @@ export class HUDMinerHighlight extends BaseHUDPart {
parameters.context.beginRoundedRect(
tooltipLocation.x + 5 * scale,
tooltipLocation.y - 3 * scale,
(isCapped ? 100 : 65) * scale,
(isCapped ? 100 : 75) * scale,
(isCapped ? 45 : 30) * scale,
2
);

View File

@ -1,6 +1,6 @@
import { ClickDetector } from "../../../core/click_detector";
import { InputReceiver } from "../../../core/input_receiver";
import { formatBigNumber, getRomanNumber, makeDiv } from "../../../core/utils";
import { formatBigNumber, formatNumber, getRomanNumber, makeDiv } from "../../../core/utils";
import { T } from "../../../translations";
import { KeyActionMapper, KEYMAPPINGS } from "../../key_action_mapper";
import { BaseHUDPart } from "../base_hud_part";
@ -91,15 +91,15 @@ export class HUDShop extends BaseHUDPart {
// Max level
handle.elemDescription.innerText = T.ingame.shop.maximumLevel.replace(
"<currentMult>",
formatBigNumber(currentTierMultiplier)
formatNumber(currentTierMultiplier)
);
continue;
}
// Set description
handle.elemDescription.innerText = T.shopUpgrades[upgradeId].description
.replace("<currentMult>", formatBigNumber(currentTierMultiplier))
.replace("<newMult>", formatBigNumber(currentTierMultiplier + tierHandle.improvement / 10));
.replace("<currentMult>", formatNumber(currentTierMultiplier))
.replace("<newMult>", formatNumber(currentTierMultiplier + tierHandle.improvement / 10));
tierHandle.required.forEach(({ shape, amount }) => {
const container = makeDiv(handle.elemRequirements, null, ["requirement"]);