@@ -5,7 +5,7 @@ import dartzee.core.util.alignCentrally
55import dartzee.utils.ResourceCache
66import java.awt.BorderLayout
77import java.awt.Color
8- import java.time.LocalDate
8+ import javax.swing.ImageIcon
99import javax.swing.JLabel
1010import javax.swing.JPanel
1111import javax.swing.SwingConstants
@@ -16,32 +16,69 @@ class ThemePanel(val themeId: ThemeId) : JPanel() {
1616 val theme = themeMap()[themeId]
1717
1818 private val panelNorth = JPanel ()
19- private val lblName = JLabel (theme?.name ? : " Classic (none) " )
19+ private val lblName = JLabel (indexedThemeName() )
2020 private val lblThemeDesc = makeTransparentTextPane().apply { alignCentrally() }
2121
2222 init {
2323 border = EmptyBorder (20 , 20 , 20 , 20 )
2424 setLayout(BorderLayout (0 , 20 ))
2525
2626 panelNorth.layout = MigLayout (" al center center" )
27- val font = theme?.font ? : ResourceCache .BASE_FONT
28- val fontColor = theme?.fontColor ? : Color .BLACK
27+ val font =
28+ theme?.getIfUnlocked(Theme ::font, ResourceCache .BASE_FONT ) ? : ResourceCache .BASE_FONT
29+ val fontColor = theme?.getIfUnlocked(Theme ::fontColor, Color .LIGHT_GRAY ) ? : Color .BLACK
30+
31+ val menuFontSize = theme?.getIfUnlocked(Theme ::menuFontSize, 14f ) ? : 14f
32+
33+ val lblLeftIcon = JLabel (getLeftIcon())
34+ lblLeftIcon.name = " LeftIcon"
35+ panelNorth.add(lblLeftIcon)
2936
30- panelNorth.add(JLabel (themedIcon(" /buttons/playerManagement.png" , theme)))
3137 panelNorth.add(lblName)
32- panelNorth.add(JLabel (themedIcon(" /buttons/newGame.png" , theme)))
33- lblName.font = font.deriveFont(20f + (theme?.menuFontSize ? : 14f ))
38+
39+ val lblRightIcon = JLabel (getRightIcon())
40+ lblRightIcon.name = " RightIcon"
41+ panelNorth.add(lblRightIcon)
42+
43+ lblName.name = " Name"
44+ lblName.font = font.deriveFont(20f + menuFontSize)
3445 lblName.foreground = fontColor
3546 lblName.horizontalAlignment = SwingConstants .CENTER
3647
37- background = theme?.background
38- panelNorth.background = theme?.background
48+ val bg = theme?.getIfUnlocked(Theme ::background, Color .DARK_GRAY )
49+ background = bg
50+ panelNorth.background = bg
3951
4052 lblThemeDesc.foreground = fontColor
41- lblThemeDesc.text = themeDescription(themeId, LocalDate .now() )
53+ lblThemeDesc.text = themeDescription(themeId)
4254 lblThemeDesc.font = ResourceCache .BASE_FONT .deriveFont(18f )
55+ lblThemeDesc.name = " Description"
4356
4457 add(panelNorth, BorderLayout .NORTH )
4558 add(lblThemeDesc, BorderLayout .CENTER )
4659 }
60+
61+ private fun getLeftIcon () = getIconIfUnlocked(" /buttons/playerManagement.png" )
62+
63+ private fun getRightIcon () = getIconIfUnlocked(" /buttons/newGame.png" )
64+
65+ private fun getIconIfUnlocked (path : String ) =
66+ if (theme?.isLocked() ? : false ) {
67+ ImageIcon (javaClass.getResource(" /theme/locked.png" ))
68+ } else {
69+ themedIcon(path, theme)
70+ }
71+
72+ private fun indexedThemeName (): String {
73+ val index = ThemeId .values().indexOf(themeId) + 1
74+ return " $index . ${getThemeName()} "
75+ }
76+
77+ private fun getThemeName (): String {
78+ if (theme == null ) {
79+ return " Classic (none)"
80+ }
81+
82+ return if (theme.isLocked()) " Locked" else theme.name
83+ }
4784}
0 commit comments