diff --git a/ModuleComputers/src/net/torvald/terrarum/modulecomputers/gameactors/FixtureHomeComputer.kt b/ModuleComputers/src/net/torvald/terrarum/modulecomputers/gameactors/FixtureHomeComputer.kt index 409d28aa1..92eea9677 100644 --- a/ModuleComputers/src/net/torvald/terrarum/modulecomputers/gameactors/FixtureHomeComputer.kt +++ b/ModuleComputers/src/net/torvald/terrarum/modulecomputers/gameactors/FixtureHomeComputer.kt @@ -2,10 +2,10 @@ package net.torvald.terrarum.modulecomputers.gameactors import com.badlogic.gdx.Gdx import com.badlogic.gdx.Input -import com.badlogic.gdx.graphics.Camera -import com.badlogic.gdx.graphics.GL20 -import com.badlogic.gdx.graphics.OrthographicCamera +import com.badlogic.gdx.graphics.* import com.badlogic.gdx.graphics.g2d.SpriteBatch +import com.badlogic.gdx.graphics.glutils.FrameBuffer +import com.badlogic.gdx.math.Matrix4 import com.badlogic.gdx.utils.Disposable import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.Job @@ -92,42 +92,48 @@ internal class UIHomeComputer : UICanvas( private val drawOffX = (width - 560).div(2).toFloat() private val drawOffY = (height - 448).div(2).toFloat() - private lateinit var batch: SpriteBatch - private lateinit var camera: OrthographicCamera + private var batch: SpriteBatch + private var camera: OrthographicCamera internal lateinit var vm: VM init { batch = SpriteBatch() - camera = OrthographicCamera(width.toFloat(), height.toFloat()) - camera.setToOrtho(false) - camera.update() + camera = OrthographicCamera(560f, 448f) + //val m = Matrix4() + //m.setToOrtho2D(0f, 0f, width.toFloat(), height.toFloat()) batch.projectionMatrix = camera.combined } + private val fbo = FrameBuffer(Pixmap.Format.RGBA8888, 560, 448, true) + override fun updateUI(delta: Float) { } - override fun renderUI(otherBatch: SpriteBatch, camera: Camera) { + override fun renderUI(otherBatch: SpriteBatch, otherCamera: Camera) { otherBatch.end() - setCameraPosition(0f, 0f) - (vm.peripheralTable[1].peripheral as? GraphicsAdapter)?.let { gpu -> - val clearCol = gpu.getBackgroundColour() - Gdx.gl.glClearColor(clearCol.r, clearCol.g, clearCol.b, clearCol.a) - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) - gpu.render(Gdx.graphics.deltaTime, batch, posX + drawOffX, posY + drawOffY) + fbo.inAction(otherCamera as OrthographicCamera, otherBatch) { + (vm.peripheralTable[1].peripheral as? GraphicsAdapter)?.let { gpu -> + val clearCol = gpu.getBackgroundColour() + Gdx.gl.glClearColor(0f,0f,0f,0f) + //Gdx.gl.glClearColor(clearCol.r, clearCol.g, clearCol.b, clearCol.a) + //Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) + gpu.render(Gdx.graphics.deltaTime, otherBatch, 0f, 0f, true) + } } otherBatch.begin() + otherBatch.color = Color.WHITE + otherBatch.draw(fbo.colorBufferTexture, posX.toFloat(), posY.toFloat(), width.toFloat(), height.toFloat()) otherBatch.color = Toolkit.Theme.COL_INACTIVE Toolkit.drawBoxBorder(otherBatch, posX - 1, posY - 1, width + 2, height + 2) } private fun setCameraPosition(newX: Float, newY: Float) { - camera.position.set((-newX + width / 2), (-newY + height / 2), 0f) // deliberate integer division - camera.update() - batch.projectionMatrix = camera.combined +// camera.position.set((-newX + width / 2), (-newY + height / 2), 0f) // deliberate integer division +// camera.update() +// batch.projectionMatrix = camera.combined } override fun doOpening(delta: Float) { @@ -143,6 +149,7 @@ internal class UIHomeComputer : UICanvas( } override fun dispose() { + fbo.dispose() } } \ No newline at end of file diff --git a/assets/graphics/fonts/terrarum-sans-bitmap/thai_variable.tga b/assets/graphics/fonts/terrarum-sans-bitmap/thai_variable.tga index fc31cd039..1c4c5be26 100755 --- a/assets/graphics/fonts/terrarum-sans-bitmap/thai_variable.tga +++ b/assets/graphics/fonts/terrarum-sans-bitmap/thai_variable.tga @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4305c172f8b9ca7615fb9ef7d2543b6658ee10c29091b7209a58fd7fcaf62ecd +oid sha256:6fb73d354ee1bdd3b541d7512aeb6f13241373ede26319def3d37b93e1148a52 size 122898 diff --git a/assets/mods/dwarventech/ModuleComputers.jar b/assets/mods/dwarventech/ModuleComputers.jar index f0c61d03e..f066a88ea 100644 Binary files a/assets/mods/dwarventech/ModuleComputers.jar and b/assets/mods/dwarventech/ModuleComputers.jar differ diff --git a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt index b7750b346..a21b0def2 100644 --- a/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt +++ b/src/net/torvald/terrarum/ui/UIItemTextLineInput.kt @@ -241,10 +241,7 @@ class UIItemTextLineInput( if (!maxLen.exceeds(textbuf, codepoints)) { textbuf.addAll(cursorX, codepoints) - cursorX += codepoints.size - cursorDrawX = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX))) - - tryCursorBack() + moveCursorToEnd(codepoints.size) } } } @@ -320,10 +317,7 @@ class UIItemTextLineInput( if (!maxLen.exceeds(textbuf, codepoints)) { textbuf.addAll(cursorX, codepoints) - cursorX += codepoints.size - cursorDrawX = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX))) - - tryCursorBack() + moveCursorToEnd(codepoints.size) } } else if (keycodes.containsSome(Input.Keys.ENTER, Input.Keys.NUMPAD_ENTER)) { @@ -423,10 +417,7 @@ class UIItemTextLineInput( actuallyInserted.removeAt(0) - textbuf.addAll(cursorX, actuallyInserted) - - cursorX += actuallyInserted.size - cursorDrawX = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX))) + moveCursorToEnd(actuallyInserted.size) tryCursorBack() @@ -441,6 +432,13 @@ class UIItemTextLineInput( return textbuf.toJavaString() } + private fun moveCursorToEnd(stride: Int) { + cursorX += stride + cursorDrawX = App.fontGame.getWidth(CodepointSequence(textbuf.subList(0, cursorX))) + + tryCursorBack() + } + override fun render(batch: SpriteBatch, camera: Camera) { val ime = getIME(true) @@ -609,10 +607,12 @@ class UIItemTextLineInput( } fun setText(s: String) { clearText() - textbuf.addAll(s.toCodePoints()) + appendText(s) } fun appendText(s: String) { - textbuf.addAll(s.toCodePoints()) + val c = s.toCodePoints() + textbuf.addAll(c) + moveCursorToEnd(c.size) } override fun dispose() { fbo.dispose()