Remove Engine.SwitchGuiPage from loading

This commit is contained in:
phosit 2025-04-23 17:50:08 +02:00
parent 02a4cf6aff
commit d842a134f9
No known key found for this signature in database
GPG key ID: C9430B600671C268
2 changed files with 34 additions and 34 deletions

View file

@ -31,27 +31,3 @@ function displayGamestateNotifications()
setTimeout(displayGamestateNotifications, 1000);
}
/**
* This function is called from the engine whenever starting a game fails.
*/
function cancelOnLoadGameError(msg)
{
Engine.EndGame();
if (Engine.HasXmppClient())
Engine.StopXmppClient();
Engine.SwitchGuiPage("page_pregame.xml");
if (msg)
Engine.OpenChildPage("page_msgbox.xml", {
"width": 500,
"height": 200,
"message": msg,
"title": translate("Loading Aborted"),
"mode": 2
});
Engine.ResetCursor();
}

View file

@ -1,6 +1,6 @@
var g_LoadingPage;
function init(data)
async function init(data)
{
g_LoadingPage = {
"initData": data,
@ -11,14 +11,38 @@ function init(data)
};
Engine.SetCursor("cursor-wait");
}
/**
* This is a reserved function name that is executed by the engine when it is ready
* to start the game (i.e. loading progress has reached 100%).
*/
function reallyStartGame()
{
Engine.SwitchGuiPage("page_session.xml", g_LoadingPage.initData);
Engine.ResetCursor();
// reallyStartGame and cancelOnLoadGameError are reserved names that are called by the engine.
// reallyStartGame is called when it is ready to start the game (i.e. loading progress has reached
// 100%).
// cancnelOnLoadGameError is called when there is an error.
return new Promise(closePageCallback =>
{
globalThis.reallyStartGame = () =>
{
Engine.ResetCursor();
closePageCallback({ [Engine.openRequest]: {
"page": "page_session.xml",
"argument": data
} });
};
globalThis.cancelOnLoadGameError = async() =>
{
Engine.ResetCursor();
Engine.EndGame();
if (Engine.HasXmppClient())
Engine.StopXmppClient();
await Engine.OpenChildPage("page_msgbox.xml", {
"width": 500,
"height": 200,
"message": errorMessage,
"title": translate("Loading Aborted"),
"mode": 2
});
closePageCallback({ [Engine.openRequest]: { "page": "page_pregame.xml" } });
};
});
}