From 332983c97b7a729c4dc5f19aa9ee4a22c420f7d8 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Tue, 27 Jun 2023 20:23:44 +1000 Subject: The Formatting String Catastrophe --- source/frontend/StarItemTooltip.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source/frontend/StarItemTooltip.cpp') diff --git a/source/frontend/StarItemTooltip.cpp b/source/frontend/StarItemTooltip.cpp index 9138349..46a2d85 100644 --- a/source/frontend/StarItemTooltip.cpp +++ b/source/frontend/StarItemTooltip.cpp @@ -81,7 +81,7 @@ void ItemTooltipBuilder::buildItemDescriptionInner( container->fetchChild("icon")->setItem(item); container->setLabel("nameLabel", item->name()); - container->setLabel("countLabel", strf("%s", item->count())); + container->setLabel("countLabel", strf("{}", item->count())); container->setLabel("rarityLabel", RarityNames.getRight(item->rarity()).titleCase()); @@ -90,8 +90,8 @@ void ItemTooltipBuilder::buildItemDescriptionInner( else container->setLabel("handednessLabel", "1-Handed"); - container->setLabel("countLabel", strf("%s", item->instanceValue("fuelAmount", 0).toUInt() * item->count())); - container->setLabel("priceLabel", strf("%s", (int)item->price())); + container->setLabel("countLabel", strf("{}", item->instanceValue("fuelAmount", 0).toUInt() * item->count())); + container->setLabel("priceLabel", strf("{}", (int)item->price())); if (auto objectItem = as(item)) { try { @@ -103,13 +103,13 @@ void ItemTooltipBuilder::buildItemDescriptionInner( } if (objectItem->tooltipKind() == "container") - container->setLabel("slotCountLabel", strf("Holds %s Items", objectItem->instanceValue("slotCount"))); + container->setLabel("slotCountLabel", strf("Holds {} Items", objectItem->instanceValue("slotCount"))); title = object->shortDescription(); subTitle = categoryDisplayName(object->category()); description = object->description(); } catch (StarException const& e) { - Logger::error("Failed to instantiate object for object item tooltip. %s", outputException(e, false)); + Logger::error("Failed to instantiate object for object item tooltip. {}", outputException(e, false)); } } else { if (container->containsChild("objectImage")) { @@ -137,9 +137,9 @@ void ItemTooltipBuilder::buildItemDescriptionInner( } if (auto fireable = as(item)) { - container->setLabel("cooldownTimeLabel", strf("%.2f", fireable->cooldownTime())); - container->setLabel("windupTimeLabel", strf("%.2f", fireable->windupTime())); - container->setLabel("speedLabel", strf("%.2f", 1.0f / (fireable->cooldownTime() + fireable->windupTime()))); + container->setLabel("cooldownTimeLabel", strf("{:.2f}", fireable->cooldownTime())); + container->setLabel("windupTimeLabel", strf("{:.2f}", fireable->windupTime())); + container->setLabel("speedLabel", strf("{:.2f}", 1.0f / (fireable->cooldownTime() + fireable->windupTime()))); } if (container->containsChild("largeImage")) { @@ -198,21 +198,21 @@ void ItemTooltipBuilder::describePersistentEffect( auto listItem = container->addItem(); listItem->fetchChild("statusImage") ->setImage(statsConfig.get(baseMultiplier->statName).getString("icon")); - listItem->setLabel("statusLabel", strf("%s%%", (baseMultiplier->baseMultiplier - 1) * 100)); + listItem->setLabel("statusLabel", strf("{}%", (baseMultiplier->baseMultiplier - 1) * 100)); } } else if (auto valueModifier = modifierEffect->ptr()) { if (statsConfig.contains(valueModifier->statName)) { auto listItem = container->addItem(); listItem->fetchChild("statusImage") ->setImage(statsConfig.get(valueModifier->statName).getString("icon")); - listItem->setLabel("statusLabel", strf("%s%s", valueModifier->value < 0 ? "-" : "", valueModifier->value)); + listItem->setLabel("statusLabel", strf("{}{}", valueModifier->value < 0 ? "-" : "", valueModifier->value)); } } else if (auto effectiveMultiplier = modifierEffect->ptr()) { if (statsConfig.contains(effectiveMultiplier->statName)) { auto listItem = container->addItem(); listItem->fetchChild("statusImage") ->setImage(statsConfig.get(effectiveMultiplier->statName).getString("icon")); - listItem->setLabel("statusLabel", strf("%s%%", (effectiveMultiplier->effectiveMultiplier - 1) * 100)); + listItem->setLabel("statusLabel", strf("{}%", (effectiveMultiplier->effectiveMultiplier - 1) * 100)); } } } -- cgit v1.2.3