mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
buildingmaker import pen click latch
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
package net.torvald.terrarum
|
package net.torvald.terrarum
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.utils.Disposable
|
import com.badlogic.gdx.utils.Disposable
|
||||||
import com.badlogic.gdx.utils.GdxRuntimeException
|
|
||||||
import net.torvald.terrarum.App.printdbg
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||||
import net.torvald.terrarum.gameactors.Actor
|
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 render(updateRate: Float) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pause() {
|
override fun pause() {
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ class NoModuleDefaultTitlescreen(batch: FlippingSpriteBatch) : IngameInstance(ba
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun render(updateRate: Float) {
|
override fun render(updateRate: Float) {
|
||||||
|
super.render(updateRate)
|
||||||
|
|
||||||
gdxClearAndEnableBlend(0f, 0f, 0f, 0f)
|
gdxClearAndEnableBlend(0f, 0f, 0f, 0f)
|
||||||
|
|
||||||
if (!init) {
|
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) {
|
override fun render(updateRate: Float) {
|
||||||
|
super.render(updateRate)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Gdx.graphics.setTitle(TerrarumIngame.getCanonicalTitle())
|
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
|
private var mouseOnUI = false
|
||||||
@@ -428,7 +440,13 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
it.title = "Export"
|
it.title = "Export"
|
||||||
it.labelDo = "Export"
|
it.labelDo = "Export"
|
||||||
it.text = listOf("WH: $w\u00D7$h", "Name of the POI:")
|
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(
|
it.setPosition(
|
||||||
240,
|
240,
|
||||||
32
|
32
|
||||||
@@ -443,7 +461,13 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
it.title = "Import"
|
it.title = "Import"
|
||||||
it.labelDo = "Import"
|
it.labelDo = "Import"
|
||||||
it.text = listOf("Name of the POI:")
|
it.text = listOf("Name of the POI:")
|
||||||
it.confirmCallback = callback
|
it.confirmCallback = { s ->
|
||||||
|
callback(s)
|
||||||
|
mousePrimaryClickLatched = true
|
||||||
|
}
|
||||||
|
it.cancelCallback = {
|
||||||
|
mousePrimaryClickLatched = true
|
||||||
|
}
|
||||||
it.setPosition(
|
it.setPosition(
|
||||||
240,
|
240,
|
||||||
32
|
32
|
||||||
@@ -456,7 +480,6 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
private fun makePenWork(x: Int, y: Int) {
|
private fun makePenWork(x: Int, y: Int) {
|
||||||
val world = gameWorld
|
val world = gameWorld
|
||||||
val palSelection = uiPaletteSelector.fore
|
val palSelection = uiPaletteSelector.fore
|
||||||
val mouseJustDown = Terrarum.mouseJustDown
|
|
||||||
|
|
||||||
when (currentPenMode) {
|
when (currentPenMode) {
|
||||||
// test paint terrain layer
|
// test paint terrain layer
|
||||||
@@ -485,7 +508,10 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
removeBlockMarker(x, y)
|
removeBlockMarker(x, y)
|
||||||
}
|
}
|
||||||
PENMODE_IMPORT -> {
|
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
|
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
|
// 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
|
// there's still things to load which needs GL context to be present
|
||||||
if (!gameFullyLoaded) {
|
if (!gameFullyLoaded) {
|
||||||
@@ -757,6 +757,8 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
gameFullyLoaded = true
|
gameFullyLoaded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.render(updateRate)
|
||||||
|
|
||||||
ingameController.update()
|
ingameController.update()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
private var introUncoverDeltaCounter = 0f
|
private var introUncoverDeltaCounter = 0f
|
||||||
|
|
||||||
override fun render(updateRate: Float) {
|
override fun render(updateRate: Float) {
|
||||||
|
super.render(updateRate)
|
||||||
// async update and render
|
// async update and render
|
||||||
gameUpdateGovernor.update(Gdx.graphics.deltaTime, App.UPDATE_RATE, updateScreen, renderScreen)
|
gameUpdateGovernor.update(Gdx.graphics.deltaTime, App.UPDATE_RATE, updateScreen, renderScreen)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import kotlin.math.roundToInt
|
|||||||
class UIBuildingMakerGetFilename : UICanvas() {
|
class UIBuildingMakerGetFilename : UICanvas() {
|
||||||
|
|
||||||
var confirmCallback: (String) -> Unit = {}
|
var confirmCallback: (String) -> Unit = {}
|
||||||
|
var cancelCallback: () -> Unit = {}
|
||||||
var title = "Export"
|
var title = "Export"
|
||||||
var text = listOf("")
|
var text = listOf("")
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ class UIBuildingMakerGetFilename : UICanvas() {
|
|||||||
).also {
|
).also {
|
||||||
it.clickOnceListener = { _, _ ->
|
it.clickOnceListener = { _, _ ->
|
||||||
reset()
|
reset()
|
||||||
|
cancelCallback()
|
||||||
this.setAsClose()
|
this.setAsClose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user