diff options
Diffstat (limited to 'source/windowing/StarItemSlotWidget.cpp')
-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 != "") { |