Ticket #4129: 4129.diff

File 4129.diff, 2.8 KB (added by fatherbushido, 8 years ago)

use sessions global as suggested by elexis

  • binaries/data/mods/public/gui/session/hotkeys/misc.xml

     
    5454        <action on="Press">stopUnits(g_Selection.toList());</action>
    5555    </object>
    5656
    5757    <!-- Find idle warrior - TODO: Potentially move this to own UI button? -->
    5858    <object hotkey="selection.idlewarrior">
    59         <action on="Press">findIdleUnit(["Hero", "Champion", "CitizenSoldier", "Siege", "Warship", "Dog"]);</action>
     59        <action on="Press">findIdleUnit(g_MilitaryTypes);</action>
    6060    </object>
    6161
    6262    <object hotkey="selection.cancel">
    6363        <action on="Press">clearSelection();</action>
    6464    </object>
  • binaries/data/mods/public/gui/session/input.js

    var unitFilters = {  
    447447    },
    448448    "isDefensive": entity => {
    449449        var entState = GetEntityState(entity);
    450450        return entState && hasClass(entState, "Defensive");
    451451    },
    452     "isNotSupport": entity => {
     452    "isMil": entity => {
    453453        var entState = GetEntityState(entity);
    454 
    455454        return entState &&
    456             hasClass(entState, "Unit") &&
    457             !hasClass(entState, "Support") &&
    458             !hasClass(entState, "Domestic");
     455            g_MilitaryTypes.some(c => hasClass(entState, c));
    459456    },
    460457    "isIdle": entity => {
    461458        var entState = GetEntityState(entity);
    462459
    463460        return entState &&
    function getPreferredEntities(ents)  
    478475    // Default filters
    479476    var filters = [unitFilters.isUnit, unitFilters.isDefensive, unitFilters.isAnything];
    480477
    481478    // Handle hotkeys
    482479    if (Engine.HotkeyIsPressed("selection.milonly"))
    483         filters = [unitFilters.isNotSupport];
     480        filters = [unitFilters.isMil];
    484481    if (Engine.HotkeyIsPressed("selection.idleonly"))
    485482        filters = [unitFilters.isIdle];
    486483
    487484    var preferredEnts = [];
    488485    for (var i = 0; i < filters.length; ++i)
  • binaries/data/mods/public/gui/session/session.js

    var g_Heroes = [];  
    143143
    144144/**
    145145 * Unit classes to be checked for the idle-worker-hotkey.
    146146 */
    147147var g_WorkerTypes = ["Female", "Trader", "FishingBoat", "CitizenSoldier"];
    148 
     148/**
     149 * Unit classes to be checked for the military-only-selection modifier and for the idle-warrior-hotkey.
     150 */
     151var g_MilitaryTypes = ["Hero", "Champion", "CitizenSoldier", "Mercenary", "Siege", "Warship", "Dog"];
    149152/**
    150153 * Cache the idle worker status.
    151154 */
    152155var g_HasIdleWorker = false;
    153156