Skip to content

Commit

Permalink
Merge pull request #321 from alyssaruth/tutorial-page-icons
Browse files Browse the repository at this point in the history
[Party mode] Proper icons for tutorial
  • Loading branch information
alyssaruth authored Apr 21, 2024
2 parents 986e3c9 + ebcd42f commit ccce78b
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import dartzee.`object`.Dart
import dartzee.screen.GameplayDartboard
import dartzee.utils.DartsColour
import dartzee.utils.InjectedThings.dartzeeCalculator
import dartzee.utils.ResourceCache
import java.awt.BorderLayout
import java.awt.Color
import java.awt.Dimension
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import javax.swing.ImageIcon
import javax.swing.JButton
import javax.swing.JLabel
import javax.swing.JPanel
Expand Down Expand Up @@ -57,7 +57,7 @@ class DartzeeRuleVerificationPanel : JPanel(), DartboardListener, ActionListener
tfResult.isEditable = false

btnReset.preferredSize = Dimension(60, 60)
btnReset.icon = ImageIcon(javaClass.getResource("/buttons/Reset.png"))
btnReset.icon = ResourceCache.ICON_RESET
btnReset.toolTipText = "Reset darts"

btnReset.addActionListener(this)
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/dartzee/screen/game/DartsGamePanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import dartzee.screen.game.x01.GamePanelX01
import dartzee.utils.InjectedThings
import dartzee.utils.InjectedThings.mainDatabase
import dartzee.utils.InjectedThings.preferenceService
import dartzee.utils.ResourceCache
import dartzee.utils.ResourceCache.ICON_STATS_LARGE
import dartzee.utils.getColourWrapperFromPrefs
import dartzee.utils.getQuotedIdStr
Expand Down Expand Up @@ -145,11 +146,11 @@ abstract class DartsGamePanel<
panelSouth.add(panelAiSlider, BorderLayout.NORTH)
panelSouth.add(panelButtons, BorderLayout.CENTER)
btnConfirm.preferredSize = Dimension(80, 80)
btnConfirm.icon = ImageIcon(javaClass.getResource("/buttons/Confirm.png"))
btnConfirm.icon = ResourceCache.ICON_CONFIRM
btnConfirm.toolTipText = "Confirm round"
panelButtons.add(btnConfirm)
btnReset.preferredSize = Dimension(80, 80)
btnReset.icon = ImageIcon(javaClass.getResource("/buttons/Reset.png"))
btnReset.icon = ResourceCache.ICON_RESET
btnReset.toolTipText = "Reset round"
panelButtons.add(btnReset)
btnResign.preferredSize = Dimension(80, 80)
Expand Down
33 changes: 20 additions & 13 deletions src/main/kotlin/dartzee/screen/game/TutorialPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ class TutorialPanel(private val parent: DartsGameScreen) :
scrollPane.setViewportView(panelWest)
panelWest.border = EtchedBorder(EtchedBorder.RAISED, null, null)
panelWest.layout = MigLayout("al center top")
panelWest.preferredSize = Dimension(500, 950)
panelWest.preferredSize = Dimension(525, 950)
add(scrollPane, BorderLayout.WEST)

val lblRules = makeTitleLabel("The Rules")
lblRules.icon = ImageIcon(javaClass.getResource("/buttons/gameReport.png"))
panelWest.add(lblRules, "cell 0 0, growx")

panelWest.add(makeDivider(), "cell 0 1, alignx center")
Expand Down Expand Up @@ -102,10 +103,10 @@ class TutorialPanel(private val parent: DartsGameScreen) :
panelSouth.add(btnConfirm)
panelSouth.add(btnReset)
btnConfirm.preferredSize = Dimension(80, 80)
btnConfirm.icon = ImageIcon(javaClass.getResource("/buttons/Confirm.png"))
btnConfirm.icon = ResourceCache.ICON_CONFIRM
btnConfirm.toolTipText = "Confirm round"
btnReset.preferredSize = Dimension(80, 80)
btnReset.icon = ImageIcon(javaClass.getResource("/buttons/Reset.png"))
btnReset.icon = ResourceCache.ICON_RESET
btnReset.toolTipText = "Reset round"
btnConfirm.isEnabled = false
btnReset.isEnabled = false
Expand Down Expand Up @@ -140,38 +141,44 @@ class TutorialPanel(private val parent: DartsGameScreen) :

private fun makeTextPane() =
makeTransparentTextPane().apply {
font = ResourceCache.UNICODE_FONT
font = ResourceCache.BASE_FONT
setFontSize(24)
border = EmptyBorder(10, 5, 20, 5)
}

private fun makeTitleLabel(text: String) =
JLabel(text).apply {
font = ResourceCache.UNICODE_FONT
font = ResourceCache.BASE_FONT
border = EmptyBorder(10, 10, 10, 0)
horizontalAlignment = SwingConstants.CENTER
setFontSize(30)
}

private fun makeRulesPane() =
makeTextPane().apply {
append("\uD83D\uDCC9 Score down from 301. First to hit 0 wins.")
insertComponent(makeIconLabel(ResourceCache.ICON_GRAPH_DECREASING))
append(" Score down from 301. First to hit 0 wins.")
append("\n\n")
append("\uD83C\uDFAF You must finish")
insertComponent(makeIconLabel(ResourceCache.ICON_CALCULATOR))
append(" You must finish")
append(" exactly", bold = true)
append(" - score too much and you'll lose your score for the round!")
append("\n\n")
append(
"\uD83D\uDDB1\uFE0F Input your score by clicking on the Dartboard. Use the ✅ to confirm."
)
insertComponent(makeIconLabel(ResourceCache.ICON_DARTBOARD))
append(" Input your score by clicking on the Dartboard. Use the ")
insertComponent(makeIconLabel(ResourceCache.ICON_CONFIRM))
append(" to confirm.")
append("\n\n")
append("❎ Use the reset button if you mis-click.")
insertComponent(makeIconLabel(ResourceCache.ICON_RESET))
append(" Use the reset button if you mis-click.")
}

private fun makeIconLabel(icon: ImageIcon) = JLabel(icon).also { it.alignmentY = 0.65f }

private fun makeDivider() =
JSeparator(SwingConstants.HORIZONTAL).apply {
border = EmptyBorder(10, 0, 10, 0)
preferredSize = Dimension(200, 2)
border = EmptyBorder(10, 0, 5, 0)
preferredSize = Dimension(240, 2)
}

override fun actionPerformed(e: ActionEvent?) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/dartzee/screen/sync/SyncManagementPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SyncManagementPanel : JPanel(), ActionListener {
layout = BorderLayout(0, 0)
add(panelMainOptions, BorderLayout.CENTER)
btnPerformSync.icon = ImageIcon(javaClass.getResource("/buttons/sync.png"))
btnReset.icon = ImageIcon(javaClass.getResource("/buttons/Reset.png"))
btnReset.icon = ResourceCache.ICON_RESET
btnPull.icon = ImageIcon(javaClass.getResource("/buttons/pull.png"))
btnPush.icon = ImageIcon(javaClass.getResource("/buttons/push.png"))

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/dartzee/utils/ApplicationConstants.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package dartzee.utils

const val DARTS_VERSION_NUMBER = "v7.1.0"
const val DARTS_VERSION_NUMBER = "v7.1.1"
const val DARTZEE_REPOSITORY_URL = "https://api.github.com/repos/alyssaruth/Dartzee"
const val DARTZEE_MANUAL_DOWNLOAD_URL = "https://github.com/alyssaruth/Dartzee/releases"
8 changes: 5 additions & 3 deletions src/main/kotlin/dartzee/utils/ResourceCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ object ResourceCache {
val ICON_PAUSE = ImageIcon(javaClass.getResource("/buttons/pause.png"))
val ICON_STATS_LARGE = ImageIcon(javaClass.getResource("/buttons/stats_large.png"))
val ICON_TEAMS = ImageIcon(javaClass.getResource("/buttons/teams.png"))
val ICON_RESET = ImageIcon(javaClass.getResource("/buttons/Reset.png"))
val ICON_CONFIRM = ImageIcon(javaClass.getResource("/buttons/Confirm.png"))
val ICON_GRAPH_DECREASING = ImageIcon(javaClass.getResource("/icons/graph_decreasing.png"))
val ICON_DARTBOARD = ImageIcon(javaClass.getResource("/icons/dartboard.png"))
val ICON_CALCULATOR = ImageIcon(javaClass.getResource("/icons/calculator_large.png"))

val AVATAR_UNSET = ImageIcon(PlayerAvatar::class.java.getResource("/avatars/Unset.png"))

Expand Down Expand Up @@ -89,9 +94,6 @@ object ResourceCache {
val BASE_FONT: Font =
Font.createFont(Font.TRUETYPE_FONT, javaClass.getResourceAsStream("/trebuc.ttf"))

val UNICODE_FONT: Font =
Font.createFont(Font.TRUETYPE_FONT, javaClass.getResourceAsStream("/arialunicode.ttf"))

private val wavPoolLock = Any()
private val hmWavToInputStreams = HashMapList<String, AudioInputStream>()

Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
--------- v7.1.1 ---------

+ Tutorial for party mode
= Other party mode tweaks
= 93.6% test coverage (14349 / 15330 lines covered by 2447 tests)

--------- v7.1.0 ---------

+ Option to not have to finish on a double in X01
Expand Down
Binary file removed src/main/resources/arialunicode.ttf
Binary file not shown.
Binary file added src/main/resources/icons/calculator_large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/icons/dartboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/icons/graph_decreasing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ccce78b

Please sign in to comment.