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 @@ -119,24 +119,33 @@ "system": { // Three cases are handled in prelobby.js "registered": msg => false, - "connected": msg => false, + "connected": msg => { + connectedGuiState(true); + 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; + connectedGuiState(false); if (!g_Kicked) + { addChatMessage({ "from": "system", "time": msg.time, "text": translate("Disconnected.") + " " + msg.reason }); + messageBox( + 400, 200, + ""+ g_Username + "\n\n" + + translate("The Lobby is disconnect, you want to reconnect?") + "\n", + translate("Information"), + [translate("Back to Mainmenu"), translate("Reconnect")], + [returnToMainMenu, reconnectLobby] + ); + } return true; }, "error": msg => { @@ -403,6 +412,34 @@ g_NetMessageTypes[msg.type][msg.level](msg); } +function reconnectLobby() +{ + if (Engine.HasXmppClient()) + Engine.StopXmppClient(); + + addChatMessage({ + "from": "system", + "text": translate("Reconnect.") + }); + + // We just use username as nick for simplicity. + Engine.StartXmppClient( + g_Username, + Engine.ConfigDB_GetValue("user", "lobby.password"), + Engine.ConfigDB_GetValue("user", "lobby.room"), + g_Username, + +Engine.ConfigDB_GetValue("user", "lobby.history") + ); + Engine.ConnectXmppClient(); +} + +function connectedGuiState(connected) +{ + for (let button of ["host", "leaderboard", "userprofile", "toggleBuddy"]) + Engine.GetGUIObjectByName(button + "Button").enabled = connected; + Engine.GetGUIObjectByName("chatInput").hidden = !connected; +} + function updateLobbyColumns() { let gameRating = Engine.ConfigDB_GetValue("user", "lobby.columns.gamerating") == "true";