diff --git a/Editor/messagebox.cpp b/Editor/messagebox.cpp index 2a2b5eaf..aab02a52 100644 --- a/Editor/messagebox.cpp +++ b/Editor/messagebox.cpp @@ -113,7 +113,7 @@ BOOLEAN MessageBoxHandled() void RemoveMessageBox( ) { - FreeMouseCursor( ); + FreeMouseCursor( FALSE ); RemoveButton( iMsgBoxCancel ); RemoveButton( iMsgBoxOk ); RemoveButton( iMsgBoxBgrnd ); diff --git a/Laptop/laptop.cpp b/Laptop/laptop.cpp index fbd5958d..78367cbb 100644 --- a/Laptop/laptop.cpp +++ b/Laptop/laptop.cpp @@ -1106,7 +1106,7 @@ void ExitLaptop() //} // release cursor - FreeMouseCursor( ); + FreeMouseCursor( FALSE ); // set the fact we are currently not in laptop, for rendering purposes fCurrentlyInLaptop = FALSE; @@ -6029,13 +6029,13 @@ void HandleKeyBoardShortCutsForLapTop( UINT16 usEvent, UINT32 usParam, UINT16 us MarkButtonsDirty( ); } } - else if( ( ( usEvent == KEY_DOWN ) || ( usEvent == KEY_REPEAT ) ) && ( ( usParam == 'z' ) || ( usParam == 'y' ) ) ) + else if( ( ( usEvent == KEY_DOWN ) || ( usEvent == KEY_REPEAT ) ) && ( usParam == 'z' ) ) { if ( usKeyState & CTRL_DOWN ) { if( IsCursorRestricted( ) ) { - FreeMouseCursor( ); + FreeMouseCursor( FALSE ); } else { diff --git a/MPChatScreen.cpp b/MPChatScreen.cpp index f9ff8e9b..48a86b22 100644 --- a/MPChatScreen.cpp +++ b/MPChatScreen.cpp @@ -322,7 +322,7 @@ INT32 DoChatBox( bool bIncludeChatLog, const STR16 zString, UINT32 uiExitScreen, { fCursorLockedToArea = TRUE; GetRestrictedClipCursor( &ChatBoxRestrictedCursorRegion ); - FreeMouseCursor( ); + FreeMouseCursor( FALSE ); } // vars for positioning controls on the chatbox @@ -501,7 +501,7 @@ INT32 DoChatBox( bool bIncludeChatLog, const STR16 zString, UINT32 uiExitScreen, // Save mouse restriction region... GetRestrictedClipCursor( &gOldCursorLimitRectangle ); - FreeMouseCursor( ); + FreeMouseCursor( FALSE ); gfNewChatBox = TRUE; diff --git a/MessageBoxScreen.cpp b/MessageBoxScreen.cpp index 79fdd803..fba9f67b 100644 --- a/MessageBoxScreen.cpp +++ b/MessageBoxScreen.cpp @@ -318,7 +318,7 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN { fCursorLockedToArea = TRUE; GetRestrictedClipCursor( &MessageBoxRestrictedCursorRegion ); - FreeMouseCursor( ); + FreeMouseCursor( FALSE ); } // Create four numbered buttons @@ -798,7 +798,7 @@ INT32 DoMessageBox( UINT8 ubStyle, const STR16 zString, UINT32 uiExitScreen, UIN // Save mouse restriction region... GetRestrictedClipCursor( &gOldCursorLimitRectangle ); - FreeMouseCursor( ); + FreeMouseCursor( FALSE ); gfNewMessageBox = TRUE; diff --git a/Standard Gaming Platform/input.cpp b/Standard Gaming Platform/input.cpp index 012ddf98..043b8a11 100644 --- a/Standard Gaming Platform/input.cpp +++ b/Standard Gaming Platform/input.cpp @@ -50,7 +50,8 @@ extern BOOLEAN gfApplicationActive; BOOLEAN gfKeyState[256]; // TRUE = Pressed, FALSE = Not Pressed BOOLEAN fCursorWasClipped = FALSE; RECT gCursorClipRect; - +extern BOOLEAN gfMouseLockedOnBorder; +extern int iWindowedMode; // The gsKeyTranslationTables basically translates scan codes to our own key value table. Please note that the table is 2 bytes @@ -1590,10 +1591,23 @@ void RestrictMouseCursor(SGPRect *pRectangle) fCursorWasClipped = TRUE; } -void FreeMouseCursor(void) +void FreeMouseCursor( BOOLEAN fLockForTacticalWindowedMode ) { ClipCursor(NULL); fCursorWasClipped = FALSE; + + // Buggler: Need to relock for fullscreen mode as ClipCursor release mouse boundary to full desktop resolution on multi-monitor setup && + // for windowed mode, lockscreen only when player activates feature in tactical screen due to mouse restriction applies to desktop too! + if ( !iWindowedMode || ( iWindowedMode && gfMouseLockedOnBorder && fLockForTacticalWindowedMode ) ) + { + SGPRect LJDRect; + + LJDRect.iLeft = 0; + LJDRect.iTop = 0; + LJDRect.iRight = SCREEN_WIDTH; + LJDRect.iBottom = SCREEN_HEIGHT; + RestrictMouseCursor( &LJDRect ); + } } void RestoreCursorClipRect( void ) diff --git a/Standard Gaming Platform/input.h b/Standard Gaming Platform/input.h index 4c65edb2..ab20d26f 100644 --- a/Standard Gaming Platform/input.h +++ b/Standard Gaming Platform/input.h @@ -105,7 +105,7 @@ extern BOOLEAN DequeueSpecificEvent(InputAtom *Event, UINT32 uiMaskFlags ); extern void RestrictMouseToXYXY(UINT16 usX1, UINT16 usY1, UINT16 usX2, UINT16 usY2); extern void RestrictMouseCursor(SGPRect *pRectangle); -extern void FreeMouseCursor(void); +extern void FreeMouseCursor( BOOLEAN fLockForTacticalWindowedMode ); extern BOOLEAN IsCursorRestricted( void ); extern void GetRestrictedClipCursor( SGPRect *pRectangle ); extern void RestoreCursorClipRect( void ); diff --git a/Standard Gaming Platform/sgp.cpp b/Standard Gaming Platform/sgp.cpp index ded1d9fd..bd8afa68 100644 --- a/Standard Gaming Platform/sgp.cpp +++ b/Standard Gaming Platform/sgp.cpp @@ -567,7 +567,7 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP SuspendVideoManager(); } gfApplicationActive=FALSE; - FreeMouseCursor(); + FreeMouseCursor( FALSE ); #endif // Set a flag to restore surfaces once a WM_ACTIVEATEAPP is received fRestore = TRUE; diff --git a/Standard Gaming Platform/video.cpp b/Standard Gaming Platform/video.cpp index 5b1d6e3a..11fee320 100644 --- a/Standard Gaming Platform/video.cpp +++ b/Standard Gaming Platform/video.cpp @@ -715,7 +715,7 @@ void ShutdownVideoManager(void) } // ATE: Release mouse cursor! - FreeMouseCursor( ); + FreeMouseCursor( FALSE ); UnRegisterDebugTopic(TOPIC_VIDEO, "Video"); } diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index 888ab3c0..dc362774 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -4163,7 +4163,7 @@ void CancelInventoryZoomInput( BOOLEAN fButtonOff ) // behave normally. fWaitingForZoomInput = 0; // Free up the mouse! - FreeMouseCursor(); + FreeMouseCursor( FALSE ); } // HEADROCK HAM 5: This function handles animation from Unzoomed inventory mode to Zoomed inventory mode. diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 6e58d163..ee5e631a 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -14469,7 +14469,7 @@ void ChangeMapScreenMaskCursor( UINT16 usCursor ) if ( !InItemStackPopup( ) ) { // cancel mouse restriction - FreeMouseCursor(); + FreeMouseCursor( FALSE ); } } else diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index 998dbd94..ef2f7e6b 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -5528,7 +5528,7 @@ void EndRubberBanding( ) { if ( gRubberBandActive ) { - FreeMouseCursor( ); + FreeMouseCursor( TRUE ); gfIgnoreScrolling = FALSE; EndMultiSoldierSelection( TRUE ); diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 197ba959..5e1c0716 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -9440,7 +9440,7 @@ void DeleteItemStackPopup( ) EnableSMPanelButtons( TRUE, FALSE ); } - FreeMouseCursor( ); + FreeMouseCursor( TRUE ); } @@ -9686,7 +9686,7 @@ void DeleteKeyRingPopup( ) EnableSMPanelButtons( TRUE, FALSE ); } - FreeMouseCursor( ); + FreeMouseCursor( TRUE ); } UINT32 GetInterfaceGraphicForItem( INVTYPE *pItem ) diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index c15fdc7c..796d926f 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -3980,7 +3980,7 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason ) { //the only way to merge items is to pick them up. In SKI when you pick up an item, the cursor is //locked in a region, free it up. - FreeMouseCursor(); + FreeMouseCursor( TRUE ); DoMessageBox( MSG_BOX_BASIC_STYLE, Message[ STR_MERGE_ITEMS ], SHOPKEEPER_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, MergeMessageBoxCallBack, NULL ); } @@ -7773,7 +7773,7 @@ void SMInvMoneyButtonCallback( MOUSE_REGION * pRegion, INT32 iReason ) //if we are in the shop keeper interface, free the cursor if( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) { - FreeMouseCursor(); + FreeMouseCursor( TRUE ); } DoMessageBox( MSG_BOX_BASIC_STYLE, zText, SHOPKEEPER_SCREEN, ( UINT8 )MSG_BOX_FLAG_YESNO, ConfirmationToDepositMoneyToPlayersAccount, NULL ); diff --git a/Tactical/ShopKeeper Interface.cpp b/Tactical/ShopKeeper Interface.cpp index fb6dd734..1f5c69e2 100644 --- a/Tactical/ShopKeeper Interface.cpp +++ b/Tactical/ShopKeeper Interface.cpp @@ -1333,7 +1333,7 @@ BOOLEAN ExitShopKeeperInterface() DeleteItemDescriptionBox( ); } - FreeMouseCursor(); + FreeMouseCursor( TRUE ); //Delete the main shopkeep background DeleteVideoObjectFromIndex( guiMainTradeScreenImage ); @@ -4824,7 +4824,7 @@ void SetSkiCursor( UINT16 usCursor ) SetCurrentCursorFromDatabase( usCursor ); - FreeMouseCursor(); + FreeMouseCursor( TRUE ); EnableAllDealersInventorySlots(); EnableAllDealersOfferSlots(); diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 9c296392..3d9d8b92 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -193,6 +193,9 @@ extern INT16 ITEMDESC_START_Y; BOOLEAN gfMouseLockedOnBorder = FALSE; extern int iWindowedMode; +extern BOOLEAN gfInItemStackPopup; +extern BOOLEAN gfInKeyRingPopup; + //Little functions called by keyboard input void SwapGoggles(SOLDIERTYPE *pTeamSoldier); @@ -1605,25 +1608,26 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) // BEGIN: by Lejardo for mouse-locking in game screen // WANNE: If the game runs in windowed mode, the user can "lock" / "unlock" the mouse cursor - if (iWindowedMode) + if ( iWindowedMode && !gfInKeyRingPopup && !gfInItemStackPopup) { - SGPRect LJDRect; - if ((InputEvent.usEvent == KEY_DOWN ) && ( InputEvent.usParam == 'z' || InputEvent.usParam == 'y')) + if ((InputEvent.usEvent == KEY_DOWN ) && InputEvent.usParam == 'z' ) { if( (InputEvent.usKeyState & CTRL_DOWN) && !(InputEvent.usKeyState & ALT_DOWN)) { // Unlock the mouse cursor if (gfMouseLockedOnBorder) { - FreeMouseCursor(); + FreeMouseCursor( FALSE ); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[MSG_WINDOWED_MODE_RELEASE_MOUSE] ); } // Lock the mouse cursor else - { + { + SGPRect LJDRect; + LJDRect.iLeft = 0; - LJDRect.iTop = 0; + LJDRect.iTop = 0; LJDRect.iRight = SCREEN_WIDTH; LJDRect.iBottom = SCREEN_HEIGHT; RestrictMouseCursor( &LJDRect ); @@ -1631,8 +1635,8 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[MSG_WINDOWED_MODE_LOCK_MOUSE] ); } - gfMouseLockedOnBorder = !gfMouseLockedOnBorder; - } + gfMouseLockedOnBorder = !gfMouseLockedOnBorder; + } } } // END: by Lejardo for mouse-locking in game screen