Ticket #277: #277.patch

File #277.patch, 2.4 KB (added by gerbilOFdoom, 12 years ago)
Line 
1Index: binaries/data/config/default.cfg
2===================================================================
3--- binaries/data/config/default.cfg (revision 10832)
4+++ binaries/data/config/default.cfg (working copy)
5@@ -142,6 +142,7 @@
6
7 ; > ENTITY SELECTION
8 hotkey.selection.add = Shift ; Add units to selection
9+hotkey.selection.milonly = Alt ; Add only military units to selection
10 hotkey.selection.remove = Ctrl ; Remove units from selection
11 hotkey.selection.idleworker = Period ; Select next idle worker
12 hotkey.selection.idlewarrior = Comma ; Select next idle warrior
13Index: binaries/data/mods/public/gui/session/input.js
14===================================================================
15--- binaries/data/mods/public/gui/session/input.js (revision 10832)
16+++ binaries/data/mods/public/gui/session/input.js (working copy)
17@@ -444,6 +444,18 @@
18 return preferredEnts;
19 }
20
21+function getMilitaryEntities(ents)
22+{
23+ var militaryEnts = [];
24+ for each (var ent in ents)
25+ {
26+ var entState = GetEntityState(ent);
27+ if (!isSupport(entState))
28+ militaryEnts.push(ent);
29+ }
30+ return militaryEnts;
31+}
32+
33 function handleInputBeforeGui(ev, hoveredObject)
34 {
35 // Capture mouse position so we can use it for displaying cursors,
36@@ -492,7 +504,6 @@
37 g_Selection.setHighlightList(ents);
38
39 return false;
40-
41 case "mousebuttonup":
42 if (ev.button == SDL_BUTTON_LEFT)
43 {
44@@ -512,8 +523,16 @@
45 var preferredEntities = getPreferredEntities(ents)
46
47 if (preferredEntities.length)
48+ {
49 ents = preferredEntities;
50-
51+ if(Engine.HotkeyIsPressed("selection.milonly"))
52+ {
53+ var militaryEntities = getMilitaryEntities(ents);
54+ if(militaryEntities.length)
55+ ents = militaryEntities;
56+ }
57+ }
58 // Remove the bandbox hover highlighting
59 g_Selection.setHighlightList([]);
60Index: binaries/data/mods/public/gui/session/utility_functions.js
61===================================================================
62--- binaries/data/mods/public/gui/session/utility_functions.js (revision 10832)
63+++ binaries/data/mods/public/gui/session/utility_functions.js (working copy)
64@@ -126,6 +126,16 @@
65 }
66 return false;
67 }
68+function isSupport(entState)
69+{
70+ if(entState.identity)
71+ {
72+ var classes = entState.identity.classes;
73+ if(classes && classes.length)
74+ return (classes.indexOf("Support") != -1);
75+ }
76+ return false;
77+}
78
79 function damageTypesToTextStacked(dmg)
80 {