mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 12:25:12 -04:00
remove TextElement init workaround, call construct after initializing
This commit is contained in:
parent
93e0876322
commit
14662b4c7f
@ -47,4 +47,6 @@ class FadingTextElementTest {
|
||||
assertFalse(element.update)
|
||||
element.assetSize(Vec2(5.0f, 11.0f))
|
||||
}
|
||||
|
||||
// TODO: rendering (alpha), show, force hide, empty again
|
||||
}
|
||||
|
@ -140,4 +140,9 @@ abstract class Element(val guiRenderer: GUIRenderer, initialCacheSize: Int = 100
|
||||
protected inline fun <T> KProperty0<T>.delegate(): GuiDelegate<T> = this.apply { isAccessible = true }.getDelegate().unsafeCast()
|
||||
protected inline fun <T> KProperty0<T>.acknowledge(): T = delegate().acknowledge()
|
||||
protected inline fun <T> KProperty0<T>.rendering(): T = delegate().rendering()
|
||||
|
||||
|
||||
protected open fun construct() {
|
||||
tryUpdate()
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ open class TextElement(
|
||||
parent: Element? = null,
|
||||
properties: TextRenderProperties = TextRenderProperties.DEFAULT,
|
||||
) : Element(guiRenderer, text.charCount * 6 * GUIMesh.GUIMeshStruct.FLOATS_PER_VERTEX), Labeled {
|
||||
protected open val updateOnInitialize: Boolean get() = true
|
||||
private var activeElement: TextComponent? = null
|
||||
lateinit var info: TextRenderInfo
|
||||
private set
|
||||
@ -75,9 +74,7 @@ open class TextElement(
|
||||
|
||||
init {
|
||||
this.parent = parent
|
||||
if (updateOnInitialize) {
|
||||
update()
|
||||
}
|
||||
construct()
|
||||
}
|
||||
|
||||
private fun updateWishSize(text: ChatComponent) {
|
||||
|
@ -35,7 +35,6 @@ class FadingTextElement(
|
||||
parent: Element? = null,
|
||||
properties: TextRenderProperties = TextRenderProperties.DEFAULT,
|
||||
) : TextElement(guiRenderer = guiRenderer, text = text, background = background, parent, properties) {
|
||||
override val updateOnInitialize: Boolean get() = false
|
||||
private var phase: FadePhase? by GuiDelegate(null)
|
||||
|
||||
var times: FadingTimes = times
|
||||
@ -48,9 +47,11 @@ class FadingTextElement(
|
||||
|
||||
init {
|
||||
show()
|
||||
tryUpdate()
|
||||
super.construct()
|
||||
}
|
||||
|
||||
override fun construct() = Unit // don't get called by TextElement before phase delegate is initialized
|
||||
|
||||
private fun updateSize() {
|
||||
this.size = if (phase == null) Vec2.EMPTY else info.size.withBackgroundSize()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user