mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
quickslot selections are controlled by the ingame rather than the 'bar UI'
This commit is contained in:
@@ -509,7 +509,7 @@ public class AppLoader implements ApplicationListener {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (java.nio.file.NoSuchFileException e) {
|
||||||
// write default config to game dir. Call this method again to read config from it.
|
// write default config to game dir. Call this method again to read config from it.
|
||||||
try {
|
try {
|
||||||
createConfigJson();
|
createConfigJson();
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ object DefaultConfig {
|
|||||||
|
|
||||||
jsonObject.addProperty("keyjump", Input.Keys.SPACE)
|
jsonObject.addProperty("keyjump", Input.Keys.SPACE)
|
||||||
|
|
||||||
val keyquickbars = JsonArray(); for (i in Input.Keys.NUMPAD_1..Input.Keys.NUMPAD_9) keyquickbars.add(i); keyquickbars.add(Input.Keys.NUMPAD_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("keyquickbars", keyquickbars)
|
jsonObject.add("keyquickslots", keyquickslots)
|
||||||
|
|
||||||
jsonObject.addProperty("mouseprimary", Input.Buttons.LEFT) // left mouse
|
jsonObject.addProperty("mouseprimary", Input.Buttons.LEFT) // left mouse
|
||||||
jsonObject.addProperty("mousesecondary", Input.Buttons.RIGHT) // right mouse
|
jsonObject.addProperty("mousesecondary", Input.Buttons.RIGHT) // right mouse
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ class ActorValue(val actor: Actor) : KVHashMap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun set(key: String, value: Any) {
|
override fun set(key: String, value: Any) {
|
||||||
|
/*if (key == AVKey.__PLAYER_QUICKSLOTSEL) {
|
||||||
|
Thread.currentThread().stackTrace.forEach { println(it) }
|
||||||
|
}*/
|
||||||
|
|
||||||
super.set(key, value)
|
super.set(key, value)
|
||||||
actor.onActorValueChange(key, value) // fire the event handler
|
actor.onActorValueChange(key, value) // fire the event handler
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.InputAdapter
|
import com.badlogic.gdx.InputAdapter
|
||||||
import net.torvald.terrarum.AppLoader
|
import net.torvald.terrarum.AppLoader
|
||||||
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.floorInt
|
||||||
|
import net.torvald.terrarum.gameactors.AVKey
|
||||||
|
import net.torvald.terrarum.itemproperties.GameItem
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
import net.torvald.terrarum.itemproperties.GameItem
|
|
||||||
import net.torvald.terrarum.floorInt
|
|
||||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,12 +71,19 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
|||||||
|
|
||||||
if (ingame.canPlayerControl) {
|
if (ingame.canPlayerControl) {
|
||||||
ingame.actorNowPlaying?.keyDown(keycode)
|
ingame.actorNowPlaying?.keyDown(keycode)
|
||||||
}
|
|
||||||
|
|
||||||
if (AppLoader.getConfigIntArray("keyquickselalt").contains(keycode)
|
// quickslot (quickbar)
|
||||||
|| keycode == AppLoader.getConfigInt("keyquicksel")) {
|
val quickslotKeys = AppLoader.getConfigIntArray("keyquickslots")
|
||||||
ingame.uiPieMenu.setAsOpen()
|
if (keycode in quickslotKeys) {
|
||||||
ingame.uiQuickBar.setAsClose()
|
ingame.actorNowPlaying?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, quickslotKeys.indexOf(keycode))
|
||||||
|
}
|
||||||
|
|
||||||
|
// pie menu
|
||||||
|
if (AppLoader.getConfigIntArray("keyquickselalt").contains(keycode)
|
||||||
|
|| keycode == AppLoader.getConfigInt("keyquicksel")) {
|
||||||
|
ingame.uiPieMenu.setAsOpen()
|
||||||
|
ingame.uiQuickBar.setAsClose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ingame.uiContainer.forEach { it.keyDown(keycode) } // for KeyboardControlled UIcanvases
|
ingame.uiContainer.forEach { it.keyDown(keycode) } // for KeyboardControlled UIcanvases
|
||||||
|
|||||||
@@ -116,11 +116,11 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
// UI aliases
|
// UI aliases
|
||||||
lateinit var uiAliases: ArrayList<UICanvas>
|
lateinit var uiAliases: ArrayList<UICanvas>
|
||||||
private set
|
private set
|
||||||
lateinit var uiAlasesPausing: ArrayList<UICanvas>
|
lateinit var uiAliasesPausing: ArrayList<UICanvas>
|
||||||
private set
|
private set
|
||||||
|
|
||||||
inline val paused: Boolean
|
inline val paused: Boolean
|
||||||
get() = uiAlasesPausing.map { if (it.isOpened) return true else 0 }.isEmpty() // isEmply is always false, which we want
|
get() = uiAliasesPausing.map { if (it.isOpened) return true else 0 }.isEmpty() // isEmpty is always false, which we want
|
||||||
/**
|
/**
|
||||||
* Set to false if UI is opened; set to true if UI is closed.
|
* Set to false if UI is opened; set to true if UI is closed.
|
||||||
*/
|
*/
|
||||||
@@ -355,13 +355,13 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
uiTooltip
|
uiTooltip
|
||||||
// drawn last
|
// drawn last
|
||||||
)
|
)
|
||||||
uiAlasesPausing = arrayListOf(
|
uiAliasesPausing = arrayListOf(
|
||||||
uiInventoryPlayer,
|
uiInventoryPlayer,
|
||||||
//uiInventoryContainer,
|
//uiInventoryContainer,
|
||||||
consoleHandler,
|
consoleHandler,
|
||||||
uiCheatMotherfuckerNootNoot
|
uiCheatMotherfuckerNootNoot
|
||||||
)
|
)
|
||||||
uiAlasesPausing.forEach { addUI(it) } // put them all to the UIContainer
|
uiAliasesPausing.forEach { addUI(it) } // put them all to the UIContainer
|
||||||
uiAliases.forEach { addUI(it) } // put them all to the UIContainer
|
uiAliases.forEach { addUI(it) } // put them all to the UIContainer
|
||||||
|
|
||||||
|
|
||||||
@@ -958,7 +958,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
actorsRenderOverlay.forEach { it.dispose() }
|
actorsRenderOverlay.forEach { it.dispose() }
|
||||||
|
|
||||||
uiAliases.forEach { it.dispose() }
|
uiAliases.forEach { it.dispose() }
|
||||||
uiAlasesPausing.forEach { it.dispose() }
|
uiAliasesPausing.forEach { it.dispose() }
|
||||||
|
|
||||||
|
|
||||||
WatchDotAlph.dispose()
|
WatchDotAlph.dispose()
|
||||||
|
|||||||
@@ -358,14 +358,7 @@ open class ActorHumanoid(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun keyDown(keycode: Int): Boolean {
|
override fun keyDown(keycode: Int): Boolean {
|
||||||
// quickslot (quickbar)
|
return false
|
||||||
val quickbarKeys = AppLoader.getConfigIntArray("keyquickbars")
|
|
||||||
if (keycode in quickbarKeys) {
|
|
||||||
actorValue[AVKey.__PLAYER_QUICKSLOTSEL] = quickbarKeys.indexOf(keycode)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_WALLS
|
|||||||
import net.torvald.terrarum.itemproperties.ItemID
|
import net.torvald.terrarum.itemproperties.ItemID
|
||||||
import net.torvald.terrarum.lock
|
import net.torvald.terrarum.lock
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.UIQuickslotBar
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.locks.Lock
|
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,13 +30,13 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
|||||||
/**
|
/**
|
||||||
* List of all equipped items (tools, armours, rings, necklaces, etc.)
|
* List of all equipped items (tools, armours, rings, necklaces, etc.)
|
||||||
*/
|
*/
|
||||||
val itemEquipped = Array<GameItem?>(GameItem.EquipPosition.INDEX_MAX, { null })
|
val itemEquipped = Array<GameItem?>(GameItem.EquipPosition.INDEX_MAX) { null }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorted by referenceID.
|
* Sorted by referenceID.
|
||||||
*/
|
*/
|
||||||
val itemList = ArrayList<InventoryPair>()
|
val itemList = ArrayList<InventoryPair>()
|
||||||
val quickBar = Array<ItemID?>(10, { null }) // 0: Slot 1, 9: Slot 10
|
val quickSlot = Array<ItemID?>(UIQuickslotBar.SLOT_COUNT) { null } // 0: Slot 1, 9: Slot 10
|
||||||
|
|
||||||
var currency = 0 // unified currency for whole civs; Dwarf Fortress approach seems too complicated
|
var currency = 0 // unified currency for whole civs; Dwarf Fortress approach seems too complicated
|
||||||
|
|
||||||
@@ -127,10 +127,10 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setQuickBar(slot: Int, dynamicID: ItemID?) {
|
fun setQuickBar(slot: Int, dynamicID: ItemID?) {
|
||||||
quickBar[slot] = dynamicID
|
quickSlot[slot] = dynamicID
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getQuickslot(slot: Int): InventoryPair? = getByDynamicID(quickBar[slot])
|
fun getQuickslot(slot: Int): InventoryPair? = getByDynamicID(quickSlot[slot])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashMap<GameItem, Amounts>
|
* HashMap<GameItem, Amounts>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.ui
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
import com.badlogic.gdx.Input
|
|
||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
@@ -87,24 +86,6 @@ class UIQuickslotBar : UICanvas() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun keyDown(keycode: Int): Boolean {
|
|
||||||
selection = when (keycode) {
|
|
||||||
Input.Keys.NUM_1 -> 0
|
|
||||||
Input.Keys.NUM_2 -> 1
|
|
||||||
Input.Keys.NUM_3 -> 2
|
|
||||||
Input.Keys.NUM_4 -> 3
|
|
||||||
Input.Keys.NUM_5 -> 4
|
|
||||||
Input.Keys.NUM_6 -> 5
|
|
||||||
Input.Keys.NUM_7 -> 6
|
|
||||||
Input.Keys.NUM_8 -> 7
|
|
||||||
Input.Keys.NUM_9 -> 8
|
|
||||||
Input.Keys.NUM_0 -> 9
|
|
||||||
else -> return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,6 @@
|
|||||||
package net.torvald.terrarum.utils
|
package net.torvald.terrarum.utils
|
||||||
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import com.google.gson.JsonParser
|
|
||||||
import net.torvald.terrarum.AppLoader.printdbg
|
import net.torvald.terrarum.AppLoader.printdbg
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
import java.io.IOException
|
|
||||||
import java.nio.file.FileSystems
|
|
||||||
import java.nio.file.Files
|
|
||||||
import java.util.ArrayList
|
|
||||||
import java.util.function.Consumer
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-02-15.
|
* Created by minjaesong on 2016-02-15.
|
||||||
@@ -18,7 +9,7 @@ object JsonFetcher {
|
|||||||
|
|
||||||
private var jsonString: StringBuffer? = null
|
private var jsonString: StringBuffer? = null
|
||||||
|
|
||||||
@Throws(java.io.IOException::class)
|
@Throws(java.nio.file.NoSuchFileException::class)
|
||||||
operator fun invoke(jsonFilePath: String): com.google.gson.JsonObject {
|
operator fun invoke(jsonFilePath: String): com.google.gson.JsonObject {
|
||||||
jsonString = StringBuffer() // reset buffer every time it called
|
jsonString = StringBuffer() // reset buffer every time it called
|
||||||
readJsonFileAsString(jsonFilePath)
|
readJsonFileAsString(jsonFilePath)
|
||||||
@@ -35,7 +26,7 @@ object JsonFetcher {
|
|||||||
return jsonObj
|
return jsonObj
|
||||||
}
|
}
|
||||||
|
|
||||||
@Throws(java.io.IOException::class)
|
@Throws(java.nio.file.NoSuchFileException::class)
|
||||||
operator fun invoke(jsonFile: java.io.File): com.google.gson.JsonObject {
|
operator fun invoke(jsonFile: java.io.File): com.google.gson.JsonObject {
|
||||||
jsonString = StringBuffer() // reset buffer every time it called
|
jsonString = StringBuffer() // reset buffer every time it called
|
||||||
readJsonFileAsString(jsonFile.canonicalPath)
|
readJsonFileAsString(jsonFile.canonicalPath)
|
||||||
@@ -52,15 +43,11 @@ object JsonFetcher {
|
|||||||
return jsonObj
|
return jsonObj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Throws(java.nio.file.NoSuchFileException::class)
|
||||||
private fun readJsonFileAsString(path: String) {
|
private fun readJsonFileAsString(path: String) {
|
||||||
try {
|
java.nio.file.Files.lines(java.nio.file.FileSystems.getDefault().getPath(path)).forEach(
|
||||||
java.nio.file.Files.lines(java.nio.file.FileSystems.getDefault().getPath(path)).forEach(
|
{ jsonString!!.append(it) }
|
||||||
{ jsonString!!.append(it) }
|
) // JSON does not require line break
|
||||||
) // JSON does not require line break
|
|
||||||
}
|
|
||||||
catch (e: IOException) {
|
|
||||||
System.err.println("[JsonFetcher] An error occurred while reading $path")
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
package net.torvald.terrarum.utils
|
package net.torvald.terrarum.utils
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.JsonElement
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
|
|
||||||
import java.io.FileWriter
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-03-04.
|
* Created by minjaesong on 2016-03-04.
|
||||||
*/
|
*/
|
||||||
object JsonWriter {
|
object JsonWriter {
|
||||||
|
|
||||||
|
private val formattingRegex = Regex("""(?<=[\{,\[])|(?=[\]}])""")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* serialise a class to the file as JSON, using Google GSON.
|
* serialise a class to the file as JSON, using Google GSON.
|
||||||
*
|
*
|
||||||
@@ -23,7 +18,7 @@ object JsonWriter {
|
|||||||
val classElem = com.google.gson.Gson().toJsonTree(c)
|
val classElem = com.google.gson.Gson().toJsonTree(c)
|
||||||
val jsonString = classElem.toString()
|
val jsonString = classElem.toString()
|
||||||
val writer = java.io.FileWriter(path)
|
val writer = java.io.FileWriter(path)
|
||||||
writer.write(jsonString)
|
writer.write(jsonString.replace(formattingRegex, "\n"))
|
||||||
writer.close()
|
writer.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +31,7 @@ object JsonWriter {
|
|||||||
@Throws(java.io.IOException::class)
|
@Throws(java.io.IOException::class)
|
||||||
fun writeToFile(jsonObject: com.google.gson.JsonObject, path: String) {
|
fun writeToFile(jsonObject: com.google.gson.JsonObject, path: String) {
|
||||||
val writer = java.io.FileWriter(path)
|
val writer = java.io.FileWriter(path)
|
||||||
writer.write(jsonObject.toString())
|
writer.write(jsonObject.toString().replace(formattingRegex, "\n"))
|
||||||
writer.close()
|
writer.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user