From 1401e130ce19fe9eb7f07e7812e4ce4fbd909f82 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 22 Jan 2023 17:13:17 +0000 Subject: [PATCH] Store items: Render 1x1 items at full size --- Source/stores.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index cebfe36a4..4bdf1442c 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -2285,22 +2285,29 @@ void PrintSString(const Surface &out, int margin, int line, string_view text, Ui const Rectangle rect { { sx, sy }, { width, 0 } }; // Space reserved for item graphic is based on the size of 2x3 cursor sprites - const int cursWidth = INV_SLOT_SIZE_PX * 2; - const int halfCursWidth = cursWidth / 2; + constexpr int CursWidth = INV_SLOT_SIZE_PX * 2; + constexpr int HalfCursWidth = CursWidth / 2; if (*sgOptions.Graphics.showItemGraphicsInStores && cursId >= 0) { - const ClxSprite halfSprite = HasAnyOf(flags, UiFlags::ColorRed) - ? GetHalfSizeItemSpriteRed(cursId) - : GetHalfSizeItemSprite(cursId); + const Size size = GetInvItemSize(static_cast(CURSOR_FIRSTITEM) + cursId); + const bool useHalfSize = size.width > INV_SLOT_SIZE_PX || size.height > INV_SLOT_SIZE_PX; + const bool useRed = HasAnyOf(flags, UiFlags::ColorRed); + const ClxSprite sprite = useHalfSize + ? (useRed ? GetHalfSizeItemSpriteRed(cursId) : GetHalfSizeItemSprite(cursId)) + : GetInvItemSprite(static_cast(CURSOR_FIRSTITEM) + cursId); const Point position { - rect.position.x + (halfCursWidth - halfSprite.width()) / 2, - rect.position.y + (TextHeight() * 3 + halfSprite.height()) / 2 + rect.position.x + (HalfCursWidth - sprite.width()) / 2, + rect.position.y + (TextHeight() * 3 + sprite.height()) / 2 }; - ClxDraw(out, position, halfSprite); + if (useHalfSize || !useRed) { + ClxDraw(out, position, sprite); + } else { + ClxDrawTRN(out, position, sprite, GetInfravisionTRN()); + } } if (*sgOptions.Graphics.showItemGraphicsInStores && cursIndent) { - const Rectangle textRect { { rect.position.x + halfCursWidth + 8, rect.position.y }, { rect.size.width - halfCursWidth + 8, rect.size.height } }; + const Rectangle textRect { { rect.position.x + HalfCursWidth + 8, rect.position.y }, { rect.size.width - HalfCursWidth + 8, rect.size.height } }; DrawString(out, text, textRect, flags); } else { DrawString(out, text, rect, flags);