From 85a23231d4e482f80a213c6f839e11963a6caa62 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 22 Apr 2024 15:26:31 +1000 Subject: [PATCH] Tweak item stat formatting to prevent way too many decimals --- source/frontend/StarInventory.cpp | 12 ++++++------ source/frontend/StarItemTooltip.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/frontend/StarInventory.cpp b/source/frontend/StarInventory.cpp index 71d2081..80055ee 100644 --- a/source/frontend/StarInventory.cpp +++ b/source/frontend/StarInventory.cpp @@ -364,16 +364,16 @@ void InventoryPane::update(float dt) { techOverlay->setVisibility(m_player->techOverridden()); auto healthLabel = fetchChild("healthtext"); - healthLabel->setText(toString(m_player->maxHealth())); + healthLabel->setText(strf("{:.2f}", m_player->maxHealth())); auto energyLabel = fetchChild("energytext"); - energyLabel->setText(toString(m_player->maxEnergy())); + energyLabel->setText(strf("{:.2f}", m_player->maxEnergy())); auto weaponLabel = fetchChild("weapontext"); - weaponLabel->setText(strf("{}%", ceil(m_player->powerMultiplier() * 100))); + weaponLabel->setText(strf("{:.2f}%", m_player->powerMultiplier() * 100)); auto defenseLabel = fetchChild("defensetext"); if (m_player->protection() == 0) defenseLabel->setText("--"); else - defenseLabel->setText(toString(ceil(m_player->protection()))); + defenseLabel->setText(strf("{:.2f}", m_player->protection())); auto moneyLabel = fetchChild("lblMoney"); moneyLabel->setText(toString(m_player->currency("money"))); @@ -406,14 +406,14 @@ void InventoryPane::update(float dt) { auto attackLabel = fetchChild("companionAttackStat"); if (auto attack = pet->stat("attack")) { - attackLabel->setText(strf("{:.0f}", *attack)); + attackLabel->setText(strf("{:.2f}", *attack)); } else { attackLabel->setText(""); } auto defenseLabel = fetchChild("companionDefenseStat"); if (auto defense = pet->stat("defense")) { - defenseLabel->setText(strf("{:.0f}", *defense)); + defenseLabel->setText(strf("{:.2f}", *defense)); } else { defenseLabel->setText(""); } diff --git a/source/frontend/StarItemTooltip.cpp b/source/frontend/StarItemTooltip.cpp index 8d7ee29..3a3d9bc 100644 --- a/source/frontend/StarItemTooltip.cpp +++ b/source/frontend/StarItemTooltip.cpp @@ -198,7 +198,7 @@ void ItemTooltipBuilder::describePersistentEffect( auto listItem = container->addItem(); listItem->fetchChild("statusImage") ->setImage(statsConfig.get(baseMultiplier->statName).getString("icon")); - listItem->setLabel("statusLabel", strf("{}%", (baseMultiplier->baseMultiplier - 1) * 100)); + listItem->setLabel("statusLabel", strf("{:.2f}%", (baseMultiplier->baseMultiplier - 1) * 100)); } } else if (auto valueModifier = modifierEffect->ptr()) { if (statsConfig.contains(valueModifier->statName)) { @@ -212,7 +212,7 @@ void ItemTooltipBuilder::describePersistentEffect( auto listItem = container->addItem(); listItem->fetchChild("statusImage") ->setImage(statsConfig.get(effectiveMultiplier->statName).getString("icon")); - listItem->setLabel("statusLabel", strf("{}%", (effectiveMultiplier->effectiveMultiplier - 1) * 100)); + listItem->setLabel("statusLabel", strf("{:.2f}%", (effectiveMultiplier->effectiveMultiplier - 1) * 100)); } } }