mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
adproperties now hold filename-related info
This commit is contained in:
@@ -15,6 +15,7 @@ class ADProperties {
|
|||||||
|
|
||||||
/** list of bodyparts used by all the skeletons */
|
/** list of bodyparts used by all the skeletons */
|
||||||
lateinit var bodyparts: List<String>; private set
|
lateinit var bodyparts: List<String>; private set
|
||||||
|
lateinit var bodypartFiles: List<String>; private set
|
||||||
/** properties that are being used as skeletons */
|
/** properties that are being used as skeletons */
|
||||||
lateinit var skeletons: List<String>; private set
|
lateinit var skeletons: List<String>; private set
|
||||||
/** properties that are recognised as animations */
|
/** properties that are recognised as animations */
|
||||||
@@ -23,6 +24,9 @@ class ADProperties {
|
|||||||
private val reservedProps = listOf("SPRITESHEET", "EXTENSION")
|
private val reservedProps = listOf("SPRITESHEET", "EXTENSION")
|
||||||
private val animMustContain = listOf("DELAY", "ROW", "SKELETON")
|
private val animMustContain = listOf("DELAY", "ROW", "SKELETON")
|
||||||
|
|
||||||
|
lateinit var baseFilename: String; private set
|
||||||
|
lateinit var extension: String; private set
|
||||||
|
|
||||||
constructor(reader: Reader) {
|
constructor(reader: Reader) {
|
||||||
javaProp.load(reader)
|
javaProp.load(reader)
|
||||||
continueLoad()
|
continueLoad()
|
||||||
@@ -41,6 +45,10 @@ class ADProperties {
|
|||||||
propTable[propName.capitalize()] = propsList
|
propTable[propName.capitalize()] = propsList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set reserved values for the animation: filename, extension
|
||||||
|
baseFilename = get("SPRITESHEET")!![0].variable
|
||||||
|
extension = get("EXTENSION")!![0].variable
|
||||||
|
|
||||||
val bodyparts = HashSet<String>()
|
val bodyparts = HashSet<String>()
|
||||||
val skeletons = HashSet<String>()
|
val skeletons = HashSet<String>()
|
||||||
val animations = ArrayList<String>()
|
val animations = ArrayList<String>()
|
||||||
@@ -67,11 +75,10 @@ class ADProperties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.bodyparts = bodyparts.toList().sorted()
|
this.bodyparts = bodyparts.toList().sorted()
|
||||||
this.skeletons = skeletons.toList().sorted()
|
this.skeletons = skeletons.toList().sorted()
|
||||||
this.animations = animations.sorted()
|
this.animations = animations.sorted()
|
||||||
|
this.bodypartFiles = this.bodyparts.map { getFullFilename(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(identifier: String) = propTable[identifier.capitalize()]
|
operator fun get(identifier: String) = propTable[identifier.capitalize()]
|
||||||
@@ -80,6 +87,8 @@ class ADProperties {
|
|||||||
fun containsKey(key: String) = propTable.containsKey(key)
|
fun containsKey(key: String) = propTable.containsKey(key)
|
||||||
fun forEach(predicate: (String, List<ADPropertyObject>) -> Unit) = propTable.forEach(predicate)
|
fun forEach(predicate: (String, List<ADPropertyObject>) -> Unit) = propTable.forEach(predicate)
|
||||||
|
|
||||||
|
fun getFullFilename(partName: String) =
|
||||||
|
"${this.baseFilename}${partName.toLowerCase()}${this.extension}"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.torvald.spriteassembler
|
package net.torvald.spriteassembler
|
||||||
|
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
|
import java.awt.Dimension
|
||||||
import java.awt.Graphics
|
import java.awt.Graphics
|
||||||
import java.awt.event.MouseAdapter
|
import java.awt.event.MouseAdapter
|
||||||
import java.awt.event.MouseEvent
|
import java.awt.event.MouseEvent
|
||||||
@@ -23,6 +24,7 @@ class SpriteAssemblerApp : JFrame() {
|
|||||||
private val panelProperties = JTree()
|
private val panelProperties = JTree()
|
||||||
private val panelAnimationsList = JList<String>()
|
private val panelAnimationsList = JList<String>()
|
||||||
private val panelBodypartsList = JList<String>()
|
private val panelBodypartsList = JList<String>()
|
||||||
|
private val panelImageFilesList = JList<String>()
|
||||||
private val panelSkeletonsList = JList<String>()
|
private val panelSkeletonsList = JList<String>()
|
||||||
private val panelCode = JTextPane()
|
private val panelCode = JTextPane()
|
||||||
private val statBar = JTextArea("Null.")
|
private val statBar = JTextArea("Null.")
|
||||||
@@ -85,20 +87,25 @@ class SpriteAssemblerApp : JFrame() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
panelPreview.preferredSize = Dimension(512,512)
|
||||||
|
|
||||||
panelAnimationsList.model = DefaultListModel()
|
panelAnimationsList.model = DefaultListModel()
|
||||||
panelBodypartsList.model = DefaultListModel()
|
panelBodypartsList.model = DefaultListModel()
|
||||||
|
panelImageFilesList.model = DefaultListModel()
|
||||||
panelSkeletonsList.model = DefaultListModel()
|
panelSkeletonsList.model = DefaultListModel()
|
||||||
|
|
||||||
val panelPartsList = JTabbedPane(JTabbedPane.TOP)
|
val panelPartsList = JTabbedPane(JTabbedPane.TOP)
|
||||||
panelPartsList.add("Animations", JScrollPane(panelAnimationsList))
|
panelPartsList.add("Animations", JScrollPane(panelAnimationsList))
|
||||||
panelPartsList.add("Bodyparts", JScrollPane(panelBodypartsList))
|
panelPartsList.add("Bodyparts", JScrollPane(panelBodypartsList))
|
||||||
|
panelPartsList.add("Images", JScrollPane(panelImageFilesList))
|
||||||
panelPartsList.add("Skeletons", JScrollPane(panelSkeletonsList))
|
panelPartsList.add("Skeletons", JScrollPane(panelSkeletonsList))
|
||||||
|
|
||||||
|
|
||||||
val panelDataView = JSplitPane(JSplitPane.VERTICAL_SPLIT, JScrollPane(panelProperties), panelPartsList)
|
val panelDataView = JSplitPane(JSplitPane.VERTICAL_SPLIT, JScrollPane(panelProperties), panelPartsList)
|
||||||
|
panelProperties.preferredSize = Dimension(1, 300)
|
||||||
|
panelPartsList.preferredSize = Dimension(1, 200)
|
||||||
|
|
||||||
val panelTop = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, JScrollPane(panelPreview), panelDataView)
|
val panelTop = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, JScrollPane(panelPreview), panelDataView)
|
||||||
|
|
||||||
val panelMain = JSplitPane(JSplitPane.VERTICAL_SPLIT, panelTop, JScrollPane(panelCode))
|
val panelMain = JSplitPane(JSplitPane.VERTICAL_SPLIT, panelTop, JScrollPane(panelCode))
|
||||||
|
|
||||||
val menu = JMenuBar()
|
val menu = JMenuBar()
|
||||||
@@ -132,8 +139,12 @@ class SpriteAssemblerApp : JFrame() {
|
|||||||
(panelAnimationsList.model as DefaultListModel).addElement(it)
|
(panelAnimationsList.model as DefaultListModel).addElement(it)
|
||||||
}
|
}
|
||||||
// populate bodyparts view
|
// populate bodyparts view
|
||||||
adProperties!!.bodyparts.forEach {
|
adProperties!!.bodyparts.forEach { partName ->
|
||||||
(panelBodypartsList.model as DefaultListModel).addElement(it)
|
(panelBodypartsList.model as DefaultListModel).addElement(partName)
|
||||||
|
}
|
||||||
|
// populate image file list view
|
||||||
|
adProperties!!.bodypartFiles.forEach { partName ->
|
||||||
|
(panelImageFilesList.model as DefaultListModel).addElement(partName)
|
||||||
}
|
}
|
||||||
// populate skeletons view
|
// populate skeletons view
|
||||||
adProperties!!.skeletons.forEach {
|
adProperties!!.skeletons.forEach {
|
||||||
|
|||||||
Reference in New Issue
Block a user