Apply patch #2003 - Add option for rotating with middle mouse button (LMB+RMB also works). refs #2003

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@11212 4a71c877-e1ca-e34f-864e-861f7616d084
master
Guangcong Luo 2010-07-16 01:26:34 +00:00 committed by Git SVN Gateway
parent a6bb433a17
commit 09d73b0ba5
6 changed files with 78 additions and 20 deletions

View File

@ -380,20 +380,17 @@ void inputHandleMouseMotionEvent(SDL_MouseMotionEvent * motionEvent)
switch (motionEvent->type) switch (motionEvent->type)
{ {
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
if(!mouseDown(MOUSE_MMB)) /* store the current mouse position */
{ mouseXPos = motionEvent->x;
/* store the current mouse position */ mouseYPos = motionEvent->y;
mouseXPos = motionEvent->x;
mouseYPos = motionEvent->y;
/* now see if a drag has started */ /* now see if a drag has started */
if ( ( aMouseState[dragKey].state == KEY_PRESSED || if ((aMouseState[dragKey].state == KEY_PRESSED ||
aMouseState[dragKey].state == KEY_DOWN ) aMouseState[dragKey].state == KEY_DOWN) &&
&& ( ABSDIF(dragX, mouseXPos) > DRAG_THRESHOLD || (ABSDIF(dragX, mouseXPos) > DRAG_THRESHOLD ||
ABSDIF(dragY, mouseYPos) > DRAG_THRESHOLD ) ) ABSDIF(dragY, mouseYPos) > DRAG_THRESHOLD))
{ {
aMouseState[dragKey].state = KEY_DRAG; aMouseState[dragKey].state = KEY_DRAG;
}
} }
break; break;
default: default:
@ -495,7 +492,10 @@ Uint16 mouseY(void)
/* This returns true if the mouse key is currently depressed */ /* This returns true if the mouse key is currently depressed */
bool mouseDown(MOUSE_KEY_CODE code) bool mouseDown(MOUSE_KEY_CODE code)
{ {
return (aMouseState[code].state != KEY_UP); return (aMouseState[code].state != KEY_UP) ||
// holding down LMB and RMB counts as holding down MMB
(code == MOUSE_MMB && aMouseState[MOUSE_LMB].state != KEY_UP && aMouseState[MOUSE_RMB].state != KEY_UP);
} }
/* This returns true if the mouse key was double clicked */ /* This returns true if the mouse key was double clicked */
@ -523,7 +523,11 @@ bool mouseReleased(MOUSE_KEY_CODE code)
/* Check for a mouse drag, return the drag start coords if dragging */ /* Check for a mouse drag, return the drag start coords if dragging */
bool mouseDrag(MOUSE_KEY_CODE code, UDWORD *px, UDWORD *py) bool mouseDrag(MOUSE_KEY_CODE code, UDWORD *px, UDWORD *py)
{ {
if (aMouseState[code].state == KEY_DRAG) if ((aMouseState[code].state == KEY_DRAG) ||
// dragging LMB and RMB counts as dragging MMB
(code == MOUSE_MMB && ((aMouseState[MOUSE_LMB].state == KEY_DRAG && aMouseState[MOUSE_RMB].state != KEY_UP) ||
(aMouseState[MOUSE_LMB].state != KEY_UP && aMouseState[MOUSE_RMB].state == KEY_DRAG))))
{ {
*px = dragX; *px = dragX;
*py = dragY; *py = dragY;

View File

@ -231,7 +231,16 @@ BOOL loadConfig(void)
setRightClickOrders(false); setRightClickOrders(false);
setWarzoneKeyNumeric("RightClickOrders", false); setWarzoneKeyNumeric("RightClickOrders", false);
} }
if (getWarzoneKeyNumeric("MiddleClickRotate", &val))
{
setMiddleClickRotate(val);
}
else
{
setMiddleClickRotate(false);
setWarzoneKeyNumeric("MiddleClickRotate", false);
}
// ////////////////////////// // //////////////////////////
// rotate radar // rotate radar
if(getWarzoneKeyNumeric("rotateRadar", &val)) if(getWarzoneKeyNumeric("rotateRadar", &val))
@ -730,6 +739,7 @@ BOOL saveConfig(void)
setWarzoneKeyNumeric("shake",(SDWORD)(getShakeStatus())); // screenshake setWarzoneKeyNumeric("shake",(SDWORD)(getShakeStatus())); // screenshake
setWarzoneKeyNumeric("mouseflip",(SDWORD)(getInvertMouseStatus())); // flipmouse setWarzoneKeyNumeric("mouseflip",(SDWORD)(getInvertMouseStatus())); // flipmouse
setWarzoneKeyNumeric("RightClickOrders",(SDWORD)(getRightClickOrders())); setWarzoneKeyNumeric("RightClickOrders",(SDWORD)(getRightClickOrders()));
setWarzoneKeyNumeric("MiddleClickRotate",(SDWORD)(getMiddleClickRotate()));
setWarzoneKeyNumeric("shadows",(SDWORD)(getDrawShadows())); // shadows setWarzoneKeyNumeric("shadows",(SDWORD)(getDrawShadows())); // shadows
setWarzoneKeyNumeric("sound", (SDWORD)war_getSoundEnabled()); setWarzoneKeyNumeric("sound", (SDWORD)war_getSoundEnabled());
setWarzoneKeyNumeric("FMVmode",(SDWORD)(war_GetFMVmode())); // sequences setWarzoneKeyNumeric("FMVmode",(SDWORD)(war_GetFMVmode())); // sequences

View File

@ -177,6 +177,7 @@ static BOOL anyDroidSelected(UDWORD player);
static BOOL cyborgDroidSelected(UDWORD player); static BOOL cyborgDroidSelected(UDWORD player);
static BOOL bInvertMouse = true; static BOOL bInvertMouse = true;
static BOOL bRightClickOrders = false; static BOOL bRightClickOrders = false;
static BOOL bMiddleClickRotate = false;
static BOOL bDrawShadows = true; static BOOL bDrawShadows = true;
static SELECTION_TYPE establishSelection(UDWORD selectedPlayer); static SELECTION_TYPE establishSelection(UDWORD selectedPlayer);
static void dealWithLMB( void ); static void dealWithLMB( void );
@ -272,6 +273,7 @@ void setInvertMouseStatus( BOOL val )
#define MOUSE_ORDER (bRightClickOrders?MOUSE_RMB:MOUSE_LMB) #define MOUSE_ORDER (bRightClickOrders?MOUSE_RMB:MOUSE_LMB)
#define MOUSE_SELECT (bRightClickOrders?MOUSE_LMB:MOUSE_RMB) #define MOUSE_SELECT (bRightClickOrders?MOUSE_LMB:MOUSE_RMB)
#define MOUSE_ROTATE (bMiddleClickRotate?MOUSE_MMB:MOUSE_RMB)
BOOL getRightClickOrders( void ) BOOL getRightClickOrders( void )
{ {
@ -284,6 +286,17 @@ void setRightClickOrders( BOOL val )
} }
BOOL getMiddleClickRotate( void )
{
return bMiddleClickRotate;
}
void setMiddleClickRotate( BOOL val )
{
bMiddleClickRotate = val;
}
BOOL getDrawShadows( void ) BOOL getDrawShadows( void )
{ {
return(bDrawShadows); return(bDrawShadows);
@ -549,7 +562,7 @@ static void CheckFinishedDrag(void)
return; return;
} }
if (mouseReleased(MOUSE_LMB)) if (mouseReleased(MOUSE_LMB) || mouseDown(MOUSE_RMB))
{ {
selectAttempt = false; selectAttempt = false;
if(dragBox3D.status == DRAG_DRAGGING) if(dragBox3D.status == DRAG_DRAGGING)
@ -800,7 +813,7 @@ void processMouseClickInput(void)
kill3DBuilding(); kill3DBuilding();
bRadarDragging = false; bRadarDragging = false;
} }
if (mouseDrag(MOUSE_RMB,(UDWORD *)&rotX,(UDWORD *)&rotY) && !rotActive && !bRadarDragging) if (mouseDrag(MOUSE_ROTATE,(UDWORD *)&rotX,(UDWORD *)&rotY) && !rotActive && !bRadarDragging)
{ {
rotInitial = player.r.y; rotInitial = player.r.y;
rotInitialUp = player.r.x; rotInitialUp = player.r.x;
@ -1320,7 +1333,7 @@ void displayWorld(void)
shakeUpdate(); shakeUpdate();
if (mouseDown(MOUSE_RMB) && rotActive) if (mouseDown(MOUSE_ROTATE) && rotActive)
{ {
if (abs(mouseX() - rotX) > 2 || xMoved > 2 || abs(mouseY() - rotY) > 2 || yMoved > 2) if (abs(mouseX() - rotX) > 2 || xMoved > 2 || abs(mouseY() - rotY) > 2 || yMoved > 2)
{ {
@ -1369,7 +1382,7 @@ void displayWorld(void)
} }
} }
if(mouseReleased(MOUSE_RMB) && rotActive) if (!mouseDown(MOUSE_ROTATE) && rotActive)
{ {
rotActive = false; rotActive = false;
xMoved = yMoved = 0; xMoved = yMoved = 0;

View File

@ -63,6 +63,9 @@ extern BOOL getInvertMouseStatus( void );
extern void setRightClickOrders( BOOL val ); extern void setRightClickOrders( BOOL val );
extern BOOL getRightClickOrders( void ); extern BOOL getRightClickOrders( void );
extern void setMiddleClickRotate( BOOL val );
extern BOOL getMiddleClickRotate( void );
extern void setDrawShadows( BOOL val ); extern void setDrawShadows( BOOL val );
extern BOOL getDrawShadows( void ); extern BOOL getDrawShadows( void );

View File

@ -995,6 +995,18 @@ static BOOL startMouseOptionsMenu(void)
addTextButton(FRONTEND_MBUTTONS_R, FRONTEND_POS2M-25, FRONTEND_POS5Y, _("Off"), 0); addTextButton(FRONTEND_MBUTTONS_R, FRONTEND_POS2M-25, FRONTEND_POS5Y, _("Off"), 0);
} }
////////////
// middle-click rotate
addTextButton(FRONTEND_MMROTATE, FRONTEND_POS2X-35, FRONTEND_POS6Y, _("Rotate Screen"), 0);
if( getMiddleClickRotate() )
{ // right-click orders
addTextButton(FRONTEND_MMROTATE_R, FRONTEND_POS2M-25, FRONTEND_POS6Y, _("Middle Mouse"), 0);
}
else
{ // left-click orders
addTextButton(FRONTEND_MMROTATE_R, FRONTEND_POS2M-25, FRONTEND_POS6Y, _("Right Mouse"), 0);
}
// Add some text down the side of the form // Add some text down the side of the form
addSideText(FRONTEND_SIDETEXT, FRONTEND_SIDEX, FRONTEND_SIDEY, _("MOUSE OPTIONS")); addSideText(FRONTEND_SIDETEXT, FRONTEND_SIDEX, FRONTEND_SIDEY, _("MOUSE OPTIONS"));
@ -1066,6 +1078,20 @@ BOOL runMouseOptionsMenu(void)
} }
break; break;
case FRONTEND_MMROTATE:
case FRONTEND_MMROTATE_R:
if( getMiddleClickRotate() )
{
setMiddleClickRotate(false);
widgSetString(psWScreen,FRONTEND_MMROTATE_R, _("Right Mouse"));
}
else
{
setMiddleClickRotate(true);
widgSetString(psWScreen,FRONTEND_MMROTATE_R, _("Middle Mouse"));
}
break;
case FRONTEND_QUIT: case FRONTEND_QUIT:
changeTitleMode(OPTIONS); changeTitleMode(OPTIONS);
break; break;

View File

@ -233,6 +233,8 @@ enum
FRONTEND_MFLIP_R, FRONTEND_MFLIP_R,
FRONTEND_MBUTTONS, FRONTEND_MBUTTONS,
FRONTEND_MBUTTONS_R, FRONTEND_MBUTTONS_R,
FRONTEND_MMROTATE,
FRONTEND_MMROTATE_R,
FRONTEND_KEYMAP = 26000, // Keymap menu FRONTEND_KEYMAP = 26000, // Keymap menu
FRONTEND_NOGAMESAVAILABLE = 31666 // Used when no games are available in lobby FRONTEND_NOGAMESAVAILABLE = 31666 // Used when no games are available in lobby