From 120993c9a9f22b246836cd5559a6cbed0bc9cb9c Mon Sep 17 00:00:00 2001 From: Nick Wicked <129680905+wkdgmr@users.noreply.github.com> Date: Thu, 14 Aug 2025 17:19:08 -0400 Subject: [PATCH] Fix Automap movement being hardcoded to right stick on gamepad (#7921) --- Source/controls/game_controls.cpp | 4 +- Source/controls/plrctrls.cpp | 49 +++++++++------- Source/cursor.cpp | 2 +- Source/diablo.cpp | 92 +++++++++++++++++++------------ Source/diablo.h | 4 +- Source/init.cpp | 2 +- Source/objects.cpp | 2 +- Source/player.cpp | 12 ++-- Source/qol/itemlabels.cpp | 2 +- Source/track.cpp | 26 ++++----- Source/track.h | 2 +- 11 files changed, 115 insertions(+), 82 deletions(-) diff --git a/Source/controls/game_controls.cpp b/Source/controls/game_controls.cpp index 3d5dcc352..60b136d08 100644 --- a/Source/controls/game_controls.cpp +++ b/Source/controls/game_controls.cpp @@ -166,7 +166,7 @@ bool GetGameAction(const SDL_Event &event, ControllerButtonEvent ctrlEvent, Game || (!VirtualGamepadState.secondaryActionButton.isHeld && ControllerActionHeld == GameActionType_SECONDARY_ACTION) || (!VirtualGamepadState.spellActionButton.isHeld && ControllerActionHeld == GameActionType_CAST_SPELL)) { ControllerActionHeld = GameActionType_NONE; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; } } } @@ -265,7 +265,7 @@ void PressControllerButton(ControllerButton button) switch (button) { case devilution::ControllerButton_BUTTON_DPAD_UP: PressEscKey(); - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; PadHotspellMenuActive = false; PadMenuNavigatorActive = false; gamemenu_on(); diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 1b71f731e..40fc7145e 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -516,7 +516,7 @@ void Interact() } NetSendCmdLoc(MyPlayerId, true, myPlayer.UsesRangedWeapon() ? CMD_RATTACKXY : CMD_SATTACKXY, position); - LastMouseButtonAction = MouseActionType::Attack; + LastPlayerAction = PlayerActionType::Attack; return; } @@ -526,19 +526,19 @@ void Interact() } else { NetSendCmdParam1(true, CMD_RATTACKID, pcursmonst); } - LastMouseButtonAction = MouseActionType::AttackMonsterTarget; + LastPlayerAction = PlayerActionType::AttackMonsterTarget; return; } if (leveltype != DTYPE_TOWN && PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) { NetSendCmdParam1(true, myPlayer.UsesRangedWeapon() ? CMD_RATTACKPID : CMD_ATTACKPID, PlayerUnderCursor->getId()); - LastMouseButtonAction = MouseActionType::AttackPlayerTarget; + LastPlayerAction = PlayerActionType::AttackPlayerTarget; return; } if (ObjectUnderCursor != nullptr) { NetSendCmdLoc(MyPlayerId, true, CMD_OPOBJXY, cursPosition); - LastMouseButtonAction = MouseActionType::OperateObject; + LastPlayerAction = PlayerActionType::OperateObject; return; } } @@ -1521,6 +1521,23 @@ void ProcessLeftStickOrDPadGameUI() handler(GetLeftStickOrDpadDirection(false)); } +void ProcessAutomapMovementGamepad() +{ + if (!AutomapActive) + return; + + const auto &padmapper = GetOptions().Padmapper; + + if (IsControllerButtonComboPressed(padmapper.ButtonComboForAction("AutomapMoveUp"))) + AutomapUp(); + if (IsControllerButtonComboPressed(padmapper.ButtonComboForAction("AutomapMoveDown"))) + AutomapDown(); + if (IsControllerButtonComboPressed(padmapper.ButtonComboForAction("AutomapMoveLeft"))) + AutomapLeft(); + if (IsControllerButtonComboPressed(padmapper.ButtonComboForAction("AutomapMoveRight"))) + AutomapRight(); +} + void Movement(Player &player) { if (PadMenuNavigatorActive || PadHotspellMenuActive || InGameMenu()) @@ -1827,15 +1844,6 @@ void HandleRightStickMotion() return; } - if (AutomapActive) { // move map - int dx = 0; - int dy = 0; - acc.Pool(&dx, &dy, 32); - AutomapOffset.deltaX += dy + dx; - AutomapOffset.deltaY += dy - dx; - return; - } - { // move cursor InvalidateInventorySlot(); int x = MousePosition.x; @@ -1900,7 +1908,7 @@ void plrctrls_after_check_curs_move() } // While holding the button down we should retain target (but potentially lose it if it dies, goes out of view, etc) - if (ControllerActionHeld != GameActionType_NONE && IsNoneOf(LastMouseButtonAction, MouseActionType::None, MouseActionType::Attack, MouseActionType::Spell)) { + if (ControllerActionHeld != GameActionType_NONE && IsNoneOf(LastPlayerAction, PlayerActionType::None, PlayerActionType::Attack, PlayerActionType::Spell)) { InvalidateTargets(); if (pcursmonst == -1 && ObjectUnderCursor == nullptr && pcursitem == -1 && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && PlayerUnderCursor == nullptr) { @@ -1937,6 +1945,7 @@ void plrctrls_every_frame() { ProcessLeftStickOrDPadGameUI(); HandleRightStickMotion(); + ProcessAutomapMovementGamepad(); } void plrctrls_after_game_logic() @@ -2101,11 +2110,11 @@ void PerformSpellAction() UpdateSpellTarget(myPlayer._pRSpell); CheckPlrSpell(false); if (PlayerUnderCursor != nullptr) - LastMouseButtonAction = MouseActionType::SpellPlayerTarget; + LastPlayerAction = PlayerActionType::SpellPlayerTarget; else if (pcursmonst != -1) - LastMouseButtonAction = MouseActionType::SpellMonsterTarget; + LastPlayerAction = PlayerActionType::SpellMonsterTarget; else - LastMouseButtonAction = MouseActionType::Spell; + LastPlayerAction = PlayerActionType::Spell; } void CtrlUseInvItem() @@ -2188,7 +2197,7 @@ void PerformSecondaryAction() NetSendCmdLocParam1(true, CMD_GOTOAGETITEM, cursPosition, pcursitem); } else if (ObjectUnderCursor != nullptr) { NetSendCmdLoc(MyPlayerId, true, CMD_OPOBJXY, cursPosition); - LastMouseButtonAction = MouseActionType::OperateObject; + LastPlayerAction = PlayerActionType::OperateObject; } else { if (pcursmissile != nullptr) { MakePlrPath(myPlayer, pcursmissile->position.tile, true); @@ -2205,7 +2214,7 @@ void PerformSecondaryAction() void QuickCast(size_t slot) { - MouseActionType prevMouseButtonAction = LastMouseButtonAction; + PlayerActionType prevMouseButtonAction = LastPlayerAction; Player &myPlayer = *MyPlayer; SpellID spell = myPlayer._pSplHotKey[slot]; SpellType spellType = myPlayer._pSplTHotKey[slot]; @@ -2215,7 +2224,7 @@ void QuickCast(size_t slot) } CheckPlrSpell(false, spell, spellType); - LastMouseButtonAction = prevMouseButtonAction; + LastPlayerAction = prevMouseButtonAction; } } // namespace devilution diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 3b9438ecd..28bfb12fe 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -771,7 +771,7 @@ void ShiftToDiamondGridAlignment(Point screenPosition, Point &tile, bool &flipfl */ bool CheckMouseHold(const Point currentTile) { - if ((sgbMouseDown != CLICK_NONE || ControllerActionHeld != GameActionType_NONE) && IsNoneOf(LastMouseButtonAction, MouseActionType::None, MouseActionType::Attack, MouseActionType::Spell)) { + if ((sgbMouseDown != CLICK_NONE || ControllerActionHeld != GameActionType_NONE) && IsNoneOf(LastPlayerAction, PlayerActionType::None, PlayerActionType::Attack, PlayerActionType::Spell)) { InvalidateTargets(); if (pcursmonst == -1 && ObjectUnderCursor == nullptr && pcursitem == -1 && pcursinvitem == -1 && pcursstashitem == StashStruct::EmptyCell && PlayerUnderCursor == nullptr) { diff --git a/Source/diablo.cpp b/Source/diablo.cpp index f509bfd09..a4b858505 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -139,7 +139,7 @@ std::vector DebugCmdsFromCommandLine; GameLogicStep gGameLogicStep = GameLogicStep::None; /** This and the following mouse variables are for handling in-game click-and-hold actions */ -MouseActionType LastMouseButtonAction = MouseActionType::None; +PlayerActionType LastPlayerAction = PlayerActionType::None; // Controller support: Actions to run after updating the cursor state. // Defined in SourceX/controls/plctrls.cpp. @@ -179,7 +179,7 @@ void StartGame(interface_mode uMsg) InitLevelCursor(); sgnTimeoutCurs = CURSOR_NONE; sgbMouseDown = CLICK_NONE; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; } void FreeGame() @@ -224,7 +224,7 @@ bool ProcessInput() #endif CheckCursMove(); plrctrls_after_check_curs_move(); - RepeatMouseAction(); + RepeatPlayerAction(); } return true; @@ -244,7 +244,7 @@ void LeftMouseCmd(bool bShift) if (pcursmonst != -1) NetSendCmdLocParam1(true, CMD_TALKXY, cursPosition, pcursmonst); if (pcursitem == -1 && pcursmonst == -1 && PlayerUnderCursor == nullptr) { - LastMouseButtonAction = MouseActionType::Walk; + LastPlayerAction = PlayerActionType::Walk; NetSendCmdLoc(MyPlayerId, true, CMD_WALKXY, cursPosition); } return; @@ -255,21 +255,21 @@ void LeftMouseCmd(bool bShift) if (pcursitem != -1 && pcurs == CURSOR_HAND && !bShift) { NetSendCmdLocParam1(true, invflag ? CMD_GOTOGETITEM : CMD_GOTOAGETITEM, cursPosition, pcursitem); } else if (ObjectUnderCursor != nullptr && !ObjectUnderCursor->IsDisabled() && (!bShift || (bNear && ObjectUnderCursor->_oBreak == 1))) { - LastMouseButtonAction = MouseActionType::OperateObject; + LastPlayerAction = PlayerActionType::OperateObject; NetSendCmdLoc(MyPlayerId, true, pcurs == CURSOR_DISARM ? CMD_DISARMXY : CMD_OPOBJXY, cursPosition); } else if (myPlayer.UsesRangedWeapon()) { if (bShift) { - LastMouseButtonAction = MouseActionType::Attack; + LastPlayerAction = PlayerActionType::Attack; NetSendCmdLoc(MyPlayerId, true, CMD_RATTACKXY, cursPosition); } else if (pcursmonst != -1) { if (CanTalkToMonst(Monsters[pcursmonst])) { NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst); } else { - LastMouseButtonAction = MouseActionType::AttackMonsterTarget; + LastPlayerAction = PlayerActionType::AttackMonsterTarget; NetSendCmdParam1(true, CMD_RATTACKID, pcursmonst); } } else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) { - LastMouseButtonAction = MouseActionType::AttackPlayerTarget; + LastPlayerAction = PlayerActionType::AttackPlayerTarget; NetSendCmdParam1(true, CMD_RATTACKPID, PlayerUnderCursor->getId()); } } else { @@ -278,23 +278,23 @@ void LeftMouseCmd(bool bShift) if (CanTalkToMonst(Monsters[pcursmonst])) { NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst); } else { - LastMouseButtonAction = MouseActionType::Attack; + LastPlayerAction = PlayerActionType::Attack; NetSendCmdLoc(MyPlayerId, true, CMD_SATTACKXY, cursPosition); } } else { - LastMouseButtonAction = MouseActionType::Attack; + LastPlayerAction = PlayerActionType::Attack; NetSendCmdLoc(MyPlayerId, true, CMD_SATTACKXY, cursPosition); } } else if (pcursmonst != -1) { - LastMouseButtonAction = MouseActionType::AttackMonsterTarget; + LastPlayerAction = PlayerActionType::AttackMonsterTarget; NetSendCmdParam1(true, CMD_ATTACKID, pcursmonst); } else if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) { - LastMouseButtonAction = MouseActionType::AttackPlayerTarget; + LastPlayerAction = PlayerActionType::AttackPlayerTarget; NetSendCmdParam1(true, CMD_ATTACKPID, PlayerUnderCursor->getId()); } } if (!bShift && pcursitem == -1 && ObjectUnderCursor == nullptr && pcursmonst == -1 && PlayerUnderCursor == nullptr) { - LastMouseButtonAction = MouseActionType::Walk; + LastPlayerAction = PlayerActionType::Walk; NetSendCmdLoc(MyPlayerId, true, CMD_WALKXY, cursPosition); } } @@ -318,7 +318,7 @@ bool TryOpenDungeonWithMouse() void LeftMouseDown(uint16_t modState) { - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; if (gmenu_left_mouse(true)) return; @@ -417,7 +417,7 @@ void LeftMouseUp(uint16_t modState) void RightMouseDown(bool isShiftHeld) { - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; if (gmenu_is_active() || sgnTimeoutCurs != CURSOR_NONE || PauseMode == 2 || MyPlayer->_pInvincible) { return; @@ -522,7 +522,7 @@ void PressKey(SDL_Keycode vkey, uint16_t modState) // Disallow player from accessing escape menu during the frames before the death message appears if (vkey == SDLK_ESCAPE && MyPlayer->_pHitPoints > 0) { if (!PressEscKey()) { - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; gamemenu_on(); } return; @@ -683,11 +683,11 @@ void HandleMouseButtonDown(Uint8 button, uint16_t modState) void HandleMouseButtonUp(Uint8 button, uint16_t modState) { if (sgbMouseDown == CLICK_LEFT && button == SDL_BUTTON_LEFT) { - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; sgbMouseDown = CLICK_NONE; LeftMouseUp(modState); } else if (sgbMouseDown == CLICK_RIGHT && button == SDL_BUTTON_RIGHT) { - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; sgbMouseDown = CLICK_NONE; } else { KeymapperRelease(static_cast(button | KeymapperMouseButtonMask)); @@ -1538,7 +1538,7 @@ void HelpKeyPressed() InfoString = StringOrView {}; AddInfoBoxString(_("No help available")); /// BUGFIX: message isn't displayed AddInfoBoxString(_("while in stores")); - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; } else { CloseInventory(); CloseCharPanel(); @@ -1638,7 +1638,7 @@ void DisplaySpellsKeyPressed() } else { SpellSelectFlag = false; } - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; } void SpellBookKeyPressed() @@ -2095,12 +2095,12 @@ void InitPadmapActions() ControllerButton_BUTTON_B, [] { ControllerActionHeld = GameActionType_PRIMARY_ACTION; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; PerformPrimaryAction(); }, [] { ControllerActionHeld = GameActionType_NONE; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; }, CanPlayerTakeAction); options.Padmapper.AddAction( @@ -2110,12 +2110,12 @@ void InitPadmapActions() ControllerButton_BUTTON_Y, [] { ControllerActionHeld = GameActionType_SECONDARY_ACTION; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; PerformSecondaryAction(); }, [] { ControllerActionHeld = GameActionType_NONE; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; }, CanPlayerTakeAction); options.Padmapper.AddAction( @@ -2125,12 +2125,12 @@ void InitPadmapActions() ControllerButton_BUTTON_X, [] { ControllerActionHeld = GameActionType_CAST_SPELL; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; PerformSpellAction(); }, [] { ControllerActionHeld = GameActionType_NONE; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; }, []() { return CanPlayerTakeAction() && !InGameMenu(); }); options.Padmapper.AddAction( @@ -2264,11 +2264,35 @@ void InitPadmapActions() nullptr, []() { return CanPlayerTakeAction() && !InGameMenu(); }); options.Padmapper.AddAction( - "Toggle Automap", + "ToggleAutomap", N_("Toggle automap"), N_("Toggles if automap is displayed."), ControllerButton_BUTTON_LEFTSTICK, DoAutoMap); + options.Padmapper.AddAction( + "AutomapMoveUp", + N_("Automap Move Up"), + N_("Moves the automap up when active."), + ControllerButton_NONE, + [] {}); + options.Padmapper.AddAction( + "AutomapMoveDown", + N_("Automap Move Down"), + N_("Moves the automap down when active."), + ControllerButton_NONE, + [] {}); + options.Padmapper.AddAction( + "AutomapMoveLeft", + N_("Automap Move Left"), + N_("Moves the automap left when active."), + ControllerButton_NONE, + [] {}); + options.Padmapper.AddAction( + "AutomapMoveRight", + N_("Automap Move Right"), + N_("Moves the automap right when active."), + ControllerButton_NONE, + [] {}); options.Padmapper.AddAction( "MouseUp", N_("Move mouse up"), @@ -2302,7 +2326,7 @@ void InitPadmapActions() auto leftMouseUp = [] { ControllerButtonCombo standGroundCombo = GetOptions().Padmapper.ButtonComboForAction("StandGround"); bool standGround = StandToggle || IsControllerButtonComboPressed(standGroundCombo); - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; sgbMouseDown = CLICK_NONE; LeftMouseUp(standGround ? KMOD_SHIFT : KMOD_NONE); }; @@ -2323,12 +2347,12 @@ void InitPadmapActions() auto rightMouseDown = [] { ControllerButtonCombo standGroundCombo = GetOptions().Padmapper.ButtonComboForAction("StandGround"); bool standGround = StandToggle || IsControllerButtonComboPressed(standGroundCombo); - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; sgbMouseDown = CLICK_RIGHT; RightMouseDown(standGround); }; auto rightMouseUp = [] { - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; sgbMouseDown = CLICK_NONE; }; options.Padmapper.AddAction( @@ -2362,7 +2386,7 @@ void InitPadmapActions() auto toggleGameMenu = [] { bool inMenu = gmenu_is_active(); PressEscKey(); - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; PadHotspellMenuActive = false; PadMenuNavigatorActive = false; if (!inMenu) @@ -2775,7 +2799,7 @@ void diablo_pause_game() PauseMode = 2; sound_stop(); qtextflag = false; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; } RedrawEverything(); @@ -2806,7 +2830,7 @@ void diablo_focus_pause() if (!GameWasAlreadyPaused) { PauseMode = 2; sound_stop(); - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; } SVidMute(); @@ -3237,7 +3261,7 @@ void LoadGameLevelCrypt() void LoadGameLevelCalculateCursor() { // Recalculate mouse selection of entities after level change/load - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; sgbMouseDown = CLICK_NONE; ResetItemlabelHighlighted(); // level changed => item changed pcursmonst = -1; // ensure pcurstemp is set to a valid value diff --git a/Source/diablo.h b/Source/diablo.h index e397bcda2..e8f7d35b6 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -51,7 +51,7 @@ enum class GameLogicStep : uint8_t { ProcessMissilesTown, }; -enum class MouseActionType : uint8_t { +enum class PlayerActionType : uint8_t { None, Walk, Spell, @@ -79,7 +79,7 @@ extern clicktype sgbMouseDown; extern uint16_t gnTickDelay; extern char gszProductName[64]; -extern MouseActionType LastMouseButtonAction; +extern PlayerActionType LastPlayerAction; void InitKeymapActions(); void SetCursorPos(Point position); diff --git a/Source/init.cpp b/Source/init.cpp index e5a4b1f5b..4b8934660 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -156,7 +156,7 @@ void MainWndProc(const SDL_Event &event) break; case SDL_WINDOWEVENT_LEAVE: sgbMouseDown = CLICK_NONE; - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; RedrawEverything(); break; case SDL_WINDOWEVENT_CLOSE: diff --git a/Source/objects.cpp b/Source/objects.cpp index 86f3f4d69..2201183e9 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1519,7 +1519,7 @@ void UpdateCircle(Object &circle) } AddMissile(playerOnCircle->position.tile, { 35, 46 }, Direction::South, MissileID::Phasing, TARGET_BOTH, *playerOnCircle, 0, 0); if (playerOnCircle == MyPlayer) { - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; sgbMouseDown = CLICK_NONE; } ClrPlrPath(*playerOnCircle); diff --git a/Source/player.cpp b/Source/player.cpp index c4630859e..9411f8c57 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3188,21 +3188,21 @@ void CheckPlrSpell(bool isShiftHeld, SpellID spellID, SpellType spellType) myPlayer.Say(HeroSpeech::ICantDoThat); break; } - LastMouseButtonAction = MouseActionType::None; + LastPlayerAction = PlayerActionType::None; } return; } const int spellFrom = 0; if (IsWallSpell(spellID)) { - LastMouseButtonAction = MouseActionType::Spell; + LastPlayerAction = PlayerActionType::Spell; Direction sd = GetDirection(myPlayer.position.tile, cursPosition); NetSendCmdLocParam4(true, CMD_SPELLXYD, cursPosition, static_cast(spellID), static_cast(spellType), static_cast(sd), spellFrom); - } else if (pcursmonst != -1 && !isShiftHeld && leveltype != DTYPE_TOWN) { - LastMouseButtonAction = MouseActionType::SpellMonsterTarget; + } else if (pcursmonst != -1 && !isShiftHeld) { + LastPlayerAction = PlayerActionType::SpellMonsterTarget; NetSendCmdParam4(true, CMD_SPELLID, pcursmonst, static_cast(spellID), static_cast(spellType), spellFrom); } else if (PlayerUnderCursor != nullptr && !isShiftHeld && !myPlayer.friendlyMode) { - LastMouseButtonAction = MouseActionType::SpellPlayerTarget; + LastPlayerAction = PlayerActionType::SpellPlayerTarget; NetSendCmdParam4(true, CMD_SPELLPID, PlayerUnderCursor->getId(), static_cast(spellID), static_cast(spellType), spellFrom); } else { Point targetedTile = cursPosition; @@ -3215,7 +3215,7 @@ void CheckPlrSpell(bool isShiftHeld, SpellID spellID, SpellType spellType) targetedTile = myPlayer.position.temp + relativeMove; } } - LastMouseButtonAction = MouseActionType::Spell; + LastPlayerAction = PlayerActionType::Spell; NetSendCmdLocParam3(true, CMD_SPELLXY, targetedTile, static_cast(spellID), static_cast(spellType), spellFrom); } } diff --git a/Source/qol/itemlabels.cpp b/Source/qol/itemlabels.cpp index 240640b65..1f5043ce4 100644 --- a/Source/qol/itemlabels.cpp +++ b/Source/qol/itemlabels.cpp @@ -196,7 +196,7 @@ void DrawItemNameLabels(const Surface &out) && !MyPlayerIsDead && !IsPlayerInStore() && IsMouseOverGameArea() - && LastMouseButtonAction == MouseActionType::None) { + && LastPlayerAction == PlayerActionType::None) { isLabelHighlighted = true; cursPosition = item.position; pcursitem = label.id; diff --git a/Source/track.cpp b/Source/track.cpp index 4aec241fb..437dfe692 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -59,7 +59,7 @@ void InvalidateTargets() } } -void RepeatMouseAction() +void RepeatPlayerAction() { if (pcurs != CURSOR_HAND) return; @@ -70,7 +70,7 @@ void RepeatMouseAction() if (IsPlayerInStore()) return; - if (LastMouseButtonAction == MouseActionType::None) + if (LastPlayerAction == PlayerActionType::None) return; Player &myPlayer = *MyPlayer; @@ -82,49 +82,49 @@ void RepeatMouseAction() return; bool rangedAttack = myPlayer.UsesRangedWeapon(); - switch (LastMouseButtonAction) { - case MouseActionType::Attack: + switch (LastPlayerAction) { + case PlayerActionType::Attack: if (InDungeonBounds(cursPosition)) NetSendCmdLoc(MyPlayerId, true, rangedAttack ? CMD_RATTACKXY : CMD_SATTACKXY, cursPosition); break; - case MouseActionType::AttackMonsterTarget: + case PlayerActionType::AttackMonsterTarget: if (pcursmonst != -1) NetSendCmdParam1(true, rangedAttack ? CMD_RATTACKID : CMD_ATTACKID, pcursmonst); break; - case MouseActionType::AttackPlayerTarget: + case PlayerActionType::AttackPlayerTarget: if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) NetSendCmdParam1(true, rangedAttack ? CMD_RATTACKPID : CMD_ATTACKPID, PlayerUnderCursor->getId()); break; - case MouseActionType::Spell: + case PlayerActionType::Spell: if (ControlMode != ControlTypes::KeyboardAndMouse) { UpdateSpellTarget(MyPlayer->_pRSpell); } CheckPlrSpell(ControlMode == ControlTypes::KeyboardAndMouse); break; - case MouseActionType::SpellMonsterTarget: + case PlayerActionType::SpellMonsterTarget: if (pcursmonst != -1) CheckPlrSpell(false); break; - case MouseActionType::SpellPlayerTarget: + case PlayerActionType::SpellPlayerTarget: if (PlayerUnderCursor != nullptr && !myPlayer.friendlyMode) CheckPlrSpell(false); break; - case MouseActionType::OperateObject: + case PlayerActionType::OperateObject: if (ObjectUnderCursor != nullptr && !ObjectUnderCursor->isDoor()) { NetSendCmdLoc(MyPlayerId, true, CMD_OPOBJXY, cursPosition); } break; - case MouseActionType::Walk: + case PlayerActionType::Walk: RepeatWalk(myPlayer); break; - case MouseActionType::None: + case PlayerActionType::None: break; } } bool track_isscrolling() { - return LastMouseButtonAction == MouseActionType::Walk; + return LastPlayerAction == PlayerActionType::Walk; } } // namespace devilution diff --git a/Source/track.h b/Source/track.h index a271e227e..dde32b2b7 100644 --- a/Source/track.h +++ b/Source/track.h @@ -8,7 +8,7 @@ namespace devilution { void InvalidateTargets(); -void RepeatMouseAction(); +void RepeatPlayerAction(); bool track_isscrolling(); } // namespace devilution