2021-06-05 10:37:18 -07:00
|
|
|
/**
|
2024-11-14 01:26:09 -08:00
|
|
|
* 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.
|
2021-06-05 10:37:18 -07:00
|
|
|
*/
|
|
|
|
|
class MiniMapFlareButton
|
|
|
|
|
{
|
2021-06-09 09:34:53 -07:00
|
|
|
constructor(playerViewControl)
|
2021-06-05 10:37:18 -07:00
|
|
|
{
|
|
|
|
|
this.flareButton = Engine.GetGUIObjectByName("flareButton");
|
2024-12-03 11:55:26 -08:00
|
|
|
|
|
|
|
|
this.flareButton.enabled = !g_IsReplay;
|
|
|
|
|
if (g_IsReplay)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-06-05 10:37:18 -07:00
|
|
|
this.flareButton.onPress = this.onPress.bind(this);
|
|
|
|
|
registerHotkeyChangeHandler(this.onHotkeyChange.bind(this));
|
2021-06-09 09:34:53 -07:00
|
|
|
playerViewControl.registerViewedPlayerChangeHandler(this.rebuild.bind(this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
{
|
2024-11-14 01:26:09 -08:00
|
|
|
this.updateTooltip();
|
2021-06-05 10:37:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onHotkeyChange()
|
|
|
|
|
{
|
2024-11-14 01:26:09 -08:00
|
|
|
this.colorizedHotkey = colorizeHotkey("%(hotkey)s" + " ", "session.flare");
|
|
|
|
|
this.updateTooltip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateTooltip()
|
|
|
|
|
{
|
|
|
|
|
this.flareButton.tooltip = this.colorizedHotkey + (g_IsObserver ? this.ObserverTooltip : this.PlayerTooltip);
|
2021-06-05 10:37:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onPress()
|
|
|
|
|
{
|
|
|
|
|
if (inputState == INPUT_NORMAL)
|
|
|
|
|
inputState = INPUT_FLARE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-14 01:26:09 -08:00
|
|
|
MiniMapFlareButton.prototype.PlayerTooltip = markForTranslation("Send a flare to your allies.");
|
|
|
|
|
MiniMapFlareButton.prototype.ObserverTooltip = markForTranslation("Send a flare to other observers.");
|