forked from mirrors/0ad
Remove Engine.SwitchGuiPage from prelobby
This commit is contained in:
@@ -222,10 +222,13 @@ export const mainMenuItems = [
|
|||||||
(Engine.StartXmppClient ? "" : translate("Launch the multiplayer lobby. \\[DISABLED BY BUILD]")),
|
(Engine.StartXmppClient ? "" : translate("Launch the multiplayer lobby. \\[DISABLED BY BUILD]")),
|
||||||
"enabled": () => !!Engine.StartXmppClient,
|
"enabled": () => !!Engine.StartXmppClient,
|
||||||
"hotkey": "lobby",
|
"hotkey": "lobby",
|
||||||
"onPress": () =>
|
"onPress": async(closePageCallback) =>
|
||||||
{
|
{
|
||||||
if (Engine.StartXmppClient)
|
if (!Engine.StartXmppClient)
|
||||||
Engine.OpenChildPage("page_prelobby_entrance.xml");
|
return;
|
||||||
|
const ret = await Engine.OpenChildPage("page_prelobby_entrance.xml");
|
||||||
|
if (ret)
|
||||||
|
closePageCallback({ [Engine.openRequest]: ret });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,17 +1,30 @@
|
|||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
if (Engine.ConfigDB_GetValue("user", "lobby.login"))
|
return Promise.race([loginButton(), cancelHandler()]);
|
||||||
loginButton();
|
}
|
||||||
|
|
||||||
|
function cancelHandler()
|
||||||
|
{
|
||||||
return new Promise(closePageCallback =>
|
return new Promise(closePageCallback =>
|
||||||
{
|
{
|
||||||
Engine.GetGUIObjectByName("cancel").onPress = closePageCallback;
|
Engine.GetGUIObjectByName("cancel").onPress = closePageCallback;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loginButton()
|
async function loginButton()
|
||||||
{
|
{
|
||||||
Engine.OpenChildPage("page_prelobby_login.xml");
|
let skipEntrance = Engine.ConfigDB_GetValue("user", "lobby.login");
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (!skipEntrance)
|
||||||
|
await new Promise(resolve => { Engine.GetGUIObjectByName("login").onPress = resolve; });
|
||||||
|
|
||||||
|
const ret = await Engine.OpenChildPage("page_prelobby_login.xml");
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
skipEntrance = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function registerButton()
|
async function registerButton()
|
||||||
|
|||||||
@@ -21,9 +21,8 @@
|
|||||||
<action on="Press">registerButton();</action>
|
<action on="Press">registerButton();</action>
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
<object type="button" size="50%-140 50 50%+140 78" style="ModernButtonRed">
|
<object name="login" type="button" size="50%-140 50 50%+140 78" style="ModernButtonRed">
|
||||||
<translatableAttribute id="caption">Login to an existing account</translatableAttribute>
|
<translatableAttribute id="caption">Login to an existing account</translatableAttribute>
|
||||||
<action on="Press">loginButton();</action>
|
|
||||||
</object>
|
</object>
|
||||||
|
|
||||||
<object name="cancel" type="button" size="18 100%-46 50%-5 100%-18" style="ModernButtonRed" hotkey="cancel">
|
<object name="cancel" type="button" size="18 100%-46 50%-5 100%-18" style="ModernButtonRed" hotkey="cancel">
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
g_LobbyMessages.connected = onLogin;
|
|
||||||
|
|
||||||
Engine.GetGUIObjectByName("continue").caption = translate("Connect");
|
Engine.GetGUIObjectByName("continue").caption = translate("Connect");
|
||||||
|
|
||||||
// Shorten the displayed password for visual reasons only
|
// Shorten the displayed password for visual reasons only
|
||||||
@@ -14,7 +12,7 @@ function init()
|
|||||||
|
|
||||||
updateFeedback();
|
updateFeedback();
|
||||||
|
|
||||||
return cancelButton();
|
return Promise.race([ onLoggedin(), cancelButton() ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateFeedback()
|
function updateFeedback()
|
||||||
@@ -42,15 +40,19 @@ function continueButton()
|
|||||||
|
|
||||||
Engine.ConnectXmppClient();
|
Engine.ConnectXmppClient();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* The data from Engine.SendGetBoardList() is used for the leaderboard, but also for autocompletion in the profile player search field.
|
async function onLoggedin()
|
||||||
*/
|
|
||||||
function onLogin(message)
|
|
||||||
{
|
{
|
||||||
|
await new Promise(resolve => { g_LobbyMessages.connected = resolve; });
|
||||||
saveCredentials();
|
saveCredentials();
|
||||||
|
|
||||||
Engine.SwitchGuiPage("page_lobby.xml", {
|
// The data from Engine.SendGetBoardList() is used for the leaderboard, but also for
|
||||||
"dialog": false
|
// autocompletion in the profile player search field.
|
||||||
});
|
|
||||||
Engine.SendGetBoardList();
|
Engine.SendGetBoardList();
|
||||||
|
return {
|
||||||
|
"page": "page_lobby.xml",
|
||||||
|
"argument": {
|
||||||
|
"dialog": false
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ class CivInfoPage extends ReferencePage
|
|||||||
|
|
||||||
switchToStructreePage()
|
switchToStructreePage()
|
||||||
{
|
{
|
||||||
this.closePageCallback({ [Engine.openRequest] : {
|
this.closePageCallback({ [Engine.openRequest]: {
|
||||||
"page": "page_structree.xml",
|
"page": "page_structree.xml",
|
||||||
"argument": {
|
"argument": {
|
||||||
"civ": this.activeCiv
|
"civ": this.activeCiv
|
||||||
}
|
}
|
||||||
}});
|
} });
|
||||||
}
|
}
|
||||||
|
|
||||||
closePage()
|
closePage()
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ class CivInfoButton
|
|||||||
|
|
||||||
onPress()
|
onPress()
|
||||||
{
|
{
|
||||||
this.parentPage.closePageCallback({ [Engine.openRequest] : {
|
this.parentPage.closePageCallback({ [Engine.openRequest]: {
|
||||||
"page": "page_civinfo.xml",
|
"page": "page_civinfo.xml",
|
||||||
"argument": {
|
"argument": {
|
||||||
"civ": this.parentPage.activeCiv
|
"civ": this.parentPage.activeCiv
|
||||||
}
|
}
|
||||||
}});
|
} });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ class StructreeButton
|
|||||||
|
|
||||||
onPress()
|
onPress()
|
||||||
{
|
{
|
||||||
this.parentPage.closePageCallback({ [Engine.openRequest] : {
|
this.parentPage.closePageCallback({ [Engine.openRequest]: {
|
||||||
"page": "page_structree.xml",
|
"page": "page_structree.xml",
|
||||||
"argument": {
|
"argument": {
|
||||||
"civ": this.parentPage.activeCiv
|
"civ": this.parentPage.activeCiv
|
||||||
}
|
}
|
||||||
}});
|
} });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user