diff --git a/binaries/data/mods/public/gui/session_new/input.js b/binaries/data/mods/public/gui/session_new/input.js
index 327753c858..2a4911cbe0 100644
--- a/binaries/data/mods/public/gui/session_new/input.js
+++ b/binaries/data/mods/public/gui/session_new/input.js
@@ -4,7 +4,7 @@ const SDL_BUTTON_RIGHT = 3;
const SDLK_RSHIFT = 303;
const SDLK_LSHIFT = 304;
-const MAX_SELECTION_SIZE = 24;
+const MAX_SELECTION_SIZE = 32;
// TODO: these constants should be defined somewhere else instead, in
// case any other code wants to use them too
@@ -266,9 +266,6 @@ function handleInputBeforeGui(ev)
g_Selection.reset();
g_Selection.addList(ents);
- // Create the selection groups
- g_Selection.groups.createGroups(ents);
-
inputState = INPUT_NORMAL;
return true;
}
@@ -616,3 +613,12 @@ function removeFromTrainingQueue(entity, id)
{
Engine.PostNetworkCommand({"type": "stop-train", "entity": entity, "id": id});
}
+
+// Called by unit selection buttons
+function changePrimarySelectionGroup(index)
+{
+ if (specialKeyStates[SDLK_RSHIFT] || specialKeyStates[SDLK_LSHIFT])
+ g_Selection.makePrimarySelection(index, true);
+ else
+ g_Selection.makePrimarySelection(index, false);
+}
diff --git a/binaries/data/mods/public/gui/session_new/menu.js b/binaries/data/mods/public/gui/session_new/menu.js
index 30ec8a5099..8edc60dd59 100644
--- a/binaries/data/mods/public/gui/session_new/menu.js
+++ b/binaries/data/mods/public/gui/session_new/menu.js
@@ -1,11 +1,3 @@
-// Group Selection by Rank
-var g_GroupSelectionByRank = true; // referenced in EntityGroups.createGroups(ents) AND in setupUnitPanel(...)
-function groupSelectionByRank(booleanValue)
-{
- g_GroupSelectionByRank = booleanValue;
- g_Selection.groups.createGroups(g_Selection.toList());
-}
-
function toggleDeveloperOverlay()
{
if (getGUIObjectByName("devCommands").hidden)
diff --git a/binaries/data/mods/public/gui/session_new/selection.js b/binaries/data/mods/public/gui/session_new/selection.js
index d197e68fbb..9c32fabc9e 100644
--- a/binaries/data/mods/public/gui/session_new/selection.js
+++ b/binaries/data/mods/public/gui/session_new/selection.js
@@ -14,163 +14,6 @@ function _setMotionOverlay(ents, enabled)
Engine.GuiInterfaceCall("SetMotionDebugOverlay", { "entities":ents, "enabled":enabled });
}
-//-------------------------------- -------------------------------- --------------------------------
-// EntityGroups class for ordering / managing entities by their templates
-//-------------------------------- -------------------------------- --------------------------------
-function EntityGroups()
-{
- // private properties
- this.primary = 0;
- this.groups = []; // Includes only highest ranked versions of each type
-}
-
-EntityGroups.prototype.Group = function(templateName, typeCount, firstOfType)
-{
- this.templateName = templateName;
- this.typeCount = typeCount;
- this.firstOfType = firstOfType;
-};
-
-EntityGroups.prototype.reset = function()
-{
- this.primary = 0;
- this.groups = [];
-};
-
-EntityGroups.prototype.getLength = function()
-{
- return this.groups.length;
-};
-
-EntityGroups.prototype.getPrimary = function()
-{
- return this.primary;
-};
-
-EntityGroups.prototype.setPrimary = function(index)
-{
- if (this.groups.length > index)
- this.primary = index;
- else
- console.write("Warning: \"index\" is larger than g_Selection.toList().length: Cannot set Primary Selection.");
-};
-
-EntityGroups.prototype.getGroup = function(templateName)
-{
- // Get the group that corresponds to the template name
- var group = this.groups[this.getGroupNumber(templateName)];
- if (group)
- return group;
-
- // The templateName didn't match any in the groups...
- // Check if it's the same unit, but a different rank and return that group
-
- if (g_GroupSelectionByRank)
- {
- var thatGenericTemplateName = templateName.substring(0, templateName.length-2);
- var templateNames = this.getTemplateNames();
-
- for (var i = 0; i < templateNames.length; i++)
- {
- var thisGenericTemplateName = templateNames[i].substring(0, templateNames[i].length-2);
- if (thisGenericTemplateName == thatGenericTemplateName)
- return this.groups[i];
- }
- }
-
- // There was no match...
- //console.write("Warning: Could not find either \"" + templateName + "\" or the more generic: \"" + thatGenericTemplateName + "\"");
- return undefined;
-};
-
-EntityGroups.prototype.addGroup = function(templateName, typeCount, firstOfType)
-{
- this.groups.push(new this.Group(templateName, typeCount, firstOfType));
-};
-
-EntityGroups.prototype.removeGroup = function(templateName)
-{
- var index = this.getGroupNumber(templateName);
- this.groups.splice(index, 1);
-};
-
-EntityGroups.prototype.getGroupNumber = function(templateName)
-{
- for (var i = 0; i < this.groups.length; i++)
- if (this.groups[i].templateName == templateName)
- return i;
-
- return -1;
-};
-
-EntityGroups.prototype.getTemplateNames = function()
-{
- var templateNames = [];
-
- for (var i = 0; i < this.groups.length; i++)
- templateNames.push(this.groups[i].templateName);
-
- return templateNames;
-};
-
-// Checks if the new rank code is greater than the old rank code (private helper function for EntityGroups.createGroups)
-EntityGroups.prototype.greaterThanPreviousRank = function(oldRank, newRank)
-{
- if (oldRank == newRank)
- return false;
- else if (oldRank == 'b' || newRank == 'e')
- return true;
- else
- return false;
-};
-
-EntityGroups.prototype.createGroups = function(ents)
-{
- // Erase old groups first
- this.reset();
-
- // Make selection groups
- for (var i = 0; i < ents.length; i++)
- {
- var templateName = Engine.GuiInterfaceCall("GetEntityState", ents[i]).template;
- var group = this.getGroup(templateName);
-
- // We already have one of these types
- if (group)
- {
- // See if the new one has a higher rank
- var isRankableUnit = ((templateName.charAt(templateName.length-2) == '_')? true : false);
-
- if (g_GroupSelectionByRank && isRankableUnit)
- {
- var oldRank = group.templateName.charAt(group.templateName.length-1);
- var newRank = templateName.charAt(templateName.length-1);
-
- if (this.greaterThanPreviousRank(oldRank, newRank))
- {
- var oldTypeCount = group.typeCount;
- this.removeGroup(group.templateName);
- this.addGroup(templateName, oldTypeCount+1, i);
- }
- else
- {
- group.typeCount += 1;
- }
- }
- else // It was not a rankable unit or its rank was not higher than the one we had
- {
- group.typeCount += 1;
- }
- }
- else // Don't have any of this type, so add it in
- {
- this.addGroup(templateName, 1, i);
- }
- }
-
- resetCycleIndex();
-}
-
//-------------------------------- -------------------------------- --------------------------------
// EntitySelection class for managing the entity selection list and the primary selection
//-------------------------------- -------------------------------- --------------------------------
@@ -178,7 +21,6 @@ function EntitySelection()
{
// Private properties:
//--------------------------------
- this.primary = 0; // The active selection in the unit details panel
this.selected = {}; // { id:id, id:id, ... } for each selected entity ID 'id'
// { id:id, ... } for mouseover-highlighted entity IDs in these, the key is a string and the value is an int;
@@ -189,38 +31,56 @@ function EntitySelection()
// Public properties:
//--------------------------------
- this.groups = new EntityGroups(); // the selection entity groups must be reset whenever the selection changes
this.dirty = false; // set whenever the selection has changed
}
-EntitySelection.prototype.getPrimaryTemplateName = function()
+// Deselect everything but entities of the chosen type if the modifier is true
+// otherwise deselect just the chosen entity
+EntitySelection.prototype.makePrimarySelection = function(primaryIndex, modifierKey)
{
- var entId = g_Selection.toList()[this.primary];
- var entState = Engine.GuiInterfaceCall("GetEntityState", entId);
-
- if (entState)
- return entState.template
-
- return undefined;
-};
+ var ents = [];
+ var selection = this.toList();
-EntitySelection.prototype.getPrimary = function()
-{
- return this.primary;
-};
+ if (modifierKey)
+ {
+ var primaryEntState = Engine.GuiInterfaceCall("GetEntityState", selection[primaryIndex]);
+ if (!primaryEntState)
+ return;
-EntitySelection.prototype.setPrimary = function(index)
-{
- if (g_Selection.toList().length > index)
- this.primary = index;
+ for (var i = 0; i < selection.length; i++)
+ {
+ var entState = Engine.GuiInterfaceCall("GetEntityState", selection[i]);
+ if (!entState)
+ return;
+
+ if (entState.template == primaryEntState.template)
+ ents.push(selection[i]);
+ }
+ }
else
- console.write("Warning: \"index\" is larger than g_Selection.toList().length: Cannot set Primary Selection.");
-};
+ {
+ ents.push(selection[primaryIndex]);
+ }
-EntitySelection.prototype.resetPrimary = function()
+ this.reset();
+ this.addList(ents);
+}
+
+// Get a list of the template names
+EntitySelection.prototype.getTemplateNames = function()
{
- this.primary = 0; // the primary selection must be reset whenever the selection changes
-};
+ var templateNames = [];
+ var ents = this.toList();
+
+ for each (var ent in ents)
+ {
+ var entState = Engine.GuiInterfaceCall("GetEntityState", ent);
+ if (entState)
+ templateNames.push(entState.template);
+ }
+
+ return templateNames;
+}
// Update the selection to take care of changes (like units that have been killed)
EntitySelection.prototype.updateSelection = function()
@@ -228,13 +88,13 @@ EntitySelection.prototype.updateSelection = function()
var numberRemoved = 0;
var i = 0;
- for each (var unit in this.selected)
+ for each (var ent in this.selected)
{
- var entState = Engine.GuiInterfaceCall("GetEntityState", unit);
+ var entState = Engine.GuiInterfaceCall("GetEntityState", ent);
if (!entState)
{
- delete this.selected[unit];
+ delete this.selected[ent];
numberRemoved++;
}
@@ -242,11 +102,7 @@ EntitySelection.prototype.updateSelection = function()
}
if (numberRemoved > 0)
- {
this.dirty = true;
- this.groups.createGroups(this.toList());
- this.resetPrimary(); // TODO: should probably set this to a unit of the same type as the unit that was removed...
- }
};
EntitySelection.prototype.toggle = function(ent)
@@ -287,8 +143,6 @@ EntitySelection.prototype.reset = function()
_setHighlight(this.toList(), g_InactiveSelectionColour);
_setMotionOverlay(this.toList(), false);
this.selected = {};
- this.resetPrimary();
- this.groups.reset();
this.dirty = true;
};
diff --git a/binaries/data/mods/public/gui/session_new/selection_details.js b/binaries/data/mods/public/gui/session_new/selection_details.js
index 5f60b2ab3e..baabfef351 100644
--- a/binaries/data/mods/public/gui/session_new/selection_details.js
+++ b/binaries/data/mods/public/gui/session_new/selection_details.js
@@ -1,96 +1,30 @@
const RESOURCE_ICON_CELL_IDS = {food : 0, wood : 1, stone : 2, metal : 3};
-// Called by unit selection buttons
-function changePrimarySelectionGroup(entType)
+function layoutSelectionMultiple()
{
- g_Selection.groups.setPrimary(g_Selection.groups.getGroupNumber(entType)); // set primary group
- g_Selection.setPrimary(g_Selection.groups.getGroup(entType).firstOfType); // set primary selection
- resetCycleIndex();
+ getGUIObjectByName("sdSpecific").hidden = true;
+ getGUIObjectByName("sdIcon").hidden = true;
+ getGUIObjectByName("sdStatsArea").hidden = true;
+ getGUIObjectByName("sdHealth").hidden = true;
+ getGUIObjectByName("sdStamina").hidden = true;
}
-// Cycle through the units in the main icon
-var cycleIndex = 0;
-var displayedCycleIndex = 1;
-
-function resetCycleIndex()
+function layoutSelectionSingle(entState)
{
- cycleIndex = 0;
- displayedCycleIndex = 1;
-}
-
-function cycleThroughSelection()
-{
- var selection = g_Selection.toList();
+ getGUIObjectByName("sdSpecific").hidden = false;
+ getGUIObjectByName("sdIcon").hidden = false;
+ getGUIObjectByName("sdStatsArea").hidden = false;
- if (selection.length > 1)
+ if (entState.maxHitpoints != undefined)
+ getGUIObjectByName("sdHealth").hidden = false;
+
+ var player = Engine.GetPlayerID();
+ if (entState.player == player || g_DevSettings.controlAll)
{
- var primaryTemplateName = g_Selection.getPrimaryTemplateName();
- var primaryIndex = g_Selection.getPrimary();
- var startIndex = cycleIndex;
- var endIndex = selection.length-1;
-
- cycleIndex = ((cycleIndex < endIndex)? cycleIndex+1 : 0);
-
- while (cycleIndex != startIndex)
- {
- var entState = Engine.GuiInterfaceCall("GetEntityState", selection[cycleIndex]);
- if (!entState)
- return;
-
- var equivalentTemplateNames;
- if (g_GroupSelectionByRank)
- equivalentTemplateNames = templatesEqualWithoutRank(primaryTemplateName, entState.template);
- else
- equivalentTemplateNames = (primaryTemplateName == entState.template);
-
- if ((cycleIndex != primaryIndex) && equivalentTemplateNames)
- {
- var typeCount = g_Selection.groups.getGroup(entState.template).typeCount;
- displayedCycleIndex = ((displayedCycleIndex < typeCount)? displayedCycleIndex+1 : 1);
- g_Selection.setPrimary(cycleIndex);
- break;
- }
-
- cycleIndex = ((cycleIndex < endIndex)? cycleIndex+1 : 0);
- }
- }
-}
-
-function reverseCycleThroughSelection()
-{
- var selection = g_Selection.toList();
-
- if (selection.length > 1)
- {
- var primaryTemplateName = g_Selection.getPrimaryTemplateName();
- var primaryIndex = g_Selection.getPrimary();
- var startIndex = cycleIndex;
- var endIndex = selection.length-1;
-
- cycleIndex = ((cycleIndex > 0)? cycleIndex-1 : endIndex);
-
- while (cycleIndex != startIndex)
- {
- var entState = Engine.GuiInterfaceCall("GetEntityState", selection[cycleIndex]);
- if (!entState)
- return;
-
- var equivalentTemplateNames;
- if (g_GroupSelectionByRank)
- equivalentTemplateNames = templatesEqualWithoutRank(primaryTemplateName, entState.template);
- else
- equivalentTemplateNames = (primaryTemplateName == entState.template);
-
- if ((cycleIndex != primaryIndex) && equivalentTemplateNames)
- {
- var typeCount = g_Selection.groups.getGroup(entState.template).typeCount;
- displayedCycleIndex = ((displayedCycleIndex > 1)? displayedCycleIndex-1 : typeCount);
- g_Selection.setPrimary(cycleIndex);
- break;
- }
-
- cycleIndex = ((cycleIndex > 0)? cycleIndex-1 : endIndex);
- }
+// if (entState.stamina != undefined)
+ getGUIObjectByName("sdStamina").hidden = false;
+// else
+// getGUIObjectByName("sdStamina").hidden = true;
}
}
@@ -107,10 +41,10 @@ function displayGeneralInfo(playerState, entState, template)
getGUIObjectByName("sdRankIcon").cell_id = rankId;
var rankText = getRankTitle(rankId);
- rankText = (rankText? " (" + rankText + ")" : "" );
+ rankText = (rankText? " (" + rankText + ")" : "");
// Specific Name
- var name = template.name.specific + rankText; // (eliteStatus? "Elite " + template.name.specific : template.name.specific);
+ var name = template.name.specific + rankText;
getGUIObjectByName("sdSpecific").caption = name;
iconTooltip += "[font=\"serif-bold-16\"]" + name + "[/font]";
@@ -126,20 +60,19 @@ function displayGeneralInfo(playerState, entState, template)
getGUIObjectByName("sdPlayer").textcolor = playerColor;
// Hitpoints
- if (entState.hitpoints != undefined)
+ if (entState.maxHitpoints != undefined)
{
- var healthSize = getGUIObjectByName("sdHealthBar").size;
+ var unitHealthBar = getGUIObjectByName("sdHealthBar");
+ var healthSize = unitHealthBar.size;
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
- getGUIObjectByName("sdHealthBar").size = healthSize;
+ unitHealthBar.size = healthSize;
var tooltipHitPoints = "[font=\"serif-bold-13\"]Hitpoints [/font]" + entState.hitpoints + "/" + entState.maxHitpoints;
getGUIObjectByName("sdHealth").tooltip = tooltipHitPoints;
- getGUIObjectByName("sdHealth").hidden = false;
iconTooltip += "\n" + tooltipHitPoints;
}
else
{
- getGUIObjectByName("sdHealth").hidden = true;
getGUIObjectByName("sdHealth").tooltip = "";
}
@@ -206,7 +139,7 @@ function updateSelectionDetails(simState)
/* If the unit has no data (e.g. it was killed), don't try displaying any
data for it. (TODO: it should probably be removed from the selection too;
also need to handle multi-unit selections) */
- var entState = Engine.GuiInterfaceCall("GetEntityState", selection[g_Selection.getPrimary()]);
+ var entState = Engine.GuiInterfaceCall("GetEntityState", selection[0]);
if (!entState)
return;
@@ -217,28 +150,9 @@ function updateSelectionDetails(simState)
// Choose the highest ranked version of the primary selection
// Different selection details are shown based on whether multiple units or a single unit is selected
if (selection.length > 1)
- {
- var typeCount = g_Selection.groups.getGroup(entState.template).typeCount;
- getGUIObjectByName("sdSelectionCount").caption = ((typeCount > 1)? displayedCycleIndex + "/" + typeCount : "");
-
- // Show cycle area if there is more than one unit of that type
- if (typeCount > 1)
- getGUIObjectByName("sdCycleArea").hidden = false;
- else
- getGUIObjectByName("sdCycleArea").hidden = true;
-
- // Hide stats area if there is more thanone group
- if (g_Selection.groups.getLength() > 1)
- getGUIObjectByName("sdStatsArea").hidden = true;
- else
- getGUIObjectByName("sdStatsArea").hidden = false;
- }
+ layoutSelectionMultiple();
else
- {
- getGUIObjectByName("sdSelectionCount").caption = "";
- getGUIObjectByName("sdCycleArea").hidden = true;
- getGUIObjectByName("sdStatsArea").hidden = false;
- }
+ layoutSelectionSingle(entState);
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
diff --git a/binaries/data/mods/public/gui/session_new/session.js b/binaries/data/mods/public/gui/session_new/session.js
index 73d06fd113..2aa165e356 100644
--- a/binaries/data/mods/public/gui/session_new/session.js
+++ b/binaries/data/mods/public/gui/session_new/session.js
@@ -139,7 +139,7 @@ function updateDebug(simState)
var selection = g_Selection.toList();
if (selection.length)
{
- var entState = Engine.GuiInterfaceCall("GetEntityState", selection[g_Selection.getPrimary()]);
+ var entState = Engine.GuiInterfaceCall("GetEntityState", selection[0]);
if (entState)
{
var template = Engine.GuiInterfaceCall("GetTemplateData", entState.template);
@@ -276,22 +276,3 @@ function getFormalCivName(civ)
return "Gaia";
}
}
-
-/*
-function getTemplateCategory(templateName)
-{
- var slashIndex = templateName.search("/");
-
- if (slashIndex >= 0)
- return templateName.substring(slashIndex+1, templateName.search("_"));
-
- return "unknown category";
-}
-*/
-
-
-function templatesEqualWithoutRank(templateName1, templateName2)
-{
- return ((templateName1.substring(0, templateName1.length-2) == templateName2.substring(0, templateName2.length-2))? true : false);
-}
-
diff --git a/binaries/data/mods/public/gui/session_new/session.xml b/binaries/data/mods/public/gui/session_new/session.xml
index 2ef335d7d0..06bdc86044 100644
--- a/binaries/data/mods/public/gui/session_new/session.xml
+++ b/binaries/data/mods/public/gui/session_new/session.xml
@@ -126,7 +126,7 @@
-
-
-
@@ -392,20 +364,20 @@
-
-
+
+
@@ -445,15 +417,15 @@
-
-
+
+
@@ -461,7 +433,7 @@
-
-
+
+
diff --git a/binaries/data/mods/public/gui/session_new/unit_commands.js b/binaries/data/mods/public/gui/session_new/unit_commands.js
index caa71d28e1..50f399509b 100644
--- a/binaries/data/mods/public/gui/session_new/unit_commands.js
+++ b/binaries/data/mods/public/gui/session_new/unit_commands.js
@@ -1,5 +1,6 @@
-// The height of a Queue or Garrison panel
-const UNIT_PANEL_HEIGHT = 63;
+// Constants used by the Queue or Garrison panel
+const UNIT_PANEL_BASE = -56; // The offset above the main panel (will often be negative)
+const UNIT_PANEL_HEIGHT = 47; // The height needed for a row of buttons
// The number of currently visible buttons (used to optimise showing/hiding)
var g_unitPanelButtons = { "Construction": 0, "Training": 0, "Queue": 0, "Selection": 0 };
@@ -32,13 +33,15 @@ function setupUnitPanel(guiName, usedPanels, playerState, unitEntState, items, c
{
usedPanels[guiName] = 1;
var i = 0;
+ var selection = g_Selection.toList();
for each (var item in items)
{
- if (i > 23) // End loop early if there are more than 24 buttons
+ // End loop early if there too many buttons
+ if ((guiName != "Selection") && (i > 23))
+ break;
+ else if (i > 31)
break;
- else if (guiName == "Selection" && i > 14) // End loop early if more then 16 selection buttons
- break
// Get templates
var entType;
@@ -54,7 +57,7 @@ function setupUnitPanel(guiName, usedPanels, playerState, unitEntState, items, c
// Name
var name;
if (guiName == "Selection")
- name = template.name.specific || template.name.generic || "???";
+ name = "[font=\"serif-bold-16\"]" + (template.name.specific || template.name.generic || "???") + "[/font]";
else
name = getFullName(template);
@@ -63,16 +66,23 @@ function setupUnitPanel(guiName, usedPanels, playerState, unitEntState, items, c
if (guiName == "Selection")
{
- var typeCount = g_Selection.groups.getGroup(item).typeCount;
+ var entState = Engine.GuiInterfaceCall("GetEntityState", selection[i]);
+ if (!entState)
+ return;
- if (typeCount > 1)
+ // Rank Title
+ var rankText = getRankTitle(getRankCellId(entState.template));
+ rankText = (rankText? " [font=\"serif-bold-16\"](" + rankText + ")[/font]" : "" );
+ tooltip += rankText;
+
+ // Hitpoints
+ if (entState.maxHitpoints != undefined)
{
- getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = typeCount;
- tooltip += " (" + typeCount + ")";
- }
- else
- {
- getGUIObjectByName("unit"+guiName+"Count["+i+"]").caption = "";
+ var unitHealthBar = getGUIObjectByName("unitSelectionHealthForeground[" + i + "]");
+ var healthSize = unitHealthBar.size;
+ healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
+ unitHealthBar.size = healthSize;
+ tooltip += " [font=\"serif-9\"](" + entState.hitpoints + "/" + entState.maxHitpoints + ")[/font]";
}
}
else if (guiName == "Queue")
@@ -104,23 +114,15 @@ function setupUnitPanel(guiName, usedPanels, playerState, unitEntState, items, c
}
}
- // Ignore this button because it is already featured on the big primary icon
- if (guiName == "Selection")
- {
- if (g_GroupSelectionByRank && templatesEqualWithoutRank(g_Selection.getPrimaryTemplateName(), item))
- continue;
- else if (g_Selection.getPrimaryTemplateName() == item)
- continue;
- }
-
// Button
var button = getGUIObjectByName("unit"+guiName+"Button["+i+"]");
var icon = getGUIObjectByName("unit"+guiName+"Icon["+i+"]");
button.hidden = false;
button.tooltip = tooltip;
- if (callback != null)
- button.onpress = (function(e) { return function() { callback(e) } })(item); // (need nested functions to get the closure right)
+ // Button Function
+ var parameter = ((guiName == "Selection")? i : item);
+ button.onpress = (function(e) { return function() { callback(e) } })(parameter); // (need nested functions to get the closure right)
// Get icon sheet
icon.sprite = template.icon_sheet;
@@ -135,7 +137,7 @@ function setupUnitPanel(guiName, usedPanels, playerState, unitEntState, items, c
// Position the visible buttons (TODO: if there's lots, maybe they should be squeezed together to fit)
var numButtons = i;
- var rowLength = ((guiName == "Selection")? 5 : 8);
+ var rowLength = 8;
var numRows = ceiling(numButtons / rowLength);
var buttonSideLength = getGUIObjectByName("unit"+guiName+"Button[0]").size.bottom;
var buttonSpacer = ((guiName == "Selection")? buttonSideLength+1 : buttonSideLength+2);
@@ -145,7 +147,7 @@ function setupUnitPanel(guiName, usedPanels, playerState, unitEntState, items, c
{
var panel = getGUIObjectByName("unitQueuePanel");
var size = panel.size;
- size.top = (-UNIT_PANEL_HEIGHT - ((numRows-1)*50));
+ size.top = (UNIT_PANEL_BASE - ((numRows-1)*UNIT_PANEL_HEIGHT));
panel.size = size;
}
@@ -193,15 +195,9 @@ function updateUnitCommands(playerState, entState, commandsPanel, selection)
function (item) { removeFromTrainingQueue(entState.id, item.id); } );
if (selection.length > 1)
- setupUnitPanel("Selection", usedPanels, playerState, entState, g_Selection.groups.getTemplateNames(),
+ setupUnitPanel("Selection", usedPanels, playerState, entState, g_Selection.getTemplateNames(),
function (entType) { changePrimarySelectionGroup(entType); } );
-
- // Stamina
- if (entState.stamina != undefined)
- getGUIObjectByName("sdStamina").hidden = false;
- else
- getGUIObjectByName("sdStamina").hidden = true;
-
+
commandsPanel.hidden = false;
}
else