From ed6eeb0f708ae8dd07cfc42527caa63b565fb401 Mon Sep 17 00:00:00 2001
From: noname <no@name.co>
Date: Fri, 17 Jun 2016 22:17:47 +0200
Subject: [PATCH] Idle selection
---
.../public/art/textures/ui/session/icons/idle.png | Bin 0 -> 748 bytes
.../mods/public/gui/credits/texts/programming.json | 1 +
binaries/data/mods/public/gui/session/input.js | 5 +++++
binaries/data/mods/public/gui/session/selection.js | 24 ++++++++++++++++++---
.../data/mods/public/gui/session/unit_actions.js | 18 ++++++++++++++++
5 files changed, 45 insertions(+), 3 deletions(-)
create mode 100644 binaries/data/mods/public/art/textures/ui/session/icons/idle.png
diff --git a/binaries/data/mods/public/art/textures/ui/session/icons/idle.png b/binaries/data/mods/public/art/textures/ui/session/icons/idle.png
new file mode 100644
index 0000000000000000000000000000000000000000..520b20efc90fe6cb81b000abdeed62fcc21a6fbf
GIT binary patch
literal 748
zcmV<I0u%j-P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F800006VoOIv0RI60
z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru;06&C3=5q-=}-Uw0(nV9
zK~z}7?N&Qz6j2mCcV^bOvu@=FjDn3-ut;!sCJ2HkHZ~Dk5n?44@zY4G+<>iuQ40${
zkV;gDh)Oh&5ClaxL@a_3?2Igtl^Az^*?sR=NdDPuKAW}KQ@-Ke^Uk^VzPUghb^K>Y
zRkM*s6JRes9t8r3s7=2>^YnDuD(XujvSW^c2~ywA#^X;Qq8G<l)l^8&8`IX-`(n`o
z0MR%qL>plE0JvcX)}pXE44W*)Ya~a8zmDEODpg!A=b9W?t-{^o<F-}eIT$ik)TIaI
z$TwE+Fl<VB!Q+DkzZ2PPY<`*2L2y1*@OxW4FI6dzu^#eSg(6c$syT(E(c=3jwU$#9
z<I#w14_C^ypaf|z>NX5?tQ4Su2~ypI<~~Jz{Yx@AG4rjZP&i<jRy(yG@DuTV047Kv
zlhNqv(iNM~@q#lV#_4iz2EpS5MH8O^=^C~ho<n4|_9;KS3g7~Wmm-K}!brZ!+6}KD
zQd-f0kBN8>fSx7PnT)tsIv)}g06(Gi(_ovuM4_U3YZ<Xg$Xr8etpJ$0f99=o3|-&v
zfSBEioFq9dkQb{}xTYRh4(UI^VM1<#j95|~Ml6<`KXR26ZV0XUe4`UYIX8&tdSQD_
z|5E$M#<sXY_}&d7I$m&hvv|tB1KS(--U6f*;D=v7zF)4XddCaTx<N!Ih;mLozo(}A
zK>D|zl9=%hfT<OaWs~ut&Ah;ZDL9lX>{K!H83YZWx|mJcLp8Jg$l##q`cc0dM0EVH
z2bql2f_Ik0@%=Utvlk=@yp}Qx1ORHPJD(DXzN(f$Y5mPK%?T0NCBTUlwjvrd1_1P-
ejyme70{#M|o=ci~m@RAo0000<MNUMnLSTaQdq%kc
literal 0
HcmV?d00001
diff --git a/binaries/data/mods/public/gui/credits/texts/programming.json b/binaries/data/mods/public/gui/credits/texts/programming.json
index 239b39b..688f066 100644
a
|
b
|
|
25 | 25 | {"nick": "aBothe", "name": "Alexander Bothe"}, |
26 | 26 | {"nick": "alpha123", "name": "Peter P. Cannici"}, |
27 | 27 | {"nick": "Aurium", "name": "Aurélio Heckert"}, |
| 28 | {"nick": "AZ8"} |
28 | 29 | {"nick": "badmadblacksad", "name": "Martin F"}, |
29 | 30 | {"name": "Mikołaj \"Bajter\" Korcz"}, |
30 | 31 | {"nick": "bb", "name": "Bouke Jansen"}, |
diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js
index c79112d..585564d 100644
a
|
b
|
function changePrimarySelectionGroup(templateName, deselectGroup)
|
1514 | 1514 | { |
1515 | 1515 | g_Selection.makePrimarySelection(templateName, Engine.HotkeyIsPressed("session.deselectgroup") || deselectGroup); |
1516 | 1516 | } |
| 1517 | function subSelectPrimaryIdleGroup(templateName) |
| 1518 | { |
| 1519 | g_Selection.makeIdleSelection(templateName); |
| 1520 | } |
| 1521 | |
1517 | 1522 | |
1518 | 1523 | // Performs the specified command (delete, town bell, repair, etc.) |
1519 | 1524 | function performCommand(entity, commandName) |
diff --git a/binaries/data/mods/public/gui/session/selection.js b/binaries/data/mods/public/gui/session/selection.js
index 63ce203..dbc5e07 100644
a
|
b
|
function EntityGroups()
|
36 | 36 | { |
37 | 37 | this.groups = {}; |
38 | 38 | this.ents = {}; |
| 39 | this.idle = new Set(); |
39 | 40 | } |
40 | 41 | |
41 | 42 | EntityGroups.prototype.reset = function() |
42 | 43 | { |
43 | 44 | this.groups = {}; |
44 | 45 | this.ents = {}; |
| 46 | this.idle = new Set(); |
45 | 47 | }; |
46 | 48 | |
| 49 | |
| 50 | |
47 | 51 | EntityGroups.prototype.add = function(ents) |
48 | 52 | { |
49 | 53 | for (let ent of ents) |
… |
… |
EntityGroups.prototype.add = function(ents)
|
73 | 77 | this.groups[key] = 1; |
74 | 78 | |
75 | 79 | this.ents[ent] = key; |
| 80 | if(entState.unitAI){ |
| 81 | if(entState.unitAI.isIdle){ |
| 82 | this.idle.add(ent); |
| 83 | }else { |
| 84 | this.idle.delete(ent); |
| 85 | } |
| 86 | } |
76 | 87 | } |
77 | 88 | } |
78 | 89 | }; |
… |
… |
EntityGroups.prototype.removeEnt = function(ent)
|
83 | 94 | |
84 | 95 | // Remove the entity |
85 | 96 | delete this.ents[ent]; |
| 97 | this.idle.delete(ent); |
86 | 98 | --this.groups[templateName]; |
87 | 99 | |
88 | 100 | // Remove the entire group |
… |
… |
function EntitySelection()
|
169 | 181 | { |
170 | 182 | // Private properties: |
171 | 183 | this.selected = {}; // { id:id, id:id, ... } for each selected entity ID 'id' |
172 | | |
| 184 | |
173 | 185 | // { id:id, ... } for mouseover-highlighted entity IDs in these, the key is a string and the value is an int; |
174 | 186 | // we want to use the int form wherever possible since it's more efficient to send to the simulation code) |
175 | 187 | this.highlighted = {}; |
… |
… |
function EntitySelection()
|
180 | 192 | this.dirty = false; // set whenever the selection has changed |
181 | 193 | this.groups = new EntityGroups(); |
182 | 194 | } |
183 | | |
184 | 195 | /** |
185 | 196 | * Deselect everything but entities of the chosen type if the modifier is true otherwise deselect just the chosen entity |
186 | 197 | */ |
… |
… |
EntitySelection.prototype.makePrimarySelection = function(templateName, modifier
|
198 | 209 | this.reset(); |
199 | 210 | this.addList(ents); |
200 | 211 | }; |
| 212 | EntitySelection.prototype.makeIdleSelection = function() |
| 213 | { |
| 214 | var ents = [...this.groups.idle] |
| 215 | |
| 216 | this.reset(); |
| 217 | this.addList(ents); |
| 218 | }; |
201 | 219 | |
202 | 220 | /** |
203 | 221 | * Get a list of the template names |
… |
… |
EntitySelection.prototype.update = function()
|
256 | 274 | continue; |
257 | 275 | } |
258 | 276 | } |
| 277 | |
259 | 278 | if (changed) |
260 | 279 | this.onChange(); |
261 | 280 | }; |
262 | | |
263 | 281 | /** |
264 | 282 | * Update selection if some selected entities were renamed |
265 | 283 | * (in case of unit promotion or finishing building structure) |
diff --git a/binaries/data/mods/public/gui/session/unit_actions.js b/binaries/data/mods/public/gui/session/unit_actions.js
index ca29ffd..ef2256b 100644
a
|
b
|
var g_EntityCommands =
|
1113 | 1113 | preSelectedAction = ACTION_REPAIR; |
1114 | 1114 | }, |
1115 | 1115 | }, |
| 1116 | "idle": { |
| 1117 | "getInfo": function(entState) |
| 1118 | { |
| 1119 | |
| 1120 | if (g_Selection.groups.idle.size === 0 || |
| 1121 | g_Selection.groups.idle.size === g_Selection.groups.getTotalCount()) |
| 1122 | return false; |
| 1123 | |
| 1124 | return { |
| 1125 | "tooltip": translate("Select idle in selection"), |
| 1126 | "icon": "idle.png" |
| 1127 | }; |
| 1128 | }, |
| 1129 | "execute": function(entState) |
| 1130 | { |
| 1131 | subSelectPrimaryIdleGroup(); |
| 1132 | }, |
| 1133 | }, |
1116 | 1134 | |
1117 | 1135 | "focus-rally": { |
1118 | 1136 | "getInfo": function(entState) |