aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/FixedComponent.kt
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/gui/FixedComponent.kt
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/gui/FixedComponent.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/gui/FixedComponent.kt10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/gui/FixedComponent.kt b/src/main/kotlin/moe/nea/firmament/gui/FixedComponent.kt
index c98feda..15d6bfc 100644
--- a/src/main/kotlin/moe/nea/firmament/gui/FixedComponent.kt
+++ b/src/main/kotlin/moe/nea/firmament/gui/FixedComponent.kt
@@ -14,20 +14,20 @@ import io.github.notenoughupdates.moulconfig.observer.GetSetter
import java.util.function.BiFunction
class FixedComponent(
- val fixedWidth: GetSetter<Int>,
- val fixedHeight: GetSetter<Int>,
+ val fixedWidth: GetSetter<Int>?,
+ val fixedHeight: GetSetter<Int>?,
val component: GuiComponent,
) : GuiComponent() {
- override fun getWidth(): Int = fixedWidth.get()
+ override fun getWidth(): Int = fixedWidth?.get() ?: component.width
- override fun getHeight(): Int = fixedHeight.get()
+ override fun getHeight(): Int = fixedHeight?.get() ?: component.height
override fun <T : Any?> foldChildren(initial: T, visitor: BiFunction<GuiComponent, T, T>): T {
return visitor.apply(component, initial)
}
fun fixContext(context: GuiImmediateContext): GuiImmediateContext =
- context.translated(0, 0, fixedWidth.get(), fixedHeight.get())
+ context.translated(0, 0, width, height)
override fun render(context: GuiImmediateContext) {
component.render(fixContext(context))