From 578d65bb077511dfba8e5d23dd232e7d7df6ce04 Mon Sep 17 00:00:00 2001
From: Marco Amadori <marco.amadori@gmail.com>
Date: Tue, 20 Mar 2012 03:06:51 +0100
Subject: [PATCH] Hotkeys for training units out of selected buildings.
---
binaries/data/config/default.cfg | 6 ++++
binaries/data/mods/public/gui/session/input.js | 29 ++++++++++++++++++++
binaries/data/mods/public/gui/session/session.xml | 20 +++++++++++++
.../data/mods/public/gui/session/unit_commands.js | 9 +++++-
4 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg
index c21878b..1efe59b 100644
a
|
b
|
hotkey.selection.group.select.9 = 9
|
178 | 178 | hotkey.selection.group.save.9 = "Ctrl+9" |
179 | 179 | hotkey.selection.group.add.9 = "Shift+9" |
180 | 180 | |
| 181 | |
181 | 182 | ; > SESSION CONTROLS |
182 | 183 | hotkey.session.kill = Delete ; Destroy selected units |
183 | 184 | hotkey.session.garrison = Ctrl ; Modifier to garrison when clicking on building |
… |
… |
hotkey.session.rotate.cw = RightBracket ; Rotate building placement preview
|
189 | 190 | hotkey.session.rotate.ccw = LeftBracket ; Rotate building placement preview anticlockwise |
190 | 191 | hotkey.timewarp.fastforward = Space ; If timewarp mode enabled, speed up the game |
191 | 192 | hotkey.timewarp.rewind = Backspace ; If timewarp mode enabled, go back to earlier point in the game |
| 193 | hotkey.session.queueunit.1 = "Z" ; add first unit type to queue |
| 194 | hotkey.session.queueunit.2 = "X" ; add second unit type to queue |
| 195 | hotkey.session.queueunit.3 = "C" ; add third unit type to queue |
| 196 | hotkey.session.queueunit.4 = "V" ; add fourth unit type to queue |
192 | 197 | |
193 | 198 | ; > OVERLAY KEYS |
194 | 199 | hotkey.fps.toggle = "Alt+F" ; Toggle frame counter |
… |
… |
hotkey.timeelapsedcounter.toggle = "F12" ; Toggle time elapsed counter
|
200 | 205 | ; > HOTKEYS ONLY |
201 | 206 | hotkey.chat = Return ; Toggle chat window |
202 | 207 | |
| 208 | |
203 | 209 | ; > GUI TEXTBOX HOTKEYS |
204 | 210 | hotkey.text.delete.left = "Ctrl+Backspace" ; Delete word to the left of cursor |
205 | 211 | hotkey.text.delete.right = "Ctrl+Del" ; Delete word to the right of cursor |
diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js
index 57b59a0..9c31acc 100644
a
|
b
|
function flushTrainingQueueBatch()
|
1174 | 1174 | Engine.PostNetworkCommand({"type": "train", "entity": batchTrainingEntity, "template": batchTrainingType, "count": batchTrainingCount}); |
1175 | 1175 | } |
1176 | 1176 | |
| 1177 | // Add the position leftmost unit to the training queue of the selected building |
| 1178 | function addQueueUnit(entity, position) |
| 1179 | { |
| 1180 | if (entity) |
| 1181 | { |
| 1182 | entState = GetEntityState(entity); |
| 1183 | if (entState && entState.training && entState.training.entities) |
| 1184 | { |
| 1185 | // it is a building that can produce units |
| 1186 | if (position < entState.training.entities.length) |
| 1187 | { |
| 1188 | addToTrainingQueue(entState.id, entState.training.entities[position]); |
| 1189 | } |
| 1190 | } |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | function addQueueAll(position) |
| 1195 | { |
| 1196 | var selection = g_Selection.toList(); |
| 1197 | |
| 1198 | if (!selection.length) |
| 1199 | return; |
| 1200 | |
| 1201 | selection.forEach(function(entity) { |
| 1202 | addQueueUnit(entity, position); |
| 1203 | }); |
| 1204 | } |
| 1205 | |
1177 | 1206 | // Called by GUI when user clicks training button |
1178 | 1207 | function addToTrainingQueue(entity, trainEntType) |
1179 | 1208 | { |
diff --git a/binaries/data/mods/public/gui/session/session.xml b/binaries/data/mods/public/gui/session/session.xml
index ca202d3..ebff419 100644
a
|
b
|
|
78 | 78 | <action on="Press">setCameraFollow(g_Selection.toList()[0]);</action> |
79 | 79 | </object> |
80 | 80 | |
| 81 | <!-- queue first unit in the training queue --> |
| 82 | <object hotkey="session.queueunit.1"> |
| 83 | <action on="Press">addQueueAll(0);</action> |
| 84 | </object> |
| 85 | |
| 86 | <!-- queue 2nd unit in the training queue --> |
| 87 | <object hotkey="session.queueunit.2"> |
| 88 | <action on="Press">addQueueAll(1);</action> |
| 89 | </object> |
| 90 | |
| 91 | <!-- queue 3rd unit in the training queue --> |
| 92 | <object hotkey="session.queueunit.3"> |
| 93 | <action on="Press">addQueueAll(2);</action> |
| 94 | </object> |
| 95 | |
| 96 | <!-- queue 4th unit in the training queue --> |
| 97 | <object hotkey="session.queueunit.4"> |
| 98 | <action on="Press">addQueueAll(3);</action> |
| 99 | </object> |
| 100 | |
81 | 101 | <!-- Find idle warrior - TODO: Potentially move this to own UI button? --> |
82 | 102 | <object hotkey="selection.idlewarrior"> |
83 | 103 | <action on="Press">findIdleUnit(["Hero", "Champion", "CitizenSoldier", "Siege", "Warship"]);</action> |
diff --git a/binaries/data/mods/public/gui/session/unit_commands.js b/binaries/data/mods/public/gui/session/unit_commands.js
index e3ff8d8..dddce3c 100644
a
|
b
|
function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)
|
256 | 256 | if (template.speed) |
257 | 257 | tooltip += "\n" + getEntitySpeed(template); |
258 | 258 | |
259 | | tooltip += "\n\n[font=\"serif-bold-13\"]Shift-click[/font][font=\"serif-13\"] to train " + trainNum + ".[/font]"; |
| 259 | if (i >= 0 && i < 4) |
| 260 | { |
| 261 | var train_hotkeys = ["Z", "X", "C", "V"]; |
| 262 | tooltip += "\n\n[font=\"serif-bold-13\"]HotKey (" + train_hotkeys[i] + ").[/font]"; |
| 263 | } else { |
| 264 | tooltip += "\n"; |
| 265 | } |
260 | 266 | |
| 267 | tooltip += "\n[font=\"serif-bold-13\"]Shift-click[/font][font=\"serif-13\"] to train " + trainNum + ".[/font]"; |
261 | 268 | break; |
262 | 269 | |
263 | 270 | case CONSTRUCTION: |