Ticket #1028: 0adTicket_1028.patch

File 0adTicket_1028.patch, 4.6 KB (added by kingadami, 11 years ago)

Implemented quantumstate's suggestions. Thanks for the input. Picking up this patch is introducing me to the code without being overwelmed (along with making me learn javascript).

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

     
    16591659}
    16601660
    16611661// Called by unit selection buttons
    1662 function changePrimarySelectionGroup(templateName)
     1662function changePrimarySelectionGroup(templateName, deselectGroup)
    16631663{
    1664     if (Engine.HotkeyIsPressed("session.deselectgroup"))
     1664    if (Engine.HotkeyIsPressed("session.deselectgroup") || deselectGroup)
    16651665        g_Selection.makePrimarySelection(templateName, true);
    16661666    else
    16671667        g_Selection.makePrimarySelection(templateName, false);
  • binaries/data/mods/public/gui/session/unit_commands.js

     
    533533        // Button Function (need nested functions to get the closure right)
    534534        // Items can have a callback element that overrides the normal caller-supplied callback function.
    535535        button.onpress = (function(e){ return function() { e.callback ? e.callback(e) : callback(e) } })(item);
     536
     537        if(guiName == SELECTION)
     538        {
     539            button.onpressright = (function(e){return function() {callback(e, true) } })(item);
     540            button.onpress = (function(e){ return function() {callback(e, false) } })(item);
     541        }
    536542
    537543        if (guiName == RESEARCH)
    538544        {
     
    973979
    974980        if (selection.length > 1)
    975981            setupUnitPanel(SELECTION, usedPanels, entState, playerState, g_Selection.groups.getTemplateNames(),
    976                 function (entType) { changePrimarySelectionGroup(entType); } );
     982                function (entType, rightPressed) { changePrimarySelectionGroup(entType, rightPressed); } );
    977983
    978984        var commands = getEntityCommandsList(entState);
    979985        if (commands.length)
  • source/gui/IGUIButtonBehavior.h

     
    115115        // Notify the gui that we aren't hovered anymore
    116116        UpdateMouseOver(NULL);
    117117        m_Pressed = false;
     118        m_PressedRight = false;
    118119    }
    119120
    120121    /**
     
    125126     * this lets us know we are done with step one (clicking).
    126127     */
    127128    bool                            m_Pressed;
     129    bool                            m_PressedRight;
    128130};
    129131
    130132#endif
  • source/gui/IGUIButtonBehavior.cpp

     
    1 /* Copyright (C) 2009 Wildfire Games.
     1/* Copyright (C) 2012 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    4848            break;
    4949
    5050        m_Pressed = true;
    51     }   break;
     51    }
     52    break;
    5253
     54    case GUIM_MOUSE_DBLCLICK_RIGHT:
     55    case GUIM_MOUSE_RELEASE_RIGHT:
     56    {
     57        bool enabled;
     58        GUI<bool>::GetSetting(this, "enabled", enabled);
     59       
     60        if (!enabled)
     61            break;
     62       
     63        if (m_PressedRight)
     64        {
     65            m_PressedRight = false;
     66            if (Message.type == GUIM_MOUSE_RELEASE_RIGHT)
     67            {
     68                // Button was right-clicked
     69                SendEvent(GUIM_PRESSED_MOUSE_RIGHT, "pressright");
     70            }
     71            else
     72            {
     73                // Button was clicked a second time. We can't tell if the button
     74                // expects to receive doublepress events or just a second press
     75                // event, so send both of them (and assume the extra unwanted press
     76                // is harmless on buttons that expect doublepress)
     77                SendEvent(GUIM_PRESSED_MOUSE_RIGHT, "pressright");
     78                SendEvent(GUIM_DOUBLE_PRESSED_MOUSE_RIGHT, "doublepressright");
     79            }
     80        }
     81    }
     82    break;
     83
     84    case GUIM_MOUSE_PRESS_RIGHT:
     85    {
     86        bool enabled;
     87        GUI<bool>::GetSetting(this, "enabled", enabled);
     88       
     89        if (!enabled)
     90            break;
     91       
     92        m_PressedRight = true;
     93    }
     94    break;
     95
    5396    case GUIM_MOUSE_DBLCLICK_LEFT:
    5497    case GUIM_MOUSE_RELEASE_LEFT:
    5598    {
     
    77120                SendEvent(GUIM_DOUBLE_PRESSED, "doublepress");
    78121            }
    79122        }
    80     }   break;
     123    }
     124    break;
    81125
    82126    default:
    83127        break;
  • source/gui/GUIbase.h

     
    1 /* Copyright (C) 2009 Wildfire Games.
     1/* Copyright (C) 2012 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    9393    GUIM_MOUSE_MOTION,
    9494    GUIM_LOAD,              // Called when an object is added to the GUI.
    9595    GUIM_GOT_FOCUS,
    96     GUIM_LOST_FOCUS
     96    GUIM_LOST_FOCUS,
     97    GUIM_PRESSED_MOUSE_RIGHT,
     98    GUIM_DOUBLE_PRESSED_MOUSE_RIGHT
    9799};
    98100
    99101/**