From 2f3cf65b27e56c05a88381b19f1872b5c77282ce Mon Sep 17 00:00:00 2001 From: qndel Date: Wed, 26 May 2021 10:44:21 +0200 Subject: [PATCH] cleanup getTextColor --- Source/control.cpp | 5 +---- Source/inv.cpp | 6 +----- Source/items.cpp | 5 +---- Source/items.h | 4 ++-- Source/qol/itemlabels.cpp | 2 +- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index eac996159..b6de147d5 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1156,10 +1156,7 @@ void DrawInfoBox(const CelOutputBuffer &out) strcpy(infostr, myPlayer.HoldItem._iIName); else strcpy(infostr, myPlayer.HoldItem._iName); - if (myPlayer.HoldItem._iMagical == ITEM_QUALITY_MAGIC) - infoclr = UIS_BLUE; - if (myPlayer.HoldItem._iMagical == ITEM_QUALITY_UNIQUE) - infoclr = UIS_GOLD; + infoclr = myPlayer.HoldItem.getTextColor(true); } } else { if (pcursitem != -1) diff --git a/Source/inv.cpp b/Source/inv.cpp index d9e30c861..f8c118ac9 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -2001,11 +2001,7 @@ char CheckInvHLight() int nGold = pi->_ivalue; strcpy(infostr, fmt::format(ngettext("{:d} gold piece", "{:d} gold pieces", nGold), nGold).c_str()); } else { - if (pi->_iMagical == ITEM_QUALITY_MAGIC) { - infoclr = UIS_BLUE; - } else if (pi->_iMagical == ITEM_QUALITY_UNIQUE) { - infoclr = UIS_GOLD; - } + infoclr = pi->getTextColor(true); if (pi->_iIdentified) { strcpy(infostr, pi->_iIName); PrintItemDetails(pi); diff --git a/Source/items.cpp b/Source/items.cpp index 26fe3ae0d..101084fc0 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3028,10 +3028,7 @@ void GetItemStr(int i) else strcpy(infostr, items[i]._iName); - if (items[i]._iMagical == ITEM_QUALITY_MAGIC) - infoclr = UIS_BLUE; - if (items[i]._iMagical == ITEM_QUALITY_UNIQUE) - infoclr = UIS_GOLD; + infoclr = items[i].getTextColor(true); } else { int nGold = items[i]._ivalue; strcpy(infostr, fmt::format(ngettext("{:d} gold piece", "{:d} gold pieces", nGold), nGold).c_str()); diff --git a/Source/items.h b/Source/items.h index 43c8735c5..a3314efb9 100644 --- a/Source/items.h +++ b/Source/items.h @@ -351,9 +351,9 @@ struct ItemStruct { } } - UiFlags getTextColor() const + UiFlags getTextColor(bool skipStatCheck = false) const { - if (!_iStatFlag) + if (!skipStatCheck && !_iStatFlag) return UIS_RED; switch (_iMagical) { case ITEM_QUALITY_MAGIC: diff --git a/Source/qol/itemlabels.cpp b/Source/qol/itemlabels.cpp index 82f87fe5f..673157e6b 100644 --- a/Source/qol/itemlabels.cpp +++ b/Source/qol/itemlabels.cpp @@ -156,7 +156,7 @@ void DrawItemNameLabels(const CelOutputBuffer &out) FillRect(out, label.pos.x, label.pos.y - height + marginY, label.width, height, PAL8_BLUE + 6); else DrawHalfTransparentRectTo(out, label.pos.x, label.pos.y - height + marginY, label.width, height); - DrawString(out, label.text.c_str(), { label.pos.x + marginX, label.pos.y, label.width, height }, itm.getTextColor()); + DrawString(out, label.text.c_str(), { label.pos.x + marginX, label.pos.y, label.width, height }, itm.getTextColor(true)); } labelQueue.clear(); }