Ticket #4284: restart-menu.diff
File restart-menu.diff, 3.2 KB (added by , 8 years ago) |
---|
-
session/menu.js
2 2 const MARGIN = 4; 3 3 4 4 // Includes the main menu button 5 const NUM_BUTTONS = 9;5 const NUM_BUTTONS = 10; 6 6 7 7 // Regular menu buttons 8 8 const BUTTON_HEIGHT = 32; … … 105 105 togglePause(); 106 106 } 107 107 108 function restartMenuButton() 109 { 110 closeOpenDialogs(); 111 pauseGame(); 112 113 if (g_GameAttributes.settings.mapType == "random") 114 messageBox( 115 400, 200, 116 translate("Are you sure you want to restart the game?"), 117 translate("Confirmation"), 118 [translate("No"), translate("Yes"), translate("Reseed")], 119 [resumeGame, restartGame, restartGame], 120 [null,false,true] 121 ); 122 else 123 messageBox( 124 400, 200, 125 translate("Are you sure you want to restart the game?"), 126 translate("Confirmation"), 127 [translate("No"), translate("Yes")], 128 [resumeGame, restartGame] 129 ); 130 } 131 108 132 function resignMenuButton() 109 133 { 110 134 closeOpenDialogs(); -
session/menu.xml
77 77 <action on="Press">togglePause();</action> 78 78 </object> 79 79 80 <!-- Restart button --> 81 <object type="button" 82 name="menuRestartButton" 83 style="StoneButtonFancy" 84 size="0 192 100% 220" 85 tooltip_style="sessionToolTip" enabled="false" 86 > 87 <translatableAttribute id="caption">Restart</translatableAttribute> 88 <action on="Press">restartMenuButton();</action> 89 </object> 90 80 91 <!-- Resign button --> 81 92 <object type="button" 82 93 name="menuResignButton" 83 94 style="StoneButtonFancy" 84 size="0 192 100% 220"95 size="0 224 100% 252" 85 96 tooltip_style="sessionToolTip" 86 97 > 87 98 <translatableAttribute id="caption">Resign</translatableAttribute> … … 92 103 <object type="button" 93 104 name="menuExitButton" 94 105 style="StoneButtonFancy" 95 size="0 2 24 100% 252"106 size="0 256 100% 284" 96 107 tooltip_style="sessionToolTip" 97 108 > 98 109 <translatableAttribute id="caption">Exit</translatableAttribute> -
session/session.js
248 248 restoreSavedGameData(initData.savedGUIData); 249 249 250 250 Engine.GetGUIObjectByName("gameSpeedButton").hidden = g_IsNetworked; 251 Engine.GetGUIObjectByName("menuRestartButton").enabled = !g_IsNetworked; 252 251 253 } 252 254 else // Needed for autostart loading option 253 255 { … … 517 519 } 518 520 519 521 /** 520 * Res ign a player.521 * @param leaveGameAfterResign If player is quitting after resignation.522 * Restart the game 523 * @param reseed If the random map should be re-seeded. 522 524 */ 525 function restartGame(reseed) 526 { 527 let playerId = Engine.GetPlayerID(); 528 let gameAttributes = g_GameAttributes; 529 530 if (reseed) 531 gameAttributes.settings.Seed = Math.floor(Math.random() * Math.pow(2, 32)); 532 533 Engine.EndGame(); 534 Engine.StartGame(gameAttributes, playerId); 535 Engine.SwitchGuiPage("page_loading.xml", { 536 "attribs": gameAttributes, 537 "isNetworked" : g_IsNetworked, 538 "playerAssignments": g_PlayerAssignments 539 }); 540 } 541 523 542 function resignGame(leaveGameAfterResign) 524 543 { 525 544 if (g_IsObserver || g_Disconnected)