Index: binaries/data/mods/public/gui/session/selection.js
===================================================================
--- binaries/data/mods/public/gui/session/selection.js	(revision 9207)
+++ binaries/data/mods/public/gui/session/selection.js	(working copy)
@@ -77,6 +77,16 @@
 	return this.groups[templateName];
 };
 
+EntityGroups.prototype.getTotalCount = function()
+{
+	var totalCount = 0;
+	for each (var group in this.groups)
+	{
+		totalCount += group;
+	}
+	return totalCount;
+};
+
 EntityGroups.prototype.getTemplateNames = function()
 {
 	var templateNames = [];
@@ -323,3 +333,52 @@
 };
 
 var g_Selection = new EntitySelection();
+
+//-------------------------------- -------------------------------- --------------------------------
+// EntityGroupsContainer class for managing grouped entities
+//-------------------------------- -------------------------------- --------------------------------
+function EntityGroupsContainer()
+{
+	this.groups = {};
+	for (var i = 0; i<10; ++i)
+	{
+		this.groups["group-"+i] = new EntityGroups();
+	}
+}
+
+EntityGroupsContainer.prototype.addEntities = function(groupName,ents)
+{
+	for each (var ent in ents)
+	{
+		for each (var group in this.groups)
+		{
+			for (var gent in group.ents)
+			{
+				if (ent == gent)
+				{
+					group.removeEnt(ent);
+				}
+			}
+		}
+	}
+	this.groups[groupName].add(ents);
+}
+
+EntityGroupsContainer.prototype.update = function()
+{
+	for each (var group in this.groups)
+	{
+		for (var ent in group.ents)
+		{
+			var entState = GetEntityState(parseInt(ent));
+
+			// Remove deleted units
+			if (!entState)
+			{
+				group.removeEnt(ent);
+			}
+		}
+	}
+}
+
+var g_Groups = new EntityGroupsContainer();
Index: binaries/data/mods/public/gui/session/session.xml
===================================================================
--- binaries/data/mods/public/gui/session/session.xml	(revision 9207)
+++ binaries/data/mods/public/gui/session/session.xml	(working copy)
@@ -79,6 +79,37 @@
 			<action on="Press">performCommand(g_Selection.toList()[0], "delete");</action>
 		</object>
 
+		<object hotkey="selection.group.0">
+			<action on="Press">performGroup("group-0");</action>
+		</object>
+		<object hotkey="selection.group.1">
+			<action on="Press">performGroup("group-1");</action>
+		</object>
+		<object hotkey="selection.group.2">
+			<action on="Press">performGroup("group-2");</action>
+		</object>
+		<object hotkey="selection.group.3">
+			<action on="Press">performGroup("group-3");</action>
+		</object>
+		<object hotkey="selection.group.4">
+			<action on="Press">performGroup("group-4");</action>
+		</object>
+		<object hotkey="selection.group.5">
+			<action on="Press">performGroup("group-5");</action>
+		</object>
+		<object hotkey="selection.group.6">
+			<action on="Press">performGroup("group-6");</action>
+		</object>
+		<object hotkey="selection.group.7">
+			<action on="Press">performGroup("group-7");</action>
+		</object>
+		<object hotkey="selection.group.8">
+			<action on="Press">performGroup("group-8");</action>
+		</object>
+		<object hotkey="selection.group.9">
+			<action on="Press">performGroup("group-9");</action>
+		</object>
+
 		<!-- camera.follow mode - follow the first unit in the selection -->
 		<object hotkey="camera.follow">
 			<action on="Press">setCameraFollow(g_Selection.toList()[0]);</action>
@@ -387,6 +418,25 @@
 	</object> <!-- END OF TOP PANEL -->
 
 	<!-- ================================  ================================ -->
+	<!-- START of GROUPS PANEL -->
+	<!-- ================================  ================================ -->
+	<object
+			name="unitGroupPanel"
+			size="0% 50%-216 0%+36 50%+144"
+			type="image"
+			hidden="false"
+			ghost="false"
+		>
+			<object size="0 0 100% 100%">
+				<repeat count="10">
+					<object name="unitGroupButton[n]" hidden="false" style="iconButton" type="button" size="0 0 36 36" tooltip_style="sessionToolTipBottomBold" z="100">
+						<object name="unitGroupIcon[n]" type="image" style="groupIcon" ghost="true" size="3 3 33 33"/>
+					</object>
+				</repeat>
+			</object>
+		</object>
+
+	<!-- ================================  ================================ -->
 	<!-- Idle Worker Button -->
 	<!-- ================================  ================================ -->
 	<object type="image"
Index: binaries/data/mods/public/gui/session/styles.xml
===================================================================
--- binaries/data/mods/public/gui/session/styles.xml	(revision 9207)
+++ binaries/data/mods/public/gui/session/styles.xml	(working copy)
@@ -123,6 +123,11 @@
 		ghost="true"
 	/>
 
+	<style name="groupIcon"
+		sprite="group"
+		ghost="true"
+	/>
+
 	<style name="commandIcon"
 		sprite="commands"
 		ghost="true"
Index: binaries/data/mods/public/gui/session/utility_functions.js
===================================================================
--- binaries/data/mods/public/gui/session/utility_functions.js	(revision 9207)
+++ binaries/data/mods/public/gui/session/utility_functions.js	(working copy)
@@ -291,6 +291,23 @@
 	return formations;
 }
 
+function getGroupList()
+{
+	var groups = [];
+
+	groups.push("group-0");
+	groups.push("group-1");
+	groups.push("group-2");
+	groups.push("group-3");
+	groups.push("group-4");
+	groups.push("group-5");
+	groups.push("group-6");
+	groups.push("group-7");
+	groups.push("group-8");
+	groups.push("group-9");
+	return groups;
+}
+
 function getEntityCommandsList(entState)
 {
 	var commands = [];
Index: binaries/data/mods/public/gui/session/sprites.xml
===================================================================
--- binaries/data/mods/public/gui/session/sprites.xml	(revision 9207)
+++ binaries/data/mods/public/gui/session/sprites.xml	(working copy)
@@ -17,6 +17,14 @@
 		/>
 	</sprite>
 
+	<sprite name="group">
+		<image
+			texture="session/icons/sheets/groups.png"
+			cell_size="64 64"
+			size="0 0 100% 100%"
+		/>
+	</sprite>
+
 	<!-- ================================  ================================ -->
 	<!-- Unit Command Icons -->
 	<!-- ================================  ================================ -->
Index: binaries/data/mods/public/gui/session/input.js
===================================================================
--- binaries/data/mods/public/gui/session/input.js	(revision 9207)
+++ binaries/data/mods/public/gui/session/input.js	(working copy)
@@ -1070,6 +1070,42 @@
 	}
 }
 
+// Performs the specified group
+function performGroup(groupName)
+{
+	console.write(groupName);
+
+	if (Engine.HotkeyIsPressed("selection.group.save"))
+	{
+		var selection = g_Selection.toList();
+		g_Groups.groups[groupName].reset();
+		g_Groups.addEntities(groupName,selection);
+	}
+	else if (Engine.HotkeyIsPressed("selection.group.add"))
+	{
+		var selection = g_Selection.toList();
+		g_Groups.addEntities(groupName,selection);
+	}
+	else
+	{
+		var toSelect = [];
+		g_Groups.update();
+		for (var ent in g_Groups.groups[groupName].ents)
+		{
+			toSelect.push(parseInt(ent));
+		}
+		g_Selection.reset();
+		if (toSelect.length)
+		{
+			g_Selection.addList(toSelect);
+			if (Engine.HotkeyIsPressed("selection.group.snap"))
+			{
+				//@todo snap
+			}
+		}
+	}
+}
+
 // Set the camera to follow the given unit
 function setCameraFollow(entity)
 {
Index: binaries/data/mods/public/gui/session/session.js
===================================================================
--- binaries/data/mods/public/gui/session/session.js	(revision 9207)
+++ binaries/data/mods/public/gui/session/session.js	(working copy)
@@ -223,6 +223,7 @@
 	handleNotifications();
 
 	updateMinimap(simState);
+	updateGroups();
 	updateDebug(simState);
 	updatePlayerDisplay(simState);
 	updateSelectionDetails();
@@ -245,6 +246,38 @@
 	}
 }
 
+function updateGroups()
+{
+	var groups = getGroupList();
+	var numberOfItems = groups.length;
+	var guiName = "Group";
+	for (i = 0; i < numberOfItems; i++)
+	{
+		var item = groups[i];
+		var button = getGUIObjectByName("unit"+guiName+"Button["+i+"]");
+		var icon = getGUIObjectByName("unit"+guiName+"Icon["+i+"]");
+		g_Groups.update();
+		if (g_Groups.groups["group-"+i].getTotalCount() == 0)
+			button.hidden = true;
+		else
+			button.hidden = false;
+		button.tooltip = toTitleCase(item);
+		var callback = function (item) { performGroup(item); };
+		button.onpress = (function(e) { return function() { callback(e) } })(item);
+		icon.cell_id = i;
+		icon.enabled = false;
+		if (!icon.enabled)
+			icon.sprite = "group";
+	}
+	var numButtons = i;
+	var rowLength = 1;
+	var numRows = Math.ceil(numButtons / rowLength);
+	var buttonSideLength = getGUIObjectByName("unit"+guiName+"Button[0]").size.bottom;
+	var buttonSpacer = buttonSideLength+1;
+	for (var i = 0; i < numRows; i++)
+		layoutButtonRow(i, guiName, buttonSideLength, buttonSpacer, rowLength*i, rowLength*(i+1) );
+}
+
 function updateDebug(simState)
 {
 	var debug = getGUIObjectByName("debug");
Index: binaries/data/mods/public/art/textures/ui/session/icons/sheets/groups.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream

Property changes on: binaries/data/mods/public/art/textures/ui/session/icons/sheets/groups.png
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mime-type
   + application/octet-stream

