mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
Display other loaded plugins in the config
This commit is contained in:
parent
1eee2a531b
commit
d779f65db4
1 changed files with 55 additions and 4 deletions
|
|
@ -27,6 +27,7 @@ import kotlin.math.ceil
|
||||||
|
|
||||||
object ReflectiveEditorView {
|
object ReflectiveEditorView {
|
||||||
var reflectiveEditorView: JPanel? = null
|
var reflectiveEditorView: JPanel? = null
|
||||||
|
val loadedPlugins: MutableList<String> = mutableListOf()
|
||||||
fun createReflectiveEditorView() {
|
fun createReflectiveEditorView() {
|
||||||
val reflectiveEditorPanel = JPanel(BorderLayout())
|
val reflectiveEditorPanel = JPanel(BorderLayout())
|
||||||
reflectiveEditorPanel.background = VIEW_BACKGROUND_COLOR
|
reflectiveEditorPanel.background = VIEW_BACKGROUND_COLOR
|
||||||
|
|
@ -38,6 +39,7 @@ object ReflectiveEditorView {
|
||||||
|
|
||||||
fun addPlugins(reflectiveEditorView: JPanel) {
|
fun addPlugins(reflectiveEditorView: JPanel) {
|
||||||
reflectiveEditorView.removeAll() // clear previous
|
reflectiveEditorView.removeAll() // clear previous
|
||||||
|
loadedPlugins.clear()
|
||||||
try {
|
try {
|
||||||
val loadedPluginsField = PluginRepository::class.java.getDeclaredField("loadedPlugins")
|
val loadedPluginsField = PluginRepository::class.java.getDeclaredField("loadedPlugins")
|
||||||
loadedPluginsField.isAccessible = true
|
loadedPluginsField.isAccessible = true
|
||||||
|
|
@ -49,8 +51,57 @@ object ReflectiveEditorView {
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a centered box for plugins that have no exposed fields
|
||||||
|
if (loadedPlugins.isNotEmpty()) {
|
||||||
|
val noExposedPanel = JPanel(BorderLayout())
|
||||||
|
noExposedPanel.background = VIEW_BACKGROUND_COLOR
|
||||||
|
noExposedPanel.border = BorderFactory.createEmptyBorder(10, 10, 10, 10)
|
||||||
|
|
||||||
|
val label = JLabel("Loaded Plugins without Exposed Fields", SwingConstants.CENTER)
|
||||||
|
label.font = Font("RuneScape Small", Font.PLAIN, 16)
|
||||||
|
label.foreground = primaryColor
|
||||||
|
noExposedPanel.add(label, BorderLayout.NORTH)
|
||||||
|
|
||||||
|
val pluginsList = JList(loadedPlugins.toTypedArray())
|
||||||
|
pluginsList.background = WIDGET_COLOR
|
||||||
|
pluginsList.foreground = secondaryColor
|
||||||
|
pluginsList.font = Font("RuneScape Small", Font.PLAIN, 16)
|
||||||
|
|
||||||
|
// Wrap the JList in a JScrollPane with a fixed height
|
||||||
|
val maxScrollPaneHeight = 200
|
||||||
|
val scrollPane = JScrollPane(pluginsList).apply {
|
||||||
|
verticalScrollBarPolicy = JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
|
||||||
|
horizontalScrollBarPolicy = JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a wrapper panel with BoxLayout to constrain the scroll pane
|
||||||
|
val scrollPaneWrapper = JPanel().apply {
|
||||||
|
layout = BoxLayout(this, BoxLayout.Y_AXIS)
|
||||||
|
add(scrollPane)
|
||||||
|
}
|
||||||
|
|
||||||
|
noExposedPanel.add(scrollPaneWrapper, BorderLayout.CENTER)
|
||||||
|
|
||||||
|
// Center the panel within the reflectiveEditorView
|
||||||
|
val centeredPanel = JPanel().apply {
|
||||||
|
preferredSize = Dimension(240, maxScrollPaneHeight)
|
||||||
|
maximumSize = preferredSize
|
||||||
|
minimumSize = preferredSize
|
||||||
|
}
|
||||||
|
centeredPanel.layout = BoxLayout(centeredPanel, BoxLayout.Y_AXIS)
|
||||||
|
centeredPanel.add(Box.createVerticalGlue())
|
||||||
|
centeredPanel.add(noExposedPanel)
|
||||||
|
centeredPanel.add(Box.createVerticalGlue())
|
||||||
|
|
||||||
|
reflectiveEditorView.add(Box.createVerticalStrut(10))
|
||||||
|
reflectiveEditorView.add(centeredPanel)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
reflectiveEditorView.revalidate()
|
reflectiveEditorView.revalidate()
|
||||||
reflectiveEditorView.repaint()
|
if(plugin.StateManager.focusedView == "REFLECTIVE_EDITOR_VIEW")
|
||||||
|
reflectiveEditorView.repaint()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addPluginToEditor(reflectiveEditorView: JPanel, pluginInfo : PluginInfo, plugin: Plugin) {
|
private fun addPluginToEditor(reflectiveEditorView: JPanel, pluginInfo : PluginInfo, plugin: Plugin) {
|
||||||
|
|
@ -210,9 +261,9 @@ object ReflectiveEditorView {
|
||||||
reflectiveEditorView.add(Box.createVerticalStrut(5))
|
reflectiveEditorView.add(Box.createVerticalStrut(5))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reflectiveEditorView.revalidate()
|
else {
|
||||||
if(KondoKit.plugin.StateManager.focusedView == "REFLECTIVE_EDITOR_VIEW")
|
loadedPlugins.add(plugin.javaClass.`package`.name);
|
||||||
reflectiveEditorView.repaint()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var customToolTipWindow: JWindow? = null
|
var customToolTipWindow: JWindow? = null
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue