Browse Source

Revert "Fix cursor jitter when clicking inv items (#6510)"

This reverts commit 2a393397a1.
pull/6512/head
Anders Jenbo 3 years ago
parent
commit
c91e69384a
  1. 5
      Source/cursor.cpp
  2. 10
      Source/inv.cpp

5
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);
}

10
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));
}
}
}
}

Loading…
Cancel
Save