Ticket #4064: 0001-Idle-selection.patch

File 0001-Idle-selection.patch, 6.2 KB (added by WhapWhap, 8 years ago)
  • new file 2001

    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
  • binaries/data/mods/public/gui/credits/texts/programming.json

    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  
    2525            {"nick": "aBothe", "name": "Alexander Bothe"},
    2626            {"nick": "alpha123", "name": "Peter P. Cannici"},
    2727            {"nick": "Aurium", "name": "Aurélio Heckert"},
     28            {"nick": "AZ8"}
    2829            {"nick": "badmadblacksad", "name": "Martin F"},
    2930            {"name": "Mikołaj \"Bajter\" Korcz"},
    3031            {"nick": "bb", "name": "Bouke Jansen"},
  • 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 c79112d..585564d 100644
    a b function changePrimarySelectionGroup(templateName, deselectGroup)  
    15141514{
    15151515    g_Selection.makePrimarySelection(templateName, Engine.HotkeyIsPressed("session.deselectgroup") || deselectGroup);
    15161516}
     1517function subSelectPrimaryIdleGroup(templateName)
     1518{
     1519    g_Selection.makeIdleSelection(templateName);
     1520}
     1521
    15171522
    15181523// Performs the specified command (delete, town bell, repair, etc.)
    15191524function performCommand(entity, commandName)
  • binaries/data/mods/public/gui/session/selection.js

    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()  
    3636{
    3737    this.groups = {};
    3838    this.ents = {};
     39    this.idle = new Set();
    3940}
    4041
    4142EntityGroups.prototype.reset = function()
    4243{
    4344    this.groups = {};
    4445    this.ents = {};
     46    this.idle = new Set();
    4547};
    4648
     49
     50
    4751EntityGroups.prototype.add = function(ents)
    4852{
    4953    for (let ent of ents)
    EntityGroups.prototype.add = function(ents)  
    7377                this.groups[key] = 1;
    7478
    7579            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            }
    7687        }
    7788    }
    7889};
    EntityGroups.prototype.removeEnt = function(ent)  
    8394
    8495    // Remove the entity
    8596    delete this.ents[ent];
     97    this.idle.delete(ent);
    8698    --this.groups[templateName];
    8799
    88100    // Remove the entire group
    function EntitySelection()  
    169181{
    170182    // Private properties:
    171183    this.selected = {}; // { id:id, id:id, ... } for each selected entity ID 'id'
    172 
     184   
    173185    // { id:id, ... } for mouseover-highlighted entity IDs in these, the key is a string and the value is an int;
    174186    //  we want to use the int form wherever possible since it's more efficient to send to the simulation code)
    175187    this.highlighted = {};
    function EntitySelection()  
    180192    this.dirty = false; // set whenever the selection has changed
    181193    this.groups = new EntityGroups();
    182194}
    183 
    184195/**
    185196 * Deselect everything but entities of the chosen type if the modifier is true otherwise deselect just the chosen entity
    186197 */
    EntitySelection.prototype.makePrimarySelection = function(templateName, modifier  
    198209    this.reset();
    199210    this.addList(ents);
    200211};
     212EntitySelection.prototype.makeIdleSelection = function()
     213{
     214    var ents = [...this.groups.idle]
     215
     216    this.reset();
     217    this.addList(ents);
     218};
    201219
    202220/**
    203221 * Get a list of the template names
    EntitySelection.prototype.update = function()  
    256274            continue;
    257275        }
    258276    }
     277
    259278    if (changed)
    260279        this.onChange();
    261280};
    262 
    263281/**
    264282 * Update selection if some selected entities were renamed
    265283 * (in case of unit promotion or finishing building structure)
  • binaries/data/mods/public/gui/session/unit_actions.js

    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 =  
    11131113            preSelectedAction = ACTION_REPAIR;
    11141114        },
    11151115    },
     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    },
    11161134
    11171135    "focus-rally": {
    11181136        "getInfo": function(entState)