aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/FixedComponent.kt
diff options
context:
space:
mode:
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))