Ticket #4112: hidereadybutton7.patch

File hidereadybutton7.patch, 2.8 KB (added by echotangoecho, 8 years ago)

cheatWarningOffset was unused, pointed out by bb_ on IRC.

  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

    function initRadioButtons()  
    522522        g_GameAttributes.settings.LastManStanding = false;
    523523        updateGameAttributes();
    524524    };
    525525}
    526526
     527function hideStartGameButton(hidden)
     528{
     529    const offset = 10;
     530    let cheatWarningOffset = Engine.GetGUIObjectByName("cancelGame").size.left - Engine.GetGUIObjectByName("cheatWarningText").size.right;
     531    let onscreenToolTipOffset = Engine.GetGUIObjectByName("cancelGame").size.left - Engine.GetGUIObjectByName("onscreenToolTip").size.right;
     532
     533    Engine.GetGUIObjectByName("startGame").hidden = hidden;
     534
     535    let right = hidden ? Engine.GetGUIObjectByName("startGame").size.right : Engine.GetGUIObjectByName("startGame").size.left - offset;
     536
     537    // Move the cheatWarningText and back button to the right when hidden.
     538    let cancelGameSize = Engine.GetGUIObjectByName("cancelGame").size;
     539    let xButtonSize = cancelGameSize.right - cancelGameSize.left;
     540    cancelGameSize.right = right;
     541    right -= xButtonSize;
     542    cancelGameSize.left = right;
     543    Engine.GetGUIObjectByName("cancelGame").size = cancelGameSize;
     544
     545    let cheatWarningTextSize = Engine.GetGUIObjectByName("cheatWarningText").size;
     546    cheatWarningTextSize.right = right - cheatWarningOffset;
     547    Engine.GetGUIObjectByName("cheatWarningText").size = cheatWarningTextSize;
     548
     549    // Increase the size of onscreenToolTip when hidden.
     550    let onscreenToolTipSize = Engine.GetGUIObjectByName("onscreenToolTip").size;
     551    onscreenToolTipSize.right = right - onscreenToolTipOffset;
     552    Engine.GetGUIObjectByName("onscreenToolTip").size = onscreenToolTipSize;
     553}
     554
    527555/**
    528556 * If we're a network client, hide the controls and show the text instead.
    529557 */
    530558function hideControls()
    531559{
    function hideControls()  
    538566        Engine.GetGUIObjectByName("playerAssignment["+i+"]").hidden = true;
    539567        Engine.GetGUIObjectByName("playerCiv["+i+"]").hidden = true;
    540568        Engine.GetGUIObjectByName("playerTeam["+i+"]").hidden = true;
    541569    }
    542570
     571    // The start game button should be hidden until the player assignments are received
     572    // and it is known whether the local player is an observer.
     573    hideStartGameButton(true);
    543574    Engine.GetGUIObjectByName("startGame").enabled = true;
    544575}
    545576
    546577/**
    547578 * Hides the GUI controls for clients and shows the read-only label instead.
    function handlePlayerAssignmentMessage(m  
    728759        if (!message.newAssignments[guid])
    729760            onClientLeave(guid);
    730761
    731762    g_PlayerAssignments = message.newAssignments;
    732763
     764    hideStartGameButton(!g_IsController && g_PlayerAssignments[Engine.GetPlayerGUID()].player == -1);
     765
    733766    updatePlayerList();
    734767    updateReadyUI();
    735768    sendRegisterGameStanza();
    736769}
    737770