Ticket #773: groups-v18-04-2011.diff
File groups-v18-04-2011.diff, 8.8 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[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 if (ent in group.ents) 356 { 357 group.removeEnt(ent); 358 } 359 } 360 } 361 this.groups[groupName].add(ents); 362 } 363 364 EntityGroupsContainer.prototype.update = function() 365 { 366 for each (var group in this.groups) 367 { 368 for (var ent in group.ents) 369 { 370 var entState = GetEntityState(+ent); 371 372 // Remove deleted units 373 if (!entState) 374 { 375 group.removeEnt(ent); 376 } 377 } 378 } 379 } 380 381 var g_Groups = new EntityGroupsContainer(); -
binaries/data/mods/public/gui/session/session.xml
387 387 </object> <!-- END OF TOP PANEL --> 388 388 389 389 <!-- ================================ ================================ --> 390 <!-- START of GROUPS PANEL --> 391 <!-- ================================ ================================ --> 392 <object 393 name="unitGroupPanel" 394 size="0% 50%-216 0%+36 50%+144" 395 type="image" 396 hidden="false" 397 ghost="false" 398 > 399 <object size="0 0 100% 100%"> 400 <repeat count="10"> 401 <object name="unitGroupButton[n]" hidden="false" style="iconButton" type="button" size="0 0 36 36" tooltip_style="sessionToolTipBottomBold" z="100"> 402 <object name="unitGroupIcon[n]" type="image" sprite="groupsIcon" ghost="true" size="3 3 33 33"/> 403 <object name="unitGroupLabel[n]" ghost="true" size="0 0 100% 100%" type="text" style="largeCenteredOutlinedText"/> 404 </object> 405 </repeat> 406 </object> 407 </object> 408 409 <!-- ================================ ================================ --> 390 410 <!-- Idle Worker Button --> 391 411 <!-- ================================ ================================ --> 392 412 <object type="image" -
binaries/data/mods/public/gui/session/input.js
47 47 // Store the previously clicked entity - ensure a double/triple click happens on the same entity 48 48 var prevClickedEntity = 0; 49 49 50 //same for keyboard 51 const doublePressTime = 500; 52 var doublePressTimer = 0; 53 var prevhotkey = 0; 54 50 55 function updateCursor() 51 56 { 52 57 if (!mouseIsOverObject) … … 646 651 return doAction(action, ev); 647 652 } 648 653 break; 654 case "hotkeydown": 655 if (ev.hotkey.indexOf("selection.group.") == 0) 656 { 657 var now = new Date(); 658 if ((now.getTime() - doublePressTimer < doublePressTime) && (ev.hotkey == prevhotkey)) 659 { 660 if (ev.hotkey.indexOf("selection.group.select") == 0) 661 { 662 var sptr = ev.hotkey.split("."); 663 performGroup("snap", sptr[3]); 664 } 665 } 666 else 667 { 668 var sptr = ev.hotkey.split("."); 669 performGroup(sptr[2], sptr[3]); 670 671 doublePressTimer = now.getTime(); 672 prevhotkey = ev.hotkey; 673 } 674 } 675 break; 649 676 } 650 677 break; 651 678 case INPUT_PRESELECTEDACTION: … … 1070 1097 } 1071 1098 } 1072 1099 1100 // Performs the specified group 1101 function performGroup(action, groupId) 1102 { 1103 switch (action) 1104 { 1105 case "snap": 1106 case "select": 1107 var toSelect = []; 1108 g_Groups.update(); 1109 for (var ent in g_Groups.groups[groupId].ents) 1110 { 1111 toSelect.push(+ent); 1112 } 1113 g_Selection.reset(); 1114 if (toSelect.length) 1115 { 1116 g_Selection.addList(toSelect); 1117 } 1118 if (action == "snap") 1119 { 1120 Engine.CameraFollow(toSelect[0]); 1121 } 1122 break; 1123 case "add": 1124 var selection = g_Selection.toList(); 1125 g_Groups.addEntities(groupId,selection); 1126 updateGroups(); 1127 break; 1128 case "save": 1129 var selection = g_Selection.toList(); 1130 g_Groups.groups[groupId].reset(); 1131 g_Groups.addEntities(groupId,selection); 1132 updateGroups(); 1133 break; 1134 } 1135 } 1136 1073 1137 // Set the camera to follow the given unit 1074 1138 function setCameraFollow(entity) 1075 1139 { -
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 guiName = "Group"; 252 for (i = 0; i < 10; i++) 253 { 254 var button = getGUIObjectByName("unit"+guiName+"Button["+i+"]"); 255 var label = getGUIObjectByName("unit"+guiName+"Label["+i+"]").caption = i; 256 g_Groups.update(); 257 if (g_Groups.groups[i].getTotalCount() == 0) 258 button.hidden = true; 259 else 260 button.hidden = false; 261 button.tooltip = "Click to select grouped units"; 262 var callback = function (i) { performGroup("select",i); }; 263 button.onpress = (function(e) { return function() { callback(e) } })(i); 264 } 265 var numButtons = i; 266 var rowLength = 1; 267 var numRows = Math.ceil(numButtons / rowLength); 268 var buttonSideLength = getGUIObjectByName("unit"+guiName+"Button[0]").size.bottom; 269 var buttonSpacer = buttonSideLength+1; 270 for (var i = 0; i < numRows; i++) 271 layoutButtonRow(i, guiName, buttonSideLength, buttonSpacer, rowLength*i, rowLength*(i+1) ); 272 } 273 248 274 function updateDebug(simState) 249 275 { 250 276 var debug = getGUIObjectByName("debug"); -
binaries/data/config/default.cfg
131 131 hotkey.console.paste = "Ctrl+V" ; Paste clipboard to console 132 132 133 133 ; > ENTITY SELECTION 134 hotkey.selection.add = Shift ; Add units to selection 135 hotkey.selection.remove = Ctrl ; Remove units from selection 136 hotkey.selection.group.0 = 0 137 hotkey.selection.group.1 = 1 138 hotkey.selection.group.2 = 2 139 hotkey.selection.group.3 = 3 140 hotkey.selection.group.4 = 4 141 hotkey.selection.group.5 = 5 142 hotkey.selection.group.6 = 6 143 hotkey.selection.group.7 = 7 144 hotkey.selection.group.8 = 8 145 hotkey.selection.group.9 = 9 146 hotkey.selection.group.add = Shift ; +group: Add units to group 147 hotkey.selection.group.save = Ctrl ; +group: Save units to group 148 hotkey.selection.group.snap = Alt ; +group: Check up on group 134 hotkey.selection.add = Shift ; Add units to selection 135 hotkey.selection.remove = Ctrl ; Remove units from selection 136 hotkey.selection.group.select.0 = 0 137 hotkey.selection.group.save.0 = "Ctrl+0" 138 hotkey.selection.group.add.0 = "Shift+0" 139 hotkey.selection.group.select.1 = 1 140 hotkey.selection.group.save.1 = "Ctrl+1" 141 hotkey.selection.group.add.1 = "Shift+1" 142 hotkey.selection.group.select.2 = 2 143 hotkey.selection.group.save.2 = "Ctrl+2" 144 hotkey.selection.group.add.2 = "Shift+2" 145 hotkey.selection.group.select.3 = 3 146 hotkey.selection.group.save.3 = "Ctrl+3" 147 hotkey.selection.group.add.3 = "Shift+3" 148 hotkey.selection.group.select.4 = 4 149 hotkey.selection.group.save.4 = "Ctrl+4" 150 hotkey.selection.group.add.4 = "Shift+4" 151 hotkey.selection.group.select.5 = 5 152 hotkey.selection.group.save.5 = "Ctrl+5" 153 hotkey.selection.group.add.5 = "Shift+5" 154 hotkey.selection.group.select.6 = 6 155 hotkey.selection.group.save.6 = "Ctrl+6" 156 hotkey.selection.group.add.6 = "Shift+6" 157 hotkey.selection.group.select.7 = 7 158 hotkey.selection.group.save.7 = "Ctrl+7" 159 hotkey.selection.group.add.7 = "Shift+7" 160 hotkey.selection.group.select.8 = 8 161 hotkey.selection.group.save.8 = "Ctrl+8" 162 hotkey.selection.group.add.8 = "Shift+8" 163 hotkey.selection.group.select.9 = 9 164 hotkey.selection.group.save.9 = "Ctrl+9" 165 hotkey.selection.group.add.9 = "Shift+9" 149 166 hotkey.selection.snap = Home ; Centre view on selection 150 167 hotkey.selection.idle = Period 151 168