diff --git a/config_colemak.json b/config_colemak.json index 3ff4ea4f3..9e89936ab 100644 --- a/config_colemak.json +++ b/config_colemak.json @@ -9,24 +9,24 @@ "multithreadedlight": false, "showhealthmessageonstartup": true, "usexinput": true, - "gamepadkeyn": 3, - "gamepadkeyw": 2, - "gamepadkeys": 0, - "gamepadkeye": 1, - "gamepadlup": 4, - "gamepadrup": 5, - "gamepadselect": 6, - "gamepadstart": 7, - "gamepadltrigger": 8, - "gamepadrtrigger": 9, - "gamepadlthumb": 10, - "gamepadrthumb": 11, - "gamepadaxislx": 1, - "gamepadaxisly": 0, - "gamepadaxisrx": 3, - "gamepadaxisry": 2, - "gamepadtriggeraxis": 4, - "gamepadtriggeraxis2": 5, + "config_gamepadkeyn": 3, + "config_gamepadkeyw": 2, + "config_gamepadkeys": 0, + "config_gamepadkeye": 1, + "config_gamepadlup": 4, + "config_gamepadrup": 5, + "config_gamepadselect": 6, + "config_gamepadstart": 7, + "config_gamepadltrigger": 8, + "config_gamepadrtrigger": 9, + "config_gamepadlthumb": 10, + "config_gamepadrthumb": 11, + "config_gamepadaxislx": 1, + "config_gamepadaxisly": 0, + "config_gamepadaxisrx": 3, + "config_gamepadaxisry": 2, + "config_gamepadtriggeraxis": 4, + "config_gamepadtriggeraxis2": 5, "gamepadaxiszeropoints": [ -0.011, -0.022, @@ -34,24 +34,24 @@ -0.044 ], "gamepadlabelstyle": "msxbone", - "keyup":34, - "keyleft":46, - "keydown":47, - "keyright":48, - "keyinventory":45, - "keyinteract":44, - "keymovementaux": 29, - "keyclose": 31, - "keyzoom": 54, - "keygamemenu": 61, - "keyquicksel": 59, - "keyquickselalt": [ + "config_keyup":34, + "config_keyleft":46, + "config_keydown":47, + "config_keyright":48, + "config_keyinventory":45, + "config_keyinteract":44, + "config_keymovementaux": 29, + "config_keyclose": 31, + "config_keyzoom": 54, + "config_keygamemenu": 61, + "config_keyquicksel": 59, + "config_keyquickselalt": [ 67, 129, 73 ], - "keyjump": 62, - "keyquickslots": [ + "config_keyjump": 62, + "config_keyquickslots": [ 8, 9, 10, @@ -63,8 +63,8 @@ 16, 7 ], - "mouseprimary": 0, - "mousesecondary": 1, + "config_mouseprimary": 0, + "config_mousesecondary": 1, "pcgamepadenv": "console", "maxparticles": 768, "temperatureunit": 1, diff --git a/src/net/torvald/UnsafePtr.kt b/src/net/torvald/UnsafePtr.kt index 992920406..36d784dcb 100644 --- a/src/net/torvald/UnsafePtr.kt +++ b/src/net/torvald/UnsafePtr.kt @@ -11,6 +11,9 @@ import sun.misc.Unsafe */ internal object UnsafeHelper { + var unsafeAllocatedSize = 0L + internal set + val unsafe: Unsafe init { @@ -57,6 +60,10 @@ internal object UnsafeHelper { * Use of hashCode() is forbidden, use the pointer instead. */ internal class UnsafePtr(pointer: Long, allocSize: Long) { + init { + UnsafeHelper.unsafeAllocatedSize += allocSize + } + var destroyed = false private set @@ -67,8 +74,10 @@ internal class UnsafePtr(pointer: Long, allocSize: Long) { private set fun realloc(newSize: Long) { + UnsafeHelper.unsafeAllocatedSize -= size ptr = UnsafeHelper.unsafe.reallocateMemory(ptr, newSize) size = newSize + UnsafeHelper.unsafeAllocatedSize += size } fun destroy() { @@ -79,6 +88,8 @@ internal class UnsafePtr(pointer: Long, allocSize: Long) { printStackTrace(this) destroyed = true + + UnsafeHelper.unsafeAllocatedSize -= size } } diff --git a/src/net/torvald/terrarum/DefaultConfig.kt b/src/net/torvald/terrarum/DefaultConfig.kt index e95d1583b..864acff0f 100644 --- a/src/net/torvald/terrarum/DefaultConfig.kt +++ b/src/net/torvald/terrarum/DefaultConfig.kt @@ -29,68 +29,68 @@ object DefaultConfig { jsonObject.addProperty("showhealthmessageonstartup", true) - // control-gamepad + + // "config_key", "config_mouse", "config_gamepad" are keyword recognised by control setup UI + jsonObject.addProperty("usexinput", true) // when FALSE, LT+RT input on xbox controller is impossible - jsonObject.addProperty("gamepadkeyn", 3) - jsonObject.addProperty("gamepadkeyw", 2) - jsonObject.addProperty("gamepadkeys", 0) - jsonObject.addProperty("gamepadkeye", 1) // xbox indices + jsonObject.addProperty("config_gamepadkeyn", 3) + jsonObject.addProperty("config_gamepadkeyw", 2) + jsonObject.addProperty("config_gamepadkeys", 0) + jsonObject.addProperty("config_gamepadkeye", 1) // xbox indices - jsonObject.addProperty("gamepadlup", 4) - jsonObject.addProperty("gamepadrup", 5) - jsonObject.addProperty("gamepadselect", 6) - jsonObject.addProperty("gamepadstart", 7) + jsonObject.addProperty("config_gamepadlup", 4) + jsonObject.addProperty("config_gamepadrup", 5) + jsonObject.addProperty("config_gamepadselect", 6) + jsonObject.addProperty("config_gamepadstart", 7) - jsonObject.addProperty("gamepadltrigger", 8) - jsonObject.addProperty("gamepadrtrigger", 9) - jsonObject.addProperty("gamepadlthumb", 10) - jsonObject.addProperty("gamepadrthumb", 11) + jsonObject.addProperty("config_gamepadltrigger", 8) + jsonObject.addProperty("config_gamepadrtrigger", 9) + jsonObject.addProperty("config_gamepadlthumb", 10) + jsonObject.addProperty("config_gamepadrthumb", 11) - jsonObject.addProperty("gamepadaxislx", 1) - jsonObject.addProperty("gamepadaxisly", 0) - jsonObject.addProperty("gamepadaxisrx", 3) - jsonObject.addProperty("gamepadaxisry", 2) // 0-1-2-3 but sometimes 3-2-1-0 ?! what the actual fuck? - jsonObject.addProperty("gamepadtriggeraxis", 4) // positive: LT, negative: RT (xbox pad) - jsonObject.addProperty("gamepadtriggeraxis2", 5) // just in case... (RT) + jsonObject.addProperty("config_gamepadaxislx", 1) + jsonObject.addProperty("config_gamepadaxisly", 0) + jsonObject.addProperty("config_gamepadaxisrx", 3) + jsonObject.addProperty("config_gamepadaxisry", 2) // 0-1-2-3 but sometimes 3-2-1-0 ?! what the actual fuck? + jsonObject.addProperty("config_gamepadtriggeraxis", 4) // positive: LT, negative: RT (xbox pad) + jsonObject.addProperty("config_gamepadtriggeraxis2", 5) // just in case... (RT) val axesZeroPoints = JsonArray(); axesZeroPoints.add(-0.011f); axesZeroPoints.add(-0.022f); axesZeroPoints.add(-0.033f); axesZeroPoints.add(-0.044f) jsonObject.add("gamepadaxiszeropoints", axesZeroPoints) // to accomodate shifted zero point of analog stick jsonObject.addProperty("gamepadlabelstyle", "msxbone") // "nwii", "logitech", "sonyps", "msxb360", "msxbone" - - // control-keyboard (GDX key codes) - jsonObject.addProperty("keyup", Input.Keys.E) - jsonObject.addProperty("keyleft", Input.Keys.S) - jsonObject.addProperty("keydown", Input.Keys.D) - jsonObject.addProperty("keyright", Input.Keys.F) // ESDF Masterrace + jsonObject.addProperty("config_keyup", Input.Keys.E) + jsonObject.addProperty("config_keyleft", Input.Keys.S) + jsonObject.addProperty("config_keydown", Input.Keys.D) + jsonObject.addProperty("config_keyright", Input.Keys.F) // ESDF Masterrace - jsonObject.addProperty("keymovementaux", Input.Keys.A) // movement-auxiliary, or hookshot - jsonObject.addProperty("keyinventory", Input.Keys.Q) - jsonObject.addProperty("keyinteract", Input.Keys.R) - jsonObject.addProperty("keyclose", Input.Keys.C) // this or hard-coded ESC - jsonObject.addProperty("keyzoom", Input.Keys.Z) + jsonObject.addProperty("config_keymovementaux", Input.Keys.A) // movement-auxiliary, or hookshot + jsonObject.addProperty("config_keyinventory", Input.Keys.Q) + jsonObject.addProperty("config_keyinteract", Input.Keys.R) + jsonObject.addProperty("config_keyclose", Input.Keys.C) // this or hard-coded ESC + jsonObject.addProperty("config_keyzoom", Input.Keys.Z) - jsonObject.addProperty("keygamemenu", Input.Keys.TAB) - jsonObject.addProperty("keyquicksel", Input.Keys.SHIFT_LEFT) // pie menu is now LShift because GDX does not read CapsLock + jsonObject.addProperty("config_keygamemenu", Input.Keys.TAB) + jsonObject.addProperty("config_keyquicksel", Input.Keys.SHIFT_LEFT) // pie menu is now LShift because GDX does not read CapsLock val keyquickselalt = JsonArray(); keyquickselalt.add(Input.Keys.BACKSPACE); keyquickselalt.add(Input.Keys.CONTROL_LEFT); keyquickselalt.add(Input.Keys.BACKSLASH) // Colemak, Workman and some typers use CapsLock as Backspace, Apple-JIS and HHKB has Control in place of CapsLock and often re-assigned to Command // so these keys are treated as the same. // FOR ~~FUCKS~~ERGONOMICS' SAKE DON'T USE CTRL AND ALT AS A KEY! - jsonObject.add("keyquickselalt", keyquickselalt) - jsonObject.addProperty("mousequicksel", Input.Buttons.MIDDLE) // middle click to open pie menu + jsonObject.add("config_keyquickselalt", keyquickselalt) + jsonObject.addProperty("config_mousequicksel", Input.Buttons.MIDDLE) // middle click to open pie menu - jsonObject.addProperty("keyjump", Input.Keys.SPACE) + jsonObject.addProperty("config_keyjump", Input.Keys.SPACE) val keyquickslots = JsonArray(); for (i in Input.Keys.NUM_1..Input.Keys.NUM_9) keyquickslots.add(i); keyquickslots.add(Input.Keys.NUM_0) // NUM_1 to NUM_0 - jsonObject.add("keyquickslots", keyquickslots) + jsonObject.add("config_keyquickslots", keyquickslots) - jsonObject.addProperty("mouseprimary", Input.Buttons.LEFT) // left mouse - jsonObject.addProperty("mousesecondary", Input.Buttons.RIGHT) // right mouse + jsonObject.addProperty("config_mouseprimary", Input.Buttons.LEFT) // left mouse + jsonObject.addProperty("config_mousesecondary", Input.Buttons.RIGHT) // right mouse jsonObject.addProperty("pcgamepadenv", "console") diff --git a/src/net/torvald/terrarum/LoadScreenBase.kt b/src/net/torvald/terrarum/LoadScreenBase.kt index 16fb0ce70..6ae264c89 100644 --- a/src/net/torvald/terrarum/LoadScreenBase.kt +++ b/src/net/torvald/terrarum/LoadScreenBase.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.ScreenAdapter import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.utils.Disposable +import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.util.CircularArray open class LoadScreenBase : ScreenAdapter(), Disposable { @@ -63,6 +64,8 @@ open class LoadScreenBase : ScreenAdapter(), Disposable { } override fun render(delta: Float) { + Gdx.graphics.setTitle(TerrarumIngame.getCanonicalTitle()) + if (screenToLoad?.gameInitialised ?: false) { doContextChange = true } diff --git a/src/net/torvald/terrarum/SanicLoadScreen.kt b/src/net/torvald/terrarum/SanicLoadScreen.kt index 55e617459..a6df9ee7e 100644 --- a/src/net/torvald/terrarum/SanicLoadScreen.kt +++ b/src/net/torvald/terrarum/SanicLoadScreen.kt @@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.jme3.math.FastMath import net.torvald.terrarum.langpack.Lang +import net.torvald.terrarum.modulebasegame.TerrarumIngame import net.torvald.util.CircularArray /** @@ -70,6 +71,8 @@ object SanicLoadScreen : LoadScreenBase() { private var messageForegroundColour = Color.WHITE override fun render(delta: Float) { + Gdx.graphics.setTitle(TerrarumIngame.getCanonicalTitle()) + val delta = Gdx.graphics.rawDeltaTime glideDispY = AppLoader.screenH - 100f - AppLoader.fontGame.lineHeight diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 7bdd7f8b8..07a549f09 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.graphics.glutils.ShapeRenderer import com.badlogic.gdx.utils.Disposable import com.jme3.math.FastMath +import net.torvald.UnsafeHelper import net.torvald.random.HQRNG import net.torvald.terrarum.AppLoader.* import net.torvald.terrarum.gameactors.Actor @@ -99,12 +100,16 @@ object Terrarum : Disposable { } val memNativeHeap: Int get() { - nativeHeapCircularArray.appendHead((Gdx.app.javaHeap shr 20).toInt()) + nativeHeapCircularArray.appendHead((Gdx.app.nativeHeap shr 20).toInt()) var acc = 0 nativeHeapCircularArray.forEach { acc = maxOf(acc, it) } return acc } + val memUnsafe: Int + get() { + return (UnsafeHelper.unsafeAllocatedSize shr 20).toInt() + } val memXmx: Int get() = (Runtime.getRuntime().maxMemory() shr 20).toInt() val updateRateStr: String diff --git a/src/net/torvald/terrarum/gamecontroller/IngameController.kt b/src/net/torvald/terrarum/gamecontroller/IngameController.kt index bccbc34ef..5fad2a017 100644 --- a/src/net/torvald/terrarum/gamecontroller/IngameController.kt +++ b/src/net/torvald/terrarum/gamecontroller/IngameController.kt @@ -61,10 +61,10 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { // also, some UIs should NOT affect item usage (e.g. quickslot) and ingame's uiOpened property is doing // the very job. - if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) { + if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))) { terrarumIngame.worldPrimaryClickStart(AppLoader.UPDATE_RATE) } - /*if Gdx.input.isButtonPressed(AppLoader.getConfigInt("mousesecondary")) { + /*if Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mousesecondary")) { ingame.worldSecondaryClickStart(AppLoader.UPDATE_RATE) }*/ @@ -93,14 +93,14 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { terrarumIngame.actorNowPlaying?.keyDown(keycode) // quickslot by number keys - val quickslotKeys = AppLoader.getConfigIntArray("keyquickslots") + val quickslotKeys = AppLoader.getConfigIntArray("config_keyquickslots") if (keycode in quickslotKeys) { terrarumIngame.actorNowPlaying?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, quickslotKeys.indexOf(keycode)) } // pie menu - if (AppLoader.getConfigIntArray("keyquickselalt").contains(keycode) - || keycode == AppLoader.getConfigInt("keyquicksel")) { + if (AppLoader.getConfigIntArray("config_keyquickselalt").contains(keycode) + || keycode == AppLoader.getConfigInt("config_keyquicksel")) { terrarumIngame.uiPieMenu.setAsOpen() terrarumIngame.uiQuickBar.setAsClose() } @@ -126,8 +126,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { } override fun keyUp(keycode: Int): Boolean { - if (AppLoader.getConfigIntArray("keyquickselalt").contains(keycode) - || keycode == AppLoader.getConfigInt("keyquicksel")) { + if (AppLoader.getConfigIntArray("config_keyquickselalt").contains(keycode) + || keycode == AppLoader.getConfigInt("config_keyquicksel")) { terrarumIngame.uiPieMenu.setAsClose() terrarumIngame.uiQuickBar.setAsOpen() } @@ -159,18 +159,18 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { if (terrarumIngame.uiContainer.map { if ((it.isOpening || it.isOpened) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right? if ( - button == AppLoader.getConfigInt("mouseprimary") || - button == AppLoader.getConfigInt("mousesecondary")) { + button == AppLoader.getConfigInt("config_mouseprimary") || + button == AppLoader.getConfigInt("config_mousesecondary")) { terrarumIngame.worldPrimaryClickEnd(AppLoader.UPDATE_RATE) } - /*if (button == AppLoader.getConfigInt("mousesecondary")) { + /*if (button == AppLoader.getConfigInt("config_mousesecondary")) { ingame.worldSecondaryClickEnd(AppLoader.UPDATE_RATE) }*/ } } // pie menu - if (button == AppLoader.getConfigInt("mousequicksel")) { + if (button == AppLoader.getConfigInt("config_mousequicksel")) { terrarumIngame.uiPieMenu.setAsClose() terrarumIngame.uiQuickBar.setAsOpen() } @@ -204,7 +204,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() { terrarumIngame.uiContainer.forEach { it.touchDown(screenX, screenY, pointer, button) } // pie menu - if (button == AppLoader.getConfigInt("mousequicksel")) { + if (button == AppLoader.getConfigInt("config_mousequicksel")) { terrarumIngame.uiPieMenu.setAsOpen() terrarumIngame.uiQuickBar.setAsClose() } diff --git a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt index 9525e97a3..1c4cee088 100644 --- a/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt +++ b/src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt @@ -367,13 +367,13 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) { // make pen work HERE // when LEFT mouse is down - if (!tappedOnUI && Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary")) && !mouseOnUI) { + if (!tappedOnUI && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) && !mouseOnUI) { makePenWork(Terrarum.mouseTileX, Terrarum.mouseTileY) // TODO drag support using bresenham's algo // for some reason it just doesn't work... } - else if (!uiPenMenu.isVisible && Gdx.input.isButtonPressed(AppLoader.getConfigInt("mousesecondary"))) { + else if (!uiPenMenu.isVisible && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mousesecondary"))) { // open pen menu // position the menu to where the cursor is uiPenMenu.posX = Terrarum.mouseScreenX - uiPenMenu.width / 2 diff --git a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt index be96fb695..4c5b96d4a 100644 --- a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt +++ b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt @@ -5,6 +5,7 @@ import com.badlogic.gdx.Input import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.g2d.SpriteBatch import net.torvald.EMDASH +import net.torvald.UnsafeHelper import net.torvald.terrarum.* import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.blockproperties.BlockPropUtil @@ -91,7 +92,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { " $EMDASH F: ${Gdx.graphics.framesPerSecond}" + if (AppLoader.IS_DEVELOPMENT_BUILD) " (ΔF${Terrarum.updateRateStr})" + - " $EMDASH M: J${Terrarum.memJavaHeap}M / N${Terrarum.memNativeHeap}M / X${Terrarum.memXmx}M" + " $EMDASH M: J${Terrarum.memJavaHeap}M / N${Terrarum.memNativeHeap}M / U${Terrarum.memUnsafe}M / X${Terrarum.memXmx}M" else "" } @@ -314,8 +315,8 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { // >- queue up game UIs that should pause the world -< uiInventoryPlayer = UIInventoryFull(actorNowPlaying!!, - toggleKeyLiteral = AppLoader.getConfigInt("keyinventory"), - toggleButtonLiteral = AppLoader.getConfigInt("gamepadstart") + toggleKeyLiteral = AppLoader.getConfigInt("config_keyinventory"), + toggleButtonLiteral = AppLoader.getConfigInt("config_gamepadstart") ) uiInventoryPlayer.setPosition(0, 0) diff --git a/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerBlockChooser.kt b/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerBlockChooser.kt index f319439cf..238f12ddd 100644 --- a/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerBlockChooser.kt +++ b/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerBlockChooser.kt @@ -81,7 +81,7 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() { } // respond to click - if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) { + if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))) { // scroll bar if (relativeMouseX in width - SCROLLBAR_SIZE until width && relativeMouseY in 0 until height) { mouseOnScroll = true diff --git a/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerPenMenu.kt b/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerPenMenu.kt index df842a1f8..42aaba8b0 100644 --- a/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerPenMenu.kt +++ b/src/net/torvald/terrarum/modulebasegame/UIBuildingMakerPenMenu.kt @@ -99,7 +99,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() { uiItems.add(button) button.clickOnceListener = { _, _, b -> - if (b == AppLoader.getConfigInt("mouseprimary")) { + if (b == AppLoader.getConfigInt("config_mouseprimary")) { toolButtonsJob[index].invoke() closeGracefully() } @@ -133,7 +133,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() { } // primary click - if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) { + if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))) { // close by clicking close button or out-of-boud if (mouseVec.distanceSquared(RADIUS, RADIUS) !in CLOSE_BUTTON_RADIUS.sqr()..RADIUSF.sqr()) { closeGracefully() @@ -163,7 +163,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() { batch.draw(ItemCodex.getItemImage(slotConfig[i]), x - 16, y - 16, 32f, 32f) // update as well while looping - if (i == mouseOnBlocksSlot && Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) { + if (i == mouseOnBlocksSlot && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))) { parent.setPencilColour(slotConfig[i]) closeGracefully() } diff --git a/src/net/torvald/terrarum/modulebasegame/WorldgenLoadScreen.kt b/src/net/torvald/terrarum/modulebasegame/WorldgenLoadScreen.kt index 124150a7d..d1fcdf45c 100644 --- a/src/net/torvald/terrarum/modulebasegame/WorldgenLoadScreen.kt +++ b/src/net/torvald/terrarum/modulebasegame/WorldgenLoadScreen.kt @@ -1,5 +1,6 @@ package net.torvald.terrarum.modulebasegame +import com.badlogic.gdx.Gdx import com.badlogic.gdx.ScreenAdapter import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Pixmap @@ -57,8 +58,6 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt } override fun render(delta: Float) { - //println("WorldgenLoadScreenRender") - gdxClearAndSetBlend(.094f, .094f, .094f, 0f) previewRenderCounter += delta @@ -103,9 +102,6 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt } - override fun addMessage(msg: String) { - super.addMessage(msg) - } override fun dispose() { if (!previewPixmap.isDisposed) diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt index 8de8779b0..6bbb27d84 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/ActorHumanoid.kt @@ -231,22 +231,22 @@ open class ActorHumanoid( private fun updateGamerControlBox() { if (isGamer) { - isUpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyup")) - isLeftDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyleft")) - isDownDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keydown")) - isRightDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyright")) - isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyjump")) + isUpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyup")) + isLeftDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyleft")) + isDownDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keydown")) + isRightDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyright")) + isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyjump")) val gamepad = AppLoader.gamepad if (gamepad != null) { - axisX = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxislx")) - axisY = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisly")) - axisRX = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisrx")) - axisRY = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisry")) + axisX = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxislx")) + axisY = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisly")) + axisRX = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisrx")) + axisRY = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisry")) - isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyjump")) || - gamepad.getButton(AppLoader.getConfigInt("gamepadltrigger")) + isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyjump")) || + gamepad.getButton(AppLoader.getConfigInt("config_gamepadltrigger")) } if (isJumpJustDown && jumpJustPressedLatched) { @@ -315,11 +315,11 @@ open class ActorHumanoid( // ↑F, ↓S if (isRightDown && !isLeftDown) { walkHorizontal(false, AXIS_KEYBOARD) - prevHMoveKey = AppLoader.getConfigInt("keyright") + prevHMoveKey = AppLoader.getConfigInt("config_keyright") } // ↓F, ↑S else if (isLeftDown && !isRightDown) { walkHorizontal(true, AXIS_KEYBOARD) - prevHMoveKey = AppLoader.getConfigInt("keyleft") + prevHMoveKey = AppLoader.getConfigInt("config_keyleft") } // ↓F, ↓S /*else if (isLeftDown && isRightDown) { if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) { @@ -343,11 +343,11 @@ open class ActorHumanoid( // ↑E, ↓D if (isDownDown && !isUpDown) { walkVertical(false, AXIS_KEYBOARD) - prevVMoveKey = AppLoader.getConfigInt("keydown") + prevVMoveKey = AppLoader.getConfigInt("config_keydown") } // ↓E, ↑D else if (isUpDown && !isDownDown) { walkVertical(true, AXIS_KEYBOARD) - prevVMoveKey = AppLoader.getConfigInt("keyup") + prevVMoveKey = AppLoader.getConfigInt("config_keyup") } // ↓E, ↓D /*else if (isUpDown && isDownDown) { if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) { diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIBasicInfo.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIBasicInfo.kt index 6486f2c58..3a3bd3f5d 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIBasicInfo.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIBasicInfo.kt @@ -38,7 +38,7 @@ class UIBasicInfo(private val player: ActorHumanoid?) : UICanvas() { ELuptimer += delta } - if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyinteract"))) { + if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyinteract"))) { ELuptimer = 0f ELon = true } diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIInventory.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIInventory.kt index db1a93dfa..94f71c84b 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIInventory.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIInventory.kt @@ -157,10 +157,10 @@ package net.torvald.terrarum.modulebasegame.ui private var isEncumbered = false - private val seekLeft: Int; get() = AppLoader.getConfigInt("keyleft") // getter used to support in-game keybind changing - private val seekRight: Int; get() = AppLoader.getConfigInt("keyright") // getter used to support in-game keybind changing - private val seekUp: Int; get() = AppLoader.getConfigInt("keyup") // getter used to support in-game keybind changing - private val seekDown: Int; get() = AppLoader.getConfigInt("keydown") // getter used to support in-game keybind changing + private val seekLeft: Int; get() = AppLoader.getConfigInt("config_keyleft") // getter used to support in-game keybind changing + private val seekRight: Int; get() = AppLoader.getConfigInt("config_keyright") // getter used to support in-game keybind changing + private val seekUp: Int; get() = AppLoader.getConfigInt("config_keyup") // getter used to support in-game keybind changing + private val seekDown: Int; get() = AppLoader.getConfigInt("config_keydown") // getter used to support in-game keybind changing init { diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryMinimap.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryMinimap.kt index 295cfebe1..da0a4f963 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryMinimap.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIInventoryMinimap.kt @@ -42,7 +42,7 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() { // update map panning // if left click is down and cursor is in the map area - if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary")) && + if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) && Terrarum.mouseScreenY in full.INVENTORY_CELLS_OFFSET_Y..full.INVENTORY_CELLS_OFFSET_Y + full.INVENTORY_CELLS_UI_HEIGHT) { minimapPanX += Terrarum.mouseDeltaX * 2f / minimapZoom minimapPanY += Terrarum.mouseDeltaY * 2f / minimapZoom diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UIScreenZoom.kt b/src/net/torvald/terrarum/modulebasegame/ui/UIScreenZoom.kt index 3a718e91f..bc5bc73a1 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UIScreenZoom.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UIScreenZoom.kt @@ -16,7 +16,7 @@ import net.torvald.terrarum.ui.UICanvas * Created by minjaesong on 2019-08-11. */ class UIScreenZoom : UICanvas( - AppLoader.getConfigInt("keyzoom") + AppLoader.getConfigInt("config_keyzoom") ) { val zoomText = "${keyToIcon(handler.toggleKeyLiteral!!)} $EMDASH Zoom Out" diff --git a/src/net/torvald/terrarum/modulebasegame/ui/UITierOneWatch.kt b/src/net/torvald/terrarum/modulebasegame/ui/UITierOneWatch.kt index 75cbbce16..98e931a2d 100644 --- a/src/net/torvald/terrarum/modulebasegame/ui/UITierOneWatch.kt +++ b/src/net/torvald/terrarum/modulebasegame/ui/UITierOneWatch.kt @@ -47,7 +47,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas() { ELuptimer += delta } - if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyinteract"))) { + if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyinteract"))) { ELuptimer = 0f ELon = true } diff --git a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt index 70467fc97..bcbecb7e9 100644 --- a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt +++ b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt @@ -203,8 +203,8 @@ class BasicDebugInfoWindow : UICanvas() { val gamepad = (Terrarum.ingame as? TerrarumIngame)?.ingameController?.gamepad if (gamepad != null) { drawGamepadAxis(gamepad, batch, - gamepad.getAxis(AppLoader.getConfigInt("gamepadaxislx")), - gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisly")), + gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxislx")), + gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisly")), AppLoader.screenW - 128 - TinyAlphNum.W * 2, line(3).toInt() ) diff --git a/src/net/torvald/terrarum/ui/UICanvas.kt b/src/net/torvald/terrarum/ui/UICanvas.kt index 7dc2ab8c4..a05be8a26 100644 --- a/src/net/torvald/terrarum/ui/UICanvas.kt +++ b/src/net/torvald/terrarum/ui/UICanvas.kt @@ -90,7 +90,7 @@ abstract class UICanvas( get() = _mouseUpThis || handler.mouseUp /** If mouse is hovering over it and mouse is down */ val mousePushed: Boolean - get() = mouseUp && Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary")) + get() = mouseUp && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) private val _mouseUpThis: Boolean get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1 diff --git a/src/net/torvald/terrarum/ui/UIItem.kt b/src/net/torvald/terrarum/ui/UIItem.kt index a8b15e417..67d201985 100644 --- a/src/net/torvald/terrarum/ui/UIItem.kt +++ b/src/net/torvald/terrarum/ui/UIItem.kt @@ -89,7 +89,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1 /** If mouse is hovering over it and mouse is down */ open val mousePushed: Boolean - get() = mouseUp && Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary")) + get() = mouseUp && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary")) /** UI to call (show up) while mouse is up */