aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/features
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-07-01 03:42:51 +0200
committerLinnea Gräf <nea@nea.moe>2024-07-03 21:05:51 +0200
commit5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e (patch)
treea5b0a6fbc8878ae62bb2c3a01dbb255388353fda /src/main/kotlin/moe/nea/firmament/features
parentdff1f9c0e2b728dba902d72816104abccc61f511 (diff)
downloadFirmament-5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e.tar.gz
Firmament-5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e.tar.bz2
Firmament-5ee4b8d925eb12e068038a1fd2e1f35cdd8ef87e.zip
[WIP] Remove LibGUI
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features')
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt22
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt58
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt6
-rw-r--r--src/main/kotlin/moe/nea/firmament/features/mining/PristineProfitTracker.kt8
4 files changed, 7 insertions, 87 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt b/src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt
index 4ba8eee..972eb1f 100644
--- a/src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/debug/DebugView.kt
@@ -6,12 +6,6 @@
package moe.nea.firmament.features.debug
-import io.github.cottonmc.cotton.gui.client.CottonHud
-import io.github.cottonmc.cotton.gui.widget.WBox
-import io.github.cottonmc.cotton.gui.widget.WDynamicLabel
-import io.github.cottonmc.cotton.gui.widget.data.Axis
-import java.util.stream.Collectors
-import kotlin.time.Duration.Companion.seconds
import moe.nea.firmament.Firmament
import moe.nea.firmament.events.TickEvent
import moe.nea.firmament.features.FirmamentFeature
@@ -36,24 +30,8 @@ object DebugView : FirmamentFeature {
}
fun recalculateDebugWidget() {
- storedVariables.entries.removeIf { it.value.timer.passedTime() > 1.seconds }
- debugWidget.streamChildren().collect(Collectors.toList()).forEach {
- debugWidget.remove(it)
- }
- storedVariables.entries.forEach {
- debugWidget.add(WDynamicLabel({ "${it.key}: ${it.value.obj}" }))
- }
- debugWidget.layout()
- if (storedVariables.isNotEmpty()) {
- CottonHud.add(debugWidget, 20, 20)
- } else {
- CottonHud.remove(debugWidget)
- }
}
- val debugWidget = WBox(Axis.VERTICAL)
-
-
override fun onLoad() {
TickEvent.subscribe {
synchronized(this) {
diff --git a/src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt b/src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt
deleted file mode 100644
index 18f502c..0000000
--- a/src/main/kotlin/moe/nea/firmament/features/debug/ObjectRenderer.kt
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- */
-
-package moe.nea.firmament.features.debug
-
-import io.github.cottonmc.cotton.gui.widget.WBox
-import io.github.cottonmc.cotton.gui.widget.WLabel
-import io.github.cottonmc.cotton.gui.widget.WWidget
-import io.github.cottonmc.cotton.gui.widget.data.Axis
-import kotlinx.serialization.encodeToString
-import kotlinx.serialization.json.Json
-import kotlin.reflect.KProperty1
-import net.minecraft.text.Text
-import moe.nea.firmament.gui.WSpacer
-
-class ObjectRenderer(val box: WBox) {
- var indent = 0
-
- fun beginObject() {
- indent++
- }
-
- fun endObject() {
- indent--
- }
-
- fun emit(label: String, widget: WWidget) {
- WSpacer(WBox(Axis.VERTICAL).also {
- it.add(WWidget())
- it.add(widget)
- }, indent * 18)
- }
-
- fun <T : Any?> getDebuggingView(label: String, obj: T) {
- if (obj == null) {
- emit(label, WLabel(Text.literal("§cnull")))
- return
- }
- if (obj is String) {
- emit(label, WLabel(Text.literal(Json.encodeToString(obj))))
- }
- getObject(label, obj)
- }
-
- fun <T : Any> getObject(label: String, obj: T) {
- emit(label, WLabel(Text.literal(obj::class.simpleName ?: "<unknown>")))
- beginObject()
- for (prop in obj::class.members.filterIsInstance<KProperty1<T, *>>()) {
- val child = prop.get(obj)
- getDebuggingView(prop.name, child)
- }
- endObject()
- }
-
-}
diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt
index fb99c7c..2e6d5c6 100644
--- a/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/inventory/PriceData.kt
@@ -39,17 +39,17 @@ object PriceData : FirmamentFeature {
it.lines.add(Text.literal(""))
it.lines.add(
Text.stringifiedTranslatable("firmament.tooltip.bazaar.sell-order",
- FirmFormatters.formatCurrency(bazaarData.quickStatus.sellPrice, 1))
+ FirmFormatters.formatCommas(bazaarData.quickStatus.sellPrice, 1))
)
it.lines.add(
Text.stringifiedTranslatable("firmament.tooltip.bazaar.buy-order",
- FirmFormatters.formatCurrency(bazaarData.quickStatus.buyPrice, 1))
+ FirmFormatters.formatCommas(bazaarData.quickStatus.buyPrice, 1))
)
} else if (lowestBin != null) {
it.lines.add(Text.literal(""))
it.lines.add(
Text.stringifiedTranslatable("firmament.tooltip.ah.lowestbin",
- FirmFormatters.formatCurrency(lowestBin, 1))
+ FirmFormatters.formatCommas(lowestBin, 1))
)
}
}
diff --git a/src/main/kotlin/moe/nea/firmament/features/mining/PristineProfitTracker.kt b/src/main/kotlin/moe/nea/firmament/features/mining/PristineProfitTracker.kt
index 1597501..dd2d2fb 100644
--- a/src/main/kotlin/moe/nea/firmament/features/mining/PristineProfitTracker.kt
+++ b/src/main/kotlin/moe/nea/firmament/features/mining/PristineProfitTracker.kt
@@ -18,7 +18,7 @@ import moe.nea.firmament.features.FirmamentFeature
import moe.nea.firmament.gui.config.ManagedConfig
import moe.nea.firmament.gui.hud.MoulConfigHud
import moe.nea.firmament.util.BazaarPriceStrategy
-import moe.nea.firmament.util.FirmFormatters.formatCurrency
+import moe.nea.firmament.util.FirmFormatters.formatCommas
import moe.nea.firmament.util.SkyblockId
import moe.nea.firmament.util.data.ProfileSpecificDataHolder
import moe.nea.firmament.util.formattedString
@@ -99,11 +99,11 @@ object PristineProfitTracker : FirmamentFeature {
if (collectionPerSecond == null || moneyPerSecond == null) return
ProfitHud.collectionCurrent = collectionPerSecond
ProfitHud.collectionText = Text.stringifiedTranslatable("firmament.pristine-profit.collection",
- formatCurrency(collectionPerSecond * SECONDS_PER_HOUR,
- 1)).formattedString()
+ formatCommas(collectionPerSecond * SECONDS_PER_HOUR,
+ 1)).formattedString()
ProfitHud.moneyCurrent = moneyPerSecond
ProfitHud.moneyText = Text.stringifiedTranslatable("firmament.pristine-profit.money",
- formatCurrency(moneyPerSecond * SECONDS_PER_HOUR, 1))
+ formatCommas(moneyPerSecond * SECONDS_PER_HOUR, 1))
.formattedString()
val data = DConfig.data
if (data != null) {