Ticket #1492: hotkeys3.patch

File hotkeys3.patch, 5.8 KB (added by picobyte, 12 years ago)

fixes a few bugs

  • binaries/data/mods/public/gui/session/input.js

    commit 9a19e955fbf67dd61d2a9152ab23aec898d4d248
    Author: Roel Kluin <roel.kluin@gmail.com>
    Date:   Mon Jun 11 00:20:19 2012 +0200
    
        Bugfix: during building placement we can now correctly select another
        idle villager for the job.
        
        Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
    
    diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js
    index b724acd..24f32a5 100644
    a b function updateBuildingPlacementPreview()  
    146146    return false;
    147147}
    148148
    149 function initBuildingPlacementView(ev)
     149function initBuildingPlacementView()
    150150{
    151151    if (placementSupport.mode === "wall")
    152152    {
    function handleInputAfterGui(ev)  
    10541054                var sptr = ev.hotkey.split(".");
    10551055                var now = new Date();
    10561056                if ((now.getTime() - doublePressTimer < doublePressTime) && (ev.hotkey == prevHotkey) && ev.hotkey.indexOf("selection.group.select.") == 0) {
    1057                     performGroup("snap", sptr[3], ev);
     1057                    performGroup("snap", sptr[3]);
    10581058                }
    10591059                else
    10601060                {
    1061                     performGroup(sptr[2], sptr[3], ev);
     1061                    performGroup(sptr[2], sptr[3]);
    10621062
    10631063                    doublePressTimer = now.getTime();
    10641064                    prevHotkey = ev.hotkey;
    function handleInputAfterGui(ev)  
    12141214        {
    12151215        case "mousemotion":
    12161216            placementSupport.position = Engine.GetTerrainAtScreenPoint(ev.x, ev.y);
    1217             initBuildingPlacementView(ev);
     1217            initBuildingPlacementView();
    12181218            return false; // continue processing mouse motion
    12191219
    12201220        case "mousebuttondown":
    function handleInputAfterGui(ev)  
    12641264                if (ev.hotkey.indexOf("selection.group.action.") == 0)
    12651265                {   // can switch buildings
    12661266                    var sptr = ev.hotkey.split(".");
    1267                     performGroup(sptr[2], sptr[3], ev);
     1267                    performGroup(sptr[2], sptr[3]);
    12681268                }
    12691269            }
    12701270            break;
    function getActionForSelection(player, selection)  
    16231623            break;
    16241624        case ACTION_BUILD:
    16251625            if (state.buildEntities && state.buildEntities.length) {
    1626                 inputState = INPUT_PRESELECTEDACTION;
     1626                if (inputState != INPUT_BUILDING_PLACEMENT)
     1627                    inputState = INPUT_PRESELECTEDACTION;
    16271628                return state.buildEntities;
    16281629            }
    16291630            break;
    function getActionForSelection(player, selection)  
    16621663}
    16631664
    16641665// Performs the specified group
    1665 function performGroup(action, nr, ev)
     1666function performGroup(action, nr)
    16661667{
    16671668    if (nr == "reset")
    16681669    {
    function performGroup(action, nr, ev)  
    17441745                    // N.B. sets inputState = INPUT_BUILDING_PLACEMENT:
    17451746                    startBuildingPlacement(lst);
    17461747                    placementSupport.position = Engine.GetTerrainAtScreenPoint(mouseX, mouseY);
    1747                     initBuildingPlacementView(ev);
     1748                    initBuildingPlacementView();
    17481749                }
    17491750                break;
    17501751            case ACTION_TRAIN:
    function findEntity(classes, mode)  
    18581859        {
    18591860            if (!getActionForSelection(player, [newEntity]).length)
    18601861                resetPreselectedAction();
     1862            else if (preSelectedAction == ACTION_BUILD)
     1863                updateBuildingPlacementPreview();
    18611864
    18621865            lastEntity = newEntity;
    18631866            g_Selection.reset();
  • binaries/data/config/default.cfg

    commit fc4d8b422f85397eda4b78de2cf849d146b33ab1
    Author: Roel Kluin <roel.kluin@gmail.com>
    Date:   Sun Jun 10 23:32:05 2012 +0200
    
        Fixes reset hotkey
        Fixes stance
        
        Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
    
    diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg
    index 1f7c35c..5201210 100644
    a b hotkey.selection.group.action.9 = "Shift+K"  
    202202hotkey.selection.group.action.10 = "Shift+L"
    203203hotkey.selection.group.action.11 = Colon
    204204hotkey.selection.group.action.12 = DoubleQuote
    205 hotkey.selection.group.reset.action = ForwardSlash
     205hotkey.selection.group.action.reset = ForwardSlash
    206206
    207207; > SESSION CONTROLS
    208208hotkey.session.kill = Delete                ; Destroy selected units
  • 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 8775bb3..b724acd 100644
    a b function findGatherType(gatherer, supply)  
    185185
    186186function resetPreselectedAction()
    187187{
    188     placementSupport.Reset();
     188    preSelectedAction = ACTION_NONE;
    189189    inputState = INPUT_NORMAL;
    190190    _optionsOfpreSelected = [];
     191    placementSupport.Reset(); // or a hotkey may leave a building snapshot
     192    updateCursorAndTooltip();
    191193
    192194}
    193195
    function handleInputAfterGui(ev)  
    10701072        switch (ev.type)
    10711073        {
    10721074        case "mousebuttondown":
    1073             if (ev.button == SDL_BUTTON_LEFT && preSelectedAction != ACTION_NONE)
     1075            if (ev.button == SDL_BUTTON_LEFT && preSelectedAction)
    10741076            {
    10751077                var action = determineAction(ev.x, ev.y);
    10761078                resetPreselectedAction();
    function handleInputAfterGui(ev)  
    10781080                    break;
    10791081                return doAction(action, ev);
    10801082            }
    1081             else if (ev.button == SDL_BUTTON_RIGHT && preSelectedAction != ACTION_NONE)
     1083            else if (ev.button == SDL_BUTTON_RIGHT)
    10821084            {
    10831085                resetPreselectedAction();
    10841086                break;
    function getActionForSelection(player, selection)  
    16381640            if (!hasClass(state, "Unit") || hasClass(state, "Animal") || state.garrisonHolder)
    16391641                break;
    16401642
    1641             if (preSelectedAction == STANCE)
     1643            if (preSelectedAction == ACTION_STANCE)
    16421644                return ["violent", "aggressive", "passive", "defensive", "standground"];
    16431645            if (ret.length) // minimimum is 2 units for formation to be enabled
    16441646                return Engine.GuiInterfaceCall("GetAvailableFormations");
    function getActionForSelection(player, selection)  
    16621664// Performs the specified group
    16631665function performGroup(action, nr, ev)
    16641666{
     1667    if (nr == "reset")
     1668    {
     1669        resetPreselectedAction();
     1670        return;
     1671    }
    16651672    switch (action)
    16661673    {
    16671674    case "snap":
    function performGroup(action, nr, ev)  
    17951802            }
    17961803        }
    17971804        break;
    1798     case "reset":
    1799         resetPreselectedAction();
    1800         break;
    18011805    }
    18021806}
    18031807