mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-16 11:30:19 -07:00
Better spacing changes
This commit is contained in:
parent
14b107861e
commit
8679bca47a
5 changed files with 56 additions and 21 deletions
|
|
@ -24,7 +24,7 @@ object ViewConstants {
|
||||||
val DEFAULT_WIDGET_SIZE = Dimension(234, 50)
|
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, 60)
|
||||||
val TOGGLE_PLACEHOLDER_SIZE = Dimension(60, 24)
|
val TOGGLE_PLACEHOLDER_SIZE = Dimension(60, 24)
|
||||||
val TOTAL_XP_WIDGET_SIZE = Dimension(220, 30)
|
val TOTAL_XP_WIDGET_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 42)
|
||||||
val IMAGE_SIZE = Dimension(25, 23)
|
val IMAGE_SIZE = Dimension(25, 23)
|
||||||
val SEARCH_FIELD_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 30)
|
val SEARCH_FIELD_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 30)
|
||||||
val DEFAULT_PANEL_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 500)
|
val DEFAULT_PANEL_SIZE = Dimension(DEFAULT_WIDGET_SIZE.width, 500)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,11 @@ import javax.swing.JPanel
|
||||||
class WidgetPanel(
|
class WidgetPanel(
|
||||||
private val widgetWidth: Int = ViewConstants.DEFAULT_WIDGET_SIZE.width,
|
private val widgetWidth: Int = ViewConstants.DEFAULT_WIDGET_SIZE.width,
|
||||||
private val widgetHeight: Int = ViewConstants.DEFAULT_WIDGET_SIZE.height,
|
private val widgetHeight: Int = ViewConstants.DEFAULT_WIDGET_SIZE.height,
|
||||||
private val addDefaultPadding: Boolean = true
|
private val addDefaultPadding: Boolean = true,
|
||||||
|
private val paddingTop: Int? = null,
|
||||||
|
private val paddingLeft: Int? = null,
|
||||||
|
private val paddingBottom: Int? = null,
|
||||||
|
private val paddingRight: Int? = null
|
||||||
) : JPanel() {
|
) : JPanel() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
@ -25,11 +29,12 @@ class WidgetPanel(
|
||||||
maximumSize = size
|
maximumSize = size
|
||||||
minimumSize = size
|
minimumSize = size
|
||||||
|
|
||||||
if (addDefaultPadding) {
|
val top = paddingTop ?: if (addDefaultPadding) 5 else 0
|
||||||
border = BorderFactory.createEmptyBorder(5, 5, 5, 5)
|
val left = paddingLeft ?: if (addDefaultPadding) 5 else 0
|
||||||
} else {
|
val bottom = paddingBottom ?: if (addDefaultPadding) 5 else 0
|
||||||
border = BorderFactory.createEmptyBorder(0, 0, 0, 0)
|
val right = paddingRight ?: if (addDefaultPadding) 5 else 0
|
||||||
}
|
|
||||||
|
border = BorderFactory.createEmptyBorder(top, left, bottom, right)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setFixedSize(width: Int, height: Int) {
|
fun setFixedSize(width: Int, height: Int) {
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ annotation class Exposed(val description: String = "")
|
||||||
|
|
||||||
class plugin : Plugin() {
|
class plugin : Plugin() {
|
||||||
companion object {
|
companion object {
|
||||||
val WIDGET_SIZE = Dimension(220, 50)
|
val WIDGET_SIZE = ViewConstants.DEFAULT_WIDGET_SIZE
|
||||||
val TOTAL_XP_WIDGET_SIZE = Dimension(220, 30)
|
val TOTAL_XP_WIDGET_SIZE = ViewConstants.TOTAL_XP_WIDGET_SIZE
|
||||||
val IMAGE_SIZE = Dimension(25, 23)
|
val IMAGE_SIZE = Dimension(25, 23)
|
||||||
|
|
||||||
// Default Theme Colors
|
// Default Theme Colors
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import KondoKit.ViewConstants
|
||||||
import KondoKit.views.XPTrackerView.wrappedWidget
|
import KondoKit.views.XPTrackerView.wrappedWidget
|
||||||
import KondoKit.components.PopupMenuComponent
|
import KondoKit.components.PopupMenuComponent
|
||||||
import KondoKit.components.ProgressBar
|
import KondoKit.components.ProgressBar
|
||||||
|
import KondoKit.components.WidgetPanel
|
||||||
import KondoKit.plugin.Companion.POPUP_BACKGROUND
|
import KondoKit.plugin.Companion.POPUP_BACKGROUND
|
||||||
import KondoKit.plugin.Companion.POPUP_FOREGROUND
|
import KondoKit.plugin.Companion.POPUP_FOREGROUND
|
||||||
import KondoKit.plugin.Companion.TITLE_BAR_COLOR
|
import KondoKit.plugin.Companion.TITLE_BAR_COLOR
|
||||||
|
|
@ -136,7 +137,7 @@ object LootTrackerView : View, OnPostClientTickCallback, OnKillingBlowNPCCallbac
|
||||||
add(Box.createVerticalStrut(5))
|
add(Box.createVerticalStrut(5))
|
||||||
totalTrackerWidget = createTotalLootWidget()
|
totalTrackerWidget = createTotalLootWidget()
|
||||||
|
|
||||||
val wrapped = wrappedWidget(totalTrackerWidget!!.container)
|
val wrapped = wrappedWidget(totalTrackerWidget!!.container, padding = 0)
|
||||||
val popupMenu = resetLootTrackerMenu()
|
val popupMenu = resetLootTrackerMenu()
|
||||||
|
|
||||||
// Create a custom MouseListener
|
// Create a custom MouseListener
|
||||||
|
|
@ -197,7 +198,7 @@ object LootTrackerView : View, OnPostClientTickCallback, OnKillingBlowNPCCallbac
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createWidgetPanel(bufferedImageSprite: BufferedImage, l1 : JLabel, l2 : JLabel): Panel {
|
private fun createWidgetPanel(bufferedImageSprite: BufferedImage, l1 : JLabel, l2 : JLabel): WidgetPanel {
|
||||||
val imageCanvas = ImageCanvas(bufferedImageSprite).apply {
|
val imageCanvas = ImageCanvas(bufferedImageSprite).apply {
|
||||||
preferredSize = Dimension(bufferedImageSprite.width, bufferedImageSprite.height)
|
preferredSize = Dimension(bufferedImageSprite.width, bufferedImageSprite.height)
|
||||||
minimumSize = preferredSize
|
minimumSize = preferredSize
|
||||||
|
|
@ -206,21 +207,33 @@ object LootTrackerView : View, OnPostClientTickCallback, OnKillingBlowNPCCallbac
|
||||||
background = WIDGET_COLOR
|
background = WIDGET_COLOR
|
||||||
}
|
}
|
||||||
|
|
||||||
val imageContainer = Panel(BorderLayout()).apply {
|
val imageContainer = JPanel(BorderLayout()).apply {
|
||||||
background = WIDGET_COLOR
|
background = WIDGET_COLOR
|
||||||
add(imageCanvas, BorderLayout.NORTH)
|
add(imageCanvas, BorderLayout.NORTH)
|
||||||
|
border = BorderFactory.createEmptyBorder(-2, 0, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Panel(BorderLayout(5, 0)).apply {
|
return WidgetPanel(
|
||||||
background = WIDGET_COLOR
|
widgetWidth = ViewConstants.DEFAULT_WIDGET_SIZE.width,
|
||||||
preferredSize = TOTAL_XP_WIDGET_SIZE
|
widgetHeight = ViewConstants.TOTAL_XP_WIDGET_SIZE.height,
|
||||||
|
addDefaultPadding = false,
|
||||||
|
paddingTop = 10,
|
||||||
|
paddingBottom = 10,
|
||||||
|
paddingRight = 10,
|
||||||
|
paddingLeft = 10
|
||||||
|
).apply {
|
||||||
|
layout = BorderLayout(5, 0)
|
||||||
|
setFixedSize(
|
||||||
|
ViewConstants.DEFAULT_WIDGET_SIZE.width,
|
||||||
|
ViewConstants.TOTAL_XP_WIDGET_SIZE.height
|
||||||
|
)
|
||||||
add(imageContainer, BorderLayout.WEST)
|
add(imageContainer, BorderLayout.WEST)
|
||||||
add(createTextPanel(l1,l2), BorderLayout.CENTER)
|
add(createTextPanel(l1,l2), BorderLayout.CENTER)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createTextPanel(l1 : JLabel, l2: JLabel): Panel {
|
private fun createTextPanel(l1 : JLabel, l2: JLabel): JPanel {
|
||||||
return Panel(GridLayout(2, 1, 5, 0)).apply {
|
return JPanel(GridLayout(2, 1, 5, 0)).apply {
|
||||||
background = WIDGET_COLOR
|
background = WIDGET_COLOR
|
||||||
add(l1)
|
add(l1)
|
||||||
add(l2)
|
add(l2)
|
||||||
|
|
@ -591,7 +604,7 @@ object LootTrackerView : View, OnPostClientTickCallback, OnKillingBlowNPCCallbac
|
||||||
lootItemPanels.clear()
|
lootItemPanels.clear()
|
||||||
totalTrackerWidget = createTotalLootWidget()
|
totalTrackerWidget = createTotalLootWidget()
|
||||||
|
|
||||||
val wrapped = wrappedWidget(totalTrackerWidget!!.container)
|
val wrapped = wrappedWidget(totalTrackerWidget!!.container, padding = 0)
|
||||||
val _popupMenu = resetLootTrackerMenu()
|
val _popupMenu = resetLootTrackerMenu()
|
||||||
|
|
||||||
// Create a custom MouseListener
|
// Create a custom MouseListener
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback {
|
||||||
|
|
||||||
private fun createTotalWidgetContainer(popupMenu: JPopupMenu): Container {
|
private fun createTotalWidgetContainer(popupMenu: JPopupMenu): Container {
|
||||||
totalXPWidget = createTotalXPWidget()
|
totalXPWidget = createTotalXPWidget()
|
||||||
return wrappedWidget(totalXPWidget!!.container).also { attachPopup(it, popupMenu) }
|
return wrappedWidget(totalXPWidget!!.container, padding = 0).also { attachPopup(it, popupMenu) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override val panel: JPanel
|
override val panel: JPanel
|
||||||
|
|
@ -294,7 +294,15 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createTotalXPWidget(): XPWidget {
|
fun createTotalXPWidget(): XPWidget {
|
||||||
val widgetPanel = WidgetPanel(TOTAL_XP_WIDGET_SIZE.width, TOTAL_XP_WIDGET_SIZE.height, addDefaultPadding = false)
|
val widgetPanel = WidgetPanel(
|
||||||
|
widgetWidth = ViewConstants.DEFAULT_WIDGET_SIZE.width,
|
||||||
|
widgetHeight = ViewConstants.TOTAL_XP_WIDGET_SIZE.height,
|
||||||
|
addDefaultPadding = false,
|
||||||
|
paddingTop = 10,
|
||||||
|
paddingBottom = 10,
|
||||||
|
paddingRight = 10,
|
||||||
|
paddingLeft = 10
|
||||||
|
)
|
||||||
|
|
||||||
val iconContainer = createIconContainer(getBufferedImageFromSprite(API.GetSprite(LVL_ICON)))
|
val iconContainer = createIconContainer(getBufferedImageFromSprite(API.GetSprite(LVL_ICON)))
|
||||||
|
|
||||||
|
|
@ -308,6 +316,11 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback {
|
||||||
textPanel.add(xpGainedLabel)
|
textPanel.add(xpGainedLabel)
|
||||||
textPanel.add(xpPerHourLabel)
|
textPanel.add(xpPerHourLabel)
|
||||||
|
|
||||||
|
widgetPanel.setFixedSize(
|
||||||
|
ViewConstants.DEFAULT_WIDGET_SIZE.width,
|
||||||
|
ViewConstants.TOTAL_XP_WIDGET_SIZE.height
|
||||||
|
)
|
||||||
|
|
||||||
widgetPanel.add(iconContainer, BorderLayout.WEST)
|
widgetPanel.add(iconContainer, BorderLayout.WEST)
|
||||||
widgetPanel.add(textPanel, BorderLayout.CENTER)
|
widgetPanel.add(textPanel, BorderLayout.CENTER)
|
||||||
|
|
||||||
|
|
@ -403,7 +416,11 @@ object XPTrackerView : View, OnUpdateCallback, OnXPUpdateCallback {
|
||||||
|
|
||||||
|
|
||||||
fun createXPWidget(skillId: Int, previousXp: Int): XPWidget {
|
fun createXPWidget(skillId: Int, previousXp: Int): XPWidget {
|
||||||
val widgetPanel = WidgetPanel(WIDGET_SIZE.width, WIDGET_SIZE.height, addDefaultPadding = false)
|
val widgetPanel = WidgetPanel(
|
||||||
|
widgetWidth = ViewConstants.DEFAULT_WIDGET_SIZE.width,
|
||||||
|
widgetHeight = ViewConstants.DEFAULT_WIDGET_SIZE.height,
|
||||||
|
addDefaultPadding = false
|
||||||
|
)
|
||||||
|
|
||||||
val iconContainer = createIconContainer(getSkillIcon(skillId))
|
val iconContainer = createIconContainer(getSkillIcon(skillId))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue