diff --git a/binaries/data/mods/public/gui/test/functions_page_session.js b/binaries/data/mods/public/gui/test/functions_page_session.js index 92caabf1f6..9935b856da 100644 --- a/binaries/data/mods/public/gui/test/functions_page_session.js +++ b/binaries/data/mods/public/gui/test/functions_page_session.js @@ -415,4 +415,4 @@ function togglePlayersList() pl.hidden = ! pl.hidden; var pls = getGUIObjectByName("PlayersListShadow"); pls.hidden = ! pls.hidden; -} \ No newline at end of file +} diff --git a/binaries/data/mods/public/gui/test/functions_page_session_status_commands.js b/binaries/data/mods/public/gui/test/functions_page_session_status_commands.js index 7922666271..36565c3de6 100644 --- a/binaries/data/mods/public/gui/test/functions_page_session_status_commands.js +++ b/binaries/data/mods/public/gui/test/functions_page_session_status_commands.js @@ -10,7 +10,9 @@ function defineCommandButtons(command) snStatusPaneCommand = new Array(); snStatusPaneCommand.tab = new Object(); snStatusPaneCommand.list = new Object(); - snStatusPaneCommand.button = new Object(); + snStatusPaneCommand.button = new Object(); + + empty = false; // Maximum number of buttons (either single or lists). snStatusPaneCommand.tab.max = command.substring (command.lastIndexOf ("d")+1, command.lastIndexOf ("_")); // 8 @@ -153,384 +155,228 @@ function updateTab (tab, type, cellSheet, attribute, attribute2, arrayCells) // * pick: Usually a group that's the same as the tab name, so use this. // * command: Tends to be "Command" (though not always), so defaults to this. // * If no value is specified, it will use the above default for the type. - // attribute: * For production & pick: the attribute containing the list of items to display (eg selection[0].actions.create.list.research), which this entity must + // attribute: * For production & pick: the attribute containing the list of items to display + // (eg selection[0].actions.create.list.research), which this entity must // have in order to update the tab with this list. // * For command: the attribute that the entity must have in order to have this command. // * If no value is specified, all entities have this attribute. - // attribute2: * For pick: The variable used to store the current item in the pick that has been selected -- placed in the tab (eg selection[0].actions.formation.curr) - // arrayCells: * Optional attribute. If true, assume that items cannot all be found in the same cellSheet; check in attribute.sheet for cell sheet name for each item. + // attribute2: * For pick: The variable used to store the current item in the pick that has been selected -- placed in the tab + // (eg selection[0].actions.formation.curr) + // arrayCells: * Optional attribute. If true, assume that items cannot all be found in the same cellSheet; check in attribute.sheet + // for cell sheet name for each item. // Store string form of attribute for future reference. attributeString = attribute; attribute2String = attribute2; - // If either attribute is not a valid property, return false. - if ( (validProperty (attributeString)) && (validProperty (attribute2String)) ) - { - // Use the value of the attribute from this point forwards. - attribute = eval (attribute); - attribute2 = eval (attribute2); - // String properties taken from entities can be a little confused about their variable type, so make sure they're considered strings. - attribute2 = String (attribute2); - -//console.write ("1st: " + tabCounter + " " + tab + " " + type + " " + cellSheet + " " + attribute + " " + attribute2); - - // Set default values. - if (cellSheet == "") - { - switch (type) - { - case "command": - cellSheet = "Command"; - break; - case "pick": - cellSheet = toTitleCase(tab); - tab = attribute2.toLowerCase(); - // avoid, pick, Stance, .traits.ai.stance.list - break; - default: - cellSheet = "Tab"; - break; - } - } - -//console.write ("2nd: " + tabCounter + " " + tab + " " + type + " " + cellSheet + " " + attribute + " " + attribute2); + // If either attribute is not a valid property, return false. + if (! ((validProperty (attributeString)) && (validProperty (attribute2String))) ) + { + return false; + } - // Get tab. - var tabObject = getGUIObjectByName ("snStatusPaneCommand" + tabCounter + "_1"); - // Enable tab. - guiUnHide (tabObject.name); - - // Set tab portrait. - switch (tab) - { - case "selection": - case "garrison": - // Temporarily (until we have the tab textures) force a particular cell ID for selection and garrison so we can see the icon. - cellGroup[cellSheet][tab].id = 2; - - // Use the horizontal tab. (Extends right.) - setPortrait ("snStatusPaneCommand" + tabCounter + "_1", "IconSheet", cellSheet + "Button_H", cellGroup[cellSheet][tab].id); - break; - default: - if (type == "pick" && cellSheet != "Tab") // Force the tab background for pick lists, - setPortrait ("snStatusPaneCommand" + tabCounter + "_1", "IconSheet", cellSheet + "TabButton", cellGroup[cellSheet][tab].id); - else - setPortrait ("snStatusPaneCommand" + tabCounter + "_1", "IconSheet", cellSheet + "Button", cellGroup[cellSheet][tab].id); - break; - } - -//console.write ("3rd: " + "snStatusPaneCommand" + tabCounter + "_1" + "|" + "IconSheet" + "|" + cellSheet + "Button" + "|" + cellGroup[cellSheet][tab].id); - + // Use the value of the attribute from this point forwards. + attribute = eval (attribute); + attribute2 = eval (attribute2); + // String properties taken from entities can be a little confused about their variable type, so make sure they're considered strings. + attribute2 = String (attribute2); + + + // Set default values. + if (cellSheet == "") + { switch (type) { case "command": - // Set tab tooltip. - var tooltip = cellGroup[cellSheet][tab].name; - tooltip += " " + cellSheet; + cellSheet = "Command"; break; case "pick": - // Set tab tooltip. - var tooltip = cellSheet; - tooltip += " List\nCurrent " + cellSheet + ": " + cellGroup[cellSheet][tab].name; + cellSheet = toTitleCase(tab); + tab = attribute2.toLowerCase(); + // avoid, pick, Stance, .traits.ai.stance.list break; default: - // Set tab tooltip. - var tooltip = cellGroup[cellSheet][tab].name; - tooltip += " " + cellSheet; + cellSheet = "Tab"; break; - } - tabObject.tooltip = tooltip; - - switch (type) - { - case "command": - // An array of actions for the command "tabs" can be triggered by clicking the individual commands. We'll set them here. - switch(tab) - { - case "rally": - tabObject.onPress = function (event) - { - setCursor("cursor-rally"); - } - break; - default: - tabObject.onPress = function (event) - { - } - break; - } - break; - - default: - // Set tab function when user moves mouse over tab. - tabObject.onMouseEnter = function (event) - { - var currTab = this.name.substring (this.name.lastIndexOf ("d")+1, this.name.lastIndexOf ("_")); - // Seek through all list tabs. (Only the one being hovered should stay open.) - for (var i = 1; i < snStatusPaneCommand.split; i++) - { - // If we've found the current tab, - if (i == currTab) - { - // Click the tab button to toggle visibility of its list. - guiToggle ( "snStatusPaneCommandGroup" + currTab ); - } - else // If it's another list tab, - { - // Ensure this tab is hidden. - guiHide ("snStatusPaneCommandGroup" + i); - } - } - } - // Set tab function when user clicks tab. - tabObject.onPress = function (event) - { - // Click the tab button to toggle visibility of its list. - guiToggle ( "snStatusPaneCommandGroup" + this.name.substring (this.name.lastIndexOf ("d")+1, this.name.lastIndexOf ("_")) ); - } - break; - } - - // Get group. - var groupObject = getGUIObjectByName ("snStatusPaneCommand" + "Group" + tabCounter); + } + } + - // If the list hasn't been hidden (tab is open), and it should have list items (it's not merely a command), - if ( type != "command" && attribute != undefined ) - { - // Reset array. - var listArray = []; - // Insert blank array element at location 0 (to buffer array so items are in 1..n range). - listArray[0] = ""; + // Get tab. + var tabObject = getGUIObjectByName ("snStatusPaneCommand" + tabCounter + "_1"); + guiUnHide (tabObject.name); + + + setTabPortrait(type, tab, cellSheet, cellGroup, tabCounter); - // Extract item list into an array. - if (!attribute.length) - { // If it's a list where each element is a value, (entity list) - for ( var i in attribute ) + setTooltip(type, tab, cellSheet, cellGroup, tabObject); + + setEvents(type, tab, tabObject); + + // Get group. + var groupObject = getGUIObjectByName ("snStatusPaneCommand" + "Group" + tabCounter); + + // If the list hasn't been hidden (tab is open), and it should have list items (it's not merely a command), + if ( type != "command" && attribute != undefined ) + { + if (tab == "queue") + { + var newAttribute = groupProductionItems(attribute); + //ok, now split newAttribute into 2 arrays: 1 containing items, and another one containing nums. + + var nums = new Array(); + attribute = new Array(); + + for (i=0; i 1) { - tempArray = []; + tempArray = new Array(); for ( var i = 0; i < selection.length; i++ ) - tempArray[i] = selection[i].tag; - tempArray.length = i; + tempArray.push(selection[i].tag); updateTab ("selection", "production", "Tab", "tempArray", ""); } } + } + + if (selection.length == 1) + { + if (selection[0].productionQueue && selection[0].productionQueue.length > 0) + { + tabCounter = snStatusPaneCommand.tab.max; + tempArray = new Array(); + var queue = selection[0].productionQueue; + + for(var i=0; i < queue.length; i++) + { + tempArray.push(queue.get(i)); + } + + updateTab("queue", "production", "Tab", "tempArray", ""); + empty = false; + } + else + { + tabCounter = snStatusPaneCommand.tab.max; + var tabObject = getGUIObjectByName ("snStatusPaneCommand" + tabCounter + "_1"); + guiHide(tabObject.name); + var groupObject = getGUIObjectByName ("snStatusPaneCommand" + "Group" + tabCounter); + guiHide(groupObject.name); + } } } @@ -675,8 +546,8 @@ function getProductionTooltip(template) first = false; tooltip += "[font=tahoma10b]Wood:[/font] " + template.traits.creation.resource.wood; } - if (template.traits.creation.resource.metal > 0) - { + if (template.traits.creation.resource.metal > 0) + { tooltip += (first ? "\n" : ", "); first = false; tooltip += "[font=tahoma10b]Metal:[/font] " + template.traits.creation.resource.metal @@ -695,4 +566,277 @@ function getProductionTooltip(template) } return tooltip; -} \ No newline at end of file +} + + +// =================================================================================== +//entity is the name. +function removeFromProductionQueue(selection, entity) +{ + var queue = selection[0].productionQueue; + + for(var i=0;i