mirror of
https://gitlab.com/2009scape/tools/rs09-thanos-tool.git
synced 2026-08-01 14:39:20 -06:00
Start of item spawn editing
This commit is contained in:
parent
12cfdbbc40
commit
d23e13d5de
7 changed files with 75 additions and 31 deletions
|
|
@ -315,6 +315,34 @@ enum class Editors(val data: EditorData) {
|
|||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}),
|
||||
ITEM_SPAWNS(object : EditorData("ground_spawns.json") {
|
||||
override fun parse() {
|
||||
Logger.logInfo("Parsing ground spawn data...")
|
||||
val spawnMap = HashMap<Int, ArrayList<TableData.ItemSpawn>>()
|
||||
configureParser()
|
||||
data.forEach { spawnRaw ->
|
||||
val spawn = spawnRaw as JSONObject
|
||||
val id = spawn["item_id"].toString().toInt()
|
||||
val datas: Array<String> = spawn["loc_data"].toString().split("-".toRegex()).toTypedArray()
|
||||
var tokens: Array<String>
|
||||
for (d in datas) {
|
||||
if(d.isEmpty()){
|
||||
continue
|
||||
}
|
||||
tokens = d.replace("{", "").replace("}", "").split(",".toRegex()).toTypedArray()
|
||||
val amount = tokens[0].trim { it <= ' ' }.toInt()
|
||||
val spawnCoords = intArrayOf(Integer.valueOf(tokens[1].trim { it <= ' ' }), Integer.valueOf(tokens[2].trim { it <= ' ' }), Integer.valueOf(tokens[3].trim { it <= ' ' }))
|
||||
val respawnTime = tokens[4].trim { it <= ' ' }.toInt() and 0xFF
|
||||
val item = TableData.ItemSpawn(id, TableData.Location(spawnCoords[0], spawnCoords[1], spawnCoords[2]), respawnTime, amount)
|
||||
val regionId = Util.getRegionId(item.location)
|
||||
if (!spawnMap.containsKey(regionId))
|
||||
spawnMap[regionId] = ArrayList()
|
||||
spawnMap[regionId]!!.add(item)
|
||||
}
|
||||
}
|
||||
TableData.itemSpawns = spawnMap
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ fun showLoaded(){
|
|||
"item_configs" -> MainScreen.openItem.isEnabled = true.also { Editors.ITEM_CONFIGS.data.parse() }
|
||||
"shops" -> MainScreen.openShops.isEnabled = true.also { Editors.SHOPS.data.parse() }
|
||||
"object_configs" -> MainScreen.openObjects.isEnabled = true.also { Editors.OBJECT_CONFIGS.data.parse()}
|
||||
"npc_spawns" -> MainScreen.openNpcItemSpawns.isEnabled = true.also { Editors.NPC_SPAWNS.data.parse() }
|
||||
"npc_spawns" -> MainScreen.openNpcItemSpawns.isEnabled = true.also { Editors.NPC_SPAWNS.data.parse(); Editors.ITEM_SPAWNS.data.parse() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,4 +154,4 @@ fun main() {
|
|||
DataStore.save()
|
||||
})
|
||||
MainScreen.isVisible = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ object Rs2MapEditor {
|
|||
val library = CacheLibrary.create(cachePath)
|
||||
var region = 12850
|
||||
var npcs = TableData.npcSpawns[region]
|
||||
var items = GroundItemSpawnParser.parseItemSpawns(region)
|
||||
var items = TableData.itemSpawns[region]
|
||||
var sceneries = TileSceneryParser.parseRegion(region)
|
||||
val npcRows = ArrayList<NPCSpawnPanel.NPCRow>()
|
||||
val itemRows = ArrayList<ItemSpawnPanel.ItemRow>()
|
||||
|
|
@ -240,7 +240,7 @@ object Rs2MapEditor {
|
|||
mapCell.layout = BorderLayout()
|
||||
mapCell.add(JLabel(YELLOW_DOT))
|
||||
}
|
||||
val itemSpawnsHere = items.filter { it.x == column && it.y == flippedY && it.plane == plane }.toList()
|
||||
val itemSpawnsHere = items!!.filter { it.location == thisAbsolute }.toList()
|
||||
if (itemSpawnsHere.isNotEmpty()) {
|
||||
mapCell.layout = BorderLayout()
|
||||
mapCell.add(JLabel(RED_DOT))
|
||||
|
|
@ -379,7 +379,7 @@ object Rs2MapEditor {
|
|||
Rs2MapEditor.region = regionId
|
||||
Rs2MapEditor.plane = 0
|
||||
npcs = TableData.npcSpawns[regionId] ?: ArrayList<TableData.NPCSpawn>().also { TableData.npcSpawns[regionId] = it }
|
||||
items = GroundItemSpawnParser.parseItemSpawns(regionId)
|
||||
items = TableData.itemSpawns[regionId] ?: ArrayList<TableData.ItemSpawn>().also { TableData.itemSpawns[regionId] = it }
|
||||
sceneries = TileSceneryParser.parseRegion(regionId)
|
||||
npcPanel.redrawRows()
|
||||
itemPanel.redrawRows()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ object TableData {
|
|||
val npcConfigKeys = HashSet<String>()
|
||||
val npcConfigs = ArrayList<JSONObject>()
|
||||
var npcSpawns = HashMap<Int, ArrayList<NPCSpawn>>()
|
||||
val itemSpawns = HashMap<Int, ArrayList<ItemSpawn>>()
|
||||
var itemSpawns = HashMap<Int, ArrayList<ItemSpawn>>()
|
||||
val objConfigKeys = HashSet<String>()
|
||||
val objConfigs = ArrayList<JSONObject>()
|
||||
var itemConfigKeys = HashSet<String>()
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ object GlobalKeybinds{
|
|||
Editors.NPC_SPAWNS.data.save()
|
||||
}
|
||||
if(Rs2MapEditor.itemsUpdated){
|
||||
GroundItemEncoder.write(Rs2MapEditor.items)
|
||||
//GroundItemEncoder.write(Rs2MapEditor.items)
|
||||
Editors.ITEM_SPAWNS.data.save()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import javax.swing.BoxLayout
|
|||
import javax.swing.JLabel
|
||||
import javax.swing.JPanel
|
||||
import javax.swing.border.MatteBorder
|
||||
import tools.*
|
||||
|
||||
class ItemSpawnPanel : JPanel() {
|
||||
val rowBorder = MatteBorder(1, 1, 1, 1, Color.WHITE)
|
||||
|
|
@ -21,7 +22,7 @@ class ItemSpawnPanel : JPanel() {
|
|||
|
||||
add(ItemSpawnerPanel())
|
||||
|
||||
Rs2MapEditor.items.forEach {
|
||||
Rs2MapEditor.items!!.filter { it.location.z == Rs2MapEditor.plane }.forEach {
|
||||
val row = ItemRow(it, this)
|
||||
row.border = rowBorder
|
||||
Rs2MapEditor.itemRows.add(row)
|
||||
|
|
@ -34,7 +35,7 @@ class ItemSpawnPanel : JPanel() {
|
|||
remove(it)
|
||||
}
|
||||
Rs2MapEditor.itemRows.clear()
|
||||
Rs2MapEditor.items.filter { it.plane == Rs2MapEditor.plane }.forEach {
|
||||
Rs2MapEditor.items!!.filter { it.location.z == Rs2MapEditor.plane }.forEach {
|
||||
val row = ItemRow(it, this)
|
||||
row.border = rowBorder
|
||||
Rs2MapEditor.itemRows.add(row)
|
||||
|
|
@ -85,22 +86,34 @@ class ItemSpawnPanel : JPanel() {
|
|||
}
|
||||
}
|
||||
|
||||
class ItemRow(val item: Item, val parent: JPanel) : JPanel(){
|
||||
class ItemRow(val item: TableData.ItemSpawn, val parent: JPanel) : JPanel(){
|
||||
init {
|
||||
layout = FlowLayout()
|
||||
add(JLabel("${item.definition.name} [${item.amount}] -- \uD83D\uDD64 ${item.respawnTime}"))
|
||||
layout = BorderLayout()
|
||||
val topPanel = JPanel(FlowLayout())
|
||||
val midPanel = JPanel(FlowLayout())
|
||||
val botPanel = JPanel(FlowLayout())
|
||||
|
||||
val deleteButton = ImgButton(Image.DELETE_HI, Image.DELTE_LO)
|
||||
add(deleteButton)
|
||||
minimumSize = Dimension(300, 40)
|
||||
preferredSize = Dimension(300, 40)
|
||||
maximumSize = Dimension(300, 40)
|
||||
topPanel.add(JLabel("${TableData.itemNames[item.id]} [${item.id}]"))
|
||||
topPanel.add(deleteButton)
|
||||
midPanel.add(JLabel("{${item.location.x},${item.location.y},${item.location.z}}"))
|
||||
botPanel.add(JLabel("AMT: ${item.amount} \uD83D\uDD64 ${item.respawnTicks}"))
|
||||
|
||||
add(topPanel, BorderLayout.NORTH)
|
||||
add(midPanel, BorderLayout.CENTER)
|
||||
add(botPanel, BorderLayout.SOUTH)
|
||||
|
||||
minimumSize = Dimension(300, 80)
|
||||
preferredSize = Dimension(300, 80)
|
||||
maximumSize = Dimension(300, 80)
|
||||
|
||||
deleteButton.onClick {
|
||||
Rs2MapEditor.items.remove(item)
|
||||
Rs2MapEditor.items!!.remove(item)
|
||||
parent.remove(this)
|
||||
parent.repaint()
|
||||
Rs2MapEditor.itemRows.remove(this)
|
||||
if(Rs2MapEditor.items.filter { it.x == item.x && it.y == item.y }.isEmpty()){
|
||||
Rs2MapEditor.componentPointMap.filter { it.key.x == item.x && it.key.y == item.y }.forEach { (_,cell) ->
|
||||
if(Rs2MapEditor.items!!.filter { it.location == item.location }.isEmpty()){
|
||||
Rs2MapEditor.componentPointMap.filter { it.key.x == item.location.localCoords[0] && it.key.y == item.location.localCoords[1] }.forEach { (_,cell) ->
|
||||
cell.components.forEach { c ->
|
||||
if(c is JLabel && c.icon == Image.RED_DOT) cell.remove(c)
|
||||
}
|
||||
|
|
@ -115,14 +128,14 @@ class ItemSpawnPanel : JPanel() {
|
|||
val defaultBorder = MatteBorder(1, 1, 1, 1, Color.GRAY)
|
||||
override fun mouseEntered(e: MouseEvent?) {
|
||||
super.mouseEntered(e)
|
||||
Rs2MapEditor.componentPointMap.filter { it.key.x == item.x && it.key.y == item.y }.forEach { it.value.border = border }
|
||||
Rs2MapEditor.componentPointMap.filter { it.key.x == item.location.localCoords[0] && it.key.y == item.location.localCoords[1] }.forEach { it.value.border = border }
|
||||
}
|
||||
|
||||
override fun mouseExited(e: MouseEvent?) {
|
||||
super.mouseExited(e)
|
||||
Rs2MapEditor.componentPointMap.filter { it.key.x == item.x && it.key.y == item.y }.forEach{ it.value.border = defaultBorder }
|
||||
Rs2MapEditor.componentPointMap.filter { it.key.x == item.location.localCoords[0] && it.key.y == item.location.localCoords[1] }.forEach{ it.value.border = defaultBorder }
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,15 +119,17 @@ class MapCell : JPanel() {
|
|||
return
|
||||
}
|
||||
|
||||
val item = Item(
|
||||
val item = TableData.ItemSpawn(
|
||||
id,
|
||||
Rs2MapEditor.selectedPointX,
|
||||
Rs2MapEditor.selectedPointY,
|
||||
Rs2MapEditor.plane,
|
||||
respawnTime,
|
||||
amount
|
||||
TableData.Location(
|
||||
Rs2MapEditor.selectedPointX,
|
||||
Rs2MapEditor.selectedPointY,
|
||||
Rs2MapEditor.plane
|
||||
),
|
||||
amount,
|
||||
respawnTime
|
||||
)
|
||||
Rs2MapEditor.items.add(item)
|
||||
Rs2MapEditor.items!!.add(item)
|
||||
Rs2MapEditor.componentPointMap.filter { it.key.x == Rs2MapEditor.selectedPointX && it.key.y == Rs2MapEditor.selectedPointY }.forEach { (_, cell) ->
|
||||
var hasLabel = false
|
||||
cell.components.forEach { if(it is JLabel && it.icon == Image.RED_DOT) hasLabel = true }
|
||||
|
|
@ -180,7 +182,7 @@ class MapCell : JPanel() {
|
|||
.append("</table>")
|
||||
.append("<br/>")
|
||||
val thisAbsolute = Util.getAbsoluteCoordinates(Rs2MapEditor.region, Rs2MapEditor.selectedPointX, Rs2MapEditor.selectedPointY, Rs2MapEditor.plane)
|
||||
val itemsHere = Rs2MapEditor.items.filter { it.x == Rs2MapEditor.selectedPointX && it.y == Rs2MapEditor.selectedPointY && it.plane == Rs2MapEditor.plane }.toList()
|
||||
val itemsHere = Rs2MapEditor.items!!.filter { it.location == thisAbsolute }.toList()
|
||||
val npcsHere = Rs2MapEditor.npcs!!.filter { it.location == thisAbsolute }.toList()
|
||||
|
||||
if(npcsHere.isNotEmpty()) {
|
||||
|
|
@ -213,7 +215,7 @@ class MapCell : JPanel() {
|
|||
for (item in itemsHere) {
|
||||
string.append("<tr style=\"text-align:center\">")
|
||||
string.append("<td>${item.id}</td>")
|
||||
string.append("<td>${item.definition.name}[${item.amount}] \uD83D\uDD64${item.respawnTime}</td>")
|
||||
string.append("<td>${TableData.itemNames[item.id]}[${item.amount}] \uD83D\uDD64${item.respawnTicks}</td>")
|
||||
string.append("</tr>")
|
||||
}
|
||||
string.append("</tbody></table><br/>")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue