Skip to content

Commit 476e61a

Browse files
authored
Merge pull request #350 from alyssaruth/final-theme-bits
Final theme bits
2 parents 65edb8a + 3ac907a commit 476e61a

49 files changed

Lines changed: 170 additions & 31 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/main/kotlin/dartzee/core/bean/DateFilterPanel.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class DateFilterPanel : JPanel() {
5050

5151
private fun getDtFrom() = cbDateFrom.date.atTime(0, 0)
5252

53-
private fun getDtTo() = cbDateTo.date.atTime(0, 0)
53+
private fun getDtTo() = cbDateTo.date.atTime(23, 59)
5454

5555
private fun makeDatePickerSettings(): DatePickerSettings {
5656
val settings = DatePickerSettings()

‎src/main/kotlin/dartzee/screen/animation/Animation.kt‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ interface IAnimation {
66
fun getAnimation(): Animation
77

88
fun getAllSounds(): List<String>
9+
10+
fun getAllImages(): List<String>
911
}
1012

1113
data class Animation(
@@ -18,10 +20,27 @@ data class Animation(
1820
override fun getAnimation() = this
1921

2022
override fun getAllSounds() = listOf(wavResource)
21-
}
2223

23-
data class CompositeAnimation(val animationOptions: List<Animation>) : IAnimation {
24-
override fun getAnimation() = animationOptions.random()
24+
override fun getAllImages() = listOfNotNull(imgResourcePath)
25+
}
2526

26-
override fun getAllSounds() = animationOptions.map { it.wavResource }
27+
data class CompositeAnimation(val animationOptions: List<IAnimation>) : IAnimation {
28+
override fun getAnimation(): Animation {
29+
val animation = animationOptions.random()
30+
if (animation is Animation) {
31+
return animation
32+
}
33+
34+
return animation.getAnimation()
35+
}
36+
37+
override fun getAllSounds() =
38+
animationOptions.flatMap {
39+
if (it is Animation) listOf(it.wavResource) else it.getAllSounds()
40+
}
41+
42+
override fun getAllImages() =
43+
animationOptions.flatMap {
44+
if (it is Animation) listOfNotNull(it.imgResourcePath) else it.getAllImages()
45+
}
2746
}

‎src/main/kotlin/dartzee/screen/animation/IAnimationTrigger.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ object BadLuckTrigger : IAnimationTrigger
1313
object BruceyBonusTrigger : IAnimationTrigger
1414

1515
object PlayerVictory : IAnimationTrigger
16+
17+
object BustTrigger : IAnimationTrigger

‎src/main/kotlin/dartzee/screen/game/x01/GamePanelX01.kt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import dartzee.game.state.X01PlayerState
1515
import dartzee.`object`.ComputedPoint
1616
import dartzee.`object`.Dart
1717
import dartzee.screen.animation.BadLuckTrigger
18+
import dartzee.screen.animation.BustTrigger
1819
import dartzee.screen.animation.TotalScoreTrigger
1920
import dartzee.screen.game.AbstractDartsGameScreen
2021
import dartzee.screen.game.GamePanelPausable
@@ -76,6 +77,8 @@ class GamePanelX01(parent: AbstractDartsGameScreen, game: GameEntity, totalPlaye
7677
total,
7778
)
7879
} else {
80+
dartboard.doDodgy(BustTrigger)
81+
7982
val startingScoreForRound =
8083
getCurrentPlayerState().getRemainingScoreForRound(currentRoundNumber - 1)
8184
AchievementEntity.updateAchievement(

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

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
package dartzee.theme
22

3+
import dartzee.game.GameType
4+
import dartzee.screen.animation.Animation
5+
import dartzee.screen.animation.BadLuckTrigger
6+
import dartzee.screen.animation.BruceyBonusTrigger
7+
import dartzee.screen.animation.BustTrigger
8+
import dartzee.screen.animation.CompositeAnimation
9+
import dartzee.screen.animation.DartScoreTrigger
10+
import dartzee.screen.animation.IAnimation
11+
import dartzee.screen.animation.IAnimationTrigger
312
import java.awt.Color
413
import java.awt.Point
514
import java.awt.Rectangle
@@ -117,11 +126,39 @@ private fun getBannerDetails(
117126
return listOf(topBanner)
118127
}
119128

129+
private val bingpotAnimation =
130+
CompositeAnimation((1..2).map { Animation("bingpot$it", "/theme/pride/horrific/holt.png") })
131+
132+
private val bustAnimation =
133+
CompositeAnimation((1..3).map { Animation("buster$it", "/theme/pride/horrific/lily.png") })
134+
135+
private val ohMy =
136+
CompositeAnimation(
137+
(1..3).map { Animation("oh-my$it", "/theme/pride/horrific/george-takei.png") }
138+
)
139+
140+
private val prideAnimations: List<Pair<IAnimationTrigger, IAnimation>> =
141+
GameType.values().flatMap { gameType ->
142+
listOf(
143+
DartScoreTrigger(gameType, 50) to bingpotAnimation,
144+
DartScoreTrigger(gameType, 25) to bingpotAnimation,
145+
DartScoreTrigger(gameType, 0) to
146+
CompositeAnimation(
147+
listOf(ohMy, Animation("nonsense", "/theme/pride/horrific/ncuti.png"))
148+
),
149+
)
150+
} +
151+
listOf(
152+
BadLuckTrigger to Animation("hooray", "/theme/pride/horrific/todd.png"),
153+
BruceyBonusTrigger to Animation("betterEfforts", "/theme/pride/horrific/julian.png"),
154+
BustTrigger to bustAnimation,
155+
)
156+
120157
val Themes.PRIDE: Theme
121158
get() =
122159
Theme(
123160
ThemeId.Pride,
124-
"TODO",
161+
"Is there enough rainbow in this theme d'you think?!",
125162
PrideColors.red,
126163
PrideColors.purple,
127164
Color.decode("#FFFFC5"),
@@ -134,6 +171,7 @@ val Themes.PRIDE: Theme
134171
festivalInfo = FestivalInfo(::findPride, "The next parade begins"),
135172
customIcons = mapOf("/flags/humanFlag.png" to ::randomHumanFlag),
136173
unlockDate = LocalDate.of(2026, Month.JUNE, 1),
174+
animations = prideAnimations.toMap(),
137175
)
138176

139177
private fun findPride(year: Int): Pair<LocalDate, LocalDate> =

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package dartzee.theme
22

3+
import com.github.weisj.jsvg.SVGDocument
34
import dartzee.logging.CODE_THEME_APPLIED
45
import dartzee.screen.animation.IAnimation
56
import dartzee.screen.animation.IAnimationTrigger
67
import dartzee.utils.InjectedThings.logger
78
import dartzee.utils.InjectedThings.now
89
import dartzee.utils.ResourceCache
910
import java.awt.Color
11+
import java.awt.Font
1012
import java.awt.GraphicsEnvironment
1113
import java.net.URL
1214
import java.time.LocalDate
@@ -36,14 +38,20 @@ data class Theme(
3638
val name = id.name
3739
private val resourcePath = name.lowercase()
3840
val font = fontForResource("/theme/$resourcePath/font.ttf")
39-
private val dartboardFont = fontForResource("/theme/$resourcePath/dartboard.ttf") ?: font
40-
val banner = svgForResource("/theme/$resourcePath/banner.svg")
41+
private val dartboardFont: Font?
42+
get() = fontForResource("/theme/$resourcePath/dartboard.ttf") ?: font
4143

42-
val menuMusic = clipForResource("/theme/$resourcePath/menu.wav")
43-
val newGameSfx = clipForResource("/theme/$resourcePath/newGame.wav")
44+
val banner: SVGDocument?
45+
get() = svgForResource("/theme/$resourcePath/banner.svg")
4446

45-
val dartboardColourWrapper =
46-
dartboardColours?.withFont(dartboardFont ?: ResourceCache.BASE_FONT)
47+
val menuMusic: AudioClip?
48+
get() = clipForResource("/theme/$resourcePath/menu.wav")
49+
50+
val newGameSfx: AudioClip?
51+
get() = clipForResource("/theme/$resourcePath/newGame.wav")
52+
53+
val dartboardColourWrapper: IDartboardPainter?
54+
get() = dartboardColours?.withFont(dartboardFont ?: ResourceCache.BASE_FONT)
4755

4856
fun apply() {
4957
logger.info(CODE_THEME_APPLIED, "Applying theme $name")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ThemePanel(val themeId: ThemeId) : JPanel() {
2828
theme?.getIfUnlocked(Theme::font, ResourceCache.BASE_FONT) ?: ResourceCache.BASE_FONT
2929
val fontColor = theme?.getIfUnlocked(Theme::fontColor, Color.LIGHT_GRAY) ?: Color.BLACK
3030

31-
val menuFontSize = theme?.getIfUnlocked(Theme::menuFontSize, 14f) ?: 14f
31+
val menuFontSize = theme?.getIfUnlocked(Theme::menuFontSize, 14f) ?: 10f
3232

3333
val lblLeftIcon = JLabel(getLeftIcon())
3434
lblLeftIcon.name = "LeftIcon"

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class ThemeSelector(private val themeIds: List<ThemeId> = ThemeId.values().toLis
2020
private var themePanel = ThemePanel(themeIds.first())
2121
private val actionListeners = mutableListOf<ActionListener>()
2222

23+
private val themePanels = themeIds.map { ThemePanel(it) }
24+
2325
private val titleBorder =
2426
TitledBorder(null, "Theme", TitledBorder.LEADING, TitledBorder.TOP, null, null)
2527

@@ -28,8 +30,8 @@ class ThemeSelector(private val themeIds: List<ThemeId> = ThemeId.values().toLis
2830

2931
setLayout(BorderLayout(20, 0))
3032

31-
btnNext.name = "Next"
32-
btnPrevious.name = "Previous"
33+
btnNext.name = "NextTheme"
34+
btnPrevious.name = "PreviousTheme"
3335

3436
btnNext.icon = themedIcon("/buttons/rightArrow.png")
3537
btnPrevious.icon = themedIcon("/buttons/leftArrow.png")
@@ -55,7 +57,7 @@ class ThemeSelector(private val themeIds: List<ThemeId> = ThemeId.values().toLis
5557

5658
private fun selectionChanged(newIndex: Int) {
5759
remove(themePanel)
58-
themePanel = ThemePanel(themeIds[newIndex])
60+
themePanel = themePanels[newIndex]
5961
add(themePanel, BorderLayout.CENTER)
6062

6163
repaint()
114 KB
205 KB

0 commit comments

Comments
 (0)