diff options
author | grbr404 <166065505+grbr404@users.noreply.github.com> | 2025-06-05 19:35:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-05 19:35:50 +0200 |
commit | 2b76e9fed1d0d0ec909d1cd36893ac38bbd88c06 (patch) | |
tree | 49bfdcbe8d2967e081e0472825bbd5287e4cc065 | |
parent | 2f7cb392aaeec3809bdd4f463adfcbead0f1271d (diff) |
try 2
-rw-r--r-- | source/windowing/StarItemSlotWidget.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/source/windowing/StarItemSlotWidget.cpp b/source/windowing/StarItemSlotWidget.cpp index 4ba3425..41fbc20 100644 --- a/source/windowing/StarItemSlotWidget.cpp +++ b/source/windowing/StarItemSlotWidget.cpp @@ -185,14 +185,31 @@ void ItemSlotWidget::renderImpl() { } } - int frame = (int)roundf(m_progress * 18); // TODO: Hardcoded lol - context()->drawInterfaceQuad(String(strf("/interface/cooldown.png:{}", frame)), Vec2F(screenPosition())); + 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();Add commentMore actions + 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"; + } else { + formattedCount = toString(count); + } + + // Ensure formatted count is at most 4 characters long + if (formattedCount.length() > 4) { + formattedCount = formattedCount.substr(0, 4); + } - if (m_item->count() > 1 && m_showCount) { // we don't need to tell people that there's only 1 of something - context()->setTextStyle(m_textStyle); - context()->setFontMode(m_countFontMode); - context()->renderInterfaceText(toString(m_item->count()), m_countPosition.translated(Vec2F(screenPosition()))); - context()->clearTextStyle(); + context()->setTextStyle(m_textStyle); + context()->setFontMode(m_countFontMode); + context()->renderInterfaceText(formattedCount, m_countPosition.translated(Vec2F(screenPosition()))); + context()->clearTextStyle(); } } else if (m_drawBackingImageWhenEmpty && m_backingImage != "") { |