Index: binaries/data/mods/public/gui/lobby/lobby.js
===================================================================
--- binaries/data/mods/public/gui/lobby/lobby.js (revision 17703)
+++ binaries/data/mods/public/gui/lobby/lobby.js (working copy)
@@ -608,24 +608,64 @@ function updateGameSelection()
}
/**
* Start the joining process on the currectly selected game.
*/
-function joinSelectedGame()
+function joinButton()
+{
+ let game = selectedGame();
+ if (!game)
+ return;
+
+ let username = g_UserRating ? g_Username + " (" + g_UserRating + ")" : g_Username;
+
+ if (game.state == "init" || game.players.split(", ").indexOf(username) > -1)
+ joinSelectedGame();
+ else
+ messageBox(
+ 400, 200,
+ translate("The game has already started.") + "\n" + translate("Do you want to join as observer?"),
+ translate("Confirmation"),
+ 0,
+ [translate("No"), translate("Yes")],
+ [null, joinSelectedGame]
+ );
+}
+
+function selectedGame()
{
var gamesBox = Engine.GetGUIObjectByName("gamesBox");
if (gamesBox.selected < 0)
+ return undefined;
+
+ return g_GameList[gamesBox.list_data[gamesBox.selected]];
+}
+
+function joinSelectedGame()
+{
+ let game = selectedGame();
+ if (!game)
return;
- var ipAddress = g_GameList[gamesBox.list_data[gamesBox.selected]].ip;
- if (ipAddress.split('.').length != 4)
+ if (game.ip.split('.').length != 4)
{
- addChatMessage({ "from": "system", "text": sprintf(translate("This game's address '%(ip)s' does not appear to be valid."), { "ip": ipAddress }) });
+ addChatMessage({
+ "from": "system",
+ "text": sprintf(
+ translate("This game's address '%(ip)s' does not appear to be valid."),
+ { "ip": game.ip }
+ )
+ });
return;
}
- Engine.PushGuiPage("page_gamesetup_mp.xml", { "multiplayerGameType": "join", "name": g_Username, "ip": ipAddress, "rating": g_UserRating });
+ Engine.PushGuiPage("page_gamesetup_mp.xml", {
+ "multiplayerGameType": "join",
+ "ip": game.ip,
+ "name": g_Username,
+ "rating": g_UserRating
+ });
}
/**
* Open the dialog box to enter the game name.
*/
Index: binaries/data/mods/public/gui/lobby/lobby.xml
===================================================================
--- binaries/data/mods/public/gui/lobby/lobby.xml (revision 17703)
+++ binaries/data/mods/public/gui/lobby/lobby.xml (working copy)
@@ -152,11 +152,11 @@