Skip to content

Commit

Permalink
Revert "Fix cursor jitter when clicking inv items (#6510)"
Browse files Browse the repository at this point in the history
This reverts commit 2a39339.
  • Loading branch information
AJenbo committed Aug 26, 2023
1 parent 2a39339 commit c91e693
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 2 additions & 3 deletions Source/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 8 additions & 2 deletions Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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));
}
}
}
}
Expand Down

0 comments on commit c91e693

Please sign in to comment.