0ad/binaries/data/mods/public/gui/session/minimap/MiniMapFlareButton.js
guerringuerrin a55f3ae0dc Add minimap position and scale configuration options and expanded mode toggle
- Toggle expanded minimap mode
- Choose between round and square minimap shapes
- `gui.session.minimap.position`, lets you switch between two positioning modes: panel-left and screen-left
- `gui.session.minimap.size`, change size between 1.0 and 2.0, default is 1.0.
2026-08-14 12:21:49 -03:00

43 lines
1.1 KiB
JavaScript

/**
* If the button that this class manages is pressed, the input state is switched to 'flare', letting the player send a flare by left-clicking on the map.
*/
class MiniMapFlareButton
{
constructor(playerViewControl)
{
this.flareButton = Engine.GetGUIObjectByName("flareButton");
this.flareButton.enabled = !g_IsReplay;
if (g_IsReplay)
return;
this.flareButton.onPress = this.onPress.bind(this);
registerHotkeyChangeHandler(this.onHotkeyChange.bind(this));
playerViewControl.registerViewedPlayerChangeHandler(this.rebuild.bind(this));
}
rebuild()
{
this.updateTooltip();
}
onHotkeyChange()
{
this.colorizedHotkey = colorizeHotkey("%(hotkey)s" + " ", "session.flare");
this.updateTooltip();
}
updateTooltip()
{
this.flareButton.tooltip = this.colorizedHotkey + (g_IsObserver ? this.ObserverTooltip : this.PlayerTooltip);
}
onPress()
{
if (inputState == INPUT_NORMAL)
inputState = INPUT_FLARE;
}
}
MiniMapFlareButton.prototype.PlayerTooltip = markForTranslation("Send a flare to your allies.");
MiniMapFlareButton.prototype.ObserverTooltip = markForTranslation("Send a flare to other observers.");