From 44eccb5eab5a909a462298d0ff06da559608685a Mon Sep 17 00:00:00 2001 From: Shadooow Date: Thu, 27 Jan 2022 22:02:13 +0000 Subject: [PATCH] Adds mouse wheel functionality to AIM member page when hovering mouse over the merc photo and for browsing Bobby Rays inventory pages. If mouse is over an item's big picture, 'ctrl' + mouse wheel will allow adding or removing items from shopping cart (by Asdow). git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9283 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/AimMembers.cpp | 122 ++++++++++++++++++++++++++---------------- Laptop/BobbyRGuns.cpp | 63 ++++++++++++++++++++++ 2 files changed, 139 insertions(+), 46 deletions(-) diff --git a/Laptop/AimMembers.cpp b/Laptop/AimMembers.cpp index 93db0671..bb09e343 100644 --- a/Laptop/AimMembers.cpp +++ b/Laptop/AimMembers.cpp @@ -704,6 +704,7 @@ UINT8 GetStatColor( INT8 bStat ); //Hotkey Assignment void HandleAimMemberKeyBoardInput(); +void HandleAimMemberMouseInput(void); void WaitForMercToFinishTalkingOrUserToClick(); @@ -1080,7 +1081,7 @@ void HandleAIMMembers() } HandleAimMemberKeyBoardInput(); - + HandleAimMemberMouseInput(); MarkButtonsDirty( ); } @@ -1757,6 +1758,57 @@ void BtnWeaponboxSelectButtonCallback( GUI_BUTTON *btn, INT32 reason ) } } +void PreviousAimMember(void) +{ + InitCreateDeleteAimPopUpBox(AIM_POPUP_DELETE, NULL, NULL, 0, 0, 0); + + if (gbCurrentIndex > 0) + { + if (_KeyDown(17)) // CTRL + gbCurrentIndex = 0; + else if (_KeyDown(16)) // SHIFT + gbCurrentIndex = __max(gbCurrentIndex - 10, 0); + else + gbCurrentIndex--; + } + else + gbCurrentIndex = MAX_NUMBER_MERCS - 1; + + gfRedrawScreen = TRUE; + + // gbCurrentSoldier = AimMercArray[gbCurrentIndex]; + gbCurrentSoldier = gAimAvailability[AimMercArray[gbCurrentIndex]].ProfilId; + gbCurrentSoldierBio = gAimAvailability[AimMercArray[gbCurrentIndex]].AimBio; + + gubVideoConferencingMode = AIM_VIDEO_NOT_DISPLAYED_MODE; +} + +void NextAimMember(void) +{ + InitCreateDeleteAimPopUpBox(AIM_POPUP_DELETE, NULL, NULL, 0, 0, 0); + + if (gbCurrentIndex < MAX_NUMBER_MERCS - 1) + { + if (_KeyDown(17)) // CTRL + gbCurrentIndex = MAX_NUMBER_MERCS - 1; + else if (_KeyDown(16)) // SHIFT + gbCurrentIndex = __min(MAX_NUMBER_MERCS - 1, gbCurrentIndex + 10); + else + gbCurrentIndex++; + } + else + gbCurrentIndex = 0; + + // gbCurrentSoldier = AimMercArray[gbCurrentIndex]; + gbCurrentSoldier = gAimAvailability[AimMercArray[gbCurrentIndex]].ProfilId; + + gbCurrentSoldierBio = gAimAvailability[AimMercArray[gbCurrentIndex]].AimBio; + + gfRedrawScreen = TRUE; + + gubVideoConferencingMode = AIM_VIDEO_NOT_DISPLAYED_MODE; +} + void BtnPreviousButtonCallback(GUI_BUTTON *btn,INT32 reason) { @@ -1772,28 +1824,7 @@ BOOLEAN Stop = FALSE; if (btn->uiFlags & BUTTON_CLICKED_ON) { btn->uiFlags &= (~BUTTON_CLICKED_ON ); - - InitCreateDeleteAimPopUpBox(AIM_POPUP_DELETE, NULL, NULL, 0, 0, 0); - - if( gbCurrentIndex > 0) - { - if (_KeyDown( 17 ) ) // CTRL - gbCurrentIndex = 0; - else if (_KeyDown( 16 ) ) // SHIFT - gbCurrentIndex = __max(gbCurrentIndex - 10, 0); - else - gbCurrentIndex--; - } - else - gbCurrentIndex = MAX_NUMBER_MERCS - 1; - - gfRedrawScreen = TRUE; - -// gbCurrentSoldier = AimMercArray[gbCurrentIndex]; - gbCurrentSoldier = gAimAvailability[AimMercArray[gbCurrentIndex]].ProfilId; - gbCurrentSoldierBio = gAimAvailability[AimMercArray[gbCurrentIndex]].AimBio; - - gubVideoConferencingMode = AIM_VIDEO_NOT_DISPLAYED_MODE; + PreviousAimMember(); InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY); } } @@ -1854,29 +1885,7 @@ BOOLEAN Stop = FALSE; if (btn->uiFlags & BUTTON_CLICKED_ON) { btn->uiFlags &= (~BUTTON_CLICKED_ON ); - InitCreateDeleteAimPopUpBox(AIM_POPUP_DELETE, NULL, NULL, 0, 0, 0); - - if( gbCurrentIndex < MAX_NUMBER_MERCS - 1 ) - { - if (_KeyDown( 17 ) ) // CTRL - gbCurrentIndex = MAX_NUMBER_MERCS - 1; - else if (_KeyDown( 16 ) ) // SHIFT - gbCurrentIndex = __min(MAX_NUMBER_MERCS - 1, gbCurrentIndex + 10); - else - gbCurrentIndex++; - } - else - gbCurrentIndex = 0; - -// gbCurrentSoldier = AimMercArray[gbCurrentIndex]; - gbCurrentSoldier = gAimAvailability[AimMercArray[gbCurrentIndex]].ProfilId; - - gbCurrentSoldierBio = gAimAvailability[AimMercArray[gbCurrentIndex]].AimBio; - - gfRedrawScreen = TRUE; - - gubVideoConferencingMode = AIM_VIDEO_NOT_DISPLAYED_MODE; - + NextAimMember(); InvalidateRegion(btn->Area.RegionTopLeftX, btn->Area.RegionTopLeftY, btn->Area.RegionBottomRightX, btn->Area.RegionBottomRightY); } } @@ -5215,6 +5224,27 @@ void HandleAimMemberKeyBoardInput() } +void HandleAimMemberMouseInput(void) +{ + gSelectedFaceRegion.WheelState = gSelectedFaceRegion.WheelState * (gGameSettings.fOptions[TOPTION_INVERT_WHEEL] ? -1 : 1); + + if (gSelectedFaceRegion.uiFlags & MSYS_MOUSE_IN_AREA) + { + if (gSelectedFaceRegion.WheelState != 0) + { + if (gSelectedFaceRegion.WheelState > 0) + { + PreviousAimMember(); + } + else + { + NextAimMember(); + } + ResetWheelState(&gSelectedFaceRegion); + } + } +} + void WaitForMercToFinishTalkingOrUserToClick() { //if the region is not active diff --git a/Laptop/BobbyRGuns.cpp b/Laptop/BobbyRGuns.cpp index adda90a6..154e419d 100644 --- a/Laptop/BobbyRGuns.cpp +++ b/Laptop/BobbyRGuns.cpp @@ -364,6 +364,7 @@ void GetHelpTextForItemInLaptop( STR16 pzStr, UINT16 usItemNumber ); //Hotkey Assignment void HandleBobbyRGunsKeyBoardInput(); +void HandleBobbyRayMouseWheel(void); void GameInitBobbyRGuns() { @@ -447,6 +448,7 @@ void HandleBobbyRGuns() { //Hotkey Assignment HandleBobbyRGunsKeyBoardInput(); + HandleBobbyRayMouseWheel(); } void RenderBobbyRGuns() @@ -4027,6 +4029,67 @@ void HandleBobbyRGunsKeyBoardInput() } } +void HandleBobbyRayMouseWheel(void) +{ + // Purchase and unpurchase via mousewheel if pressing ctrl + for (size_t i = 0; i < BOBBYR_NUM_WEAPONS_ON_PAGE; i++) + { + auto &mouseRegion = gSelectedBigImageRegion[i]; + auto wheelState = mouseRegion.WheelState * (gGameSettings.fOptions[TOPTION_INVERT_WHEEL] ? -1 : 1); + if (mouseRegion.uiFlags & MSYS_MOUSE_IN_AREA) + { + if (_KeyDown(17)) // CTRL + { + UINT16 usItemNum = (UINT16)MSYS_GetRegionUserData(&mouseRegion, 0); + if (wheelState < 0) + { + PurchaseBobbyRayItem(gusItemNumberForItemsOnScreen[usItemNum], FALSE); + } + else if (wheelState > 0) + { + UnPurchaseBobbyRayItem(gusItemNumberForItemsOnScreen[usItemNum], FALSE); + } + ResetWheelState(&mouseRegion); + + fReDrawScreenFlag = TRUE; + fPausedReDrawScreenFlag = TRUE; + } + } + } + + // Scroll through pages with regular mouse wheel + SGPPoint MousePos; + GetMousePos(&MousePos); + const auto x = MousePos.iX; + const auto y = MousePos.iY; + if ( (LAPTOP_SCREEN_UL_X < x && x < LAPTOP_SCREEN_LR_X) && (LAPTOP_SCREEN_WEB_UL_Y < y && y < LAPTOP_SCREEN_WEB_LR_Y) ) + { + if (!_KeyDown(17)) // CTRL + { + const auto Wheelstate = _WheelValue * (gGameSettings.fOptions[TOPTION_INVERT_WHEEL] ? -1 : 1); + if (Wheelstate < 0) + { + if (gubCurPage < gubNumPages - 1) + { + gubCurPage++; + fReDrawScreenFlag = TRUE; + fPausedReDrawScreenFlag = TRUE; + } + } + else if (Wheelstate > 0) + { + if (gubCurPage > 0) + { + gubCurPage--; + fReDrawScreenFlag = TRUE; + fPausedReDrawScreenFlag = TRUE; + } + } + } + _WheelValue = 0; + } +} + void GetHelpTextForItemInLaptop( STR16 pzStr, UINT16 usItemNumber ) { CHAR16 zItemName[ SIZE_ITEM_NAME ];