Draw sync reset actions

This commit is contained in:
downthecrop 2024-10-21 21:09:22 -07:00
parent d779f65db4
commit f09de70a30
3 changed files with 53 additions and 35 deletions

View file

@ -538,6 +538,14 @@ object LootTrackerView {
}
popupMenu.add(menuItem1)
menuItem1.addActionListener {
plugin.registerDrawAction {
resetLootTracker()
}
}
return popupMenu
}
private fun resetLootTracker(){
lootTrackerView?.removeAll()
npcKillCounts.clear()
lootItemPanels.clear()
@ -568,9 +576,6 @@ object LootTrackerView {
lootTrackerView?.revalidate()
lootTrackerView?.repaint()
}
return popupMenu
}
class FixedSizePanel(private val fixedSize: Dimension) : JPanel() {
override fun getPreferredSize(): Dimension {

View file

@ -1,10 +1,10 @@
package KondoKit
import KondoKit.Helpers.addMouseListenerToAll
import KondoKit.Helpers.formatHtmlLabelText
import KondoKit.Helpers.formatNumber
import KondoKit.Helpers.getProgressBarColor
import KondoKit.Helpers.getSpriteId
import KondoKit.Helpers.addMouseListenerToAll
import KondoKit.SpriteToBufferedImage.getBufferedImageFromSprite
import KondoKit.plugin.Companion.IMAGE_SIZE
import KondoKit.plugin.Companion.LVL_ICON
@ -295,14 +295,9 @@ object XPTrackerView {
// Add menu items to the popup menu
popupMenu.add(menuItem1)
//popupMenu.add(menuItem2)
//popupMenu.add(menuItem3)
// Add action listeners to each menu item (optional)
menuItem1.addActionListener { resetXPTracker(xpTrackerView!!) }
//menuItem2.addActionListener { println("Option 2 selected") }
//menuItem3.addActionListener { println("Option 3 selected") }
menuItem1.addActionListener { plugin.registerDrawAction { resetXPTracker(xpTrackerView!!) } }
return popupMenu
}

View file

@ -90,6 +90,13 @@ class plugin : Plugin() {
private var initialized = false;
private var lastClickTime = 0L
private var lastUIOffset = 0
private val drawActions = mutableListOf<() -> Unit>()
fun registerDrawAction(action: () -> Unit) {
synchronized(drawActions) {
drawActions.add(action)
}
}
}
fun allSpritesLoaded() : Boolean {
@ -259,6 +266,17 @@ class plugin : Plugin() {
accumulatedTime = 0L
}
// Draw synced actions (that require to be done between glBegin and glEnd)
if (drawActions.isNotEmpty()) {
synchronized(drawActions) {
val actionsCopy = drawActions.toList()
drawActions.clear()
for (action in actionsCopy) {
action()
}
}
}
// Init in the draw call so we know we are between glBegin and glEnd for HD
if(!initialized && mainLoadState >= loginScreen) {
initKondoUI()