Ticket #1491: civc_hotkey.patch

File civc_hotkey.patch, 3.4 KB (added by picobyte, 12 years ago)
  • binaries/data/mods/public/gui/session/input.js

     
    16481648    currIdleClass = 0;
    16491649}
    16501650
     1651var lastBuilding = 0;
     1652function selectBuilding(entity)
     1653{
     1654    if (entity)
     1655    {
     1656        var data = { prevBuilding: lastBuilding, buildingClass: entity };
     1657        var newBuilding = Engine.GuiInterfaceCall("FindBuilding", data);
     1658        if (newBuilding && newBuilding != lastBuilding)
     1659        {
     1660            lastBuilding = newBuilding;
     1661            g_Selection.reset()
     1662            g_Selection.addList([lastBuilding]);
     1663            Engine.CameraFollow(lastBuilding);
     1664        }
     1665    }
     1666    lastBuilding = 0;
     1667}
     1668
    16511669function findIdleUnit(classes)
    16521670{
    16531671    // Cycle through idling classes before giving up
  • binaries/data/mods/public/gui/session/session.xml

     
    8989            <action on="Press">findIdleUnit(["Hero", "Champion", "CitizenSoldier", "Siege", "Warship"]);</action>
    9090        </object>
    9191
     92        <!-- Select towncenter-->
     93        <object hotkey="selection.civilcenter">
     94            <action on="Press">selectBuilding("CivCentre");</action>
     95        </object>
     96
    9297        <!-- ================================  ================================ -->
    9398        <!-- Developer / Debug items -->
    9499        <!-- ================================  ================================ -->
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    14521452    return 0;
    14531453};
    14541454
     1455GuiInterface.prototype.FindBuilding = function(player, data)
     1456{
     1457    var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     1458    var playerEntities = rangeMan.GetEntitiesByPlayer(player);
     1459
     1460    // Find the first matching entity that is after the previous selection,
     1461    // so that we cycle around in a predictable order
     1462    for each (var ent in playerEntities)
     1463    {
     1464        var cmpIdentity = Engine.QueryInterface(ent, IID_Identity);
     1465        if (ent > data.prevBuilding && cmpIdentity && cmpIdentity.HasClass(data.buildingClass))
     1466            return ent;
     1467    }
     1468
     1469    // No idle entities left in the class
     1470    return 0;
     1471};
     1472
     1473
     1474
    14551475GuiInterface.prototype.GetTradingDetails = function(player, data)
    14561476{
    14571477    var cmpEntityTrader = Engine.QueryInterface(data.trader, IID_Trader);
     
    15721592    "GetFoundationSnapData": 1,
    15731593    "PlaySound": 1,
    15741594    "FindIdleUnit": 1,
     1595    "FindBuilding": 1,
    15751596    "GetTradingDetails": 1,
    15761597    "CanAttack": 1,
    15771598
  • binaries/data/config/default.cfg

     
    152152hotkey.selection.remove = Ctrl              ; Remove units from selection
    153153hotkey.selection.idleworker = Period        ; Select next idle worker
    154154hotkey.selection.idlewarrior = Comma        ; Select next idle warrior
     155hotkey.selection.civilcenter = H             ; Select towncenter
    155156hotkey.selection.offscreen = Alt            ; Include offscreen units in selection
    156157hotkey.selection.group.select.0 = 0
    157158hotkey.selection.group.save.0 = "Ctrl+0"