2019-10-18 07:11:43 -07:00
|
|
|
|
/**
|
|
|
|
|
|
* This class is extended in subclasses.
|
|
|
|
|
|
* Each subclass represents one button in the session menu.
|
|
|
|
|
|
* All subclasses store the button member so that mods can change it easily.
|
|
|
|
|
|
*/
|
|
|
|
|
|
class MenuButtons
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MenuButtons.prototype.Manual = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button, pauseControl)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.caption = translate(translate("Manual"));
|
2026-03-19 13:46:55 -07:00
|
|
|
|
this.button.hotkey = "manual";
|
2019-10-18 07:11:43 -07:00
|
|
|
|
this.pauseControl = pauseControl;
|
2026-03-19 13:46:55 -07:00
|
|
|
|
registerHotkeyChangeHandler(this.rebuild.bind(this));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button.tooltip = sprintf(translate("%(hotkey)s: Open the 0 A.D. game manual."), {
|
|
|
|
|
|
"hotkey": colorizeHotkey("%(hotkey)s", this.button.hotkey),
|
|
|
|
|
|
});
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-08 12:07:04 -07:00
|
|
|
|
async onPress()
|
2019-10-18 07:11:43 -07:00
|
|
|
|
{
|
|
|
|
|
|
closeOpenDialogs();
|
|
|
|
|
|
this.pauseControl.implicitPause();
|
2024-10-30 10:56:33 -07:00
|
|
|
|
await Engine.OpenChildPage("page_manual.xml");
|
2024-07-08 12:07:04 -07:00
|
|
|
|
resumeGame();
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MenuButtons.prototype.Chat = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button, pauseControl, playerViewControl, chat)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.caption = translate("Chat");
|
|
|
|
|
|
this.chat = chat;
|
|
|
|
|
|
registerHotkeyChangeHandler(this.rebuild.bind(this));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button.tooltip = this.chat.getOpenHotkeyTooltip().trim();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onPress()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.chat.openPage();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MenuButtons.prototype.Save = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button, pauseControl)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.caption = translate("Save");
|
|
|
|
|
|
this.pauseControl = pauseControl;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-08 12:07:04 -07:00
|
|
|
|
async onPress()
|
2019-10-18 07:11:43 -07:00
|
|
|
|
{
|
|
|
|
|
|
closeOpenDialogs();
|
|
|
|
|
|
this.pauseControl.implicitPause();
|
|
|
|
|
|
|
2024-10-30 10:56:33 -07:00
|
|
|
|
await Engine.OpenChildPage(
|
2019-10-18 07:11:43 -07:00
|
|
|
|
"page_loadgame.xml",
|
2021-03-02 07:43:44 -08:00
|
|
|
|
{
|
|
|
|
|
|
"savedGameData": getSavedGameData(),
|
|
|
|
|
|
"campaignRun": g_CampaignSession ? g_CampaignSession.run.filename : null
|
2024-07-08 12:07:04 -07:00
|
|
|
|
});
|
|
|
|
|
|
resumeGame();
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MenuButtons.prototype.Summary = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button, pauseControl)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.caption = translate("Summary");
|
|
|
|
|
|
this.button.hotkey = "summary";
|
2021-03-19 03:02:10 -07:00
|
|
|
|
// TODO: Atlas should pass g_InitAttributes.settings
|
2019-10-18 07:11:43 -07:00
|
|
|
|
this.button.enabled = !Engine.IsAtlasRunning();
|
|
|
|
|
|
|
|
|
|
|
|
this.pauseControl = pauseControl;
|
|
|
|
|
|
this.selectedData = undefined;
|
|
|
|
|
|
|
|
|
|
|
|
registerHotkeyChangeHandler(this.rebuild.bind(this));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
|
{
|
2026-03-19 13:46:55 -07:00
|
|
|
|
this.button.tooltip = sprintf(translate("%(hotkey)s: Open the summary screen."), {
|
2019-10-18 07:11:43 -07:00
|
|
|
|
"hotkey": colorizeHotkey("%(hotkey)s", this.button.hotkey),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-08 12:07:04 -07:00
|
|
|
|
async onPress()
|
2019-10-18 07:11:43 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (Engine.IsAtlasRunning())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
closeOpenDialogs();
|
|
|
|
|
|
this.pauseControl.implicitPause();
|
2025-05-30 12:33:49 -07:00
|
|
|
|
// Allows players to see their own summary.
|
2019-10-18 07:11:43 -07:00
|
|
|
|
// If they have shared ally vision researched, they are able to see the summary of there allies too.
|
2025-05-10 09:04:46 -07:00
|
|
|
|
const simState = Engine.GuiInterfaceCall("GetExtendedSimulationState");
|
2024-10-30 10:56:33 -07:00
|
|
|
|
const data = await Engine.OpenChildPage(
|
2019-10-18 07:11:43 -07:00
|
|
|
|
"page_summary.xml",
|
|
|
|
|
|
{
|
|
|
|
|
|
"sim": {
|
2021-03-19 03:02:10 -07:00
|
|
|
|
"mapSettings": g_InitAttributes.settings,
|
2019-10-18 07:11:43 -07:00
|
|
|
|
"playerStates": simState.players.filter((state, player) =>
|
2020-07-16 14:10:43 -07:00
|
|
|
|
g_IsObserver || g_ViewedPlayer == 0 || player == 0 || player == g_ViewedPlayer ||
|
2019-10-18 07:11:43 -07:00
|
|
|
|
simState.players[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer]),
|
|
|
|
|
|
"timeElapsed": simState.timeElapsed
|
|
|
|
|
|
},
|
|
|
|
|
|
"gui": {
|
|
|
|
|
|
"dialog": true,
|
2020-06-20 14:26:20 -07:00
|
|
|
|
"isInGame": true,
|
|
|
|
|
|
"summarySelection": this.summarySelection
|
2019-10-18 07:11:43 -07:00
|
|
|
|
},
|
|
|
|
|
|
});
|
2024-07-08 12:07:04 -07:00
|
|
|
|
|
|
|
|
|
|
this.summarySelection = data.summarySelection;
|
|
|
|
|
|
this.pauseControl.implicitResume();
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MenuButtons.prototype.Lobby = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.caption = translate("Lobby");
|
|
|
|
|
|
this.button.hotkey = "lobby";
|
|
|
|
|
|
this.button.enabled = Engine.HasXmppClient();
|
|
|
|
|
|
|
|
|
|
|
|
registerHotkeyChangeHandler(this.rebuild.bind(this));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
|
{
|
2026-03-19 13:46:55 -07:00
|
|
|
|
this.button.tooltip = sprintf(translate("%(hotkey)s: Open the multiplayer lobby page without leaving the game."), {
|
2019-10-18 07:11:43 -07:00
|
|
|
|
"hotkey": colorizeHotkey("%(hotkey)s", this.button.hotkey),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onPress()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!Engine.HasXmppClient())
|
|
|
|
|
|
return;
|
|
|
|
|
|
closeOpenDialogs();
|
2024-10-30 10:56:33 -07:00
|
|
|
|
Engine.OpenChildPage("page_lobby.xml", { "dialog": true });
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MenuButtons.prototype.Options = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button, pauseControl)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.caption = translate("Options");
|
2026-03-19 13:46:55 -07:00
|
|
|
|
this.button.hotkey = "options";
|
2019-10-18 07:11:43 -07:00
|
|
|
|
this.pauseControl = pauseControl;
|
2026-03-19 13:46:55 -07:00
|
|
|
|
registerHotkeyChangeHandler(this.rebuild.bind(this));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button.tooltip = sprintf(translate("%(hotkey)s: Adjust game settings."), {
|
|
|
|
|
|
"hotkey": colorizeHotkey("%(hotkey)s", this.button.hotkey),
|
|
|
|
|
|
});
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-08 12:07:04 -07:00
|
|
|
|
async onPress()
|
2019-10-18 07:11:43 -07:00
|
|
|
|
{
|
|
|
|
|
|
closeOpenDialogs();
|
|
|
|
|
|
this.pauseControl.implicitPause();
|
|
|
|
|
|
|
2024-10-30 10:56:33 -07:00
|
|
|
|
fireConfigChangeHandlers(await Engine.OpenChildPage("page_options.xml"));
|
2024-07-08 12:07:04 -07:00
|
|
|
|
resumeGame();
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.
- Provide a "Hotkey" screen to let players remap hotkeys in-game using a
convenient setup.
- Make all .cfg hotkeys refer to scancodes (i.e. position on the
keyboard), so that default hotkeys now translate correctly for AZERTY,
QWERTZ and other layouts.
- 'BackSpace' is now an alias for 'Delete', and works for killing units.
This fixes #1917, as macs don't have a proper delete key and would need
to use Fn+Del otherwise. This shifts "timewarp" to Shift+BackSpace.
Functionally, this switches hotkeys to scancodes, as that makes more
sense (they are combinations of key positions, not actual text output).
SDL includes are cleaned and key names are reused.
Fixes #2850, Fixes #2604, Refs #1810, Fixes #1917.
Follows work in 3d7784d2af.
Various diffs tested by: Angen, Stan, Freagarach
Comments by: Nescio
Differential Revision: https://code.wildfiregames.com/D2814
This was SVN commit r24215.
2020-11-19 01:27:26 -08:00
|
|
|
|
MenuButtons.prototype.Hotkeys = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button, pauseControl)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.caption = translate("Hotkeys");
|
2026-03-19 13:46:55 -07:00
|
|
|
|
this.button.hotkey = "hotkeys";
|
Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.
- Provide a "Hotkey" screen to let players remap hotkeys in-game using a
convenient setup.
- Make all .cfg hotkeys refer to scancodes (i.e. position on the
keyboard), so that default hotkeys now translate correctly for AZERTY,
QWERTZ and other layouts.
- 'BackSpace' is now an alias for 'Delete', and works for killing units.
This fixes #1917, as macs don't have a proper delete key and would need
to use Fn+Del otherwise. This shifts "timewarp" to Shift+BackSpace.
Functionally, this switches hotkeys to scancodes, as that makes more
sense (they are combinations of key positions, not actual text output).
SDL includes are cleaned and key names are reused.
Fixes #2850, Fixes #2604, Refs #1810, Fixes #1917.
Follows work in 3d7784d2af.
Various diffs tested by: Angen, Stan, Freagarach
Comments by: Nescio
Differential Revision: https://code.wildfiregames.com/D2814
This was SVN commit r24215.
2020-11-19 01:27:26 -08:00
|
|
|
|
this.pauseControl = pauseControl;
|
2026-03-19 13:46:55 -07:00
|
|
|
|
registerHotkeyChangeHandler(this.rebuild.bind(this));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button.tooltip = sprintf(translate("%(hotkey)s: Adjust hotkeys."), {
|
|
|
|
|
|
"hotkey": colorizeHotkey("%(hotkey)s", this.button.hotkey),
|
|
|
|
|
|
});
|
Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.
- Provide a "Hotkey" screen to let players remap hotkeys in-game using a
convenient setup.
- Make all .cfg hotkeys refer to scancodes (i.e. position on the
keyboard), so that default hotkeys now translate correctly for AZERTY,
QWERTZ and other layouts.
- 'BackSpace' is now an alias for 'Delete', and works for killing units.
This fixes #1917, as macs don't have a proper delete key and would need
to use Fn+Del otherwise. This shifts "timewarp" to Shift+BackSpace.
Functionally, this switches hotkeys to scancodes, as that makes more
sense (they are combinations of key positions, not actual text output).
SDL includes are cleaned and key names are reused.
Fixes #2850, Fixes #2604, Refs #1810, Fixes #1917.
Follows work in 3d7784d2af.
Various diffs tested by: Angen, Stan, Freagarach
Comments by: Nescio
Differential Revision: https://code.wildfiregames.com/D2814
This was SVN commit r24215.
2020-11-19 01:27:26 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-08 12:07:04 -07:00
|
|
|
|
async onPress()
|
Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.
- Provide a "Hotkey" screen to let players remap hotkeys in-game using a
convenient setup.
- Make all .cfg hotkeys refer to scancodes (i.e. position on the
keyboard), so that default hotkeys now translate correctly for AZERTY,
QWERTZ and other layouts.
- 'BackSpace' is now an alias for 'Delete', and works for killing units.
This fixes #1917, as macs don't have a proper delete key and would need
to use Fn+Del otherwise. This shifts "timewarp" to Shift+BackSpace.
Functionally, this switches hotkeys to scancodes, as that makes more
sense (they are combinations of key positions, not actual text output).
SDL includes are cleaned and key names are reused.
Fixes #2850, Fixes #2604, Refs #1810, Fixes #1917.
Follows work in 3d7784d2af.
Various diffs tested by: Angen, Stan, Freagarach
Comments by: Nescio
Differential Revision: https://code.wildfiregames.com/D2814
This was SVN commit r24215.
2020-11-19 01:27:26 -08:00
|
|
|
|
{
|
|
|
|
|
|
closeOpenDialogs();
|
|
|
|
|
|
this.pauseControl.implicitPause();
|
|
|
|
|
|
|
2026-03-19 13:46:55 -07:00
|
|
|
|
await Engine.OpenChildPage("page_hotkeys.xml");
|
2024-07-08 12:07:04 -07:00
|
|
|
|
resumeGame();
|
Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.
- Provide a "Hotkey" screen to let players remap hotkeys in-game using a
convenient setup.
- Make all .cfg hotkeys refer to scancodes (i.e. position on the
keyboard), so that default hotkeys now translate correctly for AZERTY,
QWERTZ and other layouts.
- 'BackSpace' is now an alias for 'Delete', and works for killing units.
This fixes #1917, as macs don't have a proper delete key and would need
to use Fn+Del otherwise. This shifts "timewarp" to Shift+BackSpace.
Functionally, this switches hotkeys to scancodes, as that makes more
sense (they are combinations of key positions, not actual text output).
SDL includes are cleaned and key names are reused.
Fixes #2850, Fixes #2604, Refs #1810, Fixes #1917.
Follows work in 3d7784d2af.
Various diffs tested by: Angen, Stan, Freagarach
Comments by: Nescio
Differential Revision: https://code.wildfiregames.com/D2814
This was SVN commit r24215.
2020-11-19 01:27:26 -08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2019-10-18 07:11:43 -07:00
|
|
|
|
MenuButtons.prototype.Pause = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button, pauseControl, playerViewControl)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.hotkey = "pause";
|
|
|
|
|
|
this.pauseControl = pauseControl;
|
|
|
|
|
|
|
|
|
|
|
|
registerPlayersInitHandler(this.rebuild.bind(this));
|
|
|
|
|
|
registerPlayersFinishedHandler(this.rebuild.bind(this));
|
|
|
|
|
|
playerViewControl.registerPlayerIDChangeHandler(this.rebuild.bind(this));
|
|
|
|
|
|
pauseControl.registerPauseHandler(this.rebuild.bind(this));
|
|
|
|
|
|
registerHotkeyChangeHandler(this.rebuild.bind(this));
|
2019-10-30 06:48:27 -07:00
|
|
|
|
registerNetworkStatusChangeHandler(this.rebuild.bind(this));
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
|
{
|
2019-10-30 06:48:27 -07:00
|
|
|
|
this.button.enabled = this.pauseControl.canPause(true);
|
2019-10-18 07:11:43 -07:00
|
|
|
|
this.button.caption = this.pauseControl.explicitPause ? translate("Resume") : translate("Pause");
|
2026-03-19 13:46:55 -07:00
|
|
|
|
this.button.tooltip = sprintf(translate("%(hotkey)s: Pause or resume the game."), {
|
2019-10-18 07:11:43 -07:00
|
|
|
|
"hotkey": colorizeHotkey("%(hotkey)s", this.button.hotkey),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onPress()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.pauseControl.setPaused(!g_PauseControl.explicitPause, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MenuButtons.prototype.Resign = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button, pauseControl, playerViewControl)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.caption = translate("Resign");
|
|
|
|
|
|
this.pauseControl = pauseControl;
|
|
|
|
|
|
|
|
|
|
|
|
registerPlayersInitHandler(this.rebuild.bind(this));
|
|
|
|
|
|
registerPlayersFinishedHandler(this.rebuild.bind(this));
|
|
|
|
|
|
playerViewControl.registerPlayerIDChangeHandler(this.rebuild.bind(this));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
rebuild()
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button.enabled = !g_IsObserver;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onPress()
|
|
|
|
|
|
{
|
2019-10-30 04:14:55 -07:00
|
|
|
|
(new ResignConfirmation()).display();
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MenuButtons.prototype.Exit = class
|
|
|
|
|
|
{
|
|
|
|
|
|
constructor(button, pauseControl)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.button = button;
|
|
|
|
|
|
this.button.caption = translate("Exit");
|
|
|
|
|
|
this.button.enabled = !Engine.IsAtlasRunning();
|
|
|
|
|
|
this.pauseControl = pauseControl;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-11 12:06:33 -07:00
|
|
|
|
onPress(closeSession)
|
2019-10-18 07:11:43 -07:00
|
|
|
|
{
|
2025-05-10 09:04:46 -07:00
|
|
|
|
for (const name in QuitConfirmationMenu.prototype)
|
2019-10-30 04:14:55 -07:00
|
|
|
|
{
|
2025-05-10 09:04:46 -07:00
|
|
|
|
const quitConfirmation = new QuitConfirmationMenu.prototype[name]();
|
2019-10-30 04:14:55 -07:00
|
|
|
|
if (quitConfirmation.enabled())
|
2026-06-11 12:06:33 -07:00
|
|
|
|
quitConfirmation.display(closeSession);
|
2019-10-30 04:14:55 -07:00
|
|
|
|
}
|
2019-10-18 07:11:43 -07:00
|
|
|
|
}
|
|
|
|
|
|
};
|