Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ binaries/data/config/default.cfg @@ -176,6 +176,7 @@ chat = Return ; Toggle chat window teamchat = "T" ; Toggle chat window in team chat mode privatechat = "L" ; Toggle chat window and select the previous private chat partner +lobby = "Alt+L" ; Show the multiplayer lobby in a dialog window. ; > QUICKSAVE quicksave = "Shift+F5" Index: binaries/data/mods/public/gui/gamesetup/gamesetup.js =================================================================== --- binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -1923,6 +1923,7 @@ if (hide) return; + lobbyButtonState(); for (let property in obj) control[property] = obj[property](playerIdx); } @@ -2504,3 +2505,16 @@ g_Autocomplete = Object.keys(autocomplete).sort().reverse().reduce((all, priority) => all.concat(autocomplete[priority]), []); } + +function openLobby() +{ + if (!Engine.HasXmppClient()) + return; + + Engine.PushGuiPage("page_lobby.xml", { "dialog": true, "callback": "lobbyButtonState" }); +} + +function lobbyButtonState() +{ + Engine.GetGUIObjectByName("lobbyButton").hidden = !Engine.HasXmppClient(); +} Index: binaries/data/mods/public/gui/gamesetup/gamesetup.xml =================================================================== --- binaries/data/mods/public/gui/gamesetup/gamesetup.xml +++ binaries/data/mods/public/gui/gamesetup/gamesetup.xml @@ -247,6 +247,18 @@ + + + Show the multiplayer lobby in a dialog window. + openLobby(); + + + + + + + + + Index: binaries/data/mods/public/gui/lobby/lobby.js =================================================================== --- binaries/data/mods/public/gui/lobby/lobby.js +++ binaries/data/mods/public/gui/lobby/lobby.js @@ -88,7 +88,7 @@ /** * All games currently running. */ -var g_GameList = {}; +var g_GameList = []; /** * Used to restore the selection after updating the playerlist. @@ -137,6 +137,10 @@ "time": msg.time, "text": translate("Disconnected.") + " " + msg.reason }); + + if (Engine.HasXmppClient()) + Engine.StopXmppClient(); + return true; }, "error": msg => { @@ -363,12 +367,18 @@ "quit": { "description": translate("Return to the main menu."), "handler": args => { - returnToMainMenu(); + leaveLobby(); return false; } } }; +/* + * Indicates, if the lobby is opened in the dialog. + */ +var g_Dialog = false; + + /** * Called after the XmppConnection succeeded and when returning from a game. * @@ -376,9 +386,17 @@ */ function init(attribs) { + g_Dialog = attribs && attribs.dialog; + + g_CallbackSet = g_Dialog && attribs && attribs.callback; + + Engine.LobbySetPlayerPresence("available"); + + initGUIObjects(); + if (!g_Settings) { - returnToMainMenu(); + leaveLobby(); return; } @@ -387,8 +405,6 @@ initGameFilters(); - Engine.LobbySetPlayerPresence("available"); - // When rejoining the lobby after a game, we don't need to process presence changes Engine.LobbyClearPresenceUpdates(); updatePlayerList(); @@ -403,6 +419,27 @@ g_NetMessageTypes[msg.type][msg.level](msg); } +/** + * Set style of GUI elements and the window style. + */ +function initGUIObjects() +{ + let lobbyWindow = Engine.GetGUIObjectByName("lobbyWindow"); + lobbyWindow.sprite = g_Dialog ? "ModernDialog" : "ModernWindow"; + lobbyWindow.size = g_Dialog ? "42 42 100%-42 100%-42" : "0 0 100% 100%"; + Engine.GetGUIObjectByName("lobbyWindowTitle").size = g_Dialog ? "50%-128 -16 50%+128 16" : "50%-128 4 50%+128 36"; + + Engine.GetGUIObjectByName("leaveButton").caption = g_Dialog ? translate("Back") : translate("Main Menu"); + Engine.GetGUIObjectByName("lobbyDialogToggle").onPress = g_Dialog ? leaveLobby : () => false; + Engine.GetGUIObjectByName("cancelDialog").onPress = g_Dialog ? leaveLobby : () => false; + Engine.GetGUIObjectByName("hostButton").hidden = g_Dialog; + Engine.GetGUIObjectByName("joinGameButton").hidden = g_Dialog; + Engine.GetGUIObjectByName("gameInfoEmpty").size = "0 0 100% 100%" + (g_Dialog ? "-30" : "-60"); + Engine.GetGUIObjectByName("gameInfo").size = "0 0 100% 100%" + (g_Dialog ? "-30" : "-90"); + + Engine.GetGUIObjectByName("fadeImage").hidden = !g_Dialog; +} + function updateLobbyColumns() { let gameRating = Engine.ConfigDB_GetValue("user", "lobby.columns.gamerating") == "true"; @@ -426,10 +463,19 @@ playersNumberFilter.size = size; } -function returnToMainMenu() +function leaveLobby() { - Engine.StopXmppClient(); - Engine.SwitchGuiPage("page_pregame.xml"); + if (g_Dialog) + { + Engine.LobbySetPlayerPresence("playing"); + closePage(); + } + else + { + if (Engine.HasXmppClient()) + Engine.StopXmppClient(); + Engine.SwitchGuiPage("page_pregame.xml"); + } } function initGameFilters() @@ -611,7 +657,7 @@ let nickList = []; let ratingList = []; - let cleanPlayerList = Engine.GetPlayerList().map(player => { + let cleanPlayerList = (Engine.GetPlayerList()).map(player => { player.isBuddy = g_Buddies.indexOf(player.name) != -1; return player; }).sort((a, b) => { @@ -903,7 +949,7 @@ g_SelectedGamePort = g_GameList[gamesBox.selected].port; } - g_GameList = Engine.GetGameList().map(game => { + g_GameList = (Engine.GetGameList()).map(game => { game.hasBuddies = 0; @@ -1015,7 +1061,7 @@ let game = selectedGame(); Engine.GetGUIObjectByName("gameInfo").hidden = !game; - Engine.GetGUIObjectByName("joinGameButton").hidden = !game; + Engine.GetGUIObjectByName("joinGameButton").hidden = g_Dialog || !game; Engine.GetGUIObjectByName("gameInfoEmpty").hidden = game; if (!game) @@ -1073,7 +1119,7 @@ function joinButton() { let game = selectedGame(); - if (!game) + if (!game || g_Dialog) return; let rating = getRejoinRating(game); Index: binaries/data/mods/public/gui/lobby/lobby.xml =================================================================== --- binaries/data/mods/public/gui/lobby/lobby.xml +++ binaries/data/mods/public/gui/lobby/lobby.xml @@ -4,10 +4,13 @@