mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 14:53:56 -07:00
Change HotkeyPress event to be non-repeating (HotkeyDown to replace the repeating case) Fix shiftlag Make toggle hotkeys only respond to the first SDL event. Many iterations of review by: elexis Test done by: Imarok Comments By: vladislav, Stan Reviewed By: wraitii Fixes: #5055 Differential Revision: https://code.wildfiregames.com/D1398 This was SVN commit r23701.
47 lines
1 KiB
JavaScript
47 lines
1 KiB
JavaScript
/**
|
|
* This is an abstract base class managing one counter shown.
|
|
* Classes implementing this class require a Config property and may have a Hotkey property.
|
|
*/
|
|
class OverlayCounter
|
|
{
|
|
constructor(overlayCounterManager)
|
|
{
|
|
this.overlayCounterManager = overlayCounterManager;
|
|
this.updateEnabled();
|
|
|
|
registerConfigChangeHandler(this.onConfigChange.bind(this));
|
|
|
|
if (this.Hotkey)
|
|
Engine.SetGlobalHotkey(this.Hotkey, "Press", this.toggle.bind(this));
|
|
}
|
|
|
|
onConfigChange(changes)
|
|
{
|
|
if (changes.has(this.Config))
|
|
this.updateEnabled();
|
|
}
|
|
|
|
isEnabled()
|
|
{
|
|
return Engine.ConfigDB_GetValue("user", this.Config) == "true";
|
|
}
|
|
|
|
updateEnabled()
|
|
{
|
|
this.overlayCounterManager.setCounterEnabled(this, this.isEnabled());
|
|
}
|
|
|
|
toggle()
|
|
{
|
|
Engine.ConfigDB_CreateValue("user", this.Config, String(!this.isEnabled()));
|
|
this.updateEnabled();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* The properties of this prototype are defined in other files. Each of them is a class
|
|
* managing a counter shown on the current page and may extend the OverlayCounter class.
|
|
*/
|
|
class OverlayCounterTypes
|
|
{
|
|
}
|