Skip to content

Commit 64d9b08

Browse files
authored
bugfix(mouse): Make Cursor Capture opt-in to prevent capture in GUIEdit (TheSuperHackers#2187)
1 parent aa37f91 commit 64d9b08

6 files changed

Lines changed: 12 additions & 16 deletions

File tree

Generals/Code/GameEngine/Include/GameClient/Mouse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ class Mouse : public SubsystemInterface
285285
virtual void setPosition( Int x, Int y ); ///< set the mouse position
286286
virtual void setCursor( MouseCursor cursor ) = 0; ///< set mouse cursor
287287

288+
void initCapture(); ///< called once to unlock the mouse capture functionality
288289
void setCursorCaptureMode(CursorCaptureMode mode); ///< set the rules for the mouse capture
289290
void refreshCursorCapture(); ///< refresh the mouse capture
290291
Bool isCursorCaptured(); ///< true if the mouse is captured in the game window
@@ -348,7 +349,6 @@ class Mouse : public SubsystemInterface
348349

349350
protected:
350351

351-
void initCapture();
352352
Bool canCapture() const; ///< true if the mouse can be captured
353353
void unblockCapture(CursorCaptureBlockReason reason); // unset a reason to block mouse capture
354354
void blockCapture(CursorCaptureBlockReason reason); // set a reason to block mouse capture

Generals/Code/GameEngine/Source/GameClient/GameClient.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,15 @@ void GameClient::init( void )
378378
TheRayEffects->setName("TheRayEffects");
379379
}
380380

381-
TheMouse->init(); //finish initializing the mouse.
382-
383381
// set the limits of the mouse now that we've created the display and such
384382
if( TheMouse )
385383
{
384+
// finish initializing the mouse.
385+
TheMouse->init();
386+
TheMouse->initCapture();
386387
TheMouse->setPosition( 0, 0 );
387388
TheMouse->setMouseLimits();
388-
TheMouse->setName("TheMouse");
389+
TheMouse->setName("TheMouse");
389390
}
390391

391392
// create the video player

Generals/Code/GameEngine/Source/GameClient/Input/Mouse.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ Mouse::Mouse( void )
520520
m_tooltipBackColor.blue = 0;
521521
m_tooltipBackColor.alpha = 255;
522522

523-
m_cursorCaptureMode = CursorCaptureMode_Default;
523+
m_cursorCaptureMode = 0;
524524

525525
m_captureBlockReasonBits = (1 << CursorCaptureBlockReason_NoInit);
526526
DEBUG_LOG(("Mouse::Mouse: m_blockCaptureReason=CursorCaptureBlockReason_NoInit"));
@@ -582,9 +582,6 @@ void Mouse::init( void )
582582

583583
// allocate a new display string
584584
m_cursorTextDisplayString = TheDisplayStringManager->newDisplayString();
585-
586-
initCapture();
587-
588585
}
589586

590587
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Include/GameClient/Mouse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ class Mouse : public SubsystemInterface
285285
virtual void setPosition( Int x, Int y ); ///< set the mouse position
286286
virtual void setCursor( MouseCursor cursor ) = 0; ///< set mouse cursor
287287

288+
void initCapture(); ///< called once to unlock the mouse capture functionality
288289
void setCursorCaptureMode(CursorCaptureMode mode); ///< set the rules for the mouse capture
289290
void refreshCursorCapture(); ///< refresh the mouse capture
290291
Bool isCursorCaptured(); ///< true if the mouse is captured in the game window
@@ -349,7 +350,6 @@ class Mouse : public SubsystemInterface
349350

350351
protected:
351352

352-
void initCapture();
353353
Bool canCapture() const; ///< true if the mouse can be captured
354354
void unblockCapture(CursorCaptureBlockReason reason); // unset a reason to block mouse capture
355355
void blockCapture(CursorCaptureBlockReason reason); // set a reason to block mouse capture

GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,14 +391,15 @@ void GameClient::init( void )
391391
TheRayEffects->setName("TheRayEffects");
392392
}
393393

394-
TheMouse->init(); //finish initializing the mouse.
395-
396394
// set the limits of the mouse now that we've created the display and such
397395
if( TheMouse )
398396
{
397+
// finish initializing the mouse.
398+
TheMouse->init();
399+
TheMouse->initCapture();
399400
TheMouse->setPosition( 0, 0 );
400401
TheMouse->setMouseLimits();
401-
TheMouse->setName("TheMouse");
402+
TheMouse->setName("TheMouse");
402403
}
403404

404405
// create the video player

GeneralsMD/Code/GameEngine/Source/GameClient/Input/Mouse.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ Mouse::Mouse( void )
520520
m_tooltipBackColor.blue = 0;
521521
m_tooltipBackColor.alpha = 255;
522522

523-
m_cursorCaptureMode = CursorCaptureMode_Default;
523+
m_cursorCaptureMode = 0;
524524

525525
m_captureBlockReasonBits = (1 << CursorCaptureBlockReason_NoInit);
526526
DEBUG_LOG(("Mouse::Mouse: m_blockCaptureReason=CursorCaptureBlockReason_NoInit"));
@@ -582,9 +582,6 @@ void Mouse::init( void )
582582

583583
// allocate a new display string
584584
m_cursorTextDisplayString = TheDisplayStringManager->newDisplayString();
585-
586-
initCapture();
587-
588585
}
589586

590587
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)