mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-20 13:30:30 -07:00
supa fixa
This commit is contained in:
parent
9f5d6f59e3
commit
16546ef862
3 changed files with 206 additions and 165 deletions
BIN
plugin-playground/src/main/kotlin/KondoKit/.DS_Store
vendored
BIN
plugin-playground/src/main/kotlin/KondoKit/.DS_Store
vendored
Binary file not shown.
|
|
@ -176,9 +176,22 @@ class plugin : Plugin() {
|
|||
// Ensure Swing updates happen on the EDT to avoid flicker
|
||||
SwingUtilities.invokeLater {
|
||||
updateDisplaySettings()
|
||||
frame.remove(rightPanelWrapper)
|
||||
rightPanelWrapper?.let { wrapper ->
|
||||
wrapper.ignoreRepaint = true
|
||||
try {
|
||||
val parent = wrapper.parent
|
||||
val wrapperNeedsAttach = parent != frame
|
||||
if (wrapperNeedsAttach) {
|
||||
parent?.remove(wrapper)
|
||||
frame.layout = BorderLayout()
|
||||
rightPanelWrapper?.let { frame.add(it, BorderLayout.EAST) }
|
||||
frame.add(wrapper, BorderLayout.EAST)
|
||||
}
|
||||
wrapper.revalidate()
|
||||
wrapper.repaint()
|
||||
} finally {
|
||||
wrapper.ignoreRepaint = false
|
||||
}
|
||||
}
|
||||
frame.revalidate()
|
||||
frame.repaint()
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,8 @@ object ReflectiveEditorView : View {
|
|||
// Search text for filtering plugins
|
||||
private var pluginSearchText: String = ""
|
||||
private var searchFieldWrapper: JPanel? = null
|
||||
private var pluginListContentPanel: JPanel? = null
|
||||
private var pluginListScrollablePanel: ScrollablePanel? = null
|
||||
|
||||
override val name: String = VIEW_NAME
|
||||
override val iconSpriteId: Int = WRENCH_ICON
|
||||
|
|
@ -166,6 +168,36 @@ object ReflectiveEditorView : View {
|
|||
panel.add(searchFieldWrapperPanel)
|
||||
panel.add(Box.createVerticalStrut(10))
|
||||
|
||||
pluginListContentPanel = JPanel().apply {
|
||||
layout = BoxLayout(this, BoxLayout.Y_AXIS)
|
||||
background = VIEW_BACKGROUND_COLOR
|
||||
alignmentX = Component.CENTER_ALIGNMENT
|
||||
}
|
||||
panel.add(pluginListContentPanel)
|
||||
|
||||
val scrollablePanel = ScrollablePanel(panel)
|
||||
pluginListScrollablePanel = scrollablePanel
|
||||
|
||||
val container = JPanel(BorderLayout())
|
||||
container.background = VIEW_BACKGROUND_COLOR
|
||||
container.add(scrollablePanel, BorderLayout.CENTER)
|
||||
|
||||
populatePluginListContent()
|
||||
|
||||
SwingUtilities.invokeLater {
|
||||
resetScrollablePanel(scrollablePanel)
|
||||
}
|
||||
|
||||
return container
|
||||
}
|
||||
|
||||
private fun populatePluginListContent() {
|
||||
val contentPanel = pluginListContentPanel ?: return
|
||||
|
||||
val treeLock = contentPanel.treeLock
|
||||
synchronized(treeLock) {
|
||||
contentPanel.removeAll()
|
||||
|
||||
try {
|
||||
// Get loaded plugins
|
||||
val loadedPluginsField = PluginRepository::class.java.getDeclaredField("loadedPlugins")
|
||||
|
|
@ -205,8 +237,8 @@ object ReflectiveEditorView : View {
|
|||
|
||||
for ((pluginInfo, plugin) in pluginsWithExposed) {
|
||||
val pluginPanel = createPluginItemPanel(pluginInfo, plugin)
|
||||
panel.add(pluginPanel)
|
||||
panel.add(Box.createVerticalStrut(5))
|
||||
contentPanel.add(pluginPanel)
|
||||
contentPanel.add(Box.createVerticalStrut(5))
|
||||
}
|
||||
|
||||
if (pluginsWithExposed.isNotEmpty() && pluginsWithoutExposed.isNotEmpty()) {
|
||||
|
|
@ -214,14 +246,14 @@ object ReflectiveEditorView : View {
|
|||
separator.background = VIEW_BACKGROUND_COLOR
|
||||
separator.preferredSize = Dimension(Int.MAX_VALUE, 1)
|
||||
separator.maximumSize = Dimension(Int.MAX_VALUE, 1)
|
||||
panel.add(separator)
|
||||
panel.add(Box.createVerticalStrut(5))
|
||||
contentPanel.add(separator)
|
||||
contentPanel.add(Box.createVerticalStrut(5))
|
||||
}
|
||||
|
||||
for ((pluginInfo, plugin) in pluginsWithoutExposed) {
|
||||
val pluginPanel = createPluginItemPanel(pluginInfo, plugin)
|
||||
panel.add(pluginPanel)
|
||||
panel.add(Box.createVerticalStrut(5))
|
||||
contentPanel.add(pluginPanel)
|
||||
contentPanel.add(Box.createVerticalStrut(5))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
|
@ -237,8 +269,8 @@ object ReflectiveEditorView : View {
|
|||
}
|
||||
if (pluginSearchText.isBlank() || pluginDir.name.contains(pluginSearchText, ignoreCase = true)) {
|
||||
val pluginPanel = createDisabledPluginItemPanel(pluginDir.name)
|
||||
panel.add(pluginPanel)
|
||||
panel.add(Box.createVerticalStrut(5))
|
||||
contentPanel.add(pluginPanel)
|
||||
contentPanel.add(Box.createVerticalStrut(5))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -265,9 +297,9 @@ object ReflectiveEditorView : View {
|
|||
separator.background = VIEW_BACKGROUND_COLOR
|
||||
separator.preferredSize = Dimension(Int.MAX_VALUE, 1)
|
||||
separator.maximumSize = Dimension(Int.MAX_VALUE, 1)
|
||||
panel.add(Box.createVerticalStrut(10))
|
||||
panel.add(separator)
|
||||
panel.add(Box.createVerticalStrut(5))
|
||||
contentPanel.add(Box.createVerticalStrut(10))
|
||||
contentPanel.add(separator)
|
||||
contentPanel.add(Box.createVerticalStrut(5))
|
||||
|
||||
val headerPanel = JPanel(FlowLayout(FlowLayout.LEFT))
|
||||
headerPanel.background = VIEW_BACKGROUND_COLOR
|
||||
|
|
@ -275,8 +307,8 @@ object ReflectiveEditorView : View {
|
|||
headerLabel.foreground = secondaryColor
|
||||
headerLabel.font = Font("RuneScape Small", Font.BOLD, 16)
|
||||
headerPanel.add(headerLabel)
|
||||
panel.add(headerPanel)
|
||||
panel.add(Box.createVerticalStrut(5))
|
||||
contentPanel.add(headerPanel)
|
||||
contentPanel.add(Box.createVerticalStrut(5))
|
||||
|
||||
if (matchingPluginStatuses.isNotEmpty()) {
|
||||
if (matchingPluginStatuses.size > 1) {
|
||||
|
|
@ -290,34 +322,23 @@ object ReflectiveEditorView : View {
|
|||
startMultiplePluginDownloads(matchingPluginStatuses)
|
||||
}
|
||||
downloadAllPanel.add(downloadAllButton)
|
||||
panel.add(downloadAllPanel)
|
||||
panel.add(Box.createVerticalStrut(5))
|
||||
contentPanel.add(downloadAllPanel)
|
||||
contentPanel.add(Box.createVerticalStrut(5))
|
||||
}
|
||||
|
||||
// Add matching plugin statuses
|
||||
for (pluginStatus in matchingPluginStatuses) {
|
||||
System.out.println("Adding plugin to UI: ${pluginStatus.name}")
|
||||
val pluginPanel = createPluginStatusItemPanel(pluginStatus)
|
||||
panel.add(pluginPanel)
|
||||
panel.add(Box.createVerticalStrut(5))
|
||||
contentPanel.add(pluginPanel)
|
||||
contentPanel.add(Box.createVerticalStrut(5))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap the panel in a ScrollablePanel for custom scrolling
|
||||
val scrollablePanel = ScrollablePanel(panel)
|
||||
|
||||
// Reset scroll position to top
|
||||
SwingUtilities.invokeLater {
|
||||
// For ScrollablePanel, we need to reset the internal offset
|
||||
resetScrollablePanel(scrollablePanel)
|
||||
}
|
||||
|
||||
val container = JPanel(BorderLayout())
|
||||
container.background = VIEW_BACKGROUND_COLOR
|
||||
container.add(scrollablePanel, BorderLayout.CENTER)
|
||||
|
||||
return container
|
||||
contentPanel.revalidate()
|
||||
contentPanel.repaint()
|
||||
}
|
||||
|
||||
private fun createPluginItemPanel(pluginInfo: PluginInfo, plugin: Plugin): JPanel {
|
||||
|
|
@ -793,30 +814,37 @@ object ReflectiveEditorView : View {
|
|||
// Update plugin statuses to reflect current loaded plugins
|
||||
updatePluginStatuses()
|
||||
|
||||
// Batch updates to avoid intermediate repaints/flicker
|
||||
mainPanel.ignoreRepaint = true
|
||||
try {
|
||||
// Remove the existing plugin list view if present
|
||||
val contentPanel = pluginListContentPanel
|
||||
if (contentPanel == null) {
|
||||
// Fallback path: rebuild the list view if it was not initialized yet
|
||||
val existingListView = mainPanel.components.find { it.name == PLUGIN_LIST_VIEW }
|
||||
val pluginListView = createPluginListView()
|
||||
pluginListView.name = PLUGIN_LIST_VIEW
|
||||
if (existingListView != null) {
|
||||
mainPanel.remove(existingListView)
|
||||
}
|
||||
|
||||
// Create a new plugin list view off-EDT (already on EDT here) and add it
|
||||
val pluginListView = createPluginListView()
|
||||
pluginListView.name = PLUGIN_LIST_VIEW
|
||||
mainPanel.add(pluginListView, PLUGIN_LIST_VIEW)
|
||||
} else {
|
||||
contentPanel.isVisible = false
|
||||
try {
|
||||
populatePluginListContent()
|
||||
} finally {
|
||||
contentPanel.isVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
searchFieldWrapper?.isVisible = true
|
||||
|
||||
// Switch card after the new component is in place
|
||||
cardLayout.show(mainPanel, PLUGIN_LIST_VIEW)
|
||||
|
||||
// Revalidate/repaint once at the end
|
||||
searchFieldWrapper?.isVisible = true
|
||||
pluginListScrollablePanel?.let { scrollPanel ->
|
||||
SwingUtilities.invokeLater {
|
||||
resetScrollablePanel(scrollPanel)
|
||||
}
|
||||
}
|
||||
|
||||
mainPanel.revalidate()
|
||||
mainPanel.repaint()
|
||||
} finally {
|
||||
mainPanel.ignoreRepaint = false
|
||||
}
|
||||
}
|
||||
|
||||
var customToolTipWindow: JWindow? = null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue