Skip to content

Commit 12d80fd

Browse files
authored
Merge pull request #341 from alyssaruth/locked-themes
Account for locked themes, prep for release
2 parents ea909bb + d4837d4 commit 12d80fd

22 files changed

Lines changed: 328 additions & 65 deletions

‎scripts/verify-jar.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ touch dartzee.log
55

66
desiredLog=$1
77

8-
nohup java -jar Dartzee.jar > dartzee.log 2>&1 &
8+
nohup java -jar Dartzee.jar justUpdated > dartzee.log 2>&1 &
99
printf "Waiting for Dartzee to start."
1010
attempt_counter=0
1111
max_attempts=20

‎src/main/kotlin/dartzee/main/DartsMain.kt‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ fun main(args: Array<String>) {
1515

1616
if (!DartsClient.trueLaunch && DartsClient.isWindowsOs()) {
1717
Runtime.getRuntime()
18-
.exec("cmd /c start javaw -Xms256m -Xmx512m -jar Dartzee.jar trueLaunch")
18+
.exec(
19+
"cmd /c start javaw -Xms256m -Xmx512m -jar Dartzee.jar trueLaunch ${args.joinToString(" ")}"
20+
)
1921
InjectedThings.exiter.exit(0)
2022
}
2123

‎src/main/kotlin/dartzee/screen/preference/AbstractPreferencesPanel.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ abstract class AbstractPreferencesPanel : JPanel() {
3838
stateChanged()
3939
}
4040

41-
fun stateChanged() {
41+
protected fun stateChanged() {
4242
btnApply.isEnabled = hasOutstandingChanges()
4343
}
4444

‎src/main/kotlin/dartzee/screen/preference/PreferencesPanelAppearance.kt‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,16 @@ class PreferencesPanelAppearance : AbstractPreferencesPanel(), ChangeListener, A
143143
preferenceService.save(Preferences.theme, themeSelector.selectedThemeId())
144144
}
145145

146-
override fun hasOutstandingChanges() =
147-
spinnerHueFactor.value != preferenceService.get(Preferences.hueFactor) ||
146+
override fun hasOutstandingChanges(): Boolean {
147+
if (themeSelector.selectionIsLocked()) {
148+
return false
149+
}
150+
151+
return spinnerHueFactor.value != preferenceService.get(Preferences.hueFactor) ||
148152
spinnerBgBrightness.value != preferenceService.get(Preferences.bgBrightness) ||
149153
spinnerFgBrightness.value != preferenceService.get(Preferences.fgBrightness) ||
150154
themeSelector.selectedThemeId() != preferenceService.get(Preferences.theme)
155+
}
151156

152157
override fun stateChanged(arg0: ChangeEvent) {
153158
repaintScorerPreview()

‎src/main/kotlin/dartzee/theme/Easter.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import dartzee.screen.animation.IAnimationTrigger
99
import dartzee.screen.animation.PlayerVictory
1010
import java.awt.Color
1111
import java.time.LocalDate
12+
import java.time.Month
1213

1314
private val pastelGreen = Color.decode("#dcf9a8")
1415
private val easterYellow = Color.decode("#ffebaf")
@@ -51,6 +52,7 @@ val Themes.EASTER: Theme
5152
bannerScaleFactor = 0.5,
5253
bannerOffset = 0.3,
5354
festivalInfo = FestivalInfo(::findEaster, "Will next pop up"),
55+
unlockDate = LocalDate.of(2026, Month.MARCH, 28),
5456
)
5557

5658
private fun findEaster(year: Int): Pair<LocalDate, LocalDate> {

‎src/main/kotlin/dartzee/theme/Halloween.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ val Themes.HALLOWEEN: Theme
5656
dartboardColours = halloweenDartboardColours,
5757
animations = halloweenAnimations.toMap(),
5858
festivalInfo = FestivalInfo(::findHalloween, "Next haunting will start"),
59+
unlockDate = LocalDate.of(2026, Month.OCTOBER, 24),
5960
)
6061

6162
private fun findHalloween(year: Int): Pair<LocalDate, LocalDate> =

‎src/main/kotlin/dartzee/theme/Oktoberfest.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ val Themes.OKTOBERFEST: Theme
5858
menuFontSize = 24f,
5959
animations = oktoberfestAnimations.toMap(),
6060
festivalInfo = FestivalInfo(::findOktoberfest, "Happy hour next begins"),
61+
unlockDate = LocalDate.of(2026, Month.SEPTEMBER, 19),
6162
)
6263

6364
private fun findOktoberfest(year: Int): Pair<LocalDate, LocalDate> {

‎src/main/kotlin/dartzee/theme/Theme.kt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import dartzee.`object`.ColourWrapper
55
import dartzee.screen.animation.IAnimation
66
import dartzee.screen.animation.IAnimationTrigger
77
import dartzee.utils.InjectedThings.logger
8+
import dartzee.utils.InjectedThings.now
89
import dartzee.utils.ResourceCache
910
import java.awt.Color
1011
import java.awt.GraphicsEnvironment
@@ -65,4 +66,9 @@ data class Theme(
6566
}
6667

6768
fun icon(path: String) = javaClass.getResource("/theme/$resourcePath$path")?.let(::ImageIcon)
69+
70+
fun isLocked() = unlockDate != null && now.isBefore(unlockDate)
71+
72+
fun <T> getIfUnlocked(getter: (Theme) -> T, lockedValue: T) =
73+
if (isLocked()) lockedValue else getter(this)
6874
}

‎src/main/kotlin/dartzee/theme/ThemePanel.kt‎

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import dartzee.core.util.alignCentrally
55
import dartzee.utils.ResourceCache
66
import java.awt.BorderLayout
77
import java.awt.Color
8-
import java.time.LocalDate
8+
import javax.swing.ImageIcon
99
import javax.swing.JLabel
1010
import javax.swing.JPanel
1111
import 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
}

‎src/main/kotlin/dartzee/theme/ThemeSelector.kt‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class ThemeSelector(private val themeIds: List<ThemeId> = ThemeId.values().toLis
5151

5252
fun selectedThemeId() = themePanel.themeId
5353

54+
fun selectionIsLocked() = themePanel.theme?.isLocked() ?: false
55+
5456
private fun selectionChanged(newIndex: Int) {
5557
remove(themePanel)
5658
themePanel = ThemePanel(themeIds[newIndex])
@@ -64,13 +66,17 @@ class ThemeSelector(private val themeIds: List<ThemeId> = ThemeId.values().toLis
6466
btnNext.icon = themedIcon("/buttons/rightArrow.png", themePanel.theme)
6567
btnPrevious.icon = themedIcon("/buttons/leftArrow.png", themePanel.theme)
6668

67-
val btnColour = themePanel.theme?.primary ?: DEFAULT_BUTTON_COLOUR
68-
val bg = themePanel.theme?.background ?: DEFAULT_BACKGROUND
69+
val btnColour =
70+
themePanel.theme?.getIfUnlocked(Theme::primary, null) ?: DEFAULT_BUTTON_COLOUR
71+
val bg =
72+
themePanel.theme?.getIfUnlocked(Theme::background, Color.DARK_GRAY)
73+
?: DEFAULT_BACKGROUND
6974

7075
btnPrevious.background = btnColour
7176
btnNext.background = btnColour
7277

73-
titleBorder.titleColor = themePanel.theme?.fontColor ?: Color.BLACK
78+
titleBorder.titleColor =
79+
themePanel.theme?.getIfUnlocked(Theme::fontColor, Color.LIGHT_GRAY) ?: Color.BLACK
7480

7581
panelRight.background = bg
7682
panelLeft.background = bg

0 commit comments

Comments
 (0)