0ad/binaries/data/mods/public/gui/session/SessionMessageBox.js
phosit df5fee6103 Rename PushGuiPage to OpenChildPage
There is no `PopGuiPage` anymore. For symmetry there should also be no
`PushGuiPage`.
2025-03-09 10:39:20 +01:00

33 lines
807 B
JavaScript

/**
* This is the same as a regular MessageBox, but it pauses if it is
* a single-player game, until the player answered the dialog.
*/
class SessionMessageBox
{
async display()
{
closeOpenDialogs();
g_PauseControl.implicitPause();
const buttonId = await Engine.OpenChildPage(
"page_msgbox.xml",
{
"width": this.Width,
"height": this.Height,
"title": this.Title,
"message": this.Caption,
"buttonCaptions": this.Buttons ? this.Buttons.map(button => button.caption) : undefined,
});
if (this.Buttons && this.Buttons[buttonId].onPress)
this.Buttons[buttonId].onPress.call(this);
if (this.ResumeOnClose)
resumeGame();
}
}
SessionMessageBox.prototype.Width = 400;
SessionMessageBox.prototype.Height = 200;
SessionMessageBox.prototype.ResumeOnClose = true;