mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-10 10:20:44 -07:00
Draw sync reset actions
This commit is contained in:
parent
d779f65db4
commit
f09de70a30
3 changed files with 53 additions and 35 deletions
|
|
@ -538,39 +538,44 @@ object LootTrackerView {
|
|||
}
|
||||
popupMenu.add(menuItem1)
|
||||
menuItem1.addActionListener {
|
||||
lootTrackerView?.removeAll()
|
||||
npcKillCounts.clear()
|
||||
lootItemPanels.clear()
|
||||
totalTrackerWidget = createTotalLootWidget()
|
||||
|
||||
val wrapped = wrappedWidget(totalTrackerWidget!!.container)
|
||||
val _popupMenu = resetLootTrackerMenu()
|
||||
|
||||
// Create a custom MouseListener
|
||||
val rightClickListener = object : MouseAdapter() {
|
||||
override fun mousePressed(e: MouseEvent) {
|
||||
if (e.isPopupTrigger) {
|
||||
_popupMenu.show(e.component, e.x, e.y)
|
||||
}
|
||||
}
|
||||
|
||||
override fun mouseReleased(e: MouseEvent) {
|
||||
if (e.isPopupTrigger) {
|
||||
_popupMenu.show(e.component, e.x, e.y)
|
||||
}
|
||||
}
|
||||
plugin.registerDrawAction {
|
||||
resetLootTracker()
|
||||
}
|
||||
addMouseListenerToAll(wrapped,rightClickListener)
|
||||
wrapped.addMouseListener(rightClickListener)
|
||||
lootTrackerView?.add(Box.createVerticalStrut(5))
|
||||
lootTrackerView?.add(wrapped)
|
||||
lootTrackerView?.add(Box.createVerticalStrut(10))
|
||||
lootTrackerView?.revalidate()
|
||||
lootTrackerView?.repaint()
|
||||
}
|
||||
return popupMenu
|
||||
}
|
||||
|
||||
private fun resetLootTracker(){
|
||||
lootTrackerView?.removeAll()
|
||||
npcKillCounts.clear()
|
||||
lootItemPanels.clear()
|
||||
totalTrackerWidget = createTotalLootWidget()
|
||||
|
||||
val wrapped = wrappedWidget(totalTrackerWidget!!.container)
|
||||
val _popupMenu = resetLootTrackerMenu()
|
||||
|
||||
// Create a custom MouseListener
|
||||
val rightClickListener = object : MouseAdapter() {
|
||||
override fun mousePressed(e: MouseEvent) {
|
||||
if (e.isPopupTrigger) {
|
||||
_popupMenu.show(e.component, e.x, e.y)
|
||||
}
|
||||
}
|
||||
|
||||
override fun mouseReleased(e: MouseEvent) {
|
||||
if (e.isPopupTrigger) {
|
||||
_popupMenu.show(e.component, e.x, e.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
addMouseListenerToAll(wrapped,rightClickListener)
|
||||
wrapped.addMouseListener(rightClickListener)
|
||||
lootTrackerView?.add(Box.createVerticalStrut(5))
|
||||
lootTrackerView?.add(wrapped)
|
||||
lootTrackerView?.add(Box.createVerticalStrut(10))
|
||||
lootTrackerView?.revalidate()
|
||||
lootTrackerView?.repaint()
|
||||
}
|
||||
|
||||
class FixedSizePanel(private val fixedSize: Dimension) : JPanel() {
|
||||
override fun getPreferredSize(): Dimension {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue