mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 06:13:55 -07:00
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>
37 lines
1 KiB
JavaScript
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";
|