Index: ps/trunk/binaries/data/config/default.cfg =================================================================== --- ps/trunk/binaries/data/config/default.cfg +++ ps/trunk/binaries/data/config/default.cfg @@ -150,7 +150,10 @@ wireframe = "Alt+Shift+W" ; Toggle wireframe mode silhouettes = "Alt+Shift+S" ; Toggle unit silhouettes showsky = "Alt+Z" ; Toggle sky + +; > DIALOG HOTKEYS summary = "Ctrl+Tab" ; Toggle in-game summary +lobby = "Alt+L" ; Show the multiplayer lobby in a dialog window. ; > CLIPBOARD CONTROLS copy = "Ctrl+C" ; Copy to clipboard Index: ps/trunk/binaries/data/mods/public/gui/common/sprites.xml =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/sprites.xml +++ ps/trunk/binaries/data/mods/public/gui/common/sprites.xml @@ -177,6 +177,22 @@ /> + + + + + + + + + + + + + Show the multiplayer lobby in a dialog window. + false, - "connected": msg => false, + "connected": msg => { + + g_AskedReconnect = false; + updateConnectedState(); + return false; + }, "disconnected": msg => { updateGameList(); updateLeaderboard(); - - Engine.GetGUIObjectByName("chatInput").hidden = true; - - for (let button of ["host", "leaderboard", "userprofile", "toggleBuddy"]) - Engine.GetGUIObjectByName(button + "Button").enabled = false; - Engine.GetGUIObjectByName("chatInput").hidden = true; + updateConnectedState(); if (!g_Kicked) + { addChatMessage({ "from": "system", "time": msg.time, "text": translate("Disconnected.") + " " + msg.reason }); + reconnectMessageBox(); + } + return true; }, "error": msg => { @@ -363,7 +378,7 @@ "quit": { "description": translate("Return to the main menu."), "handler": args => { - returnToMainMenu(); + leaveLobby(); return false; } } @@ -376,16 +391,20 @@ */ function init(attribs) { + g_Dialog = attribs && attribs.dialog; + if (!g_Settings) { - returnToMainMenu(); + leaveLobby(); return; } initMusic(); global.music.setState(global.music.states.MENU); + initDialogStyle(); initGameFilters(); + updateConnectedState(); Engine.LobbySetPlayerPresence("available"); @@ -401,6 +420,61 @@ // Get all messages since the login for (let msg of Engine.LobbyGuiPollHistoricMessages()) g_NetMessageTypes[msg.type][msg.level](msg); + + if (!Engine.IsXmppClientConnected()) + reconnectMessageBox(); +} + +function reconnectMessageBox() +{ + if (g_AskedReconnect) + return; + + g_AskedReconnect = true; + + messageBox( + 400, 200, + translate("You have been disconnected from the lobby. Do you want to reconnect?"), + translate("Confirmation"), + [translate("No"), translate("Yes")], + [null, Engine.ConnectXmppClient]); +} + +/** + * Set style of GUI elements and the window style. + */ +function initDialogStyle() +{ + 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 ? + translateWithContext("previous page", "Back") : + translateWithContext("previous page", "Main Menu"); + + Engine.GetGUIObjectByName("hostButton").hidden = g_Dialog; + Engine.GetGUIObjectByName("joinGameButton").hidden = g_Dialog; + Engine.GetGUIObjectByName("gameInfoEmpty").size = "0 0 100% 100%-30" + (g_Dialog ? "" : "-30"); + Engine.GetGUIObjectByName("gameInfo").size = "0 0 100% 100%-30" + (g_Dialog ? "" : "-60"); + + if (g_Dialog) + { + Engine.GetGUIObjectByName("lobbyDialogToggle").onPress = leaveLobby; + Engine.GetGUIObjectByName("cancelDialog").onPress = leaveLobby; + } +} + +/** + * Set style of GUI elements according to the connection state of the lobby. + */ +function updateConnectedState() +{ + Engine.GetGUIObjectByName("chatInput").hidden = !Engine.IsXmppClientConnected(); + + for (let button of ["host", "leaderboard", "userprofile", "toggleBuddy"]) + Engine.GetGUIObjectByName(button + "Button").enabled = Engine.IsXmppClientConnected(); } function updateLobbyColumns() @@ -426,10 +500,18 @@ playersNumberFilter.size = size; } -function returnToMainMenu() +function leaveLobby() { - Engine.StopXmppClient(); - Engine.SwitchGuiPage("page_pregame.xml"); + if (g_Dialog) + { + Engine.LobbySetPlayerPresence("playing"); + Engine.PopGuiPage(); + } + else + { + Engine.StopXmppClient(); + Engine.SwitchGuiPage("page_pregame.xml"); + } } function initGameFilters() @@ -1015,7 +1097,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 +1155,7 @@ function joinButton() { let game = selectedGame(); - if (!game) + if (!game || g_Dialog) return; let rating = getRejoinRating(game); Index: ps/trunk/binaries/data/mods/public/gui/lobby/lobby.xml =================================================================== --- ps/trunk/binaries/data/mods/public/gui/lobby/lobby.xml +++ ps/trunk/binaries/data/mods/public/gui/lobby/lobby.xml @@ -5,9 +5,11 @@