Skip to content

Commit

Permalink
banging wall into head
Browse files Browse the repository at this point in the history
  • Loading branch information
nextdayy committed Nov 20, 2024
1 parent 5b794c2 commit 982822e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.function.BooleanSupplier;
import java.util.function.Predicate;
import java.util.function.Supplier;

Expand Down Expand Up @@ -75,6 +76,10 @@ protected void addDependency(String option, String condition) {
addDependency(option, condition, false);
}

protected void hideIf(String option, BooleanSupplier condition) {
addDependency(option, null, () -> condition.getAsBoolean() ? Property.Display.HIDDEN : Property.Display.SHOWN);
}

protected void hideIf(String option, String condition) {
addDependency(option, condition, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ import org.polyfrost.polyui.operations.Move
import org.polyfrost.polyui.unit.Align
import org.polyfrost.polyui.unit.Vec2
import org.polyfrost.polyui.unit.seconds
import kotlin.io.path.exists
import kotlin.io.path.readText
import kotlin.io.path.writeText
import kotlin.math.PI

object HudManager {
Expand Down Expand Up @@ -111,6 +114,13 @@ object HudManager {
@ApiStatus.Internal
fun initialize() {
polyUI.translator.addDelegate("assets/oneconfig/hud")
Runtime.getRuntime().addShutdownHook(Thread {
ConfigManager.internal().folder.resolve("hudLock.lock").writeText(polyUI.size.value.toString())
})
val sizeFile = ConfigManager.internal().folder.resolve("hudLock.lock")
val size = Vec2(if (sizeFile.exists()) sizeFile.readText().toLong() else 0L)
// todo size stuff (upstream in polyui) AHHH

// todo use for inspections
// it.master.onClick { (x, y) ->
// val obj = polyUI.inputManager.rayCheckUnsafe(this, x, y) ?: return@onClick false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class LegacyHud : Hud<Drawable>() {

override fun create() = createLegacy()

abstract fun render(stack: UMatrixStack, x: Float, y: Float)
abstract fun render(stack: UMatrixStack, x: Float, y: Float, scaleX: Float, scaleY: Float)

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

override fun render() {
render(Platform.screen().smuggledMatrixStack, x, y)
render(Platform.screen().smuggledMatrixStack, x, y, scaleX, scaleY)
}

override fun postRender() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class HudVisualizer : ConfigVisualizer() {
} else super.flattenSubcategories(options)
}

override fun wrap(drawable: Drawable, title: String, desc: String?, icon: PolyImage?): Drawable {
override fun wrap(drawable: Drawable, title: String?, desc: String?, icon: PolyImage?): Drawable {
return Group(
if (icon != null) Image(icon) else null,
Group(
Text(title, fontSize = 16f).setFont { medium },
Text(title!!, fontSize = 16f).setFont { medium },
if (desc != null) Text(desc, visibleSize = Vec2(240f, 12f)) else null,
alignment = stdOpt,
),
Expand Down

0 comments on commit 982822e

Please sign in to comment.