From c91e69384a3a608d59febf064313eab78221b228 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 26 Aug 2023 04:00:38 +0200 Subject: [PATCH] Revert "Fix cursor jitter when clicking inv items (#6510)" This reverts commit 2a393397a136b308c3ba9d12042a2156e32399ef. --- Source/cursor.cpp | 5 ++--- Source/inv.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 6f20233e9..c5af4f927 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -297,9 +297,8 @@ void DrawSoftwareCursor(const Surface &out, Point position, int cursId) const ClxSprite sprite = GetInvItemSprite(cursId); if (!MyPlayer->HoldItem.isEmpty()) { const auto &heldItem = MyPlayer->HoldItem; - Size cursSize = GetInvItemSize(cursId); - ClxDrawOutline(out, GetOutlineColor(heldItem, true), position - Displacement(cursSize / 2), sprite); - DrawItem(heldItem, out, position - Displacement(cursSize / 2), sprite); + ClxDrawOutline(out, GetOutlineColor(heldItem, true), position, sprite); + DrawItem(heldItem, out, position, sprite); } else { ClxDraw(out, position, sprite); } diff --git a/Source/inv.cpp b/Source/inv.cpp index 3a52b2366..8350fc7aa 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -320,9 +320,8 @@ int FindSlotUnderCursor(Point cursorPosition, Size itemSize) void CheckInvPaste(Player &player, Point cursorPosition) { Size itemSize = GetInventorySize(player.HoldItem); - Size cursSize = GetInvItemSize(player.HoldItem._iCurs); - int slot = FindSlotUnderCursor(cursorPosition - Displacement(cursSize / 2), itemSize); + int slot = FindSlotUnderCursor(cursorPosition, itemSize); if (slot == NUM_XY_SLOTS) return; @@ -555,6 +554,8 @@ void CheckInvPaste(Player &player, Point cursorPosition) } CalcPlrInv(player, true); if (&player == MyPlayer) { + if (player.HoldItem.isEmpty() && !IsHardwareCursor()) + SetCursorPos(MousePosition + Displacement { itemSize * INV_SLOT_HALF_SIZE_PX }); NewCursor(player.HoldItem); } } @@ -818,6 +819,11 @@ void CheckInvCut(Player &player, Point cursorPosition, bool automaticMove, bool holdItem.clear(); } else { NewCursor(holdItem); + if (!IsHardwareCursor() && !dropItem) { + // For a hardware cursor, we set the "hot point" to the center of the item instead. + Size cursSize = GetInvItemSize(holdItem._iCurs + CURSOR_FIRSTITEM); + SetCursorPos(cursorPosition - Displacement(cursSize / 2)); + } } } }