0ad/binaries/data/mods/public/gui/session/developer_overlay/DeveloperOverlayControl.js
Vantha fd847c2a23
Refactor GUI object resizing JS code passages
It is possible to modify sizes by setting the properties directly.
(Without having to create a copy of it)
This allows to shorten those passages quite a bit without any functional change.
2025-06-17 12:57:37 -05:00

34 lines
643 B
JavaScript

/**
* Base class for all controls on the developer overlay.
*/
class DeveloperOverlayControl
{
constructor(handler, i)
{
this.handler = handler;
this.handler.update = () => this.update();
this.body = Engine.GetGUIObjectByName("dev_command[" + i + "]");
this.resize(i);
this.updater = this.update.bind(this);
if (this.handler.checked)
registerPlayersInitHandler(this.updater);
}
getHeight()
{
return this.body.size.bottom - this.body.size.top;
}
resize(i)
{
const height = this.body.size.bottom;
this.body.size.top = height * i;
this.body.size.bottom = height * (i + 1);
this.body.hidden = false;
}
}