diff --git a/.idea/artifacts/ModuleBasegame.xml b/.idea/artifacts/ModuleBasegame.xml
new file mode 100644
index 000000000..6e7468621
--- /dev/null
+++ b/.idea/artifacts/ModuleBasegame.xml
@@ -0,0 +1,9 @@
+
+
+ $PROJECT_DIR$/out/artifacts/ModuleBasegame
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index ab7a10c04..38e808b05 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,6 +3,7 @@
+
\ No newline at end of file
diff --git a/assets/modules/basegame/blocks/terrain.tga.gz b/assets/modules/basegame/blocks/terrain.tga.gz
index 3f0e71f43..d2a4a1c26 100644
--- a/assets/modules/basegame/blocks/terrain.tga.gz
+++ b/assets/modules/basegame/blocks/terrain.tga.gz
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:39d99625d569412bdd0dc48f6bc06d704393cfc44cea59c5fc10ee249d4cf6de
-size 3017254
+oid sha256:16e2f954dbd71e74bbf1f7772fdade8e77d99e67dc221d7252fd87324e6ab42c
+size 3017046
diff --git a/ingamemodule_basegame/ingamemodule_basegame.iml b/ingamemodule_basegame/ingamemodule_basegame.iml
new file mode 100644
index 000000000..fb8e86671
--- /dev/null
+++ b/ingamemodule_basegame/ingamemodule_basegame.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/net/torvald/terrarum/DefaultConfig.kt b/src/net/torvald/terrarum/DefaultConfig.kt
index 63e7cf522..3dc51ae3a 100644
--- a/src/net/torvald/terrarum/DefaultConfig.kt
+++ b/src/net/torvald/terrarum/DefaultConfig.kt
@@ -82,6 +82,7 @@ object DefaultConfig {
jsonObject.addProperty("fullframelightupdate", false)
+ jsonObject.addProperty("useamericanunit", false) // Metric Masterrace -- Filthy imperials.
return jsonObject
}
diff --git a/src/net/torvald/terrarum/Ingame.kt b/src/net/torvald/terrarum/Ingame.kt
index e6a36ef54..1bd5d73a9 100644
--- a/src/net/torvald/terrarum/Ingame.kt
+++ b/src/net/torvald/terrarum/Ingame.kt
@@ -32,10 +32,10 @@ import javax.swing.JOptionPane
import com.badlogic.gdx.graphics.OrthographicCamera
import net.torvald.random.HQRNG
+import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.ui.*
import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser
import net.torvald.terrarum.worldgenerator.WorldGenerator
-import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
/**
@@ -65,10 +65,10 @@ class Ingame(val batch: SpriteBatch) : Screen {
private val actorsRenderMidTop = ArrayList(ACTORCONTAINER_INITIAL_SIZE)
private val actorsRenderFront = ArrayList(ACTORCONTAINER_INITIAL_SIZE)
- var playableActorDelegate: PlayableActorDelegate? = null // DO NOT LATEINIT!
+ lateinit var playableActorDelegate: PlayableActorDelegate // player must exist; use dummy player if there is none (required for camera)
private set
- inline val player: ActorHumanoid? // currently POSSESSED actor :)
- get() = playableActorDelegate?.actor
+ inline val player: ActorHumanoid // currently POSSESSED actor :)
+ get() = playableActorDelegate.actor
var screenZoom = 1.0f
val ZOOM_MAXIMUM = 4.0f
@@ -80,12 +80,11 @@ class Ingame(val batch: SpriteBatch) : Screen {
private val worldFBOformat = if (Terrarum.environment == RunningEnvironment.MOBILE) Pixmap.Format.RGBA4444 else Pixmap.Format.RGBA8888
- private val worldBlendFBOFormat = if (Terrarum.environment == RunningEnvironment.MOBILE) Pixmap.Format.RGBA4444 else Pixmap.Format.RGBA8888
private val lightFBOformat = Pixmap.Format.RGB888
var worldDrawFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
var worldGlowFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
- var worldBlendFrameBuffer = FrameBuffer(worldBlendFBOFormat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
+ var worldBlendFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
// RGB elements of Lightmap for Color Vec4(R, G, B, 1.0) 24-bit
var lightmapFboA = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), false)
var lightmapFboB = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), false)
@@ -145,9 +144,10 @@ class Ingame(val batch: SpriteBatch) : Screen {
//private val ingameDrawThread: ThreadIngameDraw // draw must be on the main thread
+ var gameInitialised = false
+ private set
var gameFullyLoaded = false
private set
- private var postInitDone = false
//////////////
@@ -226,7 +226,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
* Init instance by loading saved world
*/
private fun enter(gameSaveData: GameSaveData) {
- if (gameFullyLoaded) {
+ if (gameInitialised) {
println("[Ingame] loaded successfully.")
}
else {
@@ -242,7 +242,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
//initGame()
- gameFullyLoaded = true
+ gameInitialised = true
}
}
@@ -250,7 +250,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
* Init instance by creating new world
*/
private fun enter(worldParams: NewWorldParameters) {
- if (gameFullyLoaded) {
+ if (gameInitialised) {
println("[Ingame] loaded successfully.")
}
else {
@@ -285,7 +285,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
//initGame()
- gameFullyLoaded = true
+ gameInitialised = true
}
}
@@ -410,17 +410,35 @@ class Ingame(val batch: SpriteBatch) : Screen {
override fun render(delta: 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 (!postInitDone) {
+ if (!gameFullyLoaded) {
if (gameLoadMode == GameLoadMode.CREATE_NEW) {
playableActorDelegate = PlayableActorDelegate(PlayerBuilderSigrid())
- addNewActor(player!!)
+
+ // determine spawn position
+ val spawnX = world.width / 2
+ var solidTileCounter = 0
+ while (true) {
+ if (BlockCodex[world.getTileFromTerrain(spawnX, solidTileCounter)].isSolid ||
+ BlockCodex[world.getTileFromTerrain(spawnX - 1, solidTileCounter)].isSolid ||
+ BlockCodex[world.getTileFromTerrain(spawnX + 1, solidTileCounter)].isSolid
+ ) break
+
+ solidTileCounter += 1
+ }
+
+ player.setPosition(
+ spawnX * FeaturesDrawer.TILE_SIZE.toDouble(),
+ solidTileCounter * FeaturesDrawer.TILE_SIZE.toDouble()
+ )
+
+ addNewActor(player)
}
initGame()
- postInitDone = true
+ gameFullyLoaded = true
}
@@ -1517,7 +1535,7 @@ class Ingame(val batch: SpriteBatch) : Screen {
worldGlowFrameBuffer.dispose()
worldGlowFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
worldBlendFrameBuffer.dispose()
- worldBlendFrameBuffer = FrameBuffer(worldBlendFBOFormat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
+ worldBlendFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, false)
lightmapFboA.dispose()
lightmapFboA = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), false)
lightmapFboB.dispose()
@@ -1546,12 +1564,12 @@ class Ingame(val batch: SpriteBatch) : Screen {
- if (gameFullyLoaded) {
+ if (gameInitialised) {
LightmapRenderer.fireRecalculateEvent()
}
- if (postInitDone) {
+ if (gameFullyLoaded) {
// resize UIs
notifier.setPosition(
diff --git a/src/net/torvald/terrarum/LoadScreen.kt b/src/net/torvald/terrarum/LoadScreen.kt
index 013ccb788..c66d229a6 100644
--- a/src/net/torvald/terrarum/LoadScreen.kt
+++ b/src/net/torvald/terrarum/LoadScreen.kt
@@ -1,7 +1,6 @@
package net.torvald.terrarum
import com.badlogic.gdx.Gdx
-import com.badlogic.gdx.Screen
import com.badlogic.gdx.ScreenAdapter
import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.glutils.FrameBuffer
@@ -127,7 +126,7 @@ object LoadScreen : ScreenAdapter() {
// change screen WHEN the timer is reset.
// In other words, the arrow must hit the goal BEFORE context change take place
- if (screenToLoad?.gameFullyLoaded ?: false) {
+ if (screenToLoad?.gameInitialised ?: false) {
doContextChange = true
}
}
diff --git a/src/net/torvald/terrarum/gameactors/ActorInventory.kt b/src/net/torvald/terrarum/gameactors/ActorInventory.kt
index 50e7bab6a..8786a8dde 100644
--- a/src/net/torvald/terrarum/gameactors/ActorInventory.kt
+++ b/src/net/torvald/terrarum/gameactors/ActorInventory.kt
@@ -59,7 +59,7 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
"These commands are NOT INTERCHANGEABLE; they handle things differently according to the context.")
if (item.originalID == Player.PLAYER_REF_ID || item.originalID == 0x51621D) // do not delete this magic
throw IllegalArgumentException("Attempted to put human player into the inventory.")
- if (Terrarum.ingame != null &&
+ if ((Terrarum.ingame?.gameFullyLoaded ?: false) &&
(item.originalID == Terrarum.ingame?.player?.referenceID))
throw IllegalArgumentException("Attempted to put active player into the inventory.")
if ((!item.stackable || item.dynamicID in ITEM_DYNAMIC) && count > 1)
diff --git a/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt b/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt
index 5df033de1..d45fe7758 100644
--- a/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt
+++ b/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt
@@ -65,8 +65,6 @@ object PlayerBuilderSigrid {
p.inventory = ActorInventory(p, 0, ActorInventory.CAPACITY_MODE_NO_ENCUMBER)
- p.setPosition((4096 * FeaturesDrawer.TILE_SIZE).toDouble(), (300 * 16).toDouble())
-
p.faction.add(FactionFactory.create("basegame", "factions/FactionSigrid.json"))
@@ -78,7 +76,10 @@ object PlayerBuilderSigrid {
Block.PLANK_BIRCH, Block.PLANK_BLOODROSE, Block.PLANK_EBONY, Block.PLANK_NORMAL,
Block.SANDSTONE, Block.SANDSTONE_BLACK, Block.SANDSTONE_GREEN,
Block.SANDSTONE_RED, Block.STONE, Block.STONE_BRICKS,
- Block.STONE_QUARRIED, Block.STONE_TILE_WHITE, Block.TORCH
+ Block.STONE_QUARRIED, Block.STONE_TILE_WHITE, Block.TORCH,
+ Block.DAYLIGHT_CAPACITOR, Block.ICE_FRAGILE,
+ Block.ILLUMINATOR_WHITE, Block.ILLUMINATOR_BLACK, Block.ILLUMINATOR_ORANGE,
+ Block.ILLUMINATOR_GREEN
)
val walls = arrayOf(
Block.AIR, Block.DIRT, Block.GLASS_CRUDE,
diff --git a/src/net/torvald/terrarum/gameworld/GameWorld.kt b/src/net/torvald/terrarum/gameworld/GameWorld.kt
index b1f980d0a..6c3b7f30b 100644
--- a/src/net/torvald/terrarum/gameworld/GameWorld.kt
+++ b/src/net/torvald/terrarum/gameworld/GameWorld.kt
@@ -2,6 +2,7 @@
package net.torvald.terrarum.gameworld
import com.badlogic.gdx.graphics.Color
+import net.torvald.dataclass.Float16
import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.blockproperties.BlockCodex
import org.dyn4j.geometry.Vector2
@@ -34,6 +35,7 @@ class GameWorld(val width: Int, val height: Int) {
var gravitation: Vector2 = Vector2(0.0, 9.8)
/** 0.0..1.0+ */
var globalLight = Color(0f,0f,0f,0f)
+ var averageTemperature = 288f // 15 deg celsius; simulates global warming
@@ -56,7 +58,7 @@ class GameWorld(val width: Int, val height: Int) {
layerTerrainLowBits = PairedMapLayer(width, height)
layerWallLowBits = PairedMapLayer(width, height)
- layerThermal = MapLayerFloat(width / 2, height / 2)
+ layerThermal = MapLayerFloat(width / 2, height / 2, averageTemperature)
time = WorldTime(
@@ -287,6 +289,12 @@ class GameWorld(val width: Int, val height: Int) {
fun getWallDamage(x: Int, y: Int): Float =
wallDamages[LandUtil.getBlockAddr(x, y)] ?: 0f
+
+ fun getTemperature(worldTileX: Int, worldTileY: Int): Float? {
+ return layerThermal.getValue((worldTileX fmod width) / 2, worldTileY / 2)
+ }
+
+
companion object {
@Transient val WALL = 0
diff --git a/src/net/torvald/terrarum/gameworld/MapLayerFloat.kt b/src/net/torvald/terrarum/gameworld/MapLayerFloat.kt
index 73c819c25..caa738dca 100644
--- a/src/net/torvald/terrarum/gameworld/MapLayerFloat.kt
+++ b/src/net/torvald/terrarum/gameworld/MapLayerFloat.kt
@@ -10,6 +10,10 @@ import net.torvald.dataclass.Float16Bits
*/
class MapLayerFloat(val width: Int, val height: Int) : Iterable {
+ constructor(width: Int, height: Int, init: Float) : this(width, height) {
+ data = Array(height) { Array(width, { Float16.fromFloat(init) }) }
+ }
+
internal @Volatile var data: Array> // in parallel programming: do not trust your register; always read freshly from RAM!
init {
@@ -45,7 +49,7 @@ class MapLayerFloat(val width: Int, val height: Int) : Iterable {
return if (x !in 0..width - 1 || y !in 0..height - 1)
null
else
- data[y][x].toFloat()
+ Float16.toFloat(data[y][x])
}
internal fun setValue(x: Int, y: Int, value: Float) {
diff --git a/src/net/torvald/terrarum/gameworld/WorldSimulator.kt b/src/net/torvald/terrarum/gameworld/WorldSimulator.kt
index 5aa60462c..e5940934a 100644
--- a/src/net/torvald/terrarum/gameworld/WorldSimulator.kt
+++ b/src/net/torvald/terrarum/gameworld/WorldSimulator.kt
@@ -155,6 +155,12 @@ object WorldSimulator {
}
}
+
+ fun disperseHeat(delta: Float) {
+
+ }
+
+
fun drawFluidMapDebug(batch: SpriteBatch) {
batch.color = colourWater
diff --git a/src/net/torvald/terrarum/modulebasegame/items/PickaxeGeneric.kt b/src/net/torvald/terrarum/modulebasegame/items/PickaxeGeneric.kt
new file mode 100644
index 000000000..13776ccb6
--- /dev/null
+++ b/src/net/torvald/terrarum/modulebasegame/items/PickaxeGeneric.kt
@@ -0,0 +1,72 @@
+package net.torvald.terrarum.modulebasegame.items
+
+import net.torvald.point.Point2d
+import net.torvald.terrarum.Terrarum
+import net.torvald.terrarum.blockproperties.Block
+import net.torvald.terrarum.gameactors.AVKey
+import net.torvald.terrarum.gameactors.ActorWithPhysics
+import net.torvald.terrarum.itemproperties.Calculate
+import net.torvald.terrarum.itemproperties.GameItem
+import net.torvald.terrarum.itemproperties.ItemID
+import net.torvald.terrarum.itemproperties.Material
+
+/**
+ * Created by minjaesong on 2017-07-17.
+ */
+class PickaxeGeneric(override val originalID: ItemID) : GameItem() {
+
+ override var dynamicID: ItemID = originalID
+ override val originalName = "PACKAGED_PICK"
+ override var baseMass = 10.0
+ override var baseToolSize: Double? = 10.0
+ override var stackable = true
+ override var maxDurability = 147
+ override var durability = maxDurability.toFloat()
+ override val equipPosition = 9
+ override var inventoryCategory = Category.TOOL
+ override val isUnique = false
+ override val isDynamic = true
+ override val material = Material(0,0,0,0,0,0,0,0,1,0.0)
+
+ init {
+ super.name = "Builtin Pickaxe"
+ }
+
+ override fun primaryUse(delta: Float): Boolean {
+ val mouseTileX = Terrarum.mouseTileX
+ val mouseTileY = Terrarum.mouseTileY
+
+ val mousePoint = Point2d(mouseTileX.toDouble(), mouseTileY.toDouble())
+ val actorvalue = Terrarum.ingame!!.player!!.actorValue
+
+ using = true
+
+ // linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
+ // return false if hitting actors
+ Terrarum.ingame!!.actorContainer.forEach({
+ if (it is ActorWithPhysics && it.tilewiseHitbox.intersects(mousePoint))
+ return false
+ })
+
+ // return false if here's no tile
+ if (Block.AIR == Terrarum.ingame!!.world.getTileFromTerrain(mouseTileX, mouseTileY))
+ return false
+
+ // filter passed, do the job
+ val swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
+
+ Terrarum.ingame!!.world.inflictTerrainDamage(
+ mouseTileX, mouseTileY,
+ Calculate.pickaxePower(Terrarum.ingame!!.player!!, material) * swingDmgToFrameDmg
+ )
+
+ return true
+ }
+
+ override fun endPrimaryUse(delta: Float): Boolean {
+ using = false
+ // reset action timer to zero
+ Terrarum.ingame!!.player!!.actorValue.set(AVKey.__ACTION_TIMER, 0.0)
+ return true
+ }
+}
\ No newline at end of file
diff --git a/src/net/torvald/terrarum/ui/UIBasicNotifier.kt b/src/net/torvald/terrarum/ui/UIBasicNotifier.kt
index 19a917248..83726773f 100644
--- a/src/net/torvald/terrarum/ui/UIBasicNotifier.kt
+++ b/src/net/torvald/terrarum/ui/UIBasicNotifier.kt
@@ -7,6 +7,7 @@ import net.torvald.terrarum.*
import net.torvald.terrarum.gameactors.ActorHumanoid
import net.torvald.terrarum.gameactors.Second
import net.torvald.terrarum.gameactors.abs
+import net.torvald.terrarum.gameactors.roundInt
import net.torvald.terrarum.imagefont.Watch7SegSmall
import net.torvald.terrarum.worlddrawer.LightmapRenderer
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
@@ -44,7 +45,21 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas() {
}
private val temperature: Int
- get() = -2
+ get() {
+ if (player != null) {
+ val playerTilePos = player.tilewiseHitbox
+ val tempCelsius = -273f + (Terrarum.ingame?.world?.getTemperature(playerTilePos.centeredX.toInt(), playerTilePos.centeredY.toInt()) ?: 288f)
+ return if (Terrarum.getConfigBoolean("useamericanunit")) {
+ tempCelsius.times(1.8f).plus(32f).roundInt()
+ }
+ else {
+ tempCelsius.roundInt()
+ }
+ }
+ else {
+ return 888
+ }
+ }
private val mailCount: Int
get() = 0
@@ -65,7 +80,12 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas() {
sb.append(temperature.abs())
- sb.append('"') // celsius superscript
+ if (Terrarum.getConfigBoolean("useamericanunit")) {
+ sb.append('#') // fahrenheit subscript
+ }
+ else {
+ sb.append('"') // celsius superscript
+ }
return sb.toString()
}
diff --git a/src/net/torvald/terrarum/ui/UIInventory.kt b/src/net/torvald/terrarum/ui/UIInventory.kt
index d8a6f0702..6399c7272 100644
--- a/src/net/torvald/terrarum/ui/UIInventory.kt
+++ b/src/net/torvald/terrarum/ui/UIInventory.kt
@@ -124,12 +124,16 @@ class UIInventory(
private val scrollLeftButton = UIItemImageButton(this,
scrollImageButtonAtlas.get(0, 0),
posX = categoryWidth,
- posY = (height - controlHelpHeight - scrollImageButtonAtlas.tileH) / 2
+ posY = 0,//(height - controlHelpHeight - scrollImageButtonAtlas.tileH) / 2,
+ width = scrollImageButtonAtlas.tileW,
+ height = height - controlHelpHeight
)
private val scrollRightButton = UIItemImageButton(this,
scrollImageButtonAtlas.get(1, 0),
posX = width - scrollImageButtonAtlas.tileW,
- posY = (height - controlHelpHeight - scrollImageButtonAtlas.tileH) / 2
+ posY = 0,//(height - controlHelpHeight - scrollImageButtonAtlas.tileH) / 2,
+ width = scrollImageButtonAtlas.tileW,
+ height = height - controlHelpHeight
)
var itemPage = 0
var itemPageCount = 1 // TODO total size of current category / items.size
@@ -139,7 +143,7 @@ class UIInventory(
var inventorySortList = ArrayList()
private var rebuildList = true
- private val SP = "${0x3000.toChar()}${0x3000.toChar()}${0x3000.toChar()}"
+ private val SP = "${0x3000.toChar()}${0x3000.toChar()}"
val listControlHelp: String
get() = if (Terrarum.environment == RunningEnvironment.PC)
"${0xe006.toChar()} ${Lang["GAME_INVENTORY_USE"]}$SP" +
@@ -161,23 +165,21 @@ class UIInventory(
private var isEncumbered = false
- private val seekLeft: Int; get() = Terrarum.getConfigInt("keyleft") // to support in-screen keybind changing
- private val seekRight: Int; get() = Terrarum.getConfigInt("keyright") // to support in-screen keybind changing
- private val seekUp: Int; get() = Terrarum.getConfigInt("keyup") // to support in-screen keybind changing
- private val seekDown: Int; get() = Terrarum.getConfigInt("keydown") // to support in-screen keybind changing
+ private val seekLeft: Int; get() = Terrarum.getConfigInt("keyleft") // getter used to support in-game keybind changing
+ private val seekRight: Int; get() = Terrarum.getConfigInt("keyright") // getter used to support in-game keybind changing
+ private val seekUp: Int; get() = Terrarum.getConfigInt("keyup") // getter used to support in-game keybind changing
+ private val seekDown: Int; get() = Terrarum.getConfigInt("keydown") // getter used to support in-game keybind changing
init {
// assign actions to the buttons
- scrollLeftButton.clickOnceAction = { mouseX, mouseY, button -> // click once action doesn't work ?!
+ scrollLeftButton.clickOnceListener = { mouseX, mouseY, button -> // click once action doesn't work ?!
if (button == Input.Buttons.LEFT) {
- println("prevpage")
itemPage = (itemPage - 1) fmod itemPageCount
}
}
- scrollRightButton.clickOnceAction = { mouseX, mouseY, button ->
+ scrollRightButton.clickOnceListener = { mouseX, mouseY, button ->
if (button == Input.Buttons.LEFT) {
- println("nextpage")
itemPage = (itemPage + 1) fmod itemPageCount
}
}
diff --git a/src/net/torvald/terrarum/ui/UIItem.kt b/src/net/torvald/terrarum/ui/UIItem.kt
index 03c87cff1..246ac517c 100644
--- a/src/net/torvald/terrarum/ui/UIItem.kt
+++ b/src/net/torvald/terrarum/ui/UIItem.kt
@@ -31,39 +31,39 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI
// kind of listener implementation
- var updateAction: ((Float) -> Unit)? = null
- var keyDownAction: ((Int) -> Unit)? = null
- var keyUpAction: ((Int) -> Unit)? = null
- var mouseMovedAction: ((Int, Int) -> Unit)? = null
- var touchDraggedAction: ((Int, Int, Int) -> Unit)? = null
- var touchDownAction: ((Int, Int, Int, Int) -> Unit)? = null
- var touchUpAction: ((Int, Int, Int, Int) -> Unit)? = null
- var scrolledAction: ((Int) -> Unit)? = null
+ var updateListener: ((Float) -> Unit)? = null
+ var keyDownListener: ((Int) -> Unit)? = null
+ var keyUpListener: ((Int) -> Unit)? = null
+ var mouseMovedListener: ((Int, Int) -> Unit)? = null
+ var touchDraggedListener: ((Int, Int, Int) -> Unit)? = null
+ var touchDownListener: ((Int, Int, Int, Int) -> Unit)? = null
+ var touchUpListener: ((Int, Int, Int, Int) -> Unit)? = null
+ var scrolledListener: ((Int) -> Unit)? = null
- var clickOnceAction: ((Int, Int, Int) -> Unit)? = null
- var clickOnceActionEngaged = false
+ var clickOnceListener: ((Int, Int, Int) -> Unit)? = null
+ var clickOnceListenerFired = false
open fun update(delta: Float) {
- if (updateAction != null) {
- updateAction!!.invoke(delta)
+ if (updateListener != null) {
+ updateListener!!.invoke(delta)
}
}
abstract fun render(batch: SpriteBatch)
// keyboard controlled
open fun keyDown(keycode: Int): Boolean {
- if (keyDownAction != null) {
- keyDownAction!!.invoke(keycode)
+ if (keyDownListener != null) {
+ keyDownListener!!.invoke(keycode)
return true
}
return false
}
open fun keyUp(keycode: Int): Boolean {
- if (keyUpAction != null) {
- keyUpAction!!.invoke(keycode)
+ if (keyUpListener != null) {
+ keyUpListener!!.invoke(keycode)
return true
}
@@ -72,16 +72,16 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI
// mouse controlled
open fun mouseMoved(screenX: Int, screenY: Int): Boolean {
- if (mouseMovedAction != null) {
- mouseMovedAction!!.invoke(relativeMouseX, relativeMouseY)
+ if (mouseMovedListener != null) {
+ mouseMovedListener!!.invoke(relativeMouseX, relativeMouseY)
return true
}
return false
}
open fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
- if (touchDraggedAction != null) {
- touchDraggedAction!!.invoke(relativeMouseX, relativeMouseY, pointer)
+ if (touchDraggedListener != null) {
+ touchDraggedListener!!.invoke(relativeMouseX, relativeMouseY, pointer)
return true
}
@@ -90,31 +90,31 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI
open fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
var actionDone = false
- if (touchDownAction != null) {
- touchDownAction!!.invoke(relativeMouseX, relativeMouseY, pointer, button)
+ if (touchDownListener != null) {
+ touchDownListener!!.invoke(relativeMouseX, relativeMouseY, pointer, button)
actionDone = true
}
- if (!clickOnceActionEngaged && mouseUp) {
- clickOnceAction!!.invoke(relativeMouseX, relativeMouseY, button)
+ if (!clickOnceListenerFired && mouseUp) {
+ clickOnceListener!!.invoke(relativeMouseX, relativeMouseY, button)
actionDone = true
}
return actionDone
}
open fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
- clickOnceActionEngaged = false
+ clickOnceListenerFired = false
- if (touchUpAction != null) {
- touchUpAction!!.invoke(relativeMouseX, relativeMouseY, pointer, button)
+ if (touchUpListener != null) {
+ touchUpListener!!.invoke(relativeMouseX, relativeMouseY, pointer, button)
return true
}
return false
}
open fun scrolled(amount: Int): Boolean {
- if (scrolledAction != null) {
- scrolledAction!!.invoke(amount)
+ if (scrolledListener != null) {
+ scrolledListener!!.invoke(amount)
return true
}
diff --git a/work_files/graphics/terrain/terrain.psd.gz b/work_files/graphics/terrain/terrain.psd.gz
index 721c10dd4..c706894d5 100644
--- a/work_files/graphics/terrain/terrain.psd.gz
+++ b/work_files/graphics/terrain/terrain.psd.gz
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
-oid sha256:a7e238df32ed73d4cda6eb102264295d313e29367a38532d10eaea9f0cd1a601
-size 528865
+oid sha256:33179f8881fef09af983a226c879dbfd42ca70ea81b9b08a0426ba54479ed59c
+size 529386