From b496d606d33e1dfb5ce800dbc3c9fa2c0d20ae38 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Mon, 16 Jan 2023 03:36:17 +0900 Subject: [PATCH] removing fbo on UIItemTextSelector: it's useless --- .../terrarum/gamecontroller/InputStrober.kt | 4 ++-- src/net/torvald/terrarum/ui/UIItemSpinner.kt | 4 ++++ .../terrarum/ui/UIItemTextLineInput.kt | 4 ++++ .../torvald/terrarum/ui/UIItemTextSelector.kt | 22 ++++++++++++++----- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/net/torvald/terrarum/gamecontroller/InputStrober.kt b/src/net/torvald/terrarum/gamecontroller/InputStrober.kt index 8a79d7741..8ed70cc41 100644 --- a/src/net/torvald/terrarum/gamecontroller/InputStrober.kt +++ b/src/net/torvald/terrarum/gamecontroller/InputStrober.kt @@ -30,7 +30,7 @@ object InputStrober { init { // println("InputStrobe start") - thread.priority = 10 + thread.priority = 5 thread.start() } @@ -94,7 +94,7 @@ object InputStrober { if (keys[0] == 0) keyChanged = false } else if (stroboStatus % 2 == 1 && System.nanoTime() - stroboTime < KEYBOARD_DELAYS[stroboStatus]) { - Thread.sleep(1L) + Thread.sleep(20L) } else { stroboStatus += 1 diff --git a/src/net/torvald/terrarum/ui/UIItemSpinner.kt b/src/net/torvald/terrarum/ui/UIItemSpinner.kt index 3f54d2f2e..78e77eb19 100644 --- a/src/net/torvald/terrarum/ui/UIItemSpinner.kt +++ b/src/net/torvald/terrarum/ui/UIItemSpinner.kt @@ -88,6 +88,10 @@ class UIItemSpinner( private var textCache = "" private var textCacheLen = 0 + override fun show() { + fboUpdateLatch = true + } + override fun render(batch: SpriteBatch, camera: Camera) { batch.end() diff --git a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt index 0543a1a34..f0eb9e8db 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt @@ -377,6 +377,10 @@ class UIItemTextLineInput( } + override fun show() { + fboUpdateLatch = true + } + override fun update(delta: Float) { if (mouseoverUpdateLatch) { super.update(delta) diff --git a/src/net/torvald/terrarum/ui/UIItemTextSelector.kt b/src/net/torvald/terrarum/ui/UIItemTextSelector.kt index 8dc6cab61..6b945ac07 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextSelector.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextSelector.kt @@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.glutils.FrameBuffer import net.torvald.terrarum.* +import net.torvald.terrarum.App.printdbg import net.torvald.terrarum.gameworld.fmod /** @@ -39,7 +40,8 @@ class UIItemTextSelector( override val height = 24 private val buttonW = 30 - private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, width - 2*buttonW - 6, height - 4, false) + private val fboWidth = width - 2*buttonW - 6 +// private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, fboWidth, height - 4, false) var selection = initialSelection private var fboUpdateLatch = true @@ -61,6 +63,10 @@ class UIItemTextSelector( private var labelCache: List = listOf() + override fun show() { + fboUpdateLatch = true + } + override fun update(delta: Float) { super.update(delta) @@ -126,7 +132,7 @@ class UIItemTextSelector( batch.end() - if (fboUpdateLatch) { + /*if (fboUpdateLatch) { fboUpdateLatch = false fbo.inAction(camera as OrthographicCamera, batch) { batch.inUse { gdxClearAndEnableBlend(0f, 0f, 0f, 0f) @@ -134,9 +140,12 @@ class UIItemTextSelector( it.color = Color.WHITE val t = labelCache[selection] val tw = App.fontGame.getWidth(t) + + printdbg(this, "Drawing text: $t") + App.fontGameFBO.draw(it, t, (fbo.width - tw) / 2, 0) } } - } + }*/ batch.begin() @@ -185,7 +194,10 @@ class UIItemTextSelector( // draw text if (!paletteShowing) { batch.color = UIItemTextLineInput.TEXTINPUT_COL_TEXT - batch.draw(fbo.colorBufferTexture, posX + buttonW + 3f, posY + 2f, fbo.width.toFloat(), fbo.height.toFloat()) + val t = labelCache[selection] + val tw = App.fontGame.getWidth(t) +// batch.draw(fbo.colorBufferTexture, posX + buttonW + 3f, posY + 2f, fbo.width.toFloat(), fbo.height.toFloat()) + App.fontGame.draw(batch, t, posX + buttonW + 3 + (fboWidth - tw) / 2, posY + 2) } // palette else { @@ -247,6 +259,6 @@ class UIItemTextSelector( } override fun dispose() { - fbo.dispose() +// fbo.dispose() } }