Region loading, map redraw improvements

This commit is contained in:
ceikry 2021-10-30 11:48:08 -05:00
parent ec83fcd86a
commit 34cd83a1ff

View file

@ -17,6 +17,7 @@ import java.awt.*
import java.awt.event.KeyEvent
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
import java.lang.Exception
import javax.swing.*
import javax.swing.border.*
import kotlin.system.exitProcess
@ -173,7 +174,7 @@ object Rs2MapEditor {
}
}
SwingUtilities.invokeLater {
this.repaint()
this.revalidate()
}
}
}
@ -642,7 +643,32 @@ object Rs2MapEditor {
class LoadRegionItem : JMenuItem("Load") {
init {
addActionListener {
println("This feature has not been enabled yet")
val region = if(npcsUpdated || tileDataUpdated || itemsUpdated){
val response = JOptionPane.showConfirmDialog(this,"You have unsaved changes, continue?")
if(response == 0){
JOptionPane.showInputDialog("Enter Desired Region ID")
}
else return@addActionListener
}
else JOptionPane.showInputDialog("Enter Desired Region ID")
val regionId = region.toIntOrNull() ?: JOptionPane.showInputDialog("Invalid Integer Entered").toIntOrNull() ?: return@addActionListener
Rs2MapEditor.region = regionId
Rs2MapEditor.plane = 0
npcs = NPCSpawnParser.parseNPCSpawns(regionId)
items = GroundItemSpawnParser.parseItemSpawns(regionId)
sceneries = TileSceneryParser.parseRegion(regionId)
npcPanel.redrawRows()
itemPanel.redrawRows()
try {
MapTileParser.init()
mapPanel.repaintMap()
} catch (e: Exception){
mapPanel.removeAll()
mapPanel.revalidate()
JOptionPane.showMessageDialog(this, "No Map Data for Region ID $regionId.")
}
}
}
}