Ticket #3739: lobby_ask_observer_join_v1.patch
File lobby_ask_observer_join_v1.patch, 3.8 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/lobby/lobby.js
function updateGameSelection() 608 608 } 609 609 610 610 /** 611 611 * Start the joining process on the currectly selected game. 612 612 */ 613 function joinSelectedGame() 613 function joinButton() 614 { 615 let game = selectedGame(); 616 if (!game) 617 return; 618 619 let username = g_UserRating ? g_Username + " (" + g_UserRating + ")" : g_Username; 620 621 if (game.state == "init" || game.players.split(", ").indexOf(username) > -1) 622 joinSelectedGame(); 623 else 624 messageBox( 625 400, 200, 626 translate("The game has already started.") + "\n" + translate("Do you want to join as observer?"), 627 translate("Confirmation"), 628 0, 629 [translate("No"), translate("Yes")], 630 [null, joinSelectedGame] 631 ); 632 } 633 634 function selectedGame() 614 635 { 615 636 var gamesBox = Engine.GetGUIObjectByName("gamesBox"); 616 637 if (gamesBox.selected < 0) 638 return undefined; 639 640 return g_GameList[gamesBox.list_data[gamesBox.selected]]; 641 } 642 643 function joinSelectedGame() 644 { 645 let game = selectedGame(); 646 if (!game) 617 647 return; 618 648 619 var ipAddress = g_GameList[gamesBox.list_data[gamesBox.selected]].ip; 620 if (ipAddress.split('.').length != 4) 649 if (game.ip.split('.').length != 4) 621 650 { 622 addChatMessage({ "from": "system", "text": sprintf(translate("This game's address '%(ip)s' does not appear to be valid."), { "ip": ipAddress }) }); 651 addChatMessage({ 652 "from": "system", 653 "text": sprintf( 654 translate("This game's address '%(ip)s' does not appear to be valid."), 655 { "ip": game.ip } 656 ) 657 }); 623 658 return; 624 659 } 625 660 626 Engine.PushGuiPage("page_gamesetup_mp.xml", { "multiplayerGameType": "join", "name": g_Username, "ip": ipAddress, "rating": g_UserRating }); 661 Engine.PushGuiPage("page_gamesetup_mp.xml", { 662 "multiplayerGameType": "join", 663 "ip": game.ip, 664 "name": g_Username, 665 "rating": g_UserRating 666 }); 627 667 } 628 668 629 669 /** 630 670 * Open the dialog box to enter the game name. 631 671 */ -
binaries/data/mods/public/gui/lobby/lobby.xml
152 152 </object> 153 153 </object> 154 154 <object name="joinGameButton" type="button" style="ModernButtonRed" size="0 100%-85 100% 100%-60" hidden="true"> 155 155 <translatableAttribute id="caption" comment="Join the game currently selected in the list.">Join Game</translatableAttribute> 156 156 <action on="Press"> 157 join SelectedGame();157 joinButton(); 158 158 </action> 159 159 </object> 160 160 <object name="hostButton" type="button" style="ModernButtonRed" size="0 100%-55 100% 100%-30"> 161 161 <translatableAttribute id="caption">Host Game</translatableAttribute> 162 162 <action on="Press"> … … 173 173 <!-- Middle panel: Filters, game list, chat box. --> 174 174 <object name="middlePanel" size="20%+5 5% 100%-255 97.2%"> 175 175 <object name="gamesBox" style="ModernList" sprite_asc="ModernArrowDown" default_column="status" default_column_order="1" sprite_desc="ModernArrowUp" sprite_not_sorted="ModernNotSorted" type="olist" sortable="true" size="0 25 100% 48%" font="sans-stroke-13"> 176 176 <action on="SelectionChange">updateGameSelection();</action> 177 177 <action on="SelectionColumnChange">applyFilters();</action> 178 <action on="mouseleftdoubleclickitem">join SelectedGame();</action>178 <action on="mouseleftdoubleclickitem">joinButton();</action> 179 179 <def id="name" color="0 60 0" width="27%"> 180 180 <translatableAttribute id="heading">Name</translatableAttribute> 181 181 </def> 182 182 <!--<def id="ip" heading="IP" color="0 128 128" width="170"/>--> 183 183 <def id="mapName" color="128 128 128" width="25%">