diff --git a/plugin-playground/src/main/kotlin/KondoKit/Helpers.kt b/plugin-playground/src/main/kotlin/KondoKit/Helpers.kt index 9a89e33..ab31c94 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/Helpers.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/Helpers.kt @@ -2,6 +2,7 @@ package KondoKit import rt4.GameShell import java.awt.* +import java.awt.image.BufferedImage import java.awt.event.MouseListener import java.nio.charset.Charset import java.nio.charset.StandardCharsets @@ -24,6 +25,37 @@ object Helpers { } } + data class ImageCanvasComponents(val canvas: ImageCanvas, val container: JPanel) + + fun createImageCanvasComponents( + bufferedImage: BufferedImage, + background: Color = plugin.WIDGET_COLOR, + size: Dimension = Dimension(bufferedImage.width, bufferedImage.height), + borderInsets: Insets = Insets(-2, 0, 0, 2), + componentPosition: String = BorderLayout.NORTH + ): ImageCanvasComponents { + val imageCanvas = ImageCanvas(bufferedImage).apply { + preferredSize = size + minimumSize = size + maximumSize = size + this.size = size + this.background = background + } + + val container = JPanel(BorderLayout()).apply { + this.background = background + add(imageCanvas, componentPosition) + border = BorderFactory.createEmptyBorder( + borderInsets.top, + borderInsets.left, + borderInsets.bottom, + borderInsets.right + ) + } + + return ImageCanvasComponents(imageCanvas, container) + } + fun convertValue(type: Class<*>, genericType: Type?, value: String): Any { return when { type == Int::class.java -> value.toInt() diff --git a/plugin-playground/src/main/kotlin/KondoKit/ViewConstants.kt b/plugin-playground/src/main/kotlin/KondoKit/ViewConstants.kt index 2349cde..7fb6216 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/ViewConstants.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/ViewConstants.kt @@ -22,7 +22,7 @@ object ViewConstants { val DIMENSION_SMALL_ICON = Dimension(12, 12) val DIMENSION_LARGE_ICON = Dimension(30, 30) val DEFAULT_WIDGET_SIZE = Dimension(234, 50) - val PLUGIN_LIST_ITEM_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 60) + val PLUGIN_LIST_ITEM_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 30) val TOGGLE_PLACEHOLDER_SIZE = Dimension(60, 24) val TOTAL_XP_WIDGET_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 42) val IMAGE_SIZE = Dimension(25, 23) diff --git a/plugin-playground/src/main/kotlin/KondoKit/res/cog.png b/plugin-playground/src/main/kotlin/KondoKit/res/cog.png deleted file mode 100644 index b683b51..0000000 Binary files a/plugin-playground/src/main/kotlin/KondoKit/res/cog.png and /dev/null differ diff --git a/plugin-playground/src/main/kotlin/KondoKit/views/LootTrackerView.kt b/plugin-playground/src/main/kotlin/KondoKit/views/LootTrackerView.kt index 768cf09..782e24b 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/views/LootTrackerView.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/views/LootTrackerView.kt @@ -199,19 +199,10 @@ object LootTrackerView : View, OnPostClientTickCallback, OnKillingBlowNPCCallbac } private fun createWidgetPanel(bufferedImageSprite: BufferedImage, l1 : JLabel, l2 : JLabel): WidgetPanel { - val imageCanvas = ImageCanvas(bufferedImageSprite).apply { - preferredSize = Dimension(bufferedImageSprite.width, bufferedImageSprite.height) - minimumSize = preferredSize - maximumSize = preferredSize - size = preferredSize - background = WIDGET_COLOR - } - - val imageContainer = JPanel(BorderLayout()).apply { - background = WIDGET_COLOR - add(imageCanvas, BorderLayout.NORTH) - border = BorderFactory.createEmptyBorder(-2, 0, 0, 0) - } + val (_, imageContainer) = Helpers.createImageCanvasComponents( + bufferedImageSprite, + borderInsets = Insets(-2, 0, 0, 0) + ) return WidgetPanel( widgetWidth = ViewConstants.DEFAULT_WIDGET_SIZE.width, diff --git a/plugin-playground/src/main/kotlin/KondoKit/views/ReflectiveEditorView.kt b/plugin-playground/src/main/kotlin/KondoKit/views/ReflectiveEditorView.kt index 1e4ca9f..f468515 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/views/ReflectiveEditorView.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/views/ReflectiveEditorView.kt @@ -129,7 +129,7 @@ object ReflectiveEditorView : View { this.searchField = searchSection.searchField searchFieldWrapper = searchSection.wrapper - panel.add(Box.createVerticalStrut(10)) + panel.add(Box.createVerticalStrut(5)) panel.add(searchSection.wrapper) panel.add(Box.createVerticalStrut(10)) diff --git a/plugin-playground/src/main/kotlin/KondoKit/views/XPTrackerView.kt b/plugin-playground/src/main/kotlin/KondoKit/views/XPTrackerView.kt index 4b0b047..4d9cbf9 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/views/XPTrackerView.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/views/XPTrackerView.kt @@ -304,7 +304,12 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback { paddingLeft = 10 ) - val iconContainer = createIconContainer(getBufferedImageFromSprite(API.GetSprite(LVL_ICON))) + val bufferedImageSprite = getBufferedImageFromSprite(API.GetSprite(LVL_ICON)) + val (_, imageContainer) = Helpers.createImageCanvasComponents( + bufferedImageSprite, + borderInsets = Insets(0, 0, 0, 5) + ) + val textPanel = JPanel(GridLayout(2, 1, 5, 0)).apply { background = WIDGET_COLOR @@ -321,7 +326,7 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback { ViewConstants.TOTAL_XP_WIDGET_SIZE.height ) - widgetPanel.add(iconContainer, BorderLayout.WEST) + widgetPanel.add(imageContainer, BorderLayout.WEST) widgetPanel.add(textPanel, BorderLayout.CENTER) return XPWidget(