From 45dbe6aa611810be103e14e503fb84b59915fa33 Mon Sep 17 00:00:00 2001 From: "Stephen C. Wills" Date: Sat, 26 Aug 2023 10:45:36 -0400 Subject: [PATCH] Shift software cursor graphic and remove special casing (#6512) --- Source/engine/render/scrollrt.cpp | 8 +++--- Source/inv.cpp | 13 ---------- Source/qol/stash.cpp | 23 +++--------------- .../timedemo/WarriorLevel1to2/demo_0.dmo | Bin 590790 -> 590790 bytes 4 files changed, 9 insertions(+), 35 deletions(-) diff --git a/Source/engine/render/scrollrt.cpp b/Source/engine/render/scrollrt.cpp index dfdd273d1..847b90696 100644 --- a/Source/engine/render/scrollrt.cpp +++ b/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); } /** diff --git a/Source/inv.cpp b/Source/inv.cpp index 8350fc7aa..dee00b18f 100644 --- a/Source/inv.cpp +++ b/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)); - } } } } diff --git a/Source/qol/stash.cpp b/Source/qol/stash.cpp index 14e5105e3..630554d13 100644 --- a/Source/qol/stash.cpp +++ b/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)); - } } } } diff --git a/test/fixtures/timedemo/WarriorLevel1to2/demo_0.dmo b/test/fixtures/timedemo/WarriorLevel1to2/demo_0.dmo index a7c10bc76ed0f0aee5a71578ca77e2f8faf33d00..ebebbb49150f7f807652bd1d65bff6ac57f4b9d5 100644 GIT binary patch delta 220 zcmV<203-j#ha|>_B(Pq`17!hsvth@0+y?CdL;wH~m(gbgP`59n0pJ1y=K(vn5~l(9 z2LsmudAAL(0b~dZZvl+}01yEH0026dk+TOVm%w!d1(!Rf0ttt*w*j}Zw*nei1A764 zx6cm)CI<#-0Sf^D5SQ^q1tPZ{7XyEY18xCvho7GVho7GWho7GXx1XN|>emKn0gnIx z5SM}W0uz@{j|M20;6noomoSY24wtV&0}7Y$#RmnKuv7;Mm%xz*6}J(12iye%Ujg&C W@O=lgF9SjXUx%ly2e+rK2p?7ss7(?8 delta 220 zcmX@su5zqhWkcL?=5R*e&56e=?yy~C)L>u`n0_&xC1AV$62=Ei%%>UUw+k(2{K3w= zo6&ze?|Q}*4(>$8WS}ZW1_lPJ=@U1zYfL{-%ECI`dKnXE`=;%T+c#}zl8RuCXN=l@ zo}XEboh_R2A;{2=uB=MiWyP86JD3v~-P`BSX9i*xAZFb@e?Hr*>ugbssUUTY-0a%st(pmx*usdM9SC=^u`=vrgX-!p=4Qz(h9D?Sd8TcUYMN8BcEiP|LnW UpIME`xqbOs_U+5pa>$1P07S-1jQ{`u