diff --git a/Packaging/resources/assets/ui_art/button.png b/Packaging/resources/assets/ui_art/button.png index bb8a07544..96f908ca8 100644 Binary files a/Packaging/resources/assets/ui_art/button.png and b/Packaging/resources/assets/ui_art/button.png differ diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 110238dd2..cf20d1d0a 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -30,6 +30,7 @@ bool sgbTouchActive = false; bool sgbControllerActive = false; Point speedspellscoords[50]; int speedspellcount = 0; +int pcurstrig = -1; /** * Native game menu, controlled by simulating a keyboard. @@ -374,7 +375,6 @@ void FindActor() } int pcursmissile; -int pcurstrig; quest_id pcursquest; void FindTrigger() diff --git a/Source/controls/touch/renderers.cpp b/Source/controls/touch/renderers.cpp index e10eb703f..216437da5 100644 --- a/Source/controls/touch/renderers.cpp +++ b/Source/controls/touch/renderers.cpp @@ -45,7 +45,7 @@ VirtualGamepadButtonType GetCastButtonType(bool isPressed) return isPressed ? GAMEPAD_CASTSPELLDOWN : GAMEPAD_CASTSPELL; } -VirtualGamepadButtonType GetCancelButtonType(bool isPressed) +VirtualGamepadButtonType GetBackButtonType(bool isPressed) { return isPressed ? GAMEPAD_BACKDOWN : GAMEPAD_BACK; } @@ -55,9 +55,34 @@ VirtualGamepadButtonType GetBlankButtonType(bool isPressed) return isPressed ? GAMEPAD_BLANKDOWN : GAMEPAD_BLANK; } +VirtualGamepadButtonType GetApplyButtonType(bool isPressed) +{ + return isPressed ? GAMEPAD_APPLYDOWN : GAMEPAD_APPLY; +} + +VirtualGamepadButtonType GetEquipButtonType(bool isPressed) +{ + return isPressed ? GAMEPAD_EQUIPDOWN : GAMEPAD_EQUIP; +} + +VirtualGamepadButtonType GetDropButtonType(bool isPressed) +{ + return isPressed ? GAMEPAD_DROPDOWN : GAMEPAD_DROP; +} + +VirtualGamepadButtonType GetStairsButtonType(bool isPressed) +{ + return isPressed ? GAMEPAD_STAIRSDOWN : GAMEPAD_STAIRS; +} + +VirtualGamepadButtonType GetStandButtonType(bool isPressed) +{ + return isPressed ? GAMEPAD_STANDDOWN : GAMEPAD_STAND; +} + void LoadButtonArt(Art *buttonArt, SDL_Renderer *renderer) { - const int Frames = 14; + const int Frames = 24; buttonArt->surface.reset(LoadPNG("ui_art\\button.png")); if (buttonArt->surface == nullptr) return; @@ -351,21 +376,50 @@ VirtualGamepadButtonType PrimaryActionButtonRenderer::GetInventoryButtonType() return GetBlankButtonType(virtualPadButton->isHeld); } +extern int pcurstrig; + VirtualGamepadButtonType SecondaryActionButtonRenderer::GetButtonType() { - // NEED: Stairs surface + if (pcurstrig != -1) + return GetStairsButtonType(virtualPadButton->isHeld); if (InGameMenu() || QuestLogIsOpen || sbookflag) return GetBlankButtonType(virtualPadButton->isHeld); if (pcursobj != -1) return GetObjectButtonType(virtualPadButton->isHeld); if (pcursitem != -1) return GetItemButtonType(virtualPadButton->isHeld); + if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) + return GetApplyButtonType(virtualPadButton->isHeld); + + if (pcursinvitem != -1) { + Item *item; + if (pcursinvitem < INVITEM_INV_FIRST) + item = &MyPlayer->InvBody[pcursinvitem]; + else if (pcursinvitem <= INVITEM_INV_LAST) + item = &MyPlayer->InvList[pcursinvitem - INVITEM_INV_FIRST]; + else + item = &MyPlayer->SpdList[pcursinvitem - INVITEM_BELT_FIRST]; + + if (!item->IsScroll() || !spelldata[item->_iSpell].sTargeted) { + if (!item->isEquipment()) { + return GetApplyButtonType(virtualPadButton->isHeld); + } + } + } + return GetBlankButtonType(virtualPadButton->isHeld); } VirtualGamepadButtonType SpellActionButtonRenderer::GetButtonType() { - if (!InGameMenu() && !QuestLogIsOpen && !sbookflag) + if (pcurs >= CURSOR_FIRSTITEM) + return GetDropButtonType(virtualPadButton->isHeld); + + if (pcursinvitem != -1 && pcurs == CURSOR_HAND) { + return GetEquipButtonType(virtualPadButton->isHeld); + } + + if (!invflag && !InGameMenu() && !QuestLogIsOpen && !sbookflag) return GetCastButtonType(virtualPadButton->isHeld); return GetBlankButtonType(virtualPadButton->isHeld); } @@ -373,9 +427,9 @@ VirtualGamepadButtonType SpellActionButtonRenderer::GetButtonType() VirtualGamepadButtonType CancelButtonRenderer::GetButtonType() { if (InGameMenu()) - return GetCancelButtonType(virtualPadButton->isHeld); + return GetBackButtonType(virtualPadButton->isHeld); if (DoomFlag || invflag || sbookflag || QuestLogIsOpen || chrflag) - return GetCancelButtonType(virtualPadButton->isHeld); + return GetBackButtonType(virtualPadButton->isHeld); return GetBlankButtonType(virtualPadButton->isHeld); } diff --git a/Source/controls/touch/renderers.h b/Source/controls/touch/renderers.h index 8af22142f..0da22ff33 100644 --- a/Source/controls/touch/renderers.h +++ b/Source/controls/touch/renderers.h @@ -25,6 +25,16 @@ enum VirtualGamepadButtonType { GAMEPAD_BACKDOWN, GAMEPAD_BLANK, GAMEPAD_BLANKDOWN, + GAMEPAD_APPLY, + GAMEPAD_APPLYDOWN, + GAMEPAD_EQUIP, + GAMEPAD_EQUIPDOWN, + GAMEPAD_DROP, + GAMEPAD_DROPDOWN, + GAMEPAD_STAIRS, + GAMEPAD_STAIRSDOWN, + GAMEPAD_STAND, + GAMEPAD_STANDDOWN, }; enum VirtualGamepadPotionType {