config: user-configurable control entries now have config- prefix

This commit is contained in:
minjaesong
2020-11-21 11:24:15 +09:00
parent 44c11cef76
commit b8a7dee7ac
21 changed files with 145 additions and 126 deletions

View File

@@ -9,24 +9,24 @@
"multithreadedlight": false, "multithreadedlight": false,
"showhealthmessageonstartup": true, "showhealthmessageonstartup": true,
"usexinput": true, "usexinput": true,
"gamepadkeyn": 3, "config_gamepadkeyn": 3,
"gamepadkeyw": 2, "config_gamepadkeyw": 2,
"gamepadkeys": 0, "config_gamepadkeys": 0,
"gamepadkeye": 1, "config_gamepadkeye": 1,
"gamepadlup": 4, "config_gamepadlup": 4,
"gamepadrup": 5, "config_gamepadrup": 5,
"gamepadselect": 6, "config_gamepadselect": 6,
"gamepadstart": 7, "config_gamepadstart": 7,
"gamepadltrigger": 8, "config_gamepadltrigger": 8,
"gamepadrtrigger": 9, "config_gamepadrtrigger": 9,
"gamepadlthumb": 10, "config_gamepadlthumb": 10,
"gamepadrthumb": 11, "config_gamepadrthumb": 11,
"gamepadaxislx": 1, "config_gamepadaxislx": 1,
"gamepadaxisly": 0, "config_gamepadaxisly": 0,
"gamepadaxisrx": 3, "config_gamepadaxisrx": 3,
"gamepadaxisry": 2, "config_gamepadaxisry": 2,
"gamepadtriggeraxis": 4, "config_gamepadtriggeraxis": 4,
"gamepadtriggeraxis2": 5, "config_gamepadtriggeraxis2": 5,
"gamepadaxiszeropoints": [ "gamepadaxiszeropoints": [
-0.011, -0.011,
-0.022, -0.022,
@@ -34,24 +34,24 @@
-0.044 -0.044
], ],
"gamepadlabelstyle": "msxbone", "gamepadlabelstyle": "msxbone",
"keyup":34, "config_keyup":34,
"keyleft":46, "config_keyleft":46,
"keydown":47, "config_keydown":47,
"keyright":48, "config_keyright":48,
"keyinventory":45, "config_keyinventory":45,
"keyinteract":44, "config_keyinteract":44,
"keymovementaux": 29, "config_keymovementaux": 29,
"keyclose": 31, "config_keyclose": 31,
"keyzoom": 54, "config_keyzoom": 54,
"keygamemenu": 61, "config_keygamemenu": 61,
"keyquicksel": 59, "config_keyquicksel": 59,
"keyquickselalt": [ "config_keyquickselalt": [
67, 67,
129, 129,
73 73
], ],
"keyjump": 62, "config_keyjump": 62,
"keyquickslots": [ "config_keyquickslots": [
8, 8,
9, 9,
10, 10,
@@ -63,8 +63,8 @@
16, 16,
7 7
], ],
"mouseprimary": 0, "config_mouseprimary": 0,
"mousesecondary": 1, "config_mousesecondary": 1,
"pcgamepadenv": "console", "pcgamepadenv": "console",
"maxparticles": 768, "maxparticles": 768,
"temperatureunit": 1, "temperatureunit": 1,

View File

@@ -11,6 +11,9 @@ import sun.misc.Unsafe
*/ */
internal object UnsafeHelper { internal object UnsafeHelper {
var unsafeAllocatedSize = 0L
internal set
val unsafe: Unsafe val unsafe: Unsafe
init { init {
@@ -57,6 +60,10 @@ internal object UnsafeHelper {
* Use of hashCode() is forbidden, use the pointer instead. * Use of hashCode() is forbidden, use the pointer instead.
*/ */
internal class UnsafePtr(pointer: Long, allocSize: Long) { internal class UnsafePtr(pointer: Long, allocSize: Long) {
init {
UnsafeHelper.unsafeAllocatedSize += allocSize
}
var destroyed = false var destroyed = false
private set private set
@@ -67,8 +74,10 @@ internal class UnsafePtr(pointer: Long, allocSize: Long) {
private set private set
fun realloc(newSize: Long) { fun realloc(newSize: Long) {
UnsafeHelper.unsafeAllocatedSize -= size
ptr = UnsafeHelper.unsafe.reallocateMemory(ptr, newSize) ptr = UnsafeHelper.unsafe.reallocateMemory(ptr, newSize)
size = newSize size = newSize
UnsafeHelper.unsafeAllocatedSize += size
} }
fun destroy() { fun destroy() {
@@ -79,6 +88,8 @@ internal class UnsafePtr(pointer: Long, allocSize: Long) {
printStackTrace(this) printStackTrace(this)
destroyed = true destroyed = true
UnsafeHelper.unsafeAllocatedSize -= size
} }
} }

View File

@@ -29,68 +29,68 @@ object DefaultConfig {
jsonObject.addProperty("showhealthmessageonstartup", true) jsonObject.addProperty("showhealthmessageonstartup", true)
// control-gamepad // 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("usexinput", true) // when FALSE, LT+RT input on xbox controller is impossible
jsonObject.addProperty("gamepadkeyn", 3) jsonObject.addProperty("config_gamepadkeyn", 3)
jsonObject.addProperty("gamepadkeyw", 2) jsonObject.addProperty("config_gamepadkeyw", 2)
jsonObject.addProperty("gamepadkeys", 0) jsonObject.addProperty("config_gamepadkeys", 0)
jsonObject.addProperty("gamepadkeye", 1) // xbox indices jsonObject.addProperty("config_gamepadkeye", 1) // xbox indices
jsonObject.addProperty("gamepadlup", 4) jsonObject.addProperty("config_gamepadlup", 4)
jsonObject.addProperty("gamepadrup", 5) jsonObject.addProperty("config_gamepadrup", 5)
jsonObject.addProperty("gamepadselect", 6) jsonObject.addProperty("config_gamepadselect", 6)
jsonObject.addProperty("gamepadstart", 7) jsonObject.addProperty("config_gamepadstart", 7)
jsonObject.addProperty("gamepadltrigger", 8) jsonObject.addProperty("config_gamepadltrigger", 8)
jsonObject.addProperty("gamepadrtrigger", 9) jsonObject.addProperty("config_gamepadrtrigger", 9)
jsonObject.addProperty("gamepadlthumb", 10) jsonObject.addProperty("config_gamepadlthumb", 10)
jsonObject.addProperty("gamepadrthumb", 11) jsonObject.addProperty("config_gamepadrthumb", 11)
jsonObject.addProperty("gamepadaxislx", 1) jsonObject.addProperty("config_gamepadaxislx", 1)
jsonObject.addProperty("gamepadaxisly", 0) jsonObject.addProperty("config_gamepadaxisly", 0)
jsonObject.addProperty("gamepadaxisrx", 3) jsonObject.addProperty("config_gamepadaxisrx", 3)
jsonObject.addProperty("gamepadaxisry", 2) // 0-1-2-3 but sometimes 3-2-1-0 ?! what the actual fuck? jsonObject.addProperty("config_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("config_gamepadtriggeraxis", 4) // positive: LT, negative: RT (xbox pad)
jsonObject.addProperty("gamepadtriggeraxis2", 5) // just in case... (RT) 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) 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.add("gamepadaxiszeropoints", axesZeroPoints) // to accomodate shifted zero point of analog stick
jsonObject.addProperty("gamepadlabelstyle", "msxbone") // "nwii", "logitech", "sonyps", "msxb360", "msxbone" jsonObject.addProperty("gamepadlabelstyle", "msxbone") // "nwii", "logitech", "sonyps", "msxb360", "msxbone"
// control-keyboard (GDX key codes) // control-keyboard (GDX key codes)
jsonObject.addProperty("keyup", Input.Keys.E) jsonObject.addProperty("config_keyup", Input.Keys.E)
jsonObject.addProperty("keyleft", Input.Keys.S) jsonObject.addProperty("config_keyleft", Input.Keys.S)
jsonObject.addProperty("keydown", Input.Keys.D) jsonObject.addProperty("config_keydown", Input.Keys.D)
jsonObject.addProperty("keyright", Input.Keys.F) // ESDF Masterrace jsonObject.addProperty("config_keyright", Input.Keys.F) // ESDF Masterrace
jsonObject.addProperty("keymovementaux", Input.Keys.A) // movement-auxiliary, or hookshot jsonObject.addProperty("config_keymovementaux", Input.Keys.A) // movement-auxiliary, or hookshot
jsonObject.addProperty("keyinventory", Input.Keys.Q) jsonObject.addProperty("config_keyinventory", Input.Keys.Q)
jsonObject.addProperty("keyinteract", Input.Keys.R) jsonObject.addProperty("config_keyinteract", Input.Keys.R)
jsonObject.addProperty("keyclose", Input.Keys.C) // this or hard-coded ESC jsonObject.addProperty("config_keyclose", Input.Keys.C) // this or hard-coded ESC
jsonObject.addProperty("keyzoom", Input.Keys.Z) jsonObject.addProperty("config_keyzoom", Input.Keys.Z)
jsonObject.addProperty("keygamemenu", Input.Keys.TAB) jsonObject.addProperty("config_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_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) 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 // 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. // so these keys are treated as the same.
// FOR ~~FUCKS~~ERGONOMICS' SAKE DON'T USE CTRL AND ALT AS A KEY! // FOR ~~FUCKS~~ERGONOMICS' SAKE DON'T USE CTRL AND ALT AS A KEY!
jsonObject.add("keyquickselalt", keyquickselalt) jsonObject.add("config_keyquickselalt", keyquickselalt)
jsonObject.addProperty("mousequicksel", Input.Buttons.MIDDLE) // middle click to open pie menu 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 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("config_mouseprimary", Input.Buttons.LEFT) // left mouse
jsonObject.addProperty("mousesecondary", Input.Buttons.RIGHT) // right mouse jsonObject.addProperty("config_mousesecondary", Input.Buttons.RIGHT) // right mouse
jsonObject.addProperty("pcgamepadenv", "console") jsonObject.addProperty("pcgamepadenv", "console")

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.ScreenAdapter import com.badlogic.gdx.ScreenAdapter
import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.graphics.OrthographicCamera
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.util.CircularArray import net.torvald.util.CircularArray
open class LoadScreenBase : ScreenAdapter(), Disposable { open class LoadScreenBase : ScreenAdapter(), Disposable {
@@ -63,6 +64,8 @@ open class LoadScreenBase : ScreenAdapter(), Disposable {
} }
override fun render(delta: Float) { override fun render(delta: Float) {
Gdx.graphics.setTitle(TerrarumIngame.getCanonicalTitle())
if (screenToLoad?.gameInitialised ?: false) { if (screenToLoad?.gameInitialised ?: false) {
doContextChange = true doContextChange = true
} }

View File

@@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.glutils.FrameBuffer import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.terrarum.langpack.Lang import net.torvald.terrarum.langpack.Lang
import net.torvald.terrarum.modulebasegame.TerrarumIngame
import net.torvald.util.CircularArray import net.torvald.util.CircularArray
/** /**
@@ -70,6 +71,8 @@ object SanicLoadScreen : LoadScreenBase() {
private var messageForegroundColour = Color.WHITE private var messageForegroundColour = Color.WHITE
override fun render(delta: Float) { override fun render(delta: Float) {
Gdx.graphics.setTitle(TerrarumIngame.getCanonicalTitle())
val delta = Gdx.graphics.rawDeltaTime val delta = Gdx.graphics.rawDeltaTime
glideDispY = AppLoader.screenH - 100f - AppLoader.fontGame.lineHeight glideDispY = AppLoader.screenH - 100f - AppLoader.fontGame.lineHeight

View File

@@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer
import com.badlogic.gdx.graphics.glutils.ShapeRenderer import com.badlogic.gdx.graphics.glutils.ShapeRenderer
import com.badlogic.gdx.utils.Disposable import com.badlogic.gdx.utils.Disposable
import com.jme3.math.FastMath import com.jme3.math.FastMath
import net.torvald.UnsafeHelper
import net.torvald.random.HQRNG import net.torvald.random.HQRNG
import net.torvald.terrarum.AppLoader.* import net.torvald.terrarum.AppLoader.*
import net.torvald.terrarum.gameactors.Actor import net.torvald.terrarum.gameactors.Actor
@@ -99,12 +100,16 @@ object Terrarum : Disposable {
} }
val memNativeHeap: Int val memNativeHeap: Int
get() { get() {
nativeHeapCircularArray.appendHead((Gdx.app.javaHeap shr 20).toInt()) nativeHeapCircularArray.appendHead((Gdx.app.nativeHeap shr 20).toInt())
var acc = 0 var acc = 0
nativeHeapCircularArray.forEach { acc = maxOf(acc, it) } nativeHeapCircularArray.forEach { acc = maxOf(acc, it) }
return acc return acc
} }
val memUnsafe: Int
get() {
return (UnsafeHelper.unsafeAllocatedSize shr 20).toInt()
}
val memXmx: Int val memXmx: Int
get() = (Runtime.getRuntime().maxMemory() shr 20).toInt() get() = (Runtime.getRuntime().maxMemory() shr 20).toInt()
val updateRateStr: String val updateRateStr: String

View File

@@ -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 // also, some UIs should NOT affect item usage (e.g. quickslot) and ingame's uiOpened property is doing
// the very job. // the very job.
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) { if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))) {
terrarumIngame.worldPrimaryClickStart(AppLoader.UPDATE_RATE) 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) ingame.worldSecondaryClickStart(AppLoader.UPDATE_RATE)
}*/ }*/
@@ -93,14 +93,14 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
terrarumIngame.actorNowPlaying?.keyDown(keycode) terrarumIngame.actorNowPlaying?.keyDown(keycode)
// quickslot by number keys // quickslot by number keys
val quickslotKeys = AppLoader.getConfigIntArray("keyquickslots") val quickslotKeys = AppLoader.getConfigIntArray("config_keyquickslots")
if (keycode in quickslotKeys) { if (keycode in quickslotKeys) {
terrarumIngame.actorNowPlaying?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, quickslotKeys.indexOf(keycode)) terrarumIngame.actorNowPlaying?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, quickslotKeys.indexOf(keycode))
} }
// pie menu // pie menu
if (AppLoader.getConfigIntArray("keyquickselalt").contains(keycode) if (AppLoader.getConfigIntArray("config_keyquickselalt").contains(keycode)
|| keycode == AppLoader.getConfigInt("keyquicksel")) { || keycode == AppLoader.getConfigInt("config_keyquicksel")) {
terrarumIngame.uiPieMenu.setAsOpen() terrarumIngame.uiPieMenu.setAsOpen()
terrarumIngame.uiQuickBar.setAsClose() terrarumIngame.uiQuickBar.setAsClose()
} }
@@ -126,8 +126,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
} }
override fun keyUp(keycode: Int): Boolean { override fun keyUp(keycode: Int): Boolean {
if (AppLoader.getConfigIntArray("keyquickselalt").contains(keycode) if (AppLoader.getConfigIntArray("config_keyquickselalt").contains(keycode)
|| keycode == AppLoader.getConfigInt("keyquicksel")) { || keycode == AppLoader.getConfigInt("config_keyquicksel")) {
terrarumIngame.uiPieMenu.setAsClose() terrarumIngame.uiPieMenu.setAsClose()
terrarumIngame.uiQuickBar.setAsOpen() 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 (terrarumIngame.uiContainer.map { if ((it.isOpening || it.isOpened) && it.mouseUp) 1 else 0 }.sum() == 0) { // no UI on the mouse, right?
if ( if (
button == AppLoader.getConfigInt("mouseprimary") || button == AppLoader.getConfigInt("config_mouseprimary") ||
button == AppLoader.getConfigInt("mousesecondary")) { button == AppLoader.getConfigInt("config_mousesecondary")) {
terrarumIngame.worldPrimaryClickEnd(AppLoader.UPDATE_RATE) terrarumIngame.worldPrimaryClickEnd(AppLoader.UPDATE_RATE)
} }
/*if (button == AppLoader.getConfigInt("mousesecondary")) { /*if (button == AppLoader.getConfigInt("config_mousesecondary")) {
ingame.worldSecondaryClickEnd(AppLoader.UPDATE_RATE) ingame.worldSecondaryClickEnd(AppLoader.UPDATE_RATE)
}*/ }*/
} }
} }
// pie menu // pie menu
if (button == AppLoader.getConfigInt("mousequicksel")) { if (button == AppLoader.getConfigInt("config_mousequicksel")) {
terrarumIngame.uiPieMenu.setAsClose() terrarumIngame.uiPieMenu.setAsClose()
terrarumIngame.uiQuickBar.setAsOpen() terrarumIngame.uiQuickBar.setAsOpen()
} }
@@ -204,7 +204,7 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
terrarumIngame.uiContainer.forEach { it.touchDown(screenX, screenY, pointer, button) } terrarumIngame.uiContainer.forEach { it.touchDown(screenX, screenY, pointer, button) }
// pie menu // pie menu
if (button == AppLoader.getConfigInt("mousequicksel")) { if (button == AppLoader.getConfigInt("config_mousequicksel")) {
terrarumIngame.uiPieMenu.setAsOpen() terrarumIngame.uiPieMenu.setAsOpen()
terrarumIngame.uiQuickBar.setAsClose() terrarumIngame.uiQuickBar.setAsClose()
} }

View File

@@ -367,13 +367,13 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
// make pen work HERE // make pen work HERE
// when LEFT mouse is down // 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) makePenWork(Terrarum.mouseTileX, Terrarum.mouseTileY)
// TODO drag support using bresenham's algo // TODO drag support using bresenham's algo
// for some reason it just doesn't work... // 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 // open pen menu
// position the menu to where the cursor is // position the menu to where the cursor is
uiPenMenu.posX = Terrarum.mouseScreenX - uiPenMenu.width / 2 uiPenMenu.posX = Terrarum.mouseScreenX - uiPenMenu.width / 2

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.EMDASH import net.torvald.EMDASH
import net.torvald.UnsafeHelper
import net.torvald.terrarum.* import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.blockproperties.BlockPropUtil import net.torvald.terrarum.blockproperties.BlockPropUtil
@@ -91,7 +92,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
" $EMDASH F: ${Gdx.graphics.framesPerSecond}" + " $EMDASH F: ${Gdx.graphics.framesPerSecond}" +
if (AppLoader.IS_DEVELOPMENT_BUILD) if (AppLoader.IS_DEVELOPMENT_BUILD)
" (ΔF${Terrarum.updateRateStr})" + " (Δ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 else
"" ""
} }
@@ -314,8 +315,8 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) {
// >- queue up game UIs that should pause the world -< // >- queue up game UIs that should pause the world -<
uiInventoryPlayer = UIInventoryFull(actorNowPlaying!!, uiInventoryPlayer = UIInventoryFull(actorNowPlaying!!,
toggleKeyLiteral = AppLoader.getConfigInt("keyinventory"), toggleKeyLiteral = AppLoader.getConfigInt("config_keyinventory"),
toggleButtonLiteral = AppLoader.getConfigInt("gamepadstart") toggleButtonLiteral = AppLoader.getConfigInt("config_gamepadstart")
) )
uiInventoryPlayer.setPosition(0, 0) uiInventoryPlayer.setPosition(0, 0)

View File

@@ -81,7 +81,7 @@ class UIBuildingMakerBlockChooser(val parent: BuildingMaker): UICanvas() {
} }
// respond to click // respond to click
if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary"))) { if (Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))) {
// scroll bar // scroll bar
if (relativeMouseX in width - SCROLLBAR_SIZE until width && relativeMouseY in 0 until height) { if (relativeMouseX in width - SCROLLBAR_SIZE until width && relativeMouseY in 0 until height) {
mouseOnScroll = true mouseOnScroll = true

View File

@@ -99,7 +99,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
uiItems.add(button) uiItems.add(button)
button.clickOnceListener = { _, _, b -> button.clickOnceListener = { _, _, b ->
if (b == AppLoader.getConfigInt("mouseprimary")) { if (b == AppLoader.getConfigInt("config_mouseprimary")) {
toolButtonsJob[index].invoke() toolButtonsJob[index].invoke()
closeGracefully() closeGracefully()
} }
@@ -133,7 +133,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
} }
// primary click // 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 // close by clicking close button or out-of-boud
if (mouseVec.distanceSquared(RADIUS, RADIUS) !in CLOSE_BUTTON_RADIUS.sqr()..RADIUSF.sqr()) { if (mouseVec.distanceSquared(RADIUS, RADIUS) !in CLOSE_BUTTON_RADIUS.sqr()..RADIUSF.sqr()) {
closeGracefully() closeGracefully()
@@ -163,7 +163,7 @@ class UIBuildingMakerPenMenu(val parent: BuildingMaker): UICanvas() {
batch.draw(ItemCodex.getItemImage(slotConfig[i]), x - 16, y - 16, 32f, 32f) batch.draw(ItemCodex.getItemImage(slotConfig[i]), x - 16, y - 16, 32f, 32f)
// update as well while looping // 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]) parent.setPencilColour(slotConfig[i])
closeGracefully() closeGracefully()
} }

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.modulebasegame package net.torvald.terrarum.modulebasegame
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.ScreenAdapter import com.badlogic.gdx.ScreenAdapter
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Pixmap
@@ -57,8 +58,6 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
} }
override fun render(delta: Float) { override fun render(delta: Float) {
//println("WorldgenLoadScreenRender")
gdxClearAndSetBlend(.094f, .094f, .094f, 0f) gdxClearAndSetBlend(.094f, .094f, .094f, 0f)
previewRenderCounter += delta previewRenderCounter += delta
@@ -103,9 +102,6 @@ class WorldgenLoadScreen(screenToBeLoaded: IngameInstance, private val worldwidt
} }
override fun addMessage(msg: String) {
super.addMessage(msg)
}
override fun dispose() { override fun dispose() {
if (!previewPixmap.isDisposed) if (!previewPixmap.isDisposed)

View File

@@ -231,22 +231,22 @@ open class ActorHumanoid(
private fun updateGamerControlBox() { private fun updateGamerControlBox() {
if (isGamer) { if (isGamer) {
isUpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyup")) isUpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyup"))
isLeftDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyleft")) isLeftDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyleft"))
isDownDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keydown")) isDownDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keydown"))
isRightDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyright")) isRightDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyright"))
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyjump")) isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyjump"))
val gamepad = AppLoader.gamepad val gamepad = AppLoader.gamepad
if (gamepad != null) { if (gamepad != null) {
axisX = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxislx")) axisX = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxislx"))
axisY = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisly")) axisY = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisly"))
axisRX = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisrx")) axisRX = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisrx"))
axisRY = gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisry")) axisRY = gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisry"))
isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyjump")) || isJumpDown = Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyjump")) ||
gamepad.getButton(AppLoader.getConfigInt("gamepadltrigger")) gamepad.getButton(AppLoader.getConfigInt("config_gamepadltrigger"))
} }
if (isJumpJustDown && jumpJustPressedLatched) { if (isJumpJustDown && jumpJustPressedLatched) {
@@ -315,11 +315,11 @@ open class ActorHumanoid(
// ↑F, ↓S // ↑F, ↓S
if (isRightDown && !isLeftDown) { if (isRightDown && !isLeftDown) {
walkHorizontal(false, AXIS_KEYBOARD) walkHorizontal(false, AXIS_KEYBOARD)
prevHMoveKey = AppLoader.getConfigInt("keyright") prevHMoveKey = AppLoader.getConfigInt("config_keyright")
} // ↓F, ↑S } // ↓F, ↑S
else if (isLeftDown && !isRightDown) { else if (isLeftDown && !isRightDown) {
walkHorizontal(true, AXIS_KEYBOARD) walkHorizontal(true, AXIS_KEYBOARD)
prevHMoveKey = AppLoader.getConfigInt("keyleft") prevHMoveKey = AppLoader.getConfigInt("config_keyleft")
} // ↓F, ↓S } // ↓F, ↓S
/*else if (isLeftDown && isRightDown) { /*else if (isLeftDown && isRightDown) {
if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) { if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) {
@@ -343,11 +343,11 @@ open class ActorHumanoid(
// ↑E, ↓D // ↑E, ↓D
if (isDownDown && !isUpDown) { if (isDownDown && !isUpDown) {
walkVertical(false, AXIS_KEYBOARD) walkVertical(false, AXIS_KEYBOARD)
prevVMoveKey = AppLoader.getConfigInt("keydown") prevVMoveKey = AppLoader.getConfigInt("config_keydown")
} // ↓E, ↑D } // ↓E, ↑D
else if (isUpDown && !isDownDown) { else if (isUpDown && !isDownDown) {
walkVertical(true, AXIS_KEYBOARD) walkVertical(true, AXIS_KEYBOARD)
prevVMoveKey = AppLoader.getConfigInt("keyup") prevVMoveKey = AppLoader.getConfigInt("config_keyup")
} // ↓E, ↓D } // ↓E, ↓D
/*else if (isUpDown && isDownDown) { /*else if (isUpDown && isDownDown) {
if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) { if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) {

View File

@@ -38,7 +38,7 @@ class UIBasicInfo(private val player: ActorHumanoid?) : UICanvas() {
ELuptimer += delta ELuptimer += delta
} }
if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyinteract"))) { if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyinteract"))) {
ELuptimer = 0f ELuptimer = 0f
ELon = true ELon = true
} }

View File

@@ -157,10 +157,10 @@ package net.torvald.terrarum.modulebasegame.ui
private var isEncumbered = false private var isEncumbered = false
private val seekLeft: Int; get() = AppLoader.getConfigInt("keyleft") // 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("keyright") // 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("keyup") // 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("keydown") // 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 { init {

View File

@@ -42,7 +42,7 @@ class UIInventoryMinimap(val full: UIInventoryFull) : UICanvas() {
// update map panning // update map panning
// if left click is down and cursor is in the map area // 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) { Terrarum.mouseScreenY in full.INVENTORY_CELLS_OFFSET_Y..full.INVENTORY_CELLS_OFFSET_Y + full.INVENTORY_CELLS_UI_HEIGHT) {
minimapPanX += Terrarum.mouseDeltaX * 2f / minimapZoom minimapPanX += Terrarum.mouseDeltaX * 2f / minimapZoom
minimapPanY += Terrarum.mouseDeltaY * 2f / minimapZoom minimapPanY += Terrarum.mouseDeltaY * 2f / minimapZoom

View File

@@ -16,7 +16,7 @@ import net.torvald.terrarum.ui.UICanvas
* Created by minjaesong on 2019-08-11. * Created by minjaesong on 2019-08-11.
*/ */
class UIScreenZoom : UICanvas( class UIScreenZoom : UICanvas(
AppLoader.getConfigInt("keyzoom") AppLoader.getConfigInt("config_keyzoom")
) { ) {
val zoomText = "${keyToIcon(handler.toggleKeyLiteral!!)} $EMDASH Zoom Out" val zoomText = "${keyToIcon(handler.toggleKeyLiteral!!)} $EMDASH Zoom Out"

View File

@@ -47,7 +47,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas() {
ELuptimer += delta ELuptimer += delta
} }
if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("keyinteract"))) { if (mouseUp || Gdx.input.isKeyPressed(AppLoader.getConfigInt("config_keyinteract"))) {
ELuptimer = 0f ELuptimer = 0f
ELon = true ELon = true
} }

View File

@@ -203,8 +203,8 @@ class BasicDebugInfoWindow : UICanvas() {
val gamepad = (Terrarum.ingame as? TerrarumIngame)?.ingameController?.gamepad val gamepad = (Terrarum.ingame as? TerrarumIngame)?.ingameController?.gamepad
if (gamepad != null) { if (gamepad != null) {
drawGamepadAxis(gamepad, batch, drawGamepadAxis(gamepad, batch,
gamepad.getAxis(AppLoader.getConfigInt("gamepadaxislx")), gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxislx")),
gamepad.getAxis(AppLoader.getConfigInt("gamepadaxisly")), gamepad.getAxis(AppLoader.getConfigInt("config_gamepadaxisly")),
AppLoader.screenW - 128 - TinyAlphNum.W * 2, AppLoader.screenW - 128 - TinyAlphNum.W * 2,
line(3).toInt() line(3).toInt()
) )

View File

@@ -90,7 +90,7 @@ abstract class UICanvas(
get() = _mouseUpThis || handler.mouseUp get() = _mouseUpThis || handler.mouseUp
/** If mouse is hovering over it and mouse is down */ /** If mouse is hovering over it and mouse is down */
val mousePushed: Boolean val mousePushed: Boolean
get() = mouseUp && Gdx.input.isButtonPressed(AppLoader.getConfigInt("mouseprimary")) get() = mouseUp && Gdx.input.isButtonPressed(AppLoader.getConfigInt("config_mouseprimary"))
private val _mouseUpThis: Boolean private val _mouseUpThis: Boolean
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1 get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1

View File

@@ -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 get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
/** If mouse is hovering over it and mouse is down */ /** If mouse is hovering over it and mouse is down */
open val mousePushed: Boolean 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 */ /** UI to call (show up) while mouse is up */