diff options
author | grbr404 <166065505+grbr404@users.noreply.github.com> | 2025-06-05 20:07:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-05 20:07:00 +0200 |
commit | f4217740b311b24d4bc0aa51633a0d342ab76086 (patch) | |
tree | 77c7c4e5a719802066a7288c9350b287c72f9ed7 | |
parent | 442964bb330a0337d12aab607b9ce7b1b8a20af6 (diff) |
try 4
-rw-r--r-- | source/windowing/StarItemSlotWidget.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/source/windowing/StarItemSlotWidget.cpp b/source/windowing/StarItemSlotWidget.cpp index c8aa79c..bd2e26b 100644 --- a/source/windowing/StarItemSlotWidget.cpp +++ b/source/windowing/StarItemSlotWidget.cpp @@ -186,19 +186,23 @@ void ItemSlotWidget::renderImpl() { } if (m_item->count() > 1 && m_showCount) { // we don't need to tell people that there's only 1 of something - uint32_t count = m_item->count(); std::string formattedCount; - if (count >= 1000000000000000) { // Quadrillions (Q) - formattedCount = toString(count / 1000000000000000) + "Q"; - } else if (count >= 1000000000) { // Billions (B) - formattedCount = toString(count / 1000000000) + "B"; - } else if (count >= 1000000) { // Millions (M) - formattedCount = toString(count / 1000000) + "M"; - } else if (count >= 1000) { // Thousands (K) - formattedCount = toString(count / 1000) + "K"; + if (m_item->count() >= 1000000000000000) { // Quadrillions (Q) + formattedCount = toString(m_item->count() / 1000000000000000) + "Q"; + } else if (m_item->count() >= 1000000000) { // Billions (B) + formattedCount = toString(m_item->count() / 1000000000) + "B"; + } else if (m_item->count() >= 1000000) { // Millions (M) + formattedCount = toString(m_item->count() / 1000000) + "M"; + } else if (m_item->count() >= 1000) { // Thousands (K) + formattedCount = toString(m_item->count() / 1000) + "K"; } else { - formattedCount = toString(count); + formattedCount = toString(m_item->count()); + } + + // Ensure formatted count is at most 4 characters long + if (formattedCount.length() > 4) { + formattedCount = formattedCount.substr(0, 4); } context()->setTextStyle(m_textStyle); |