1
0
forked from 0ad/0ad

Added right click selection removal. Fixes #1028. Thanks to kingadami and GerbilOfDoom for the patch.

This was SVN commit r13040.
This commit is contained in:
Jonathan Waller 2013-01-03 22:53:46 +00:00
parent ba94247744
commit 0d204037b6
5 changed files with 62 additions and 8 deletions

View File

@ -1659,9 +1659,9 @@ function removeFromProductionQueue(entity, id)
}
// Called by unit selection buttons
function changePrimarySelectionGroup(templateName)
function changePrimarySelectionGroup(templateName, deselectGroup)
{
if (Engine.HotkeyIsPressed("session.deselectgroup"))
if (Engine.HotkeyIsPressed("session.deselectgroup") || deselectGroup)
g_Selection.makePrimarySelection(templateName, true);
else
g_Selection.makePrimarySelection(templateName, false);

View File

@ -534,6 +534,12 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, playerState, items, c
// Items can have a callback element that overrides the normal caller-supplied callback function.
button.onpress = (function(e){ return function() { e.callback ? e.callback(e) : callback(e) } })(item);
if(guiName == SELECTION)
{
button.onpressright = (function(e){return function() {callback(e, true) } })(item);
button.onpress = (function(e){ return function() {callback(e, false) } })(item);
}
if (guiName == RESEARCH)
{
if (item.pair)
@ -973,7 +979,7 @@ function updateUnitCommands(entState, supplementalDetailsPanel, commandsPanel, s
if (selection.length > 1)
setupUnitPanel(SELECTION, usedPanels, entState, playerState, g_Selection.groups.getTemplateNames(),
function (entType) { changePrimarySelectionGroup(entType); } );
function (entType, rightPressed) { changePrimarySelectionGroup(entType, rightPressed); } );
var commands = getEntityCommandsList(entState);
if (commands.length)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games.
/* Copyright (C) 2012 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -93,7 +93,9 @@ enum EGUIMessageType
GUIM_MOUSE_MOTION,
GUIM_LOAD, // Called when an object is added to the GUI.
GUIM_GOT_FOCUS,
GUIM_LOST_FOCUS
GUIM_LOST_FOCUS,
GUIM_PRESSED_MOUSE_RIGHT,
GUIM_DOUBLE_PRESSED_MOUSE_RIGHT
};
/**

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games.
/* Copyright (C) 2012 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -48,7 +48,50 @@ void IGUIButtonBehavior::HandleMessage(SGUIMessage &Message)
break;
m_Pressed = true;
} break;
}
break;
case GUIM_MOUSE_DBLCLICK_RIGHT:
case GUIM_MOUSE_RELEASE_RIGHT:
{
bool enabled;
GUI<bool>::GetSetting(this, "enabled", enabled);
if (!enabled)
break;
if (m_PressedRight)
{
m_PressedRight = false;
if (Message.type == GUIM_MOUSE_RELEASE_RIGHT)
{
// Button was right-clicked
SendEvent(GUIM_PRESSED_MOUSE_RIGHT, "pressright");
}
else
{
// Button was clicked a second time. We can't tell if the button
// expects to receive doublepress events or just a second press
// event, so send both of them (and assume the extra unwanted press
// is harmless on buttons that expect doublepress)
SendEvent(GUIM_PRESSED_MOUSE_RIGHT, "pressright");
SendEvent(GUIM_DOUBLE_PRESSED_MOUSE_RIGHT, "doublepressright");
}
}
}
break;
case GUIM_MOUSE_PRESS_RIGHT:
{
bool enabled;
GUI<bool>::GetSetting(this, "enabled", enabled);
if (!enabled)
break;
m_PressedRight = true;
}
break;
case GUIM_MOUSE_DBLCLICK_LEFT:
case GUIM_MOUSE_RELEASE_LEFT:
@ -77,7 +120,8 @@ void IGUIButtonBehavior::HandleMessage(SGUIMessage &Message)
SendEvent(GUIM_DOUBLE_PRESSED, "doublepress");
}
}
} break;
}
break;
default:
break;

View File

@ -115,6 +115,7 @@ protected:
// Notify the gui that we aren't hovered anymore
UpdateMouseOver(NULL);
m_Pressed = false;
m_PressedRight = false;
}
/**
@ -125,6 +126,7 @@ protected:
* this lets us know we are done with step one (clicking).
*/
bool m_Pressed;
bool m_PressedRight;
};
#endif