mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
improved ActorValueTracker: can now change actor currently tracking
Former-commit-id: 71daf44209f700b8702f2b73294583edefda49c9 Former-commit-id: 3ab76c6509086490ba6ea9501b1ba08e444a7e53
This commit is contained in:
@@ -41,6 +41,6 @@ object AVTracker : ConsoleCommand {
|
||||
}
|
||||
|
||||
fun update() {
|
||||
jPanelInstances.forEach { it.setInfoLabel() }
|
||||
jPanelInstances.forEach { it.update() }
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,6 @@ object ActorsList : ConsoleCommand {
|
||||
}
|
||||
|
||||
fun update() {
|
||||
jPanelInstances.forEach { it.setInfoLabel() }
|
||||
jPanelInstances.forEach { it.update() }
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ internal object GetAV : ConsoleCommand {
|
||||
" $ccO" +
|
||||
Terrarum.ingame.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
||||
)
|
||||
println("id.av = " +
|
||||
println("$id.$av = " +
|
||||
Terrarum.ingame.getActorByID(id).actorValue[av] +
|
||||
" " +
|
||||
Terrarum.ingame.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.debuggerapp
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.SetAV
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
@@ -24,11 +25,11 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
setTrackingActor(actor)
|
||||
}
|
||||
|
||||
private val selectedActorLabel = JLabel("Actor not selected")
|
||||
private val avInfoArea = JTextArea()
|
||||
private val avInfoScroller = JScrollPane(avInfoArea)
|
||||
private val avPosArea = JTextArea()
|
||||
private val avPosScroller = JScrollPane(avPosArea)
|
||||
|
||||
private var actor: ActorWithBody? = null
|
||||
private var actorValue: ActorValue? = null
|
||||
|
||||
@@ -38,6 +39,10 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
private val buttonAddAV = JButton("Add/Mod")
|
||||
private val buttonDelAV = JButton("Delete")
|
||||
|
||||
//private val selectedActorLabel = JLabel("Selected actor: ")
|
||||
private val actorIDField = JTextField()
|
||||
private val buttonChangeActor = JButton("Change")
|
||||
|
||||
init {
|
||||
title = "Actor value tracker"
|
||||
defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE
|
||||
@@ -51,6 +56,9 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
avInfoScroller.horizontalScrollBarPolicy = JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
|
||||
avPosScroller.horizontalScrollBarPolicy = JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
|
||||
|
||||
if (actor != null) {
|
||||
actorIDField.text = "${actor!!.referenceID}"
|
||||
}
|
||||
|
||||
// button listener for buttons
|
||||
buttonAddAV.addMouseListener(object : MouseListener {
|
||||
@@ -82,17 +90,36 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
}
|
||||
}
|
||||
})
|
||||
buttonChangeActor.addMouseListener(object : MouseListener {
|
||||
override fun mouseEntered(e: MouseEvent?) { }
|
||||
override fun mouseClicked(e: MouseEvent?) { }
|
||||
override fun mouseReleased(e: MouseEvent?) { }
|
||||
override fun mouseExited(e: MouseEvent?) { }
|
||||
override fun mousePressed(e: MouseEvent?) {
|
||||
if (actorIDField.text.toLowerCase() == "player") {
|
||||
actor = Terrarum.ingame.player
|
||||
actorValue = actor!!.actorValue
|
||||
}
|
||||
else if (actorIDField.text.isNotBlank()) {
|
||||
actor = Terrarum.ingame.getActorByID(actorIDField.text.toInt()) as ActorWithBody
|
||||
actorValue = actor!!.actorValue
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// panel elements
|
||||
divPanel.add(selectedActorLabel, BorderLayout.PAGE_START)
|
||||
val actorNameBar = JPanel()
|
||||
actorNameBar.layout = BorderLayout(2, 0)
|
||||
actorNameBar.add(JLabel("RefID: "), BorderLayout.LINE_START)
|
||||
actorNameBar.add(actorIDField, BorderLayout.CENTER)
|
||||
actorNameBar.add(buttonChangeActor, BorderLayout.LINE_END)
|
||||
|
||||
val posAndAV = JPanel()
|
||||
posAndAV.layout = BorderLayout()
|
||||
posAndAV.add(avPosScroller, BorderLayout.PAGE_START)
|
||||
posAndAV.add(avInfoScroller, BorderLayout.CENTER)
|
||||
|
||||
divPanel.add(posAndAV, BorderLayout.CENTER)
|
||||
|
||||
val toolbox = JPanel()
|
||||
toolbox.layout = BorderLayout()
|
||||
|
||||
@@ -115,13 +142,16 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
modpanel.layout = BorderLayout(4, 2)
|
||||
modpanel.add(modpanelLabels, BorderLayout.LINE_START)
|
||||
modpanel.add(modpanelFields, BorderLayout.CENTER)
|
||||
modpanel.add(JLabel(
|
||||
"<html>Messed-up type or careless delete will crash the game.<br>" +
|
||||
"Prepend two underscores for boolean literals.</html>"
|
||||
), BorderLayout.PAGE_END)
|
||||
|
||||
toolbox.add(toolpanel, BorderLayout.PAGE_START)
|
||||
toolbox.add(modpanel, BorderLayout.CENTER)
|
||||
modpanel.add(JLabel(
|
||||
"<html>Messed-up type or careless delete will crash the game.</html>"
|
||||
), BorderLayout.PAGE_END)
|
||||
|
||||
divPanel.add(actorNameBar, BorderLayout.PAGE_START)
|
||||
divPanel.add(posAndAV, BorderLayout.CENTER)
|
||||
divPanel.add(toolbox, BorderLayout.PAGE_END)
|
||||
|
||||
|
||||
@@ -133,20 +163,20 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
fun setTrackingActor(actor: Actor) {
|
||||
this.actorValue = actor.actorValue
|
||||
|
||||
selectedActorLabel.text = "Actor: $actor"
|
||||
this.title = "AVTracker — $actor"
|
||||
|
||||
if (actor is ActorWithBody) {
|
||||
this.actor = actor
|
||||
}
|
||||
|
||||
setInfoLabel()
|
||||
update()
|
||||
}
|
||||
|
||||
fun setInfoLabel() {
|
||||
fun update() {
|
||||
val sb = StringBuilder()
|
||||
|
||||
if (actor != null) {
|
||||
sb.append("toString: ${actor!!}\n")
|
||||
sb.append("X: ${actor!!.hitbox.pointedX} (${(actor!!.hitbox.pointedX / MapDrawer.TILE_SIZE).toInt()})\n")
|
||||
sb.append("Y: ${actor!!.hitbox.pointedY} (${(actor!!.hitbox.pointedY / MapDrawer.TILE_SIZE).toInt()})")
|
||||
|
||||
@@ -156,16 +186,10 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
|
||||
if (actorValue != null) {
|
||||
for (key in actorValue!!.keySet) {
|
||||
val value = actorValue!![key.toString()]
|
||||
val value = actorValue!![key.toString()]!!
|
||||
val type = value.javaClass.simpleName
|
||||
|
||||
sb.append("$key = ${
|
||||
if (value is String)
|
||||
"\"$value\"" // name = "Sigrid"
|
||||
else if (value is Boolean)
|
||||
"_$value" // intelligent = __true
|
||||
else
|
||||
"$value" // scale = 1.0
|
||||
}\n")
|
||||
sb.append("$key = $value ($type)\n")
|
||||
}
|
||||
|
||||
sb.deleteCharAt(sb.length - 1) // delete trailing \n
|
||||
@@ -180,22 +204,17 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
/*
|
||||
|
||||
+--------------------------------+
|
||||
| Actor: 5333533 (Sigrid) LBL |
|
||||
| Actor: [5333533 ] [Change] | LBL TFL BTN
|
||||
+--------------------------------+
|
||||
| X: 65532.655654747 (4095) LBL |
|
||||
| Y: 3050.4935465 (190) LBL |
|
||||
| X: 65532.655654747 (4095) | TAR
|
||||
| Y: 3050.4935465 (190) |
|
||||
| ... |
|
||||
+--------------------------------+
|
||||
| < TOOLBOX > BTN |
|
||||
| [ Add/Mod ] [ Delete ] | BTN BTN
|
||||
+--------------------------------+
|
||||
| Key [ ] |
|
||||
| Value [ ] |
|
||||
| Key [ ] | LBL TFL
|
||||
| Value [ ] | LBL TFL
|
||||
+--------------------------------+
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
@@ -52,11 +52,11 @@ class ActorsLister(
|
||||
|
||||
|
||||
this.add(divPanel)
|
||||
this.setSize(300, 600)
|
||||
this.setSize(300, 300)
|
||||
this.isVisible = true
|
||||
}
|
||||
|
||||
fun setInfoLabel() {
|
||||
fun update() {
|
||||
countsLabel.text = "Total: ${actorContainer.size + actorContainerInactive.size}, " +
|
||||
"Active: ${actorContainer.size}, Dormant: ${actorContainerInactive.size}"
|
||||
|
||||
@@ -78,16 +78,17 @@ class ActorsLister(
|
||||
/*
|
||||
|
||||
+-------------------------------------+
|
||||
| Total: 3, Active: 2, Dormant: 1 LBL |
|
||||
| Total: 3, Active: 2, Dormant: 1 | LBL
|
||||
+-------------------------------------+
|
||||
| Active actors LBL |
|
||||
| Active actors | LBL
|
||||
++-----------------------------------++
|
||||
||43232949 ||
|
||||
||43232949 || TAR
|
||||
||5333533 (Sigrid) ||
|
||||
++-----------------------------------++
|
||||
| Dormant actors LBL |
|
||||
|=====================================| SPN
|
||||
| Dormant actors | LBL
|
||||
++-----------------------------------++
|
||||
||12345678 (Cynthia) ||
|
||||
||12345678 (Cynthia) || TAR
|
||||
++===================================++
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user