Skip to content

Commit

Permalink
more fixes/improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssaruth committed Aug 19, 2024
1 parent ad608dc commit 0bc7bd0
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 36 deletions.
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/FundamentalsGlossary.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import util.EntropyColour
import util.Registry

class FundamentalsGlossary : HelpPanel(), Registry {
override val panelName = "FundamentalsGlossary"
override val nodeName = "Glossary"

private val title = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/FundamentalsTheDeck.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import util.Registry

class FundamentalsTheDeck : HelpPanel(), Registry {
override val nodeName = "The Deck"
override val panelName = "FundamentalsTheDeck"

private var clubString = "clubs (<font color = \"black\">\u2663</font>)"
private var diamondString = "diamonds (<font color=\"red\">\u2666</font>)"
Expand Down
21 changes: 10 additions & 11 deletions client/src/main/kotlin/help/HelpPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import utils.getAllChildComponentsForType

/** Object representing a 'page' of the help dialog. */
abstract class HelpPanel : JPanel() {
abstract val panelName: String
abstract val nodeName: String

protected open fun searchTermsToExclude(): List<String> {
Expand Down Expand Up @@ -186,21 +185,21 @@ abstract class HelpPanel : JPanel() {
val helpDialog = ScreenCache.getHelpDialog()

if (keyWord.startsWith("bidd")) {
if (panelName.contains("Entropy")) {
helpDialog.setSelectionForWord("RulesEntropyBidding")
} else if (panelName.contains("Vectropy")) {
helpDialog.setSelectionForWord("RulesVectropyBidding")
if (javaClass.simpleName.contains("Entropy")) {
helpDialog.selectPane<RulesEntropyBidding>()
} else if (javaClass.simpleName.contains("Vectropy")) {
helpDialog.selectPane<RulesVectropyBidding>()
}
} else if (keyWord.startsWith("chall")) {
if (panelName.contains("Entropy")) {
helpDialog.setSelectionForWord("RulesEntropyChallenging")
} else if (panelName.contains("Vectropy")) {
helpDialog.setSelectionForWord("RulesVectropyChallenging")
if (javaClass.simpleName.contains("Entropy")) {
helpDialog.selectPane<RulesEntropyChallenging>()
} else if (javaClass.simpleName.contains("Vectropy")) {
helpDialog.selectPane<RulesVectropyChallenging>()
}
} else if (keyWord == "order") {
helpDialog.setSelectionForWord("FundamentalsTheDeck")
helpDialog.selectPane<FundamentalsTheDeck>()
} else if (keyWord == "perfect") {
helpDialog.setSelectionForWord("FundamentalsGlossary")
helpDialog.selectPane<FundamentalsGlossary>()
}
}

Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/MiscBugReport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import util.EntropyColour

class MiscBugReport : HelpPanel() {
override val nodeName = "Bug Report"
override val panelName = "MiscBugReport"

private val title = JTextPane()
private val paneIntro = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/MiscCheatCodes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import util.EntropyColour

class MiscCheatCodes : HelpPanel() {
override val nodeName = "Cheat Codes"
override val panelName = "MiscCheatCodes"

private val title = JTextPane()
private val paneIntro = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/MiscClearingSaveData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import util.EntropyColour

class MiscClearingSaveData : HelpPanel() {
override val nodeName = "Clearing Data"
override val panelName = "MiscClearingSaveData"

private val title = JTextPane()
private val paneIntro = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/RulesEntropyBidding.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import util.EntropyColour

class RulesEntropyBidding : HelpPanel() {
override val nodeName = "Bidding"
override val panelName = "RulesEntropyBidding"

private val title = JTextPane()
private val paneOne = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/RulesEntropyChallenging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import util.EntropyColour

class RulesEntropyChallenging : HelpPanel() {
override val nodeName = "Challenging"
override val panelName = "RulesEntropyChallenging"

private val title = JTextPane()
private val paneOne = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/RulesEntropyIntroduction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import util.EntropyColour

class RulesEntropyIntroduction : HelpPanel() {
override val nodeName = "Introduction"
override val panelName = "RulesEntropyIntroduction"

private val title = JTextPane()
private val paneOne = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/RulesIllegal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import util.EntropyColour

class RulesIllegal : HelpPanel() {
override val nodeName = "Illegal!"
override val panelName = "RulesIllegal"

private val title = JTextPane()
private val paneOne = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/RulesVectropyBidding.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import util.Registry

class RulesVectropyBidding : HelpPanel(), Registry {
override val nodeName = "Bidding"
override val panelName = "RulesVectropyBidding"

private val title = JTextPane()
private val paneOne = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/RulesVectropyChallenging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import util.EntropyColour

class RulesVectropyChallenging : HelpPanel() {
override val nodeName = "Challenging"
override val panelName = "RulesVectropyChallenging"

private val title = JTextPane()
private val paneOne = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/RulesVectropyIntroduction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import util.EntropyColour

class RulesVectropyIntroduction : HelpPanel() {
override val nodeName = "Introduction"
override val panelName = "RulesVectropyIntroduction"

private val title = JTextPane()
private val paneOne = JTextPane()
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/ToolsGameplaySettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import util.Registry

class ToolsGameplaySettings : HelpPanel(), Registry {
override val nodeName = "Gameplay Settings"
override val panelName = "ToolsGameplaySettings"

private val title = JTextPane()
private val bulletThree = JLabel("")
Expand Down
1 change: 0 additions & 1 deletion client/src/main/kotlin/help/ToolsReplayViewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import util.EntropyColour

class ToolsReplayViewer : HelpPanel() {
override val nodeName = "Replay Viewer"
override val panelName = "ToolsReplayViewer"

private val title = JTextPane()
private val lblReplayTable = JLabel("")
Expand Down
25 changes: 14 additions & 11 deletions client/src/main/kotlin/screen/HelpDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,11 @@ class HelpDialog : JFrame(), TreeSelectionListener, WindowListener, Registry {
tree.selectionModel.selectionMode = TreeSelectionModel.SINGLE_TREE_SELECTION
tree.addTreeSelectionListener(this)

val count = tree.rowCount

if (count == 1) {
if (root.childCount == 0) {
treePane.setViewportView(noSearchResults)
helpPane.setViewportView(JPanel())
} else {
for (i in 0 ..< tree.rowCount) {
for (i in 0 ..< 50) {
tree.expandRow(i)
}

Expand Down Expand Up @@ -326,28 +324,33 @@ class HelpDialog : JFrame(), TreeSelectionListener, WindowListener, Registry {
}
}

fun setSelectionForWord(word: String) {
inline fun <reified T : HelpPanel> selectPane() {
selectPane(T::class.java)
}

fun <T : HelpPanel> selectPane(clazz: Class<T>) {
searchBox.text = ""
refreshNodes("")
val children = root.children()
setSelectionForWordRecursively(children, word)
selectPaneRecursively(children, clazz)
}

private fun setSelectionForWordRecursively(nodes: Enumeration<TreeNode>, word: String) {
private fun <T : HelpPanel> selectPaneRecursively(
nodes: Enumeration<TreeNode>,
clazz: Class<T>
) {
while (nodes.hasMoreElements()) {
val node = nodes.nextElement() as DefaultMutableTreeNode
if (node.isLeaf) {
val panel = node.userObject as HelpPanel
val panelName = panel.panelName
if (panelName == word) {
if (node.userObject.javaClass == clazz) {
val model = tree.model as DefaultTreeModel
val nodePath = model.getPathToRoot(node)
tree.selectionPath = TreePath(nodePath)
break
}
} else {
val children = node.children()
setSelectionForWordRecursively(children, word)
selectPaneRecursively(children, clazz)
}
}
}
Expand Down

0 comments on commit 0bc7bd0

Please sign in to comment.