0ad/binaries/data/mods/public/gui/session/OverlayCounterElapsedTime.js
Ralph Sennhauser 50a5d4b366
Fix eslint rule 'prefer-const' in gui/session
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/gui/session

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-10 18:05:22 +02:00

37 lines
1 KiB
JavaScript

/**
* This class shows the simulated match time below the FPS counter.
*/
OverlayCounterTypes.prototype.ElapsedTime = class extends OverlayCounter
{
constructor(overlayCounterManager)
{
super(overlayCounterManager);
// Performance optimization
this.caption = translate(this.Caption);
this.sprintfData = {};
}
get()
{
if (!g_SimState)
return "";
const time = timeToString(g_SimState.timeElapsed);
const speed = Engine.GetSimRate();
if (speed == 1)
return time;
this.sprintfData.time = time;
this.sprintfData.speed = Engine.FormatDecimalNumberIntoString(speed);
return sprintf(this.caption, this.sprintfData);
}
};
// Translation: The "x" means "times", with the mathematical meaning of multiplication.
OverlayCounterTypes.prototype.ElapsedTime.prototype.Caption = markForTranslation("%(time)s (%(speed)sx)");
OverlayCounterTypes.prototype.ElapsedTime.prototype.Config = "gui.session.timeelapsedcounter";
OverlayCounterTypes.prototype.ElapsedTime.prototype.Hotkey = "timeelapsedcounter.toggle";