mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-16 03:20:21 -07:00
Move shared definitions to a central location
This commit is contained in:
parent
df091ac94b
commit
9f5d6f59e3
9 changed files with 132 additions and 91 deletions
68
plugin-playground/src/main/kotlin/KondoKit/ViewConstants.kt
Normal file
68
plugin-playground/src/main/kotlin/KondoKit/ViewConstants.kt
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
package KondoKit
|
||||||
|
|
||||||
|
import java.awt.Color
|
||||||
|
import java.awt.Dimension
|
||||||
|
import java.awt.Font
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared constants for fonts, dimensions, and colors across the entire KondoKit plugin.
|
||||||
|
* This helps avoid repeated initialization of common elements and provides better consistency.
|
||||||
|
*/
|
||||||
|
object ViewConstants {
|
||||||
|
|
||||||
|
// Common Fonts
|
||||||
|
val FONT_RUNESCAPE_SMALL_16 = Font("RuneScape Small", Font.TRUETYPE_FONT, 16)
|
||||||
|
val FONT_RUNESCAPE_SMALL_14 = Font("RuneScape Small", Font.PLAIN, 14)
|
||||||
|
val FONT_RUNESCAPE_SMALL_PLAIN_16 = Font("RuneScape Small", Font.PLAIN, 16)
|
||||||
|
val FONT_ARIAL_PLAIN_14 = Font("Arial", Font.PLAIN, 14)
|
||||||
|
val FONT_ARIAL_BOLD_12 = Font("Arial", Font.BOLD, 12)
|
||||||
|
|
||||||
|
// Common Dimensions
|
||||||
|
val DIMENSION_SMALL_ICON = Dimension(12, 12)
|
||||||
|
val DIMENSION_LARGE_ICON = Dimension(30, 30)
|
||||||
|
val DEFAULT_WIDGET_SIZE = Dimension(220, 50)
|
||||||
|
val TOTAL_XP_WIDGET_SIZE = Dimension(220, 30)
|
||||||
|
val IMAGE_SIZE = Dimension(25, 23)
|
||||||
|
val SEARCH_FIELD_SIZE = Dimension(230, 30)
|
||||||
|
val DEFAULT_PANEL_SIZE = Dimension(230, 500)
|
||||||
|
val FILTER_PANEL_SIZE = Dimension(230, 30)
|
||||||
|
val SKILLS_PANEL_SIZE = Dimension(230, 290)
|
||||||
|
val TOTAL_COMBAT_PANEL_SIZE = Dimension(230, 30)
|
||||||
|
val SKILL_PANEL_SIZE = Dimension(76, 35)
|
||||||
|
val IMAGE_CANVAS_SIZE = Dimension(20, 20)
|
||||||
|
val SKILL_SPRITE_SIZE = Dimension(14, 14)
|
||||||
|
val NUMBER_LABEL_SIZE = Dimension(20, 20)
|
||||||
|
val PROGRESS_BAR_SIZE = Dimension(220, 16)
|
||||||
|
val TOGGLE_SWITCH_SIZE = Dimension(32, 20)
|
||||||
|
|
||||||
|
// Common Colors
|
||||||
|
val COLOR_WHITE = Color.WHITE
|
||||||
|
val COLOR_BLACK = Color.BLACK
|
||||||
|
val COLOR_DARK_GRAY = Color.DARK_GRAY
|
||||||
|
val COLOR_RED = Color.RED
|
||||||
|
val COLOR_GRAY = Color.GRAY
|
||||||
|
|
||||||
|
// UI Colors (already defined in plugin.kt companion object, but referenced here for consistency)
|
||||||
|
// These should match the ones in plugin.kt Companion object
|
||||||
|
val COLOR_WIDGET = Color(30, 30, 30)
|
||||||
|
val COLOR_TITLE_BAR = Color(21, 21, 21)
|
||||||
|
val COLOR_VIEW_BACKGROUND = Color(40, 40, 40)
|
||||||
|
val COLOR_PRIMARY = Color(165, 165, 165)
|
||||||
|
val COLOR_SECONDARY = Color(255, 255, 255)
|
||||||
|
val COLOR_POPUP_BACKGROUND = Color(45, 45, 45)
|
||||||
|
val COLOR_POPUP_FOREGROUND = Color(220, 220, 220)
|
||||||
|
val COLOR_TOOLTIP_BACKGROUND = Color(50, 50, 50)
|
||||||
|
val COLOR_SCROLL_BAR = Color(64, 64, 64)
|
||||||
|
val COLOR_PROGRESS_BAR_FILL = Color(61, 56, 49)
|
||||||
|
|
||||||
|
// Skill display order
|
||||||
|
val SKILL_DISPLAY_ORDER = arrayOf(0, 3, 14, 2, 16, 13, 1, 15, 10, 4, 17, 7, 5, 12, 11, 6, 9, 8, 20, 18, 19, 22, 21, 23)
|
||||||
|
|
||||||
|
// Sprite IDs
|
||||||
|
const val COMBAT_LVL_SPRITE = 168
|
||||||
|
const val IRONMAN_SPRITE = 4
|
||||||
|
const val MAG_SPRITE = 1423
|
||||||
|
const val LVL_BAR_SPRITE = 898
|
||||||
|
const val WRENCH_ICON = 907
|
||||||
|
const val LOOT_ICON = 777
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package KondoKit.components
|
package KondoKit.components
|
||||||
|
|
||||||
|
import KondoKit.ViewConstants
|
||||||
import KondoKit.plugin.Companion.TITLE_BAR_COLOR
|
import KondoKit.plugin.Companion.TITLE_BAR_COLOR
|
||||||
import KondoKit.plugin.Companion.WIDGET_COLOR
|
import KondoKit.plugin.Companion.WIDGET_COLOR
|
||||||
import KondoKit.plugin.Companion.secondaryColor
|
import KondoKit.plugin.Companion.secondaryColor
|
||||||
|
|
@ -21,7 +22,7 @@ class ButtonPanel(
|
||||||
val button = JButton(text).apply {
|
val button = JButton(text).apply {
|
||||||
background = TITLE_BAR_COLOR
|
background = TITLE_BAR_COLOR
|
||||||
foreground = secondaryColor
|
foreground = secondaryColor
|
||||||
font = Font("RuneScape Small", Font.PLAIN, 14)
|
font = ViewConstants.FONT_RUNESCAPE_SMALL_14
|
||||||
addActionListener {
|
addActionListener {
|
||||||
action()
|
action()
|
||||||
}
|
}
|
||||||
|
|
@ -34,7 +35,7 @@ class ButtonPanel(
|
||||||
val button = JButton(icon).apply {
|
val button = JButton(icon).apply {
|
||||||
background = TITLE_BAR_COLOR
|
background = TITLE_BAR_COLOR
|
||||||
foreground = secondaryColor
|
foreground = secondaryColor
|
||||||
font = Font("RuneScape Small", Font.PLAIN, 14)
|
font = ViewConstants.FONT_RUNESCAPE_SMALL_14
|
||||||
addActionListener {
|
addActionListener {
|
||||||
action()
|
action()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package KondoKit.components
|
package KondoKit.components
|
||||||
|
|
||||||
import KondoKit.Helpers.formatHtmlLabelText
|
import KondoKit.Helpers.formatHtmlLabelText
|
||||||
|
import KondoKit.ViewConstants
|
||||||
import KondoKit.plugin.Companion.primaryColor
|
import KondoKit.plugin.Companion.primaryColor
|
||||||
import KondoKit.plugin.Companion.secondaryColor
|
import KondoKit.plugin.Companion.secondaryColor
|
||||||
import java.awt.Font
|
import java.awt.Font
|
||||||
|
|
@ -17,7 +18,7 @@ class LabelComponent(
|
||||||
init {
|
init {
|
||||||
this.text = text
|
this.text = text
|
||||||
this.horizontalAlignment = alignment
|
this.horizontalAlignment = alignment
|
||||||
this.font = Font("RuneScape Small", Font.TRUETYPE_FONT, 16)
|
this.font = ViewConstants.FONT_RUNESCAPE_SMALL_16
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateText(plainText: String, color: Color = secondaryColor) {
|
fun updateText(plainText: String, color: Color = secondaryColor) {
|
||||||
|
|
@ -30,6 +31,6 @@ class LabelComponent(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setAsHeader() {
|
fun setAsHeader() {
|
||||||
font = Font("RuneScape Small", Font.BOLD, 16)
|
font = ViewConstants.FONT_RUNESCAPE_SMALL_16.deriveFont(Font.BOLD)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
package KondoKit.components
|
package KondoKit.components
|
||||||
|
|
||||||
|
import KondoKit.ViewConstants
|
||||||
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 java.awt.Font
|
|
||||||
import javax.swing.JMenuItem
|
import javax.swing.JMenuItem
|
||||||
import javax.swing.JPopupMenu
|
import javax.swing.JPopupMenu
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ class PopupMenuComponent : JPopupMenu() {
|
||||||
|
|
||||||
fun addMenuItem(text: String, action: () -> Unit): JMenuItem {
|
fun addMenuItem(text: String, action: () -> Unit): JMenuItem {
|
||||||
val menuItem = JMenuItem(text).apply {
|
val menuItem = JMenuItem(text).apply {
|
||||||
font = Font("RuneScape Small", Font.TRUETYPE_FONT, 16)
|
font = ViewConstants.FONT_RUNESCAPE_SMALL_16
|
||||||
background = POPUP_BACKGROUND
|
background = POPUP_BACKGROUND
|
||||||
foreground = POPUP_FOREGROUND
|
foreground = POPUP_FOREGROUND
|
||||||
addActionListener {
|
addActionListener {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
package KondoKit.components
|
package KondoKit.components
|
||||||
|
|
||||||
|
import KondoKit.ViewConstants
|
||||||
import KondoKit.plugin.Companion.PROGRESS_BAR_FILL
|
import KondoKit.plugin.Companion.PROGRESS_BAR_FILL
|
||||||
import KondoKit.plugin.Companion.secondaryColor
|
import KondoKit.plugin.Companion.secondaryColor
|
||||||
import java.awt.Canvas
|
import java.awt.Canvas
|
||||||
import java.awt.Color
|
import java.awt.Color
|
||||||
import java.awt.Dimension
|
import java.awt.Dimension
|
||||||
import java.awt.Font
|
|
||||||
import java.awt.Graphics
|
import java.awt.Graphics
|
||||||
|
|
||||||
class ProgressBar(
|
class ProgressBar(
|
||||||
|
|
@ -16,7 +16,7 @@ class ProgressBar(
|
||||||
) : Canvas() {
|
) : Canvas() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
font = Font("RuneScape Small", Font.TRUETYPE_FONT, 16)
|
font = ViewConstants.FONT_RUNESCAPE_SMALL_16
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun paint(g: Graphics) {
|
override fun paint(g: Graphics) {
|
||||||
|
|
@ -49,11 +49,11 @@ class ProgressBar(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPreferredSize(): Dimension {
|
override fun getPreferredSize(): Dimension {
|
||||||
return Dimension(220, 16) // Force the height to 16px, width can be anything appropriate
|
return ViewConstants.PROGRESS_BAR_SIZE // Force the height to 16px, width can be anything appropriate
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getMinimumSize(): Dimension {
|
override fun getMinimumSize(): Dimension {
|
||||||
return Dimension(220, 16) // Force the minimum height to 16px, width can be smaller
|
return ViewConstants.PROGRESS_BAR_SIZE // Force the minimum height to 16px, width can be smaller
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateProgress(newProgress: Double, currentLevel: Int, nextLevel: Int, isVisible : Boolean) {
|
fun updateProgress(newProgress: Double, currentLevel: Int, nextLevel: Int, isVisible : Boolean) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package KondoKit.components
|
package KondoKit.components
|
||||||
|
|
||||||
import KondoKit.ImageCanvas
|
import KondoKit.ImageCanvas
|
||||||
|
import KondoKit.ViewConstants
|
||||||
import KondoKit.SpriteToBufferedImage
|
import KondoKit.SpriteToBufferedImage
|
||||||
import KondoKit.plugin.Companion.WIDGET_COLOR
|
import KondoKit.plugin.Companion.WIDGET_COLOR
|
||||||
import KondoKit.plugin.Companion.secondaryColor
|
import KondoKit.plugin.Companion.secondaryColor
|
||||||
|
|
@ -26,7 +27,7 @@ class SearchField(
|
||||||
private val bufferedImageSprite = SpriteToBufferedImage.getBufferedImageFromSprite(API.GetSprite(1423)) // MAG_SPRITE
|
private val bufferedImageSprite = SpriteToBufferedImage.getBufferedImageFromSprite(API.GetSprite(1423)) // MAG_SPRITE
|
||||||
private val imageCanvas = bufferedImageSprite.let {
|
private val imageCanvas = bufferedImageSprite.let {
|
||||||
ImageCanvas(it).apply {
|
ImageCanvas(it).apply {
|
||||||
preferredSize = Dimension(12, 12)
|
preferredSize = ViewConstants.DIMENSION_SMALL_ICON
|
||||||
size = preferredSize
|
size = preferredSize
|
||||||
minimumSize = preferredSize
|
minimumSize = preferredSize
|
||||||
maximumSize = preferredSize
|
maximumSize = preferredSize
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package KondoKit.components
|
package KondoKit.components
|
||||||
|
|
||||||
|
import KondoKit.ViewConstants
|
||||||
import KondoKit.plugin.Companion.PROGRESS_BAR_FILL
|
import KondoKit.plugin.Companion.PROGRESS_BAR_FILL
|
||||||
import KondoKit.plugin.Companion.WIDGET_COLOR
|
import KondoKit.plugin.Companion.WIDGET_COLOR
|
||||||
import KondoKit.plugin.Companion.primaryColor
|
import KondoKit.plugin.Companion.primaryColor
|
||||||
|
|
@ -31,9 +32,9 @@ class ToggleSwitch : JPanel() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
cursor = Cursor(Cursor.HAND_CURSOR)
|
cursor = Cursor(Cursor.HAND_CURSOR)
|
||||||
preferredSize = Dimension(32, 20)
|
preferredSize = ViewConstants.TOGGLE_SWITCH_SIZE
|
||||||
maximumSize = Dimension(32, 20)
|
maximumSize = ViewConstants.TOGGLE_SWITCH_SIZE
|
||||||
minimumSize = Dimension(32, 20)
|
minimumSize = ViewConstants.TOGGLE_SWITCH_SIZE
|
||||||
isOpaque = false // Make the panel background transparent
|
isOpaque = false // Make the panel background transparent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -288,7 +288,7 @@ class plugin : Plugin() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val otherIcons = arrayOf(LVL_ICON, MAG_SPRITE, LOOT_ICON, WRENCH_ICON, Constants.COMBAT_LVL_SPRITE, LootTrackerView.BAG_ICON)
|
val otherIcons = arrayOf(LVL_ICON, MAG_SPRITE, LOOT_ICON, WRENCH_ICON, ViewConstants.COMBAT_LVL_SPRITE, LootTrackerView.BAG_ICON)
|
||||||
for (icon in otherIcons) {
|
for (icon in otherIcons) {
|
||||||
if(!js5Archive8.isFileReady(icon)){
|
if(!js5Archive8.isFileReady(icon)){
|
||||||
return false
|
return false
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package KondoKit.views
|
||||||
import KondoKit.Helpers.getSpriteId
|
import KondoKit.Helpers.getSpriteId
|
||||||
import KondoKit.Helpers.showToast
|
import KondoKit.Helpers.showToast
|
||||||
import KondoKit.ImageCanvas
|
import KondoKit.ImageCanvas
|
||||||
|
import KondoKit.ViewConstants
|
||||||
import KondoKit.SpriteToBufferedImage.getBufferedImageFromSprite
|
import KondoKit.SpriteToBufferedImage.getBufferedImageFromSprite
|
||||||
import KondoKit.components.SearchField
|
import KondoKit.components.SearchField
|
||||||
import KondoKit.components.LabelComponent
|
import KondoKit.components.LabelComponent
|
||||||
|
|
@ -25,45 +26,13 @@ import javax.swing.*
|
||||||
import javax.swing.border.MatteBorder
|
import javax.swing.border.MatteBorder
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
|
|
||||||
object Constants {
|
|
||||||
// Sprite IDs
|
|
||||||
const val COMBAT_LVL_SPRITE = 168
|
|
||||||
const val IRONMAN_SPRITE = 4
|
|
||||||
const val MAG_SPRITE = 1423
|
|
||||||
const val LVL_BAR_SPRITE = 898
|
|
||||||
|
|
||||||
// Dimensions
|
|
||||||
val SEARCH_FIELD_DIMENSION = Dimension(230, 30)
|
|
||||||
val ICON_DIMENSION_SMALL = Dimension(12, 12)
|
|
||||||
val ICON_DIMENSION_LARGE = Dimension(30, 30)
|
|
||||||
val HISCORE_PANEL_DIMENSION = Dimension(230, 500)
|
|
||||||
val FILTER_PANEL_DIMENSION = Dimension(230, 30)
|
|
||||||
val SKILLS_PANEL_DIMENSION = Dimension(230, 290)
|
|
||||||
val TOTAL_COMBAT_PANEL_DIMENSION = Dimension(230, 30)
|
|
||||||
val SKILL_PANEL_DIMENSION = Dimension(76, 35)
|
|
||||||
val IMAGE_CANVAS_DIMENSION = Dimension(20, 20)
|
|
||||||
val SKILL_SPRITE_DIMENSION = Dimension(14, 14)
|
|
||||||
val NUMBER_LABEL_DIMENSION = Dimension(20, 20)
|
|
||||||
|
|
||||||
// Colors
|
|
||||||
val COLOR_BACKGROUND_DARK = WIDGET_COLOR
|
|
||||||
val COLOR_BACKGROUND_MEDIUM = VIEW_BACKGROUND_COLOR
|
|
||||||
val COLOR_FOREGROUND_LIGHT = POPUP_FOREGROUND
|
|
||||||
|
|
||||||
// Fonts
|
|
||||||
val FONT_ARIAL_PLAIN_14 = Font("Arial", Font.PLAIN, 14)
|
|
||||||
val FONT_ARIAL_PLAIN_12 = Font("RuneScape Small", Font.TRUETYPE_FONT, 16)
|
|
||||||
val FONT_ARIAL_BOLD_12 = Font("Arial", Font.BOLD, 12)
|
|
||||||
val SKILL_DISPLAY_ORDER = arrayOf(0,3,14,2,16,13,1,15,10,4,17,7,5,12,11,6,9,8,20,18,19,22,21,23)
|
|
||||||
}
|
|
||||||
|
|
||||||
object HiscoresView : View {
|
object HiscoresView : View {
|
||||||
|
|
||||||
const val VIEW_NAME = "HISCORE_SEARCH_VIEW"
|
const val VIEW_NAME = "HISCORE_SEARCH_VIEW"
|
||||||
var hiScoreView: JPanel? = null
|
var hiScoreView: JPanel? = null
|
||||||
var customSearchField: SearchField? = null
|
var customSearchField: SearchField? = null
|
||||||
override val name: String = VIEW_NAME
|
override val name: String = VIEW_NAME
|
||||||
override val iconSpriteId: Int = Constants.MAG_SPRITE
|
override val iconSpriteId: Int = ViewConstants.MAG_SPRITE
|
||||||
|
|
||||||
override val panel: JPanel
|
override val panel: JPanel
|
||||||
get() = hiScoreView ?: JPanel()
|
get() = hiScoreView ?: JPanel()
|
||||||
|
|
@ -78,8 +47,8 @@ object HiscoresView : View {
|
||||||
|
|
||||||
fun createHiscoreSearchView() {
|
fun createHiscoreSearchView() {
|
||||||
val hiscorePanel = BaseView(VIEW_NAME, addDefaultSpacing = false).apply {
|
val hiscorePanel = BaseView(VIEW_NAME, addDefaultSpacing = false).apply {
|
||||||
background = Constants.COLOR_BACKGROUND_MEDIUM
|
background = VIEW_BACKGROUND_COLOR
|
||||||
setViewSize(Constants.HISCORE_PANEL_DIMENSION.height)
|
setViewSize(ViewConstants.DEFAULT_PANEL_SIZE.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
customSearchField = SearchField(
|
customSearchField = SearchField(
|
||||||
|
|
@ -97,8 +66,8 @@ object HiscoresView : View {
|
||||||
|
|
||||||
val searchFieldWrapper = JPanel().apply {
|
val searchFieldWrapper = JPanel().apply {
|
||||||
layout = BoxLayout(this, BoxLayout.X_AXIS)
|
layout = BoxLayout(this, BoxLayout.X_AXIS)
|
||||||
background = Constants.COLOR_BACKGROUND_MEDIUM
|
background = VIEW_BACKGROUND_COLOR
|
||||||
preferredSize = Constants.SEARCH_FIELD_DIMENSION
|
preferredSize = ViewConstants.SEARCH_FIELD_SIZE
|
||||||
maximumSize = preferredSize
|
maximumSize = preferredSize
|
||||||
minimumSize = preferredSize
|
minimumSize = preferredSize
|
||||||
alignmentX = Component.CENTER_ALIGNMENT
|
alignmentX = Component.CENTER_ALIGNMENT
|
||||||
|
|
@ -107,7 +76,7 @@ object HiscoresView : View {
|
||||||
|
|
||||||
val searchPanel = JPanel().apply {
|
val searchPanel = JPanel().apply {
|
||||||
layout = BoxLayout(this, BoxLayout.Y_AXIS)
|
layout = BoxLayout(this, BoxLayout.Y_AXIS)
|
||||||
background = Constants.COLOR_BACKGROUND_MEDIUM
|
background = VIEW_BACKGROUND_COLOR
|
||||||
add(searchFieldWrapper)
|
add(searchFieldWrapper)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +87,7 @@ object HiscoresView : View {
|
||||||
val playerNamePanel = JPanel().apply {
|
val playerNamePanel = JPanel().apply {
|
||||||
layout = GridBagLayout() // This will center the JLabel both vertically and horizontally
|
layout = GridBagLayout() // This will center the JLabel both vertically and horizontally
|
||||||
background = TOOLTIP_BACKGROUND.darker()
|
background = TOOLTIP_BACKGROUND.darker()
|
||||||
preferredSize = Constants.FILTER_PANEL_DIMENSION
|
preferredSize = ViewConstants.FILTER_PANEL_SIZE
|
||||||
maximumSize = preferredSize
|
maximumSize = preferredSize
|
||||||
minimumSize = preferredSize
|
minimumSize = preferredSize
|
||||||
name = "playerNameLabel"
|
name = "playerNameLabel"
|
||||||
|
|
@ -128,42 +97,42 @@ object HiscoresView : View {
|
||||||
hiscorePanel.add(Box.createVerticalStrut(5))
|
hiscorePanel.add(Box.createVerticalStrut(5))
|
||||||
|
|
||||||
val skillsPanel = JPanel(FlowLayout(FlowLayout.CENTER, 0, 0)).apply {
|
val skillsPanel = JPanel(FlowLayout(FlowLayout.CENTER, 0, 0)).apply {
|
||||||
background = Constants.COLOR_BACKGROUND_MEDIUM
|
background = VIEW_BACKGROUND_COLOR
|
||||||
preferredSize = Constants.SKILLS_PANEL_DIMENSION
|
preferredSize = ViewConstants.SKILLS_PANEL_SIZE
|
||||||
maximumSize = preferredSize
|
maximumSize = preferredSize
|
||||||
minimumSize = preferredSize
|
minimumSize = preferredSize
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i in Constants.SKILL_DISPLAY_ORDER) {
|
for (i in ViewConstants.SKILL_DISPLAY_ORDER) {
|
||||||
val skillPanel = JPanel().apply {
|
val skillPanel = JPanel().apply {
|
||||||
layout = BorderLayout()
|
layout = BorderLayout()
|
||||||
background = Constants.COLOR_BACKGROUND_DARK
|
background = WIDGET_COLOR
|
||||||
preferredSize = Constants.SKILL_PANEL_DIMENSION
|
preferredSize = ViewConstants.SKILL_PANEL_SIZE
|
||||||
maximumSize = preferredSize
|
maximumSize = preferredSize
|
||||||
minimumSize = preferredSize
|
minimumSize = preferredSize
|
||||||
border = MatteBorder(5, 0, 0, 0, Constants.COLOR_BACKGROUND_DARK)
|
border = MatteBorder(5, 0, 0, 0, WIDGET_COLOR)
|
||||||
}
|
}
|
||||||
|
|
||||||
val bufferedImageSprite = getBufferedImageFromSprite(API.GetSprite(getSpriteId(i)))
|
val bufferedImageSprite = getBufferedImageFromSprite(API.GetSprite(getSpriteId(i)))
|
||||||
|
|
||||||
val imageCanvas = bufferedImageSprite.let {
|
val imageCanvas = bufferedImageSprite.let {
|
||||||
ImageCanvas(it).apply {
|
ImageCanvas(it).apply {
|
||||||
preferredSize = Constants.SKILL_SPRITE_DIMENSION
|
preferredSize = ViewConstants.SKILL_SPRITE_SIZE
|
||||||
size = Constants.SKILL_SPRITE_DIMENSION
|
size = ViewConstants.SKILL_SPRITE_SIZE
|
||||||
fillColor = Constants.COLOR_BACKGROUND_DARK
|
fillColor = WIDGET_COLOR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val numberLabel = JLabel("", JLabel.RIGHT).apply {
|
val numberLabel = JLabel("", JLabel.RIGHT).apply {
|
||||||
name = "skillLabel_$i"
|
name = "skillLabel_$i"
|
||||||
foreground = Constants.COLOR_FOREGROUND_LIGHT
|
foreground = POPUP_FOREGROUND
|
||||||
font = Constants.FONT_ARIAL_PLAIN_12
|
font = ViewConstants.FONT_RUNESCAPE_SMALL_16
|
||||||
preferredSize = Constants.NUMBER_LABEL_DIMENSION
|
preferredSize = ViewConstants.NUMBER_LABEL_SIZE
|
||||||
minimumSize = Constants.NUMBER_LABEL_DIMENSION
|
minimumSize = ViewConstants.NUMBER_LABEL_SIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
val imageContainer = JPanel(FlowLayout(FlowLayout.CENTER, 5, 0)).apply {
|
val imageContainer = JPanel(FlowLayout(FlowLayout.CENTER, 5, 0)).apply {
|
||||||
background = Constants.COLOR_BACKGROUND_DARK
|
background = WIDGET_COLOR
|
||||||
add(imageCanvas)
|
add(imageCanvas)
|
||||||
add(numberLabel)
|
add(numberLabel)
|
||||||
}
|
}
|
||||||
|
|
@ -175,52 +144,52 @@ object HiscoresView : View {
|
||||||
hiscorePanel.add(skillsPanel)
|
hiscorePanel.add(skillsPanel)
|
||||||
|
|
||||||
val totalCombatPanel = JPanel(FlowLayout(FlowLayout.CENTER, 0, 0)).apply {
|
val totalCombatPanel = JPanel(FlowLayout(FlowLayout.CENTER, 0, 0)).apply {
|
||||||
background = Constants.COLOR_BACKGROUND_DARK
|
background = WIDGET_COLOR
|
||||||
preferredSize = Constants.TOTAL_COMBAT_PANEL_DIMENSION
|
preferredSize = ViewConstants.TOTAL_COMBAT_PANEL_SIZE
|
||||||
maximumSize = preferredSize
|
maximumSize = preferredSize
|
||||||
minimumSize = preferredSize
|
minimumSize = preferredSize
|
||||||
}
|
}
|
||||||
|
|
||||||
val bufferedImageSprite = getBufferedImageFromSprite(API.GetSprite(Constants.LVL_BAR_SPRITE))
|
val bufferedImageSprite = getBufferedImageFromSprite(API.GetSprite(ViewConstants.LVL_BAR_SPRITE))
|
||||||
|
|
||||||
val totalLevelIcon = ImageCanvas(bufferedImageSprite).apply {
|
val totalLevelIcon = ImageCanvas(bufferedImageSprite).apply {
|
||||||
fillColor = Constants.COLOR_BACKGROUND_DARK
|
fillColor = WIDGET_COLOR
|
||||||
preferredSize = Constants.ICON_DIMENSION_LARGE
|
preferredSize = ViewConstants.DIMENSION_LARGE_ICON
|
||||||
size = Constants.ICON_DIMENSION_LARGE
|
size = ViewConstants.DIMENSION_LARGE_ICON
|
||||||
}
|
}
|
||||||
|
|
||||||
val totalLevelLabel = JLabel("").apply {
|
val totalLevelLabel = JLabel("").apply {
|
||||||
name = "totalLevelLabel"
|
name = "totalLevelLabel"
|
||||||
foreground = Constants.COLOR_FOREGROUND_LIGHT
|
foreground = POPUP_FOREGROUND
|
||||||
font = Constants.FONT_ARIAL_BOLD_12
|
font = ViewConstants.FONT_ARIAL_BOLD_12
|
||||||
horizontalAlignment = JLabel.LEFT
|
horizontalAlignment = JLabel.LEFT
|
||||||
iconTextGap = 10
|
iconTextGap = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
val totalLevelPanel = JPanel(FlowLayout(FlowLayout.LEFT)).apply {
|
val totalLevelPanel = JPanel(FlowLayout(FlowLayout.LEFT)).apply {
|
||||||
background = Constants.COLOR_BACKGROUND_DARK
|
background = WIDGET_COLOR
|
||||||
add(totalLevelIcon)
|
add(totalLevelIcon)
|
||||||
add(totalLevelLabel)
|
add(totalLevelLabel)
|
||||||
}
|
}
|
||||||
|
|
||||||
val bufferedImageSprite2 = getBufferedImageFromSprite(API.GetSprite(Constants.COMBAT_LVL_SPRITE))
|
val bufferedImageSprite2 = getBufferedImageFromSprite(API.GetSprite(ViewConstants.COMBAT_LVL_SPRITE))
|
||||||
|
|
||||||
val combatLevelIcon = ImageCanvas(bufferedImageSprite2).apply {
|
val combatLevelIcon = ImageCanvas(bufferedImageSprite2).apply {
|
||||||
fillColor = Constants.COLOR_BACKGROUND_DARK
|
fillColor = WIDGET_COLOR
|
||||||
preferredSize = Constants.ICON_DIMENSION_LARGE
|
preferredSize = ViewConstants.DIMENSION_LARGE_ICON
|
||||||
size = Constants.ICON_DIMENSION_LARGE
|
size = ViewConstants.DIMENSION_LARGE_ICON
|
||||||
}
|
}
|
||||||
|
|
||||||
val combatLevelLabel = JLabel("").apply {
|
val combatLevelLabel = JLabel("").apply {
|
||||||
name = "combatLevelLabel"
|
name = "combatLevelLabel"
|
||||||
foreground = Constants.COLOR_FOREGROUND_LIGHT
|
foreground = POPUP_FOREGROUND
|
||||||
font = Constants.FONT_ARIAL_BOLD_12
|
font = ViewConstants.FONT_ARIAL_BOLD_12
|
||||||
horizontalAlignment = JLabel.LEFT
|
horizontalAlignment = JLabel.LEFT
|
||||||
iconTextGap = 10
|
iconTextGap = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
val combatLevelPanel = JPanel(FlowLayout(FlowLayout.LEFT)).apply {
|
val combatLevelPanel = JPanel(FlowLayout(FlowLayout.LEFT)).apply {
|
||||||
background = Constants.COLOR_BACKGROUND_DARK
|
background = WIDGET_COLOR
|
||||||
add(combatLevelIcon)
|
add(combatLevelIcon)
|
||||||
add(combatLevelLabel)
|
add(combatLevelLabel)
|
||||||
}
|
}
|
||||||
|
|
@ -316,8 +285,8 @@ object HiscoresView : View {
|
||||||
playerNameLabel?.removeAll() // Clear previous components
|
playerNameLabel?.removeAll() // Clear previous components
|
||||||
var nameLabel = LabelComponent().apply {
|
var nameLabel = LabelComponent().apply {
|
||||||
updateHtmlText(username, secondaryColor, "", primaryColor)
|
updateHtmlText(username, secondaryColor, "", primaryColor)
|
||||||
font = Constants.FONT_ARIAL_BOLD_12
|
font = ViewConstants.FONT_ARIAL_BOLD_12
|
||||||
foreground = Constants.COLOR_FOREGROUND_LIGHT
|
foreground = POPUP_FOREGROUND
|
||||||
border = BorderFactory.createEmptyBorder(0, 6, 0, 0) // Top, Left, Bottom, Right padding
|
border = BorderFactory.createEmptyBorder(0, 6, 0, 0) // Top, Left, Bottom, Right padding
|
||||||
horizontalAlignment = JLabel.CENTER
|
horizontalAlignment = JLabel.CENTER
|
||||||
}
|
}
|
||||||
|
|
@ -333,11 +302,11 @@ object HiscoresView : View {
|
||||||
|
|
||||||
if (ironMode != "0") {
|
if (ironMode != "0") {
|
||||||
val ironmanBufferedImage =
|
val ironmanBufferedImage =
|
||||||
getBufferedImageFromSprite(Sprites.nameIcons[Constants.IRONMAN_SPRITE + ironMode.toInt() - 1])
|
getBufferedImageFromSprite(Sprites.nameIcons[ViewConstants.IRONMAN_SPRITE + ironMode.toInt() - 1])
|
||||||
val imageCanvas = ironmanBufferedImage.let {
|
val imageCanvas = ironmanBufferedImage.let {
|
||||||
ImageCanvas(it).apply {
|
ImageCanvas(it).apply {
|
||||||
preferredSize = Constants.IMAGE_CANVAS_DIMENSION
|
preferredSize = ViewConstants.IMAGE_CANVAS_SIZE
|
||||||
size = Constants.IMAGE_CANVAS_DIMENSION
|
size = ViewConstants.IMAGE_CANVAS_SIZE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -347,8 +316,8 @@ object HiscoresView : View {
|
||||||
val exp_multiplier = data.info.exp_multiplier
|
val exp_multiplier = data.info.exp_multiplier
|
||||||
nameLabel = LabelComponent().apply {
|
nameLabel = LabelComponent().apply {
|
||||||
updateHtmlText(username, secondaryColor, " (${exp_multiplier}x)", primaryColor)
|
updateHtmlText(username, secondaryColor, " (${exp_multiplier}x)", primaryColor)
|
||||||
font = Constants.FONT_ARIAL_BOLD_12
|
font = ViewConstants.FONT_ARIAL_BOLD_12
|
||||||
foreground = Constants.COLOR_FOREGROUND_LIGHT
|
foreground = POPUP_FOREGROUND
|
||||||
border = BorderFactory.createEmptyBorder(0, 6, 0, 0) // Top, Left, Bottom, Right padding
|
border = BorderFactory.createEmptyBorder(0, 6, 0, 0) // Top, Left, Bottom, Right padding
|
||||||
horizontalAlignment = JLabel.CENTER
|
horizontalAlignment = JLabel.CENTER
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue