Ticket #1226: 0001-Hotkeys-for-training-units-out-of-selected-buildings.2.patch

File 0001-Hotkeys-for-training-units-out-of-selected-buildings.2.patch, 5.5 KB (added by Marco Amadori, 12 years ago)

Refreshed Patch to r11393

  • binaries/data/config/default.cfg

    From 3785c6671d7644eb8e93e264217aae5152010d4e 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 1/2] 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 10e03e1..0243e02 100644
    a b hotkey.selection.group.select.9 = 9  
    178178hotkey.selection.group.save.9 = "Ctrl+9"
    179179hotkey.selection.group.add.9 = "Shift+9"
    180180
     181
    181182; > SESSION CONTROLS
    182183hotkey.session.kill = Delete                ; Destroy selected units
    183184hotkey.session.garrison = Ctrl              ; Modifier to garrison when clicking on building
    hotkey.session.rotate.cw = RightBracket ; Rotate building placement preview  
    190191hotkey.session.rotate.ccw = LeftBracket     ; Rotate building placement preview anticlockwise
    191192hotkey.timewarp.fastforward = Space         ; If timewarp mode enabled, speed up the game
    192193hotkey.timewarp.rewind = Backspace          ; If timewarp mode enabled, go back to earlier point in the game
     194hotkey.session.queueunit.1 = "Z"            ; add first unit type to queue
     195hotkey.session.queueunit.2 = "X"            ; add second unit type to queue
     196hotkey.session.queueunit.3 = "C"            ; add third unit type to queue
     197hotkey.session.queueunit.4 = "V"            ; add fourth unit type to queue
    193198
    194199; > OVERLAY KEYS
    195200hotkey.fps.toggle = "Alt+F"                  ; Toggle frame counter
    hotkey.timeelapsedcounter.toggle = "F12" ; Toggle time elapsed counter  
    201206; > HOTKEYS ONLY
    202207hotkey.chat = Return                        ; Toggle chat window
    203208
     209
    204210; > GUI TEXTBOX HOTKEYS
    205211hotkey.text.delete.left = "Ctrl+Backspace"    ; Delete word to the left of cursor
    206212hotkey.text.delete.right = "Ctrl+Del"         ; Delete word to the right of cursor
  • binaries/data/mods/public/gui/session/input.js

    diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js
    index 0e62fff..1b705ec 100644
    a b function flushTrainingQueueBatch()  
    11741174    Engine.PostNetworkCommand({"type": "train", "entity": batchTrainingEntity, "template": batchTrainingType, "count": batchTrainingCount});
    11751175}
    11761176
     1177// Add the position leftmost unit to the training queue of the selected building
     1178function 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
     1194function 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
    11771206// Called by GUI when user clicks training button
    11781207function addToTrainingQueue(entity, trainEntType)
    11791208{
  • binaries/data/mods/public/gui/session/session.xml

    diff --git a/binaries/data/mods/public/gui/session/session.xml b/binaries/data/mods/public/gui/session/session.xml
    index fb9477f..c14bf29 100644
    a b  
    7878            <action on="Press">setCameraFollow(g_Selection.toList()[0]);</action>
    7979        </object>
    8080
     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
    81101        <!-- Find idle warrior - TODO: Potentially move this to own UI button? -->
    82102        <object hotkey="selection.idlewarrior">
    83103            <action on="Press">findIdleUnit(["Hero", "Champion", "CitizenSoldier", "Siege", "Warship"]);</action>
  • binaries/data/mods/public/gui/session/unit_commands.js

    diff --git a/binaries/data/mods/public/gui/session/unit_commands.js b/binaries/data/mods/public/gui/session/unit_commands.js
    index 1fdf817..b50fb42 100644
    a b function setupUnitPanel(guiName, usedPanels, unitEntState, items, callback)  
    256256                if (template.speed)
    257257                    tooltip += "\n" + getEntitySpeed(template);
    258258
    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                }
    260266
     267                tooltip += "\n[font=\"serif-bold-13\"]Shift-click[/font][font=\"serif-13\"] to train " + trainNum + ".[/font]";
    261268                break;
    262269
    263270            case CONSTRUCTION: