From 1ce438a26f3ba52ec5adbea12e4f76882ee9e75c Mon Sep 17 00:00:00 2001 From: freenity Date: Sat, 18 Oct 2008 17:59:27 +0000 Subject: [PATCH] Fixing multiple Open/Close options in players slots This was SVN commit r6430. --- .../gui/test/functions_page_pregame_setup.js | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/binaries/data/mods/public/gui/test/functions_page_pregame_setup.js b/binaries/data/mods/public/gui/test/functions_page_pregame_setup.js index c538a66cb5..f307beac52 100644 --- a/binaries/data/mods/public/gui/test/functions_page_pregame_setup.js +++ b/binaries/data/mods/public/gui/test/functions_page_pregame_setup.js @@ -20,55 +20,56 @@ function openSessionSetup (sessionReturnWindow) getGUIObjectByName ("pgSessionSetupP" + i).caption = "(Host)"; } else - { -// pushItem ("pgSessionSetupP" + i, "session"); - pushItem ("pgSessionSetupP" + i, "Open"); - pushItem ("pgSessionSetupP" + i, "Closed"); -// pushItem ("pgSessionSetupP" + i, "local"); -// pushItem ("pgSessionSetupP" + i, "AI"); - - // Set other slots to Open. - var result = setCurrItemValue ("pgSessionSetupP" + i, "Open"); - - // Setup onchange event (closing and opening affects host slots). - getGUIObjectByName ("pgSessionSetupP" + i).onSelectionChange = function (event) + { + if (getNumItems("pgSessionSetupP" + i) == 0) { - var slotNumber = this.name.substring (this.name.length-1, this.name.length); - switch (getCurrItemValue (this.name)) + //pushItem ("pgSessionSetupP" + i, "session"); + pushItem ("pgSessionSetupP" + i, "Open"); + pushItem ("pgSessionSetupP" + i, "Closed"); + //pushItem ("pgSessionSetupP" + i, "local"); + //pushItem ("pgSessionSetupP" + i, "AI"); + + // Set other slots to Open. + var result = setCurrItemValue ("pgSessionSetupP" + i, "Open"); + + // Setup onchange event (closing and opening affects host slots). + getGUIObjectByName ("pgSessionSetupP" + i).onSelectionChange = function (event) { - case "Open": - // If "Open" selected, + var slotNumber = this.name.substring (this.name.length-1, this.name.length); + switch (getCurrItemValue (this.name)) + { + case "Open": + // If "Open" selected, - // Open the slot. - g_GameAttributes.slots[slotNumber-1].assignOpen(); + // Open the slot. + g_GameAttributes.slots[slotNumber-1].assignOpen(); - //console.write ("Opened slot " + this.name); - break; - case "Closed": - // If "Closed" selected, + //console.write ("Opened slot " + this.name); + break; + case "Closed": + // If "Closed" selected, - // And slot is occupied, - if (g_GameAttributes.slots[slotNumber-1].assignment == "session") - { - // Remove player name from slot list. - removeItem (this.name, g_GameAttributes.slots[slotNumber-1].player); + // And slot is occupied, + if (g_GameAttributes.slots[slotNumber-1].assignment == "session") + { + // Remove player name from slot list. + removeItem (this.name, g_GameAttributes.slots[slotNumber-1].player); - // Prompt that player was kicked. - // (Change this to a chat message when functionality available.) - console.write (g_GameAttributes.slots[slotNumber-1].player + " was kicked by the host."); - } + // Prompt that player was kicked. + // (Change this to a chat message when functionality available.) + console.write (g_GameAttributes.slots[slotNumber-1].player + " was kicked by the host."); + } - // Close the slot. - g_GameAttributes.slots[slotNumber-1].assignClosed(); + // Close the slot. + g_GameAttributes.slots[slotNumber-1].assignClosed(); - //console.write ("Closed slot " + this.name); - break; - default: - break; + //console.write ("Closed slot " + this.name); + break; + default: + break; + } } } - - } // Make objects non-interactive to client.