feat: Prettier price formatting
Co-authored-by: jani270 <69345714+jani270@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
package moe.nea.firmament.features.inventory
|
package moe.nea.firmament.features.inventory
|
||||||
|
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
@@ -8,8 +6,12 @@ import moe.nea.firmament.events.ItemTooltipEvent
|
|||||||
import moe.nea.firmament.features.FirmamentFeature
|
import moe.nea.firmament.features.FirmamentFeature
|
||||||
import moe.nea.firmament.gui.config.ManagedConfig
|
import moe.nea.firmament.gui.config.ManagedConfig
|
||||||
import moe.nea.firmament.repo.HypixelStaticData
|
import moe.nea.firmament.repo.HypixelStaticData
|
||||||
import moe.nea.firmament.util.FirmFormatters
|
import moe.nea.firmament.util.FirmFormatters.formatCommas
|
||||||
|
import moe.nea.firmament.util.bold
|
||||||
|
import moe.nea.firmament.util.gold
|
||||||
import moe.nea.firmament.util.skyBlockId
|
import moe.nea.firmament.util.skyBlockId
|
||||||
|
import moe.nea.firmament.util.tr
|
||||||
|
import moe.nea.firmament.util.yellow
|
||||||
|
|
||||||
object PriceData : FirmamentFeature {
|
object PriceData : FirmamentFeature {
|
||||||
override val identifier: String
|
override val identifier: String
|
||||||
@@ -22,6 +24,20 @@ object PriceData : FirmamentFeature {
|
|||||||
|
|
||||||
override val config get() = TConfig
|
override val config get() = TConfig
|
||||||
|
|
||||||
|
fun formatPrice(label: Text, price: Double): Text {
|
||||||
|
return Text.literal("")
|
||||||
|
.yellow()
|
||||||
|
.bold()
|
||||||
|
.append(label)
|
||||||
|
.append(": ")
|
||||||
|
.append(
|
||||||
|
Text.literal(formatCommas(price, fractionalDigits = 1))
|
||||||
|
.append(if(price != 1.0) " coins" else " coin")
|
||||||
|
.gold()
|
||||||
|
.bold()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
fun onItemTooltip(it: ItemTooltipEvent) {
|
fun onItemTooltip(it: ItemTooltipEvent) {
|
||||||
if (!TConfig.tooltipEnabled && !TConfig.enableKeybinding.isPressed()) {
|
if (!TConfig.tooltipEnabled && !TConfig.enableKeybinding.isPressed()) {
|
||||||
@@ -33,18 +49,24 @@ object PriceData : FirmamentFeature {
|
|||||||
if (bazaarData != null) {
|
if (bazaarData != null) {
|
||||||
it.lines.add(Text.literal(""))
|
it.lines.add(Text.literal(""))
|
||||||
it.lines.add(
|
it.lines.add(
|
||||||
Text.stringifiedTranslatable("firmament.tooltip.bazaar.sell-order",
|
formatPrice(
|
||||||
FirmFormatters.formatCommas(bazaarData.quickStatus.sellPrice, 1))
|
tr("firmament.tooltip.bazaar.sell-order", "Bazaar Sell Order"),
|
||||||
|
bazaarData.quickStatus.sellPrice
|
||||||
|
)
|
||||||
)
|
)
|
||||||
it.lines.add(
|
it.lines.add(
|
||||||
Text.stringifiedTranslatable("firmament.tooltip.bazaar.buy-order",
|
formatPrice(
|
||||||
FirmFormatters.formatCommas(bazaarData.quickStatus.buyPrice, 1))
|
tr("firmament.tooltip.bazaar.buy-order", "Bazaar Buy Order"),
|
||||||
|
bazaarData.quickStatus.buyPrice
|
||||||
|
)
|
||||||
)
|
)
|
||||||
} else if (lowestBin != null) {
|
} else if (lowestBin != null) {
|
||||||
it.lines.add(Text.literal(""))
|
it.lines.add(Text.literal(""))
|
||||||
it.lines.add(
|
it.lines.add(
|
||||||
Text.stringifiedTranslatable("firmament.tooltip.ah.lowestbin",
|
formatPrice(
|
||||||
FirmFormatters.formatCommas(lowestBin, 1))
|
tr("firmament.tooltip.ah.lowestbin", "Lowest BIN"),
|
||||||
|
lowestBin
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -375,9 +375,6 @@
|
|||||||
"firmament.sbinfo.server": "Locraw Server: %s",
|
"firmament.sbinfo.server": "Locraw Server: %s",
|
||||||
"firmament.toggle.false": "Off",
|
"firmament.toggle.false": "Off",
|
||||||
"firmament.toggle.true": "On",
|
"firmament.toggle.true": "On",
|
||||||
"firmament.tooltip.ah.lowestbin": "Lowest BIN: %d",
|
|
||||||
"firmament.tooltip.bazaar.buy-order": "Bazaar Buy Order: %s",
|
|
||||||
"firmament.tooltip.bazaar.sell-order": "Bazaar Sell Order: %s",
|
|
||||||
"firmament.tooltip.copied.lore": "Copied Name and Lore",
|
"firmament.tooltip.copied.lore": "Copied Name and Lore",
|
||||||
"firmament.tooltip.copied.modelid": "Copied Texture Id: %s",
|
"firmament.tooltip.copied.modelid": "Copied Texture Id: %s",
|
||||||
"firmament.tooltip.copied.modelid.fail": "Failed to copy Texture Id",
|
"firmament.tooltip.copied.modelid.fail": "Failed to copy Texture Id",
|
||||||
|
|||||||
Reference in New Issue
Block a user