From 8ceb36a4cbddce33e6407d358229e682cbccf271 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 22 May 2021 19:07:39 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20GetItemTextColor(item)=20-?= =?UTF-8?q?>=20item.getTextColor()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will help with the Alt highlight feature. --- Source/items.h | 15 +++++++++++++++ Source/stores.cpp | 27 ++++++++------------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Source/items.h b/Source/items.h index 0c2202f15..3293cd790 100644 --- a/Source/items.h +++ b/Source/items.h @@ -7,6 +7,7 @@ #include +#include "DiabloUI/ui_item.h" #include "engine.h" #include "itemdat.h" #include "utils/stdcompat/optional.hpp" @@ -348,6 +349,20 @@ struct ItemStruct { return false; } } + + UiFlags getTextColor() const + { + if (!_iStatFlag) + return UIS_RED; + switch (_iMagical) { + case ITEM_QUALITY_MAGIC: + return UIS_BLUE; + case ITEM_QUALITY_UNIQUE: + return UIS_GOLD; + default: + return UIS_SILVER; + } + } }; struct ItemGetRecordStruct { diff --git a/Source/stores.cpp b/Source/stores.cpp index 12ee98a19..2211e5bbe 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -73,17 +73,6 @@ const char *const talkname[] = { "Wirt" }; -uint16_t GetItemTextColor(ItemStruct &item) -{ - if (!item._iStatFlag) - return UIS_RED; - if (item._iMagical == ITEM_QUALITY_MAGIC) - return UIS_BLUE; - if (item._iMagical == ITEM_QUALITY_UNIQUE) - return UIS_GOLD; - return UIS_SILVER; -} - void DrawSTextBack(const CelOutputBuffer &out) { CelDrawTo(out, PANEL_X + 320 + 24, 327 + UI_OFFSET_Y, *pSTextBoxCels, 1); @@ -248,7 +237,7 @@ void S_ScrollSBuy(int idx) for (l = 5; l < 20; l += 4) { if (!smithitem[ls].isEmpty()) { - uint16_t iclr = GetItemTextColor(smithitem[ls]); + uint16_t iclr = smithitem[ls].getTextColor(); if (smithitem[ls]._iMagical) { AddSText(20, l, smithitem[ls]._iIName, iclr, true); @@ -306,7 +295,7 @@ void S_ScrollSPBuy(int idx) for (l = 5; l < 20 && idx < SMITH_PREMIUM_ITEMS; l += 4) { if (!premiumitems[idx].isEmpty()) { - uint16_t iclr = GetItemTextColor(premiumitems[idx]); + uint16_t iclr = premiumitems[idx].getTextColor(); AddSText(20, l, premiumitems[idx]._iIName, iclr, true); AddSTextVal(l, premiumitems[idx]._iIvalue); PrintStoreItem(&premiumitems[idx], l + 1, iclr); @@ -396,7 +385,7 @@ void S_ScrollSSell(int idx) if (idx >= storenumh) break; if (!storehold[idx].isEmpty()) { - uint16_t iclr = GetItemTextColor(storehold[idx]); + uint16_t iclr = storehold[idx].getTextColor(); if (storehold[idx]._iMagical && storehold[idx]._iIdentified) { AddSText(20, l, storehold[idx]._iIName, iclr, true); @@ -596,7 +585,7 @@ void S_ScrollWBuy(int idx) for (l = 5; l < 20; l += 4) { if (!witchitem[ls].isEmpty()) { - uint16_t iclr = GetItemTextColor(witchitem[ls]); + uint16_t iclr = witchitem[ls].getTextColor(); if (witchitem[ls]._iMagical) { AddSText(20, l, witchitem[ls]._iIName, iclr, true); @@ -837,7 +826,7 @@ void S_StartConfirm() StartStore(stextshold); stextscrl = false; ClearSText(5, 23); - uint16_t iclr = GetItemTextColor(plr[myplr].HoldItem); + uint16_t iclr = plr[myplr].HoldItem.getTextColor(); idprint = plr[myplr].HoldItem._iMagical != ITEM_QUALITY_NORMAL; @@ -919,7 +908,7 @@ void S_StartBBoy() AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); - uint16_t iclr = GetItemTextColor(boyitem); + uint16_t iclr = boyitem.getTextColor(); if (boyitem._iMagical != ITEM_QUALITY_NORMAL) AddSText(20, 10, boyitem._iIName, iclr, true); @@ -968,7 +957,7 @@ void S_ScrollHBuy(int idx) stextup = 5; for (l = 5; l < 20; l += 4) { if (!healitem[idx].isEmpty()) { - uint16_t iclr = GetItemTextColor(healitem[idx]); + uint16_t iclr = healitem[idx].getTextColor(); AddSText(20, l, healitem[idx]._iName, iclr, true); AddSTextVal(l, healitem[idx]._iIvalue); @@ -1115,7 +1104,7 @@ void S_StartIdShow() StartStore(stextshold); stextscrl = false; ClearSText(5, 23); - uint16_t iclr = GetItemTextColor(plr[myplr].HoldItem); + uint16_t iclr = plr[myplr].HoldItem.getTextColor(); AddSText(0, 7, _("This item is:"), UIS_SILVER | UIS_CENTER, false); AddSText(20, 11, plr[myplr].HoldItem._iIName, iclr, false);