Skip to content

Commit 982822e

Browse files
committed
banging wall into head
1 parent 5b794c2 commit 982822e

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

modules/config-impl/src/main/java/org/polyfrost/oneconfig/api/config/v1/Config.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.nio.file.Path;
3535
import java.util.ArrayList;
3636
import java.util.Arrays;
37+
import java.util.function.BooleanSupplier;
3738
import java.util.function.Predicate;
3839
import java.util.function.Supplier;
3940

@@ -75,6 +76,10 @@ protected void addDependency(String option, String condition) {
7576
addDependency(option, condition, false);
7677
}
7778

79+
protected void hideIf(String option, BooleanSupplier condition) {
80+
addDependency(option, null, () -> condition.getAsBoolean() ? Property.Display.HIDDEN : Property.Display.SHOWN);
81+
}
82+
7883
protected void hideIf(String option, String condition) {
7984
addDependency(option, condition, true);
8085
}

modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/HudManager.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ import org.polyfrost.polyui.operations.Move
5252
import org.polyfrost.polyui.unit.Align
5353
import org.polyfrost.polyui.unit.Vec2
5454
import org.polyfrost.polyui.unit.seconds
55+
import kotlin.io.path.exists
56+
import kotlin.io.path.readText
57+
import kotlin.io.path.writeText
5558
import kotlin.math.PI
5659

5760
object HudManager {
@@ -111,6 +114,13 @@ object HudManager {
111114
@ApiStatus.Internal
112115
fun initialize() {
113116
polyUI.translator.addDelegate("assets/oneconfig/hud")
117+
Runtime.getRuntime().addShutdownHook(Thread {
118+
ConfigManager.internal().folder.resolve("hudLock.lock").writeText(polyUI.size.value.toString())
119+
})
120+
val sizeFile = ConfigManager.internal().folder.resolve("hudLock.lock")
121+
val size = Vec2(if (sizeFile.exists()) sizeFile.readText().toLong() else 0L)
122+
// todo size stuff (upstream in polyui) AHHH
123+
114124
// todo use for inspections
115125
// it.master.onClick { (x, y) ->
116126
// val obj = polyUI.inputManager.rayCheckUnsafe(this, x, y) ?: return@onClick false

modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/LegacyHud.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ abstract class LegacyHud : Hud<Drawable>() {
5050

5151
override fun create() = createLegacy()
5252

53-
abstract fun render(stack: UMatrixStack, x: Float, y: Float)
53+
abstract fun render(stack: UMatrixStack, x: Float, y: Float, scaleX: Float, scaleY: Float)
5454

5555
/**
5656
* Wraps the [render] method in a [Drawable] instance, with the [Drawable.size] property delegating to [width] and [height].
@@ -73,7 +73,7 @@ abstract class LegacyHud : Hud<Drawable>() {
7373
override fun preRender(delta: Long) {}
7474

7575
override fun render() {
76-
render(Platform.screen().smuggledMatrixStack, x, y)
76+
render(Platform.screen().smuggledMatrixStack, x, y, scaleX, scaleY)
7777
}
7878

7979
override fun postRender() {}

modules/hud/src/main/kotlin/org/polyfrost/oneconfig/api/hud/v1/internal/HudVisualizer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ class HudVisualizer : ConfigVisualizer() {
5050
} else super.flattenSubcategories(options)
5151
}
5252

53-
override fun wrap(drawable: Drawable, title: String, desc: String?, icon: PolyImage?): Drawable {
53+
override fun wrap(drawable: Drawable, title: String?, desc: String?, icon: PolyImage?): Drawable {
5454
return Group(
5555
if (icon != null) Image(icon) else null,
5656
Group(
57-
Text(title, fontSize = 16f).setFont { medium },
57+
Text(title!!, fontSize = 16f).setFont { medium },
5858
if (desc != null) Text(desc, visibleSize = Vec2(240f, 12f)) else null,
5959
alignment = stdOpt,
6060
),

0 commit comments

Comments
 (0)