mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-08 04:41:51 +09:00
new debugging tool ActorsList
Former-commit-id: 51109b6766a1ebd92613055064e3fa8bd69c37fc Former-commit-id: d5fc3d52b208d3cbbdcec47758cd73aef3240dc8
This commit is contained in:
@@ -41,8 +41,6 @@ object AVTracker : ConsoleCommand {
|
||||
}
|
||||
|
||||
fun update() {
|
||||
jPanelInstances.forEach {
|
||||
it.setInfoLabel()
|
||||
}
|
||||
jPanelInstances.forEach { it.setInfoLabel() }
|
||||
}
|
||||
}
|
||||
27
src/net/torvald/terrarum/console/ActorsList.kt
Normal file
27
src/net/torvald/terrarum/console/ActorsList.kt
Normal file
@@ -0,0 +1,27 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.debuggerapp.ActorsLister
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2016-12-29.
|
||||
*/
|
||||
object ActorsList : ConsoleCommand {
|
||||
private val jPanelInstances = ArrayList<ActorsLister>()
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
jPanelInstances.add(ActorsLister(
|
||||
Terrarum.ingame.actorContainer,
|
||||
Terrarum.ingame.actorContainerInactive)
|
||||
)
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
Echo("Pops up new window that displays the list of actors currently in the game")
|
||||
}
|
||||
|
||||
fun update() {
|
||||
jPanelInstances.forEach { it.setInfoLabel() }
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,8 @@ object CommandDict {
|
||||
Pair("seed", Seed),
|
||||
Pair("println", EchoConsole),
|
||||
Pair("inventory", Inventory),
|
||||
Pair("avtracker", AVTracker),
|
||||
Pair("actorslist", ActorsList),
|
||||
|
||||
// Test codes
|
||||
Pair("bulletintest", SetBulletin),
|
||||
|
||||
@@ -77,8 +77,8 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
override fun mousePressed(e: MouseEvent?) {
|
||||
if (actorValue != null && modavInputKey.text.isNotBlank()) {
|
||||
actorValue!!.remove(modavInputKey.text)
|
||||
Echo("${SetAV.ccW}Removed key ${SetAV.ccG}${modavInputKey.text} ${SetAV.ccW}of ${SetAV.ccY}${actor!!.referenceID}")
|
||||
println("[ActorValueTracker] Removed key '${modavInputKey.text}' of $actor")
|
||||
Echo("${SetAV.ccW}Removed ${SetAV.ccM}${modavInputKey.text} ${SetAV.ccW}of ${SetAV.ccY}${actor!!.referenceID}")
|
||||
println("[ActorValueTracker] Removed ActorValue '${modavInputKey.text}' of $actor")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
94
src/net/torvald/terrarum/debuggerapp/ActorsLister.kt
Normal file
94
src/net/torvald/terrarum/debuggerapp/ActorsLister.kt
Normal file
@@ -0,0 +1,94 @@
|
||||
package net.torvald.terrarum.debuggerapp
|
||||
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.Dimension
|
||||
import java.awt.GridLayout
|
||||
import java.util.*
|
||||
import javax.swing.*
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2016-12-29.
|
||||
*/
|
||||
class ActorsLister(
|
||||
val actorContainer: ArrayList<Actor>,
|
||||
val actorContainerInactive: ArrayList<Actor>) : JFrame() {
|
||||
|
||||
private val activeActorArea = JTextArea()
|
||||
private val activeActorScroller = JScrollPane(activeActorArea)
|
||||
private val inactiveActorArea = JTextArea()
|
||||
private val inactiveActorScroller = JScrollPane(inactiveActorArea)
|
||||
|
||||
private val countsLabel = JLabel()
|
||||
|
||||
init {
|
||||
title = "Actors list"
|
||||
defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE
|
||||
|
||||
activeActorArea.highlighter = null // prevent text-drag-crash
|
||||
inactiveActorArea.highlighter = null // prevent text-drag-crash
|
||||
|
||||
|
||||
val divPanel = JPanel()
|
||||
divPanel.layout = BorderLayout(0, 2)
|
||||
|
||||
val activeCard = JPanel()
|
||||
activeCard.layout = BorderLayout(0, 2)
|
||||
activeCard.add(JLabel("Active actors"), BorderLayout.PAGE_START)
|
||||
activeCard.add(activeActorScroller, BorderLayout.CENTER)
|
||||
|
||||
val inactiveCard = JPanel()
|
||||
inactiveCard.layout = BorderLayout(0, 2)
|
||||
inactiveCard.add(JLabel("Dormant actors"), BorderLayout.PAGE_START)
|
||||
inactiveCard.add(inactiveActorScroller, BorderLayout.CENTER)
|
||||
|
||||
val splitPane = JSplitPane(JSplitPane.VERTICAL_SPLIT, activeCard, inactiveCard)
|
||||
splitPane.topComponent.minimumSize = Dimension(0, 24)
|
||||
splitPane.bottomComponent.minimumSize = Dimension(0, 24)
|
||||
splitPane.resizeWeight = 0.5
|
||||
|
||||
divPanel.add(countsLabel, BorderLayout.PAGE_START)
|
||||
divPanel.add(splitPane, BorderLayout.CENTER)
|
||||
|
||||
|
||||
this.add(divPanel)
|
||||
this.setSize(300, 600)
|
||||
this.isVisible = true
|
||||
}
|
||||
|
||||
fun setInfoLabel() {
|
||||
countsLabel.text = "Total: ${actorContainer.size + actorContainerInactive.size}, " +
|
||||
"Active: ${actorContainer.size}, Dormant: ${actorContainerInactive.size}"
|
||||
|
||||
val sb = StringBuilder()
|
||||
|
||||
actorContainer.forEach { sb.append("$it\n") }
|
||||
sb.deleteCharAt(sb.length - 1) // delete trailing \n
|
||||
activeActorArea.text = "$sb"
|
||||
|
||||
sb.setLength(0) // clear stringbuffer
|
||||
|
||||
actorContainerInactive.forEach { sb.append("$it\n") }
|
||||
if (sb.length > 1) {
|
||||
sb.deleteCharAt(sb.length - 1) // delete trailing \n
|
||||
}
|
||||
inactiveActorArea.text = "$sb"
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
+-------------------------------------+
|
||||
| Total: 3, Active: 2, Dormant: 1 LBL |
|
||||
+-------------------------------------+
|
||||
| Active actors LBL |
|
||||
++-----------------------------------++
|
||||
||43232949 ||
|
||||
||5333533 (Sigrid) ||
|
||||
++-----------------------------------++
|
||||
| Dormant actors LBL |
|
||||
++-----------------------------------++
|
||||
||12345678 (Cynthia) ||
|
||||
++===================================++
|
||||
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user