mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 06:43:58 -07:00
Rebuild the counters every 250ms instead of every frame and minimize object creation. Differential Revision: https://code.wildfiregames.com/D2391 Comments By: Stan This was SVN commit r23096.
32 lines
776 B
JavaScript
32 lines
776 B
JavaScript
/**
|
|
* This counter displays the current framerate in the screen corner.
|
|
*/
|
|
OverlayCounterTypes.prototype.FPS = class extends OverlayCounter
|
|
{
|
|
constructor(overlayCounterManager)
|
|
{
|
|
super(overlayCounterManager);
|
|
|
|
// Tiny performance improvement
|
|
this.caption = translate(this.Caption);
|
|
|
|
// Minimize object construction
|
|
this.fpsObject = {};
|
|
}
|
|
|
|
/**
|
|
* This function is called frequently and thus minimized.
|
|
*/
|
|
get()
|
|
{
|
|
this.fpsObject.fps = Engine.GetFPS();
|
|
return sprintf(this.caption, this.fpsObject);
|
|
}
|
|
};
|
|
|
|
// dennis-ignore: *
|
|
OverlayCounterTypes.prototype.FPS.prototype.Caption = markForTranslation("FPS: %(fps)4s");
|
|
|
|
OverlayCounterTypes.prototype.FPS.prototype.Config = "overlay.fps";
|
|
|
|
OverlayCounterTypes.prototype.FPS.prototype.Hotkey = "fps.toggle";
|