Ticket #4284: restart-menu.patch

File restart-menu.patch, 2.6 KB (added by Jon Baer, 8 years ago)
  • gui/session/menu.js

     
    22const MARGIN = 4;
    33
    44// Includes the main menu button
    5 const NUM_BUTTONS = 9;
     5const NUM_BUTTONS = 10;
    66
    77// Regular menu buttons
    88const BUTTON_HEIGHT = 32;
     
    105105    togglePause();
    106106}
    107107
     108function restartMenuButton()
     109{
     110    closeOpenDialogs();
     111    pauseGame();
     112
     113    messageBox(
     114        400, 200,
     115        translate("Are you sure you want to restart the game?"),
     116        translate("Confirmation"),
     117        [translate("No"), translate("Yes")],
     118        [resumeGame, restartGame]
     119    );
     120}
     121
    108122function resignMenuButton()
    109123{
    110124    closeOpenDialogs();
  • gui/session/menu.xml

     
    7777            <action on="Press">togglePause();</action>
    7878        </object>
    7979
     80        <!-- Restart button -->
     81        <object type="button"
     82            name="menuRestartButton"
     83            style="StoneButtonFancy"
     84            size="0 192 100% 220"
     85            tooltip_style="sessionToolTip"
     86        >
     87            <translatableAttribute id="caption">Restart</translatableAttribute>
     88            <action on="Press">restartMenuButton();</action>
     89        </object>
     90
    8091        <!-- Resign button -->
    8192        <object type="button"
    8293            name="menuResignButton"
    8394            style="StoneButtonFancy"
    84             size="0 192 100% 220"
     95            size="0 224 100% 252"
    8596            tooltip_style="sessionToolTip"
    8697        >
    8798            <translatableAttribute id="caption">Resign</translatableAttribute>
     
    92103        <object type="button"
    93104            name="menuExitButton"
    94105            style="StoneButtonFancy"
    95             size="0 224 100% 252"
     106            size="0 256 100% 284"
    96107            tooltip_style="sessionToolTip"
    97108        >
    98109            <translatableAttribute id="caption">Exit</translatableAttribute>
  • gui/session/session.js

     
    520520 * Resign a player.
    521521 * @param leaveGameAfterResign If player is quitting after resignation.
    522522 */
     523
     524function restartGame()
     525{
     526    let playerId = Engine.GetPlayerID();
     527    let gameAttributes = g_GameAttributes;
     528    gameAttributes.settings.Seed = Math.floor(Math.random() * Math.pow(2, 32));
     529    Engine.EndGame();
     530    Engine.StartGame(gameAttributes, playerId);
     531    Engine.SwitchGuiPage("page_loading.xml", {
     532        "attribs": gameAttributes,
     533        "isNetworked" : g_IsNetworked,
     534        "playerAssignments": g_PlayerAssignments
     535    });
     536}
     537
    523538function resignGame(leaveGameAfterResign)
    524539{
    525540    if (g_IsObserver || g_Disconnected)