Browse Source

Shift software cursor graphic and remove special casing (#6512)

pull/6519/head
Stephen C. Wills 3 years ago committed by GitHub
parent
commit
45dbe6aa61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      Source/engine/render/scrollrt.cpp
  2. 13
      Source/inv.cpp
  3. 23
      Source/qol/stash.cpp
  4. BIN
      test/fixtures/timedemo/WarriorLevel1to2/demo_0.dmo

8
Source/engine/render/scrollrt.cpp

@ -263,13 +263,15 @@ void DrawCursor(const Surface &out)
// Copy the buffer before the item cursor and its 1px outline are drawn to a temporary buffer.
const int outlineWidth = !MyPlayer->HoldItem.isEmpty() ? 1 : 0;
Displacement offset = !MyPlayer->HoldItem.isEmpty() ? Displacement { cursSize / 2 } : Displacement { 0 };
Point cursPosition = MousePosition - offset;
Rectangle &rect = cursor.rect;
rect.position.x = MousePosition.x - outlineWidth;
rect.position.x = cursPosition.x - outlineWidth;
rect.size.width = cursSize.width + 2 * outlineWidth;
Clip(rect.position.x, rect.size.width, out.w());
rect.position.y = MousePosition.y - outlineWidth;
rect.position.y = cursPosition.y - outlineWidth;
rect.size.height = cursSize.height + 2 * outlineWidth;
Clip(rect.position.y, rect.size.height, out.h());
@ -277,7 +279,7 @@ void DrawCursor(const Surface &out)
return;
BlitCursor(cursor.behindBuffer, rect.size.width, &out[rect.position], out.pitch(), rect.size.width, rect.size.height);
DrawSoftwareCursor(out, MousePosition + Displacement { 0, cursSize.height - 1 }, pcurs);
DrawSoftwareCursor(out, cursPosition + Displacement { 0, cursSize.height - 1 }, pcurs);
}
/**

13
Source/inv.cpp

@ -288,12 +288,6 @@ int FindSlotUnderCursor(Point cursorPosition, Size itemSize)
int i = cursorPosition.x;
int j = cursorPosition.y;
if (!IsHardwareCursor()) {
// offset the cursor position to match the hot pixel we'd use for a hardware cursor
i += itemSize.width * INV_SLOT_HALF_SIZE_PX;
j += itemSize.height * INV_SLOT_HALF_SIZE_PX;
}
for (int r = 0; r < NUM_XY_SLOTS; r++) {
int xo = GetRightPanel().position.x;
int yo = GetRightPanel().position.y;
@ -554,8 +548,6 @@ 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);
}
}
@ -819,11 +811,6 @@ 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));
}
}
}
}

23
Source/qol/stash.cpp

@ -94,12 +94,10 @@ void CheckStashPaste(Point cursorPosition)
Player &player = *MyPlayer;
const Size itemSize = GetInventorySize(player.HoldItem);
const Displacement hotPixelOffset = Displacement(itemSize * INV_SLOT_HALF_SIZE_PX);
if (IsHardwareCursor()) {
// It's more natural to select the top left cell of the region the sprite is overlapping when putting an item
// into an inventory grid, so compensate for the adjusted hot pixel of hardware cursors.
cursorPosition -= hotPixelOffset;
}
// It's more natural to select the top left cell of the region the sprite is overlapping when putting an item
// into an inventory grid, so compensate for the adjusted hot pixel of item cursors.
cursorPosition -= Displacement(itemSize * INV_SLOT_HALF_SIZE_PX);
if (!IsItemAllowedInStash(player.HoldItem))
return;
@ -111,10 +109,6 @@ void CheckStashPaste(Point cursorPosition)
player.HoldItem.clear();
PlaySFX(IS_GOLD);
Stash.dirty = true;
if (!IsHardwareCursor()) {
// To make software cursors behave like hardware cursors we need to adjust the hand cursor position manually
SetCursorPos(cursorPosition + hotPixelOffset);
}
NewCursor(CURSOR_HAND);
return;
}
@ -165,10 +159,6 @@ void CheckStashPaste(Point cursorPosition)
Stash.dirty = true;
if (player.HoldItem.isEmpty() && !IsHardwareCursor()) {
// To make software cursors behave like hardware cursors we need to adjust the hand cursor position manually
SetCursorPos(cursorPosition + hotPixelOffset);
}
NewCursor(player.HoldItem);
}
@ -243,11 +233,6 @@ void CheckStashCut(Point cursorPosition, bool automaticMove)
holdItem.clear();
} else {
NewCursor(holdItem);
if (!IsHardwareCursor()) {
// 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));
}
}
}
}

BIN
test/fixtures/timedemo/WarriorLevel1to2/demo_0.dmo vendored

Binary file not shown.
Loading…
Cancel
Save