aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/features
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-08-31 19:38:38 +0200
committernea <nea@nea.moe>2023-08-31 21:22:26 +0200
commitcb032e7c221e40736ab26b193eea4e32d06113d9 (patch)
treee49047b3b78fb9887d72cbe9458af44ecbc179d4 /src/main/kotlin/moe/nea/firmament/features
parentb7b01f1c6fbf889ae9bfcdb5b34c5ccfa48d5ba0 (diff)
downloadFirmament-cb032e7c221e40736ab26b193eea4e32d06113d9.tar.gz
Firmament-cb032e7c221e40736ab26b193eea4e32d06113d9.tar.bz2
Firmament-cb032e7c221e40736ab26b193eea4e32d06113d9.zip
Add price tooltips
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt2
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt61
2 files changed, 63 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt b/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt
index facb821..91f5e03 100644
--- a/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt
@@ -14,6 +14,7 @@ import moe.nea.firmament.features.debug.DebugView
import moe.nea.firmament.features.debug.DeveloperFeatures
import moe.nea.firmament.features.fixes.Fixes
import moe.nea.firmament.features.inventory.CraftingOverlay
+import moe.nea.firmament.features.inventory.PriceData
import moe.nea.firmament.features.inventory.SaveCursorPosition
import moe.nea.firmament.features.inventory.SlotLocking
import moe.nea.firmament.features.inventory.storageoverlay.StorageOverlay
@@ -48,6 +49,7 @@ object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "feature
loadFeature(ChatLinks)
loadFeature(SaveCursorPosition)
loadFeature(CustomSkyBlockTextures)
+ loadFeature(PriceData)
loadFeature(Fixes)
if (Firmament.DEBUG) {
loadFeature(DeveloperFeatures)
diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt
new file mode 100644
index 0000000..3ae7b00
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt
@@ -0,0 +1,61 @@
+/*
+ * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.features.inventory
+
+import net.minecraft.text.Text
+import moe.nea.firmament.events.ItemTooltipEvent
+import moe.nea.firmament.features.FirmamentFeature
+import moe.nea.firmament.gui.config.ManagedConfig
+import moe.nea.firmament.repo.HypixelStaticData
+import moe.nea.firmament.util.FirmFormatters
+import moe.nea.firmament.util.skyBlockId
+
+object PriceData : FirmamentFeature {
+ override val identifier: String
+ get() = "price-data"
+
+ object TConfig : ManagedConfig(identifier) {
+ val tooltipEnabled by toggle("enable-always") { true }
+ val enableKeybinding by keyBindingWithDefaultUnbound("enable-keybind")
+ }
+
+ override val config get() = TConfig
+
+ override fun onLoad() {
+ ItemTooltipEvent.subscribe {
+ if (!TConfig.tooltipEnabled && !TConfig.enableKeybinding.isPressed()) {
+ return@subscribe
+ }
+ val sbId = it.stack.skyBlockId
+ val bazaarData = HypixelStaticData.bazaarData[sbId]
+ val lowestBin = HypixelStaticData.lowestBin[sbId]
+ if (bazaarData != null) {
+ it.lines.add(Text.literal(""))
+ it.lines.add(
+ Text.translatable(
+ "firmament.tooltip.bazaar.sell-order",
+ FirmFormatters.toString(bazaarData.quickStatus.sellPrice, 1)
+ )
+ )
+ it.lines.add(
+ Text.translatable(
+ "firmament.tooltip.bazaar.buy-order",
+ FirmFormatters.toString(bazaarData.quickStatus.buyPrice, 1)
+ )
+ )
+ } else if (lowestBin != null) {
+ it.lines.add(Text.literal(""))
+ it.lines.add(
+ Text.translatable(
+ "firmament.tooltip.ah.lowestbin",
+ FirmFormatters.toString(lowestBin, 1)
+ )
+ )
+ }
+ }
+ }
+}