mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 13:51:53 +09:00
buildingmaker import pen click latch
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user