diff --git a/Source/inv.cpp b/Source/inv.cpp index f8a1e7321..a97cea96e 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1017,7 +1017,7 @@ int CreateGoldItemInInventorySlot(Player &player, int slotIndex, int value) } // namespace -void InvDrawSlotBack(const Surface &out, Point targetPosition, Size size) +void InvDrawSlotBack(const Surface &out, Point targetPosition, Size size, item_quality itemQuality) { SDL_Rect srcRect = MakeSdlRect(0, 0, size.width, size.height); out.Clip(&srcRect, &targetPosition); @@ -1030,11 +1030,18 @@ void InvDrawSlotBack(const Surface &out, Point targetPosition, Size size) for (int hgt = size.height; hgt != 0; hgt--, dst -= dstPitch + size.width) { for (int wdt = size.width; wdt != 0; wdt--) { std::uint8_t pix = *dst; - if (pix >= PAL16_BLUE) { - if (pix <= PAL16_BLUE + 15) - pix -= PAL16_BLUE - PAL16_BEIGE; - else if (pix >= PAL16_GRAY) - pix -= PAL16_GRAY - PAL16_BEIGE; + if (pix >= PAL16_GRAY) { + switch (itemQuality) { + case ITEM_QUALITY_MAGIC: + pix -= PAL16_GRAY - PAL16_BLUE - 1; + break; + case ITEM_QUALITY_UNIQUE: + pix -= PAL16_GRAY - PAL16_YELLOW - 1; + break; + default: + pix -= PAL16_GRAY - PAL16_BEIGE - 1; + break; + } } *dst++ = pix; } @@ -1104,7 +1111,7 @@ void DrawInv(const Surface &out) if (!myPlayer.InvBody[slot].isEmpty()) { int screenX = slotPos[slot].x; int screenY = slotPos[slot].y; - InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, { screenX, screenY }), { slotSize[slot].width * InventorySlotSizeInPixels.width, slotSize[slot].height * InventorySlotSizeInPixels.height }); + InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, { screenX, screenY }), { slotSize[slot].width * InventorySlotSizeInPixels.width, slotSize[slot].height * InventorySlotSizeInPixels.height }, myPlayer.InvBody[slot]._iMagical); const int cursId = myPlayer.InvBody[slot]._iCurs + CURSOR_FIRSTITEM; @@ -1130,7 +1137,7 @@ void DrawInv(const Surface &out) if (slot == INVLOC_HAND_LEFT) { if (myPlayer.GetItemLocation(myPlayer.InvBody[slot]) == ILOC_TWOHAND) { - InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, slotPos[INVLOC_HAND_RIGHT]), { slotSize[INVLOC_HAND_RIGHT].width * InventorySlotSizeInPixels.width, slotSize[INVLOC_HAND_RIGHT].height * InventorySlotSizeInPixels.height }); + InvDrawSlotBack(out, GetPanelPosition(UiPanels::Inventory, slotPos[INVLOC_HAND_RIGHT]), { slotSize[INVLOC_HAND_RIGHT].width * InventorySlotSizeInPixels.width, slotSize[INVLOC_HAND_RIGHT].height * InventorySlotSizeInPixels.height }, myPlayer.InvBody[slot]._iMagical); LightTableIndex = 0; cel_transparency_active = true; @@ -1149,7 +1156,8 @@ void DrawInv(const Surface &out) InvDrawSlotBack( out, GetPanelPosition(UiPanels::Inventory, InvRect[i + SLOTXY_INV_FIRST]) + Displacement { 0, -1 }, - InventorySlotSizeInPixels); + InventorySlotSizeInPixels, + myPlayer.InvList[abs(myPlayer.InvGrid[i]) - 1]._iMagical); } } @@ -1187,7 +1195,7 @@ void DrawInvBelt(const Surface &out) } const Point position { InvRect[i + SLOTXY_BELT_FIRST].x + mainPanelPosition.x, InvRect[i + SLOTXY_BELT_FIRST].y + mainPanelPosition.y - 1 }; - InvDrawSlotBack(out, position, InventorySlotSizeInPixels); + InvDrawSlotBack(out, position, InventorySlotSizeInPixels, myPlayer.SpdList[i]._iMagical); const int cursId = myPlayer.SpdList[i]._iCurs + CURSOR_FIRSTITEM; const ClxSprite sprite = GetInvItemSprite(cursId); diff --git a/Source/inv.h b/Source/inv.h index c28676c0c..e18501bae 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -86,7 +86,7 @@ extern bool invflag; extern bool drawsbarflag; extern const Point InvRect[73]; -void InvDrawSlotBack(const Surface &out, Point targetPosition, Size size); +void InvDrawSlotBack(const Surface &out, Point targetPosition, Size size, item_quality itemQuality); /** * @brief Checks whether the given item can be placed on the belt. Takes item size as well as characteristics into account. Items * that cannot be placed on the belt have to be placed in the inventory instead. diff --git a/Source/qol/stash.cpp b/Source/qol/stash.cpp index 1e17a09a0..505c60989 100644 --- a/Source/qol/stash.cpp +++ b/Source/qol/stash.cpp @@ -353,8 +353,10 @@ void DrawStash(const Surface &out) constexpr Displacement offset { 0, INV_SLOT_SIZE_PX - 1 }; for (auto slot : StashGridRange) { + StashStruct::StashCell itemId = Stash.GetItemIdAtPosition(slot); + Item &item = Stash.stashList[itemId]; if (Stash.IsItemAtPosition(slot)) { - InvDrawSlotBack(out, GetStashSlotCoord(slot) + offset, InventorySlotSizeInPixels); + InvDrawSlotBack(out, GetStashSlotCoord(slot) + offset, InventorySlotSizeInPixels, item._iMagical); } }