From b7e2c649cf599b03cc2d2ea556165ef7e42f2b64 Mon Sep 17 00:00:00 2001 From: obligaron Date: Sat, 21 Jan 2023 16:17:26 +0100 Subject: [PATCH] Recalculate cursor position after level change --- Source/diablo.cpp | 14 ++++++-------- Source/qol/itemlabels.cpp | 5 +++++ Source/qol/itemlabels.h | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 8e8c01473..5018b2ff0 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -747,8 +747,6 @@ void GameEventHandler(const SDL_Event &event, uint16_t modState) nthread_ignore_mutex(true); PaletteFadeOut(8); sound_stop(); - LastMouseButtonAction = MouseActionType::None; - sgbMouseDown = CLICK_NONE; ShowProgress(GetCustomEvent(event.type)); RedrawEverything(); @@ -2923,12 +2921,12 @@ void LoadGameLevel(bool firstflag, lvl_entry lvldir) CompleteProgress(); - // Reset mouse selection of entities - pcursmonst = -1; - ObjectUnderCursor = nullptr; - pcursitem = -1; - pcursinvitem = -1; - pcursplr = -1; + // Recalculate mouse selection of entities after level change/load + LastMouseButtonAction = MouseActionType::None; + sgbMouseDown = CLICK_NONE; + ResetItemlabelHighlighted(); // level changed => item changed + pcursmonst = -1; // ensure pcurstemp is set to a valid value + CheckCursMove(); } bool game_loop(bool bStartup) diff --git a/Source/qol/itemlabels.cpp b/Source/qol/itemlabels.cpp index 83f95ba63..4d7a03a9f 100644 --- a/Source/qol/itemlabels.cpp +++ b/Source/qol/itemlabels.cpp @@ -83,6 +83,11 @@ bool IsItemLabelHighlighted() return isLabelHighlighted; } +void ResetItemlabelHighlighted() +{ + isLabelHighlighted = false; +} + bool IsHighlightingLabelsEnabled() { return altPressed != *sgOptions.Gameplay.showItemLabels; diff --git a/Source/qol/itemlabels.h b/Source/qol/itemlabels.h index cd8c7c9e8..c024b7214 100644 --- a/Source/qol/itemlabels.h +++ b/Source/qol/itemlabels.h @@ -12,6 +12,7 @@ namespace devilution { void ToggleItemLabelHighlight(); void AltPressed(bool pressed); bool IsItemLabelHighlighted(); +void ResetItemlabelHighlighted(); bool IsHighlightingLabelsEnabled(); void AddItemToLabelQueue(int id, Point position); void DrawItemNameLabels(const Surface &out);