aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/config
diff options
context:
space:
mode:
authorronald <inglettronald@gmail.com>2023-07-26 18:52:23 -0500
committerronald <inglettronald@gmail.com>2023-07-26 18:52:23 -0500
commit45180d569a87740ed8da9535b8b362192e891988 (patch)
tree19795c7efa4cef23b941372fa7d3ba6a0b895fbb /src/main/kotlin/com/dulkirfabric/config
parent829203c44dc2361e78764a59673f3f41fd306e33 (diff)
downloadDulkirMod-Fabric-45180d569a87740ed8da9535b8b362192e891988.tar.gz
DulkirMod-Fabric-45180d569a87740ed8da9535b8b362192e891988.tar.bz2
DulkirMod-Fabric-45180d569a87740ed8da9535b8b362192e891988.zip
wip
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/config')
-rw-r--r--src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
index d310be4..7447595 100644
--- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
+++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt
@@ -25,6 +25,7 @@ import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import me.shedaniel.clothconfig2.api.ConfigBuilder
+import meteordevelopment.orbit.EventHandler
import moe.nea.jarvis.api.Point
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.util.InputUtil
@@ -304,25 +305,24 @@ class DulkirConfig {
var configOptions = ConfigOptions()
- val huds = mutableListOf<Pair<HudElement, Point>>()
+ val huds = mutableListOf<Triple<HudElement, Point, Float>>()
fun hudElement(
id: String, label: Text, width: Int, height: Int,
- defaultPosition: Point
+ defaultPosition: Point, scale: Float = 1f
): HudElement {
val element = HudElement(
configOptions.positions.getOrPut(
id
- ) { HudElement.Positioning(defaultPosition.x(), defaultPosition.y(), 1F) },
+ ) { HudElement.Positioning(defaultPosition.x(), defaultPosition.y(), scale) },
id,
label, width, height,
)
- huds.add(Pair(element, defaultPosition))
+ huds.add(Triple(element, defaultPosition, scale))
return element
}
-
- private fun saveConfig() {
+ fun saveConfig() {
val json = Json {
prettyPrint = true
ignoreUnknownKeys = true
@@ -349,11 +349,10 @@ class DulkirConfig {
}
configOptions = json.decodeFromString<ConfigOptions>(configFile.readText())
}
- huds.forEach { (element, defaultPosition) ->
+ huds.forEach { (element, defaultPosition, scale) ->
element.positioning = configOptions.positions.getOrPut(
- element.key,
- { HudElement.Positioning(defaultPosition.x(), defaultPosition.y(), 1F) }
- )
+ element.key
+ ) { HudElement.Positioning(defaultPosition.x(), defaultPosition.y(), scale) }
}
}
}