buildingmaker import pen click latch

This commit is contained in:
minjaesong
2023-10-24 16:49:04 +09:00
parent a5a2c98041
commit a8b44c1cac
6 changed files with 40 additions and 6 deletions

View File

@@ -1,8 +1,8 @@
package net.torvald.terrarum
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.utils.Disposable
import com.badlogic.gdx.utils.GdxRuntimeException
import net.torvald.terrarum.App.printdbg
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.gameactors.Actor
@@ -187,6 +187,7 @@ open class IngameInstance(val batch: FlippingSpriteBatch, val isMultiplayer: Boo
}
override fun render(updateRate: Float) {
}
override fun pause() {

View File

@@ -58,6 +58,8 @@ class NoModuleDefaultTitlescreen(batch: FlippingSpriteBatch) : IngameInstance(ba
}
override fun render(updateRate: Float) {
super.render(updateRate)
gdxClearAndEnableBlend(0f, 0f, 0f, 0f)
if (!init) {

View File

@@ -298,7 +298,14 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
}
private var mousePrimaryClickLatched = false
var mousePrimaryJustDown = false; private set
override fun render(updateRate: Float) {
super.render(updateRate)
Gdx.graphics.setTitle(TerrarumIngame.getCanonicalTitle())
@@ -316,6 +323,11 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
)
)
if (!Gdx.input.isButtonPressed(App.getConfigInt("config_mouseprimary"))) {
mousePrimaryClickLatched = false
}
}
private var mouseOnUI = false
@@ -428,7 +440,13 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
it.title = "Export"
it.labelDo = "Export"
it.text = listOf("WH: $w\u00D7$h", "Name of the POI:")
it.confirmCallback = callback
it.confirmCallback = { s ->
callback(s)
mousePrimaryClickLatched = true
}
it.cancelCallback = {
mousePrimaryClickLatched = true
}
it.setPosition(
240,
32
@@ -443,7 +461,13 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
it.title = "Import"
it.labelDo = "Import"
it.text = listOf("Name of the POI:")
it.confirmCallback = callback
it.confirmCallback = { s ->
callback(s)
mousePrimaryClickLatched = true
}
it.cancelCallback = {
mousePrimaryClickLatched = true
}
it.setPosition(
240,
32
@@ -456,7 +480,6 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
private fun makePenWork(x: Int, y: Int) {
val world = gameWorld
val palSelection = uiPaletteSelector.fore
val mouseJustDown = Terrarum.mouseJustDown
when (currentPenMode) {
// test paint terrain layer
@@ -485,7 +508,10 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
removeBlockMarker(x, y)
}
PENMODE_IMPORT -> {
if (mouseJustDown) importPoi(x, y)
if (!mousePrimaryClickLatched) {
importPoi(x, y)
mousePrimaryClickLatched = true
}
}
}
}

View File

@@ -732,7 +732,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
internal var autosaveTimer = 0f
override fun render(`_`: Float) {
override fun render(updateRate: Float) {
// Q&D solution for LoadScreen and Ingame, where while LoadScreen is working, Ingame now no longer has GL Context
// there's still things to load which needs GL context to be present
if (!gameFullyLoaded) {
@@ -757,6 +757,8 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
gameFullyLoaded = true
}
super.render(updateRate)
ingameController.update()

View File

@@ -302,6 +302,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
private var introUncoverDeltaCounter = 0f
override fun render(updateRate: Float) {
super.render(updateRate)
// async update and render
gameUpdateGovernor.update(Gdx.graphics.deltaTime, App.UPDATE_RATE, updateScreen, renderScreen)
}

View File

@@ -12,6 +12,7 @@ import kotlin.math.roundToInt
class UIBuildingMakerGetFilename : UICanvas() {
var confirmCallback: (String) -> Unit = {}
var cancelCallback: () -> Unit = {}
var title = "Export"
var text = listOf("")
@@ -63,6 +64,7 @@ class UIBuildingMakerGetFilename : UICanvas() {
).also {
it.clickOnceListener = { _, _ ->
reset()
cancelCallback()
this.setAsClose()
}
}