From ff3dee8d452e69b2c4aa9d3ee727ebbc318af2db Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Mon, 31 May 2021 00:33:42 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Replace=20poor=20usages=20?= =?UTF-8?q?of=20'Size'=20with=20'Point's?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/controls/plrctrls.cpp | 32 ++++++++++++------------- Source/inv.cpp | 46 ++++++++++++++++++------------------ Source/inv.h | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 65b658070..e9c9a096b 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -502,32 +502,32 @@ coords InvGetEquipSlotCoord(const inv_body_loc inv_slot) result.x -= (icursW28 - 1) * (INV_SLOT_SIZE_PX / 2); switch (inv_slot) { case INVLOC_HEAD: - result.x += ((InvRect[SLOTXY_HEAD_FIRST].Width + InvRect[SLOTXY_HEAD_LAST].Width) / 2); - result.y += ((InvRect[SLOTXY_HEAD_FIRST].Height + InvRect[SLOTXY_HEAD_LAST].Height) / 2); + result.x += ((InvRect[SLOTXY_HEAD_FIRST].x + InvRect[SLOTXY_HEAD_LAST].x) / 2); + result.y += ((InvRect[SLOTXY_HEAD_FIRST].y + InvRect[SLOTXY_HEAD_LAST].y) / 2); break; case INVLOC_RING_LEFT: - result.x += InvRect[SLOTXY_RING_LEFT].Width; - result.y += InvRect[SLOTXY_RING_LEFT].Height; + result.x += InvRect[SLOTXY_RING_LEFT].x; + result.y += InvRect[SLOTXY_RING_LEFT].y; break; case INVLOC_RING_RIGHT: - result.x += InvRect[SLOTXY_RING_RIGHT].Width; - result.y += InvRect[SLOTXY_RING_RIGHT].Height; + result.x += InvRect[SLOTXY_RING_RIGHT].x; + result.y += InvRect[SLOTXY_RING_RIGHT].y; break; case INVLOC_AMULET: - result.x += InvRect[SLOTXY_AMULET].Width; - result.y += InvRect[SLOTXY_AMULET].Height; + result.x += InvRect[SLOTXY_AMULET].x; + result.y += InvRect[SLOTXY_AMULET].y; break; case INVLOC_HAND_LEFT: - result.x += ((InvRect[SLOTXY_HAND_LEFT_FIRST].Width + InvRect[SLOTXY_HAND_LEFT_LAST].Width) / 2); - result.y += ((InvRect[SLOTXY_HAND_LEFT_FIRST].Height + InvRect[SLOTXY_HAND_LEFT_LAST].Height) / 2); + result.x += ((InvRect[SLOTXY_HAND_LEFT_FIRST].x + InvRect[SLOTXY_HAND_LEFT_LAST].x) / 2); + result.y += ((InvRect[SLOTXY_HAND_LEFT_FIRST].y + InvRect[SLOTXY_HAND_LEFT_LAST].y) / 2); break; case INVLOC_HAND_RIGHT: - result.x += ((InvRect[SLOTXY_HAND_RIGHT_FIRST].Width + InvRect[SLOTXY_HAND_RIGHT_LAST].Width) / 2); - result.y += ((InvRect[SLOTXY_HAND_RIGHT_FIRST].Height + InvRect[SLOTXY_HAND_RIGHT_LAST].Height) / 2); + result.x += ((InvRect[SLOTXY_HAND_RIGHT_FIRST].x + InvRect[SLOTXY_HAND_RIGHT_LAST].x) / 2); + result.y += ((InvRect[SLOTXY_HAND_RIGHT_FIRST].y + InvRect[SLOTXY_HAND_RIGHT_LAST].y) / 2); break; case INVLOC_CHEST: - result.x += ((InvRect[SLOTXY_CHEST_FIRST].Width + InvRect[SLOTXY_CHEST_LAST].Width) / 2); - result.y += ((InvRect[SLOTXY_CHEST_FIRST].Height + InvRect[SLOTXY_CHEST_LAST].Height) / 2); + result.x += ((InvRect[SLOTXY_CHEST_FIRST].x + InvRect[SLOTXY_CHEST_LAST].x) / 2); + result.y += ((InvRect[SLOTXY_CHEST_FIRST].y + InvRect[SLOTXY_CHEST_LAST].y) / 2); break; default: break; @@ -568,7 +568,7 @@ coords InvGetEquipSlotCoordFromInvSlot(const inv_xy_slot slot) coords InvGetSlotCoord(int slot) { assert(slot <= SLOTXY_INV_LAST); - return { InvRect[slot].Width + RIGHT_PANEL, InvRect[slot].Height }; + return { InvRect[slot].x + RIGHT_PANEL, InvRect[slot].y }; } /** @@ -577,7 +577,7 @@ coords InvGetSlotCoord(int slot) coords BeltGetSlotCoord(int slot) { assert(slot >= SLOTXY_BELT_FIRST && slot <= SLOTXY_BELT_LAST); - return { InvRect[slot].Width + PANEL_LEFT, InvRect[slot].Height + PANEL_TOP }; + return { InvRect[slot].x + PANEL_LEFT, InvRect[slot].y + PANEL_TOP }; } /** diff --git a/Source/inv.cpp b/Source/inv.cpp index 5709f6a55..b210c5081 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -48,7 +48,7 @@ int sgdwLastTime; // check name * 65 66 67 68 69 70 71 72 * @see graphics/inv/inventory.png */ -const Size InvRect[] = { +const Point InvRect[] = { // clang-format off // X, Y { 132, 31 }, // helmet @@ -191,7 +191,7 @@ void DrawInv(const CelOutputBuffer &out) { 2, 3 }, // chest }; - Size slotPos[] = { + Point slotPos[] = { { 133, 59 }, //head { 48, 205 }, //left ring { 249, 205 }, //right ring @@ -205,8 +205,8 @@ void DrawInv(const CelOutputBuffer &out) for (int slot = INVLOC_HEAD; slot < NUM_INVLOC; slot++) { if (!myPlayer.InvBody[slot].isEmpty()) { - int screenX = slotPos[slot].Width; - int screenY = slotPos[slot].Height; + int screenX = slotPos[slot].x; + int screenY = slotPos[slot].y; InvDrawSlotBack(out, RIGHT_PANEL_X + screenX, screenY, slotSize[slot].Width * INV_SLOT_SIZE_PX, slotSize[slot].Height * INV_SLOT_SIZE_PX); int frame = myPlayer.InvBody[slot]._iCurs + CURSOR_FIRSTITEM; @@ -239,12 +239,12 @@ void DrawInv(const CelOutputBuffer &out) if (myPlayer._pClass != HeroClass::Barbarian || (myPlayer.InvBody[slot]._itype != ITYPE_SWORD && myPlayer.InvBody[slot]._itype != ITYPE_MACE)) { - InvDrawSlotBack(out, RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].Width, slotPos[INVLOC_HAND_RIGHT].Height, slotSize[INVLOC_HAND_RIGHT].Width * INV_SLOT_SIZE_PX, slotSize[INVLOC_HAND_RIGHT].Height * INV_SLOT_SIZE_PX); + InvDrawSlotBack(out, RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].x, slotPos[INVLOC_HAND_RIGHT].y, slotSize[INVLOC_HAND_RIGHT].Width * INV_SLOT_SIZE_PX, slotSize[INVLOC_HAND_RIGHT].Height * INV_SLOT_SIZE_PX); light_table_index = 0; cel_transparency_active = true; - const int dstX = RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].Width + (frameW == INV_SLOT_SIZE_PX ? 13 : -1); - const int dstY = slotPos[INVLOC_HAND_RIGHT].Height; + const int dstX = RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].x + (frameW == INV_SLOT_SIZE_PX ? 13 : -1); + const int dstY = slotPos[INVLOC_HAND_RIGHT].y; CelClippedBlitLightTransTo(out, { dstX, dstY }, cel, celFrame); cel_transparency_active = false; @@ -258,8 +258,8 @@ void DrawInv(const CelOutputBuffer &out) if (myPlayer.InvGrid[i] != 0) { InvDrawSlotBack( out, - InvRect[i + SLOTXY_INV_FIRST].Width + RIGHT_PANEL_X, - InvRect[i + SLOTXY_INV_FIRST].Height - 1, + InvRect[i + SLOTXY_INV_FIRST].x + RIGHT_PANEL_X, + InvRect[i + SLOTXY_INV_FIRST].y - 1, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); } @@ -272,7 +272,7 @@ void DrawInv(const CelOutputBuffer &out) const auto &cel = GetInvItemSprite(frame); const int celFrame = GetInvItemFrame(frame); - const Point position { InvRect[j + SLOTXY_INV_FIRST].Width + RIGHT_PANEL_X, InvRect[j + SLOTXY_INV_FIRST].Height - 1 }; + const Point position { InvRect[j + SLOTXY_INV_FIRST].x + RIGHT_PANEL_X, InvRect[j + SLOTXY_INV_FIRST].y - 1 }; if (pcursinvitem == ii + INVITEM_INV_FIRST) { CelBlitOutlineTo( out, @@ -305,7 +305,7 @@ void DrawInvBelt(const CelOutputBuffer &out) continue; } - const Point position { InvRect[i + SLOTXY_BELT_FIRST].Width + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Height + PANEL_Y - 1 }; + const Point position { InvRect[i + SLOTXY_BELT_FIRST].x + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].y + PANEL_Y - 1 }; InvDrawSlotBack(out, position.x, position.y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX); int frame = myPlayer.SpdList[i]._iCurs + CURSOR_FIRSTITEM; @@ -325,8 +325,8 @@ void DrawInvBelt(const CelOutputBuffer &out) && myPlayer.SpdList[i]._itype != ITYPE_GOLD) { sprintf(tempstr, "%i", i + 1); SDL_Rect rect { - InvRect[i + SLOTXY_BELT_FIRST].Width + PANEL_X + INV_SLOT_SIZE_PX - GetLineWidth(tempstr), - InvRect[i + SLOTXY_BELT_FIRST].Height + PANEL_Y - 1, + InvRect[i + SLOTXY_BELT_FIRST].x + PANEL_X + INV_SLOT_SIZE_PX - GetLineWidth(tempstr), + InvRect[i + SLOTXY_BELT_FIRST].y + PANEL_Y - 1, 0, 0 }; @@ -816,8 +816,8 @@ void CheckInvPaste(int pnum, Point cursorPosition) yo = PANEL_TOP; } - if (i >= InvRect[r].Width + xo && i <= InvRect[r].Width + xo + INV_SLOT_SIZE_PX) { - if (j >= InvRect[r].Height + yo - INV_SLOT_SIZE_PX - 1 && j < InvRect[r].Height + yo) { + if (i >= InvRect[r].x + xo && i <= InvRect[r].x + xo + INV_SLOT_SIZE_PX) { + if (j >= InvRect[r].y + yo - INV_SLOT_SIZE_PX - 1 && j < InvRect[r].y + yo) { done = true; r--; } @@ -1228,10 +1228,10 @@ void CheckInvCut(int pnum, Point cursorPosition, bool automaticMove) } // check which inventory rectangle the mouse is in, if any - if (cursorPosition.x >= InvRect[r].Width + xo - && cursorPosition.x < InvRect[r].Width + xo + (INV_SLOT_SIZE_PX + 1) - && cursorPosition.y >= InvRect[r].Height + yo - (INV_SLOT_SIZE_PX + 1) - && cursorPosition.y < InvRect[r].Height + yo) { + if (cursorPosition.x >= InvRect[r].x + xo + && cursorPosition.x < InvRect[r].x + xo + (INV_SLOT_SIZE_PX + 1) + && cursorPosition.y >= InvRect[r].y + yo - (INV_SLOT_SIZE_PX + 1) + && cursorPosition.y < InvRect[r].y + yo) { done = true; r--; } @@ -1931,10 +1931,10 @@ char CheckInvHLight() yo = PANEL_TOP; } - if (MouseX >= InvRect[r].Width + xo - && MouseX < InvRect[r].Width + xo + (INV_SLOT_SIZE_PX + 1) - && MouseY >= InvRect[r].Height + yo - (INV_SLOT_SIZE_PX + 1) - && MouseY < InvRect[r].Height + yo) { + if (MouseX >= InvRect[r].x + xo + && MouseX < InvRect[r].x + xo + (INV_SLOT_SIZE_PX + 1) + && MouseY >= InvRect[r].y + yo - (INV_SLOT_SIZE_PX + 1) + && MouseY < InvRect[r].y + yo) { break; } } diff --git a/Source/inv.h b/Source/inv.h index fcabcd754..e9ece77e0 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -80,7 +80,7 @@ enum item_color : uint8_t { extern bool invflag; extern bool drawsbarflag; -extern const Size InvRect[73]; +extern const Point InvRect[73]; void FreeInvGFX(); void InitInv();