Design/Layout

This commit is contained in:
downthecrop 2025-08-13 03:19:50 -07:00
parent f386c464f4
commit 2cee659582
2 changed files with 95 additions and 57 deletions

View file

@ -79,8 +79,48 @@ object ReflectiveEditorView {
loadedPluginsField.isAccessible = true
val loadedPlugins = loadedPluginsField.get(null) as HashMap<*, *>
// Separate plugins with and without exposed attributes
val pluginsWithExposed = mutableListOf<Pair<PluginInfo, Plugin>>()
val pluginsWithoutExposed = mutableListOf<Pair<PluginInfo, Plugin>>()
for ((pluginInfo, plugin) in loadedPlugins) {
val pluginPanel = createPluginItemPanel(pluginInfo as PluginInfo, plugin as Plugin)
val exposedFields = (plugin as Plugin).javaClass.declaredFields.filter { field ->
field.annotations.any { annotation ->
annotation.annotationClass.simpleName == "Exposed"
}
}
if (exposedFields.isNotEmpty()) {
pluginsWithExposed.add(pluginInfo as PluginInfo to plugin as Plugin)
} else {
pluginsWithoutExposed.add(pluginInfo as PluginInfo to plugin as Plugin)
}
}
// Sort both lists by package name
pluginsWithExposed.sortBy { it.second.javaClass.`package`.name }
pluginsWithoutExposed.sortBy { it.second.javaClass.`package`.name }
// Add plugins with exposed attributes first
for ((pluginInfo, plugin) in pluginsWithExposed) {
val pluginPanel = createPluginItemPanel(pluginInfo, plugin)
panel.add(pluginPanel)
panel.add(Box.createVerticalStrut(5))
}
// Add a separator if we have plugins with exposed attributes
if (pluginsWithExposed.isNotEmpty() && pluginsWithoutExposed.isNotEmpty()) {
val separator = JPanel()
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))
}
// Add plugins without exposed attributes
for ((pluginInfo, plugin) in pluginsWithoutExposed) {
val pluginPanel = createPluginItemPanel(pluginInfo, plugin)
panel.add(pluginPanel)
panel.add(Box.createVerticalStrut(5))
}
@ -119,18 +159,30 @@ object ReflectiveEditorView {
nameLabel.foreground = secondaryColor
nameLabel.font = Font("RuneScape Small", Font.BOLD, 16)
// Check if plugin has exposed attributes
val exposedFields = plugin.javaClass.declaredFields.filter { field ->
field.annotations.any { annotation ->
annotation.annotationClass.simpleName == "Exposed"
}
}
// Edit button (only show if plugin has exposed attributes)
val editButton = if (exposedFields.isNotEmpty()) {
val button = JButton("Edit")
button.background = TITLE_BAR_COLOR
button.foreground = secondaryColor
button.font = Font("RuneScape Small", Font.PLAIN, 14)
button.addActionListener {
showPluginDetails(pluginInfo, plugin)
}
button
} else {
null
}
// Plugin toggle switch (iOS style)
val toggleSwitch = createToggleSwitch(plugin, pluginInfo)
// Edit button
val editButton = JButton("Edit")
editButton.background = TITLE_BAR_COLOR
editButton.foreground = secondaryColor
editButton.font = Font("RuneScape Small", Font.PLAIN, 14)
editButton.addActionListener {
showPluginDetails(pluginInfo, plugin)
}
// Layout
val infoPanel = JPanel(BorderLayout())
infoPanel.background = WIDGET_COLOR
@ -138,8 +190,12 @@ object ReflectiveEditorView {
val controlsPanel = JPanel(FlowLayout(FlowLayout.RIGHT, 5, 0))
controlsPanel.background = WIDGET_COLOR
// Add edit button first (left side of controls)
editButton?.let { controlsPanel.add(it) }
// Add toggle switch second (right side of controls)
controlsPanel.add(toggleSwitch)
controlsPanel.add(editButton)
panel.add(infoPanel, BorderLayout.CENTER)
panel.add(controlsPanel, BorderLayout.EAST)