Ticket #773: groups-v08-04-2011.diff
File groups-v08-04-2011.diff, 9.2 KB (added by , 13 years ago) |
---|
-
binaries/data/mods/public/gui/session/selection.js
77 77 return this.groups[templateName]; 78 78 }; 79 79 80 EntityGroups.prototype.getTotalCount = function() 81 { 82 var totalCount = 0; 83 for each (var group in this.groups) 84 { 85 totalCount += group; 86 } 87 return totalCount; 88 }; 89 80 90 EntityGroups.prototype.getTemplateNames = function() 81 91 { 82 92 var templateNames = []; … … 323 333 }; 324 334 325 335 var g_Selection = new EntitySelection(); 336 337 //-------------------------------- -------------------------------- -------------------------------- 338 // EntityGroupsContainer class for managing grouped entities 339 //-------------------------------- -------------------------------- -------------------------------- 340 function EntityGroupsContainer() 341 { 342 this.groups = {}; 343 for (var i = 0; i<10; ++i) 344 { 345 this.groups["group-"+i] = new EntityGroups(); 346 } 347 } 348 349 EntityGroupsContainer.prototype.addEntities = function(groupName,ents) 350 { 351 for each (var ent in ents) 352 { 353 for each (var group in this.groups) 354 { 355 for (var gent in group.ents) 356 { 357 if (ent == gent) 358 { 359 group.removeEnt(ent); 360 } 361 } 362 } 363 } 364 this.groups[groupName].add(ents); 365 } 366 367 EntityGroupsContainer.prototype.update = function() 368 { 369 for each (var group in this.groups) 370 { 371 for (var ent in group.ents) 372 { 373 var entState = GetEntityState(parseInt(ent)); 374 375 // Remove deleted units 376 if (!entState) 377 { 378 group.removeEnt(ent); 379 } 380 } 381 } 382 } 383 384 var g_Groups = new EntityGroupsContainer(); -
binaries/data/mods/public/gui/session/session.xml
79 79 <action on="Press">performCommand(g_Selection.toList()[0], "delete");</action> 80 80 </object> 81 81 82 <object hotkey="selection.group.0"> 83 <action on="Press">performGroup("group-0");</action> 84 </object> 85 <object hotkey="selection.group.1"> 86 <action on="Press">performGroup("group-1");</action> 87 </object> 88 <object hotkey="selection.group.2"> 89 <action on="Press">performGroup("group-2");</action> 90 </object> 91 <object hotkey="selection.group.3"> 92 <action on="Press">performGroup("group-3");</action> 93 </object> 94 <object hotkey="selection.group.4"> 95 <action on="Press">performGroup("group-4");</action> 96 </object> 97 <object hotkey="selection.group.5"> 98 <action on="Press">performGroup("group-5");</action> 99 </object> 100 <object hotkey="selection.group.6"> 101 <action on="Press">performGroup("group-6");</action> 102 </object> 103 <object hotkey="selection.group.7"> 104 <action on="Press">performGroup("group-7");</action> 105 </object> 106 <object hotkey="selection.group.8"> 107 <action on="Press">performGroup("group-8");</action> 108 </object> 109 <object hotkey="selection.group.9"> 110 <action on="Press">performGroup("group-9");</action> 111 </object> 112 82 113 <!-- camera.follow mode - follow the first unit in the selection --> 83 114 <object hotkey="camera.follow"> 84 115 <action on="Press">setCameraFollow(g_Selection.toList()[0]);</action> … … 387 418 </object> <!-- END OF TOP PANEL --> 388 419 389 420 <!-- ================================ ================================ --> 421 <!-- START of GROUPS PANEL --> 422 <!-- ================================ ================================ --> 423 <object 424 name="unitGroupPanel" 425 size="0% 50%-216 0%+36 50%+144" 426 type="image" 427 hidden="false" 428 ghost="false" 429 > 430 <object size="0 0 100% 100%"> 431 <repeat count="10"> 432 <object name="unitGroupButton[n]" hidden="false" style="iconButton" type="button" size="0 0 36 36" tooltip_style="sessionToolTipBottomBold" z="100"> 433 <object name="unitGroupIcon[n]" type="image" style="groupIcon" ghost="true" size="3 3 33 33"/> 434 </object> 435 </repeat> 436 </object> 437 </object> 438 439 <!-- ================================ ================================ --> 390 440 <!-- Idle Worker Button --> 391 441 <!-- ================================ ================================ --> 392 442 <object type="image" -
binaries/data/mods/public/gui/session/styles.xml
123 123 ghost="true" 124 124 /> 125 125 126 <style name="groupIcon" 127 sprite="group" 128 ghost="true" 129 /> 130 126 131 <style name="commandIcon" 127 132 sprite="commands" 128 133 ghost="true" -
binaries/data/mods/public/gui/session/utility_functions.js
291 291 return formations; 292 292 } 293 293 294 function getGroupList() 295 { 296 var groups = []; 297 298 groups.push("group-0"); 299 groups.push("group-1"); 300 groups.push("group-2"); 301 groups.push("group-3"); 302 groups.push("group-4"); 303 groups.push("group-5"); 304 groups.push("group-6"); 305 groups.push("group-7"); 306 groups.push("group-8"); 307 groups.push("group-9"); 308 return groups; 309 } 310 294 311 function getEntityCommandsList(entState) 295 312 { 296 313 var commands = []; -
binaries/data/mods/public/gui/session/sprites.xml
17 17 /> 18 18 </sprite> 19 19 20 <sprite name="group"> 21 <image 22 texture="session/icons/sheets/groups.png" 23 cell_size="64 64" 24 size="0 0 100% 100%" 25 /> 26 </sprite> 27 20 28 <!-- ================================ ================================ --> 21 29 <!-- Unit Command Icons --> 22 30 <!-- ================================ ================================ --> -
binaries/data/mods/public/gui/session/input.js
1070 1070 } 1071 1071 } 1072 1072 1073 // Performs the specified group 1074 function performGroup(groupName) 1075 { 1076 console.write(groupName); 1077 1078 if (Engine.HotkeyIsPressed("selection.group.save")) 1079 { 1080 var selection = g_Selection.toList(); 1081 g_Groups.groups[groupName].reset(); 1082 g_Groups.addEntities(groupName,selection); 1083 } 1084 else if (Engine.HotkeyIsPressed("selection.group.add")) 1085 { 1086 var selection = g_Selection.toList(); 1087 g_Groups.addEntities(groupName,selection); 1088 } 1089 else 1090 { 1091 var toSelect = []; 1092 g_Groups.update(); 1093 for (var ent in g_Groups.groups[groupName].ents) 1094 { 1095 toSelect.push(parseInt(ent)); 1096 } 1097 g_Selection.reset(); 1098 if (toSelect.length) 1099 { 1100 g_Selection.addList(toSelect); 1101 if (Engine.HotkeyIsPressed("selection.group.snap")) 1102 { 1103 //@todo snap 1104 } 1105 } 1106 } 1107 } 1108 1073 1109 // Set the camera to follow the given unit 1074 1110 function setCameraFollow(entity) 1075 1111 { -
binaries/data/mods/public/gui/session/session.js
223 223 handleNotifications(); 224 224 225 225 updateMinimap(simState); 226 updateGroups(); 226 227 updateDebug(simState); 227 228 updatePlayerDisplay(simState); 228 229 updateSelectionDetails(); … … 245 246 } 246 247 } 247 248 249 function updateGroups() 250 { 251 var groups = getGroupList(); 252 var numberOfItems = groups.length; 253 var guiName = "Group"; 254 for (i = 0; i < numberOfItems; i++) 255 { 256 var item = groups[i]; 257 var button = getGUIObjectByName("unit"+guiName+"Button["+i+"]"); 258 var icon = getGUIObjectByName("unit"+guiName+"Icon["+i+"]"); 259 g_Groups.update(); 260 if (g_Groups.groups["group-"+i].getTotalCount() == 0) 261 button.hidden = true; 262 else 263 button.hidden = false; 264 button.tooltip = toTitleCase(item); 265 var callback = function (item) { performGroup(item); }; 266 button.onpress = (function(e) { return function() { callback(e) } })(item); 267 icon.cell_id = i; 268 icon.enabled = false; 269 if (!icon.enabled) 270 icon.sprite = "group"; 271 } 272 var numButtons = i; 273 var rowLength = 1; 274 var numRows = Math.ceil(numButtons / rowLength); 275 var buttonSideLength = getGUIObjectByName("unit"+guiName+"Button[0]").size.bottom; 276 var buttonSpacer = buttonSideLength+1; 277 for (var i = 0; i < numRows; i++) 278 layoutButtonRow(i, guiName, buttonSideLength, buttonSpacer, rowLength*i, rowLength*(i+1) ); 279 } 280 248 281 function updateDebug(simState) 249 282 { 250 283 var debug = getGUIObjectByName("debug");