This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9791 for ps


Ignore:
Timestamp:
07/10/11 04:11:51 (14 years ago)
Author:
ben
Message:

Adds hotkey for finding idle warriors (comma). See #792.
Updates finding idle units to be more flexible.
Resets finding idle units when unit is deselected.
Adds Warship class to relevant templates.

Location:
ps/trunk/binaries/data
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/config/default.cfg

    r9658 r9791  
    137137hotkey.selection.add = Shift                ; Add units to selection
    138138hotkey.selection.remove = Ctrl              ; Remove units from selection
    139 hotkey.selection.idle = Period              ; Select next idle unit
     139hotkey.selection.idleworker = Period        ; Select next idle worker
     140hotkey.selection.idlewarrior = Comma        ; Select next idle warrior
    140141hotkey.selection.offscreen = Alt            ; Include offscreen units in selection
    141142hotkey.selection.group.select.0 = 0
  • ps/trunk/binaries/data/mods/public/gui/session/input.js

    r9764 r9791  
    338338    {
    339339        // invalid location - don't build it
     340        // TODO: play a sound?
    340341        return false;
    341342    }
     
    734735                {
    735736                    g_Selection.reset();
     737                    resetIdleUnit();
    736738                    inputState = INPUT_NORMAL;
    737739                    return true;
     
    919921    case "garrison":
    920922        Engine.PostNetworkCommand({"type": "garrison", "entities": selection, "target": action.target, "queued": queued});
    921         //Need to play some sound here??
     923        // TODO: Play a sound?
    922924        return true;
    923925       
     
    11961198}
    11971199
    1198 var lastIdleWorker = 0;
     1200var lastIdleUnit = 0;
    11991201var currIdleClass = 0;
    1200 function findIdleWorker()
     1202
     1203function resetIdleUnit()
     1204{
     1205    lastIdleUnit = 0;
     1206    currIdleClass = 0;
     1207}
     1208
     1209function findIdleUnit(classes)
    12011210{
    12021211    // Cycle through idling classes before giving up
    1203     var idleClasses = ["Worker", "Trade", "CitizenSoldier"];
    1204     for (var i = 0; i <= idleClasses.length; ++i)
    1205     {
    1206         var data = { prevWorker: lastIdleWorker, idleClass: idleClasses[currIdleClass] };
    1207         lastIdleWorker = Engine.GuiInterfaceCall("FindIdleWorker", data);
     1212    for (var i = 0; i <= classes.length; ++i)
     1213    {
     1214        var data = { prevUnit: lastIdleUnit, idleClass: classes[currIdleClass] };
     1215        var newIdleUnit = Engine.GuiInterfaceCall("FindIdleUnit", data);
    12081216   
    1209         // Check if we have valid entity
    1210         if (lastIdleWorker)
    1211         {
     1217        // Check if we have new valid entity
     1218        if (newIdleUnit && newIdleUnit != lastIdleUnit)
     1219        {
     1220            lastIdleUnit = newIdleUnit;
    12121221            g_Selection.reset()
    1213             g_Selection.addList([lastIdleWorker]);
    1214             Engine.CameraFollow(lastIdleWorker);
     1222            g_Selection.addList([lastIdleUnit]);
     1223            Engine.CameraFollow(lastIdleUnit);
    12151224           
    12161225            return;
    12171226        }
    12181227       
    1219         lastIdleWorker = 0;
    1220         currIdleClass = (currIdleClass + 1) % idleClasses.length;
     1228        lastIdleUnit = 0;
     1229        currIdleClass = (currIdleClass + 1) % classes.length;
    12211230    }
    12221231   
    12231232    // TODO: display a message or play a sound to indicate no more idle units, or something
    12241233    // Reset for next cycle
    1225     currIdleClass = 0;
     1234    resetIdleUnit();
    12261235}
    12271236
  • ps/trunk/binaries/data/mods/public/gui/session/session.xml

    r9780 r9791  
    8383        <object hotkey="camera.follow">
    8484            <action on="Press">setCameraFollow(g_Selection.toList()[0]);</action>
     85        </object>
     86       
     87        <!-- Find idle warrior - TODO: Potentially move this to own UI button? -->
     88        <object hotkey="selection.idlewarrior">
     89            <action on="Press">findIdleUnit(["Hero", "Super", "CitizenSoldier", "Siege", "Warship"]);</action>
    8590        </object>
    8691       
     
    446451                    tooltip_style="sessionToolTip"
    447452                    tooltip="Find idle worker"
    448                     hotkey="selection.idle"
     453                    hotkey="selection.idleworker"
    449454                >
    450455                    <!-- TODO: should highlight the button if there's non-zero idle workers -->
    451456                    <object size="0 0 100% 100%" type="image" sprite="idleWorker" ghost="true" />
    452                     <action on="Press">findIdleWorker();</action>
     457                    <action on="Press">findIdleUnit(["Worker", "Trade", "CitizenSoldier"]);</action>
    453458                </object>
    454459            </object>
  • ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js

    r9726 r9791  
    504504};
    505505
    506 function isIdleWorker(ent, idleClass)
     506function isIdleUnit(ent, idleClass)
    507507{
    508508    var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
     
    513513}
    514514
    515 GuiInterface.prototype.FindIdleWorker = function(player, data)
     515GuiInterface.prototype.FindIdleUnit = function(player, data)
    516516{
    517517    var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     
    522522    for each (var ent in playerEntities)
    523523    {
    524         if (ent > data.prevWorker && isIdleWorker(ent, data.idleClass))
     524        if (ent > data.prevUnit && isIdleUnit(ent, data.idleClass))
    525525            return ent;
    526526    }
     
    585585    "SetBuildingPlacementPreview": 1,
    586586    "PlaySound": 1,
    587     "FindIdleWorker": 1,
     587    "FindIdleUnit": 1,
    588588
    589589    "SetPathfinderDebugOverlay": 1,
  • ps/trunk/binaries/data/mods/public/simulation/components/Identity.js

    r9776 r9791  
    9090                        "<value>CitizenSoldier</value>" +
    9191                        "<value>Trade</value>" +
     92                        "<value>Warship</value>" +
    9293                        "<value a:help='Primary weapon type'>Bow</value>" + // TODO: what are these used for?
    9394                        "<value a:help='Primary weapon type'>Javelin</value>" +
  • ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_bireme.xml

    r9598 r9791  
    44    <GenericName>Light Warship</GenericName>
    55    <Tooltip>Light Warship.</Tooltip>
     6    <Classes datatype="tokens">Warship</Classes>
    67  </Identity>
    78  <Cost>
  • ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_quinquereme.xml

    r9762 r9791  
    44    <GenericName>Heavy Warship</GenericName>
    55    <Tooltip>Heavy Warship.</Tooltip>
     6    <Classes datatype="tokens">Warship</Classes>
    67  </Identity>
    78  <Cost>
  • ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_trireme.xml

    r9762 r9791  
    44    <GenericName>Medium Warship</GenericName>
    55    <Tooltip>Medium Warship.</Tooltip>
     6    <Classes datatype="tokens">Warship</Classes>
    67  </Identity>
    78  <Cost>
Note: See TracChangeset for help on using the changeset viewer.