aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/gui
diff options
context:
space:
mode:
authorJ10a1n15 <45315647+j10a1n15@users.noreply.github.com>2024-03-28 10:07:10 +0100
committerGitHub <noreply@github.com>2024-03-28 10:07:10 +0100
commit0beb9e3b3132bcc14c99759628732625ee97d6a8 (patch)
tree314ec7c1904072821d067f6ce36242615466c13e /src/main/java/at/hannibal2/skyhanni/features/gui
parent78ede4944f463fd2f0ac3715d68c3c6530c3f09e (diff)
downloadskyhanni-0beb9e3b3132bcc14c99759628732625ee97d6a8.tar.gz
skyhanni-0beb9e3b3132bcc14c99759628732625ee97d6a8.tar.bz2
skyhanni-0beb9e3b3132bcc14c99759628732625ee97d6a8.zip
Improvement: Reordered Custom Scoreboard Config (#1294)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/gui')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt50
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt36
4 files changed, 66 insertions, 34 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt
index b9ad9960e..37e2a2098 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboard.kt
@@ -52,7 +52,7 @@ class CustomScoreboard {
RenderBackground().renderBackground()
val render =
- if (!TabListData.fullyLoaded && config.displayConfig.cacheScoreboardOnIslandSwitch && cache.isNotEmpty()) {
+ if (!TabListData.fullyLoaded && displayConfig.cacheScoreboardOnIslandSwitch && cache.isNotEmpty()) {
cache
} else {
display
@@ -67,7 +67,6 @@ class CustomScoreboard {
@SubscribeEvent
fun onGuiPositionMoved(event: GuiPositionMovedEvent) {
if (event.guiName == guiName) {
- val alignmentConfig = config.displayConfig.alignment
if (alignmentConfig.alignRight || alignmentConfig.alignCenterVertically) {
alignmentConfig.alignRight = false
alignmentConfig.alignCenterVertically = false
@@ -94,10 +93,16 @@ class CustomScoreboard {
companion object {
internal val config get() = SkyHanniMod.feature.gui.customScoreboard
- internal val displayConfig get() = config.displayConfig
- internal val eventsConfig get() = displayConfig.eventsConfig
- internal val informationFilteringConfig get() = config.informationFilteringConfig
- internal val backgroundConfig get() = config.backgroundConfig
+ internal val displayConfig get() = config.display
+ internal val alignmentConfig get() = displayConfig.alignment
+ internal val arrowConfig get() = displayConfig.arrow
+ internal val eventsConfig get() = displayConfig.events
+ internal val mayorConfig get() = displayConfig.mayor
+ internal val partyConfig get() = displayConfig.party
+ internal val maxwellConfig get() = displayConfig.maxwell
+ internal val informationFilteringConfig get() = config.informationFiltering
+ internal val backgroundConfig get() = config.background
+ internal val devConfig get() = SkyHanniMod.feature.dev
}
private fun createLines() = buildList<ScoreboardElementType> {
@@ -129,7 +134,7 @@ class CustomScoreboard {
}
private fun List<ScoreboardElementType>.removeEmptyLinesFromEdges(): List<ScoreboardElementType> {
- if (config.informationFilteringConfig.hideEmptyLinesAtTopAndBottom) {
+ if (config.informationFiltering.hideEmptyLinesAtTopAndBottom) {
return this
.dropWhile { it.first.isEmpty() }
.dropLastWhile { it.first.isEmpty() }
@@ -164,16 +169,39 @@ class CustomScoreboard {
}
private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled
- private fun isHideVanillaScoreboardEnabled() = isEnabled() && config.displayConfig.hideVanillaScoreboard
+ private fun isHideVanillaScoreboardEnabled() = isEnabled() && displayConfig.hideVanillaScoreboard
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
- val prefix = "gui.customScoreboard.displayConfig"
- event.move(28, "$prefix.showAllActiveEvents", "$prefix.eventsConfig.showAllActiveEvents")
- event.transform(30, "$prefix.eventsConfig.eventEntries") { element ->
+ val prefix = "gui.customScoreboard"
+ val displayConfigPrefix = "$prefix.displayConfig"
+ val displayPrefix = "$prefix.display"
+ event.move(28, "$prefix.displayConfig.showAllActiveEvents", "$prefix.displayConfig.eventsConfig.showAllActiveEvents")
+ event.transform(30, "$prefix.displayConfig.eventsConfig.eventEntries") { element ->
val array = element.asJsonArray
array.add(JsonPrimitive(ScoreboardEvents.HOT_DOG_CONTEST.name))
array
}
+
+ event.move(31, "$displayConfigPrefix.arrowAmountDisplay", "$displayPrefix.arrow.amountDisplay")
+ event.move(31, "$displayConfigPrefix.colorArrowAmount", "$displayPrefix.arrow.colorArrowAmount")
+ event.move(31, "$displayConfigPrefix.showMagicalPower", "$displayPrefix.maxwell.showMagicalPower")
+ event.move(31, "$displayConfigPrefix.compactTuning", "$displayPrefix.maxwell.compactTuning")
+ event.move(31, "$displayConfigPrefix.tuningAmount", "$displayPrefix.maxwell.tuningAmount")
+ event.move(31, "$displayConfigPrefix.hideVanillaScoreboard", "$displayPrefix.hideVanillaScoreboard")
+ event.move(31, "$displayConfigPrefix.displayNumbersFirst", "$displayPrefix.displayNumbersFirst")
+ event.move(31, "$displayConfigPrefix.showUnclaimedBits", "$displayPrefix.showUnclaimedBits")
+ event.move(31, "$displayConfigPrefix.showMaxIslandPlayers", "$displayPrefix.showMaxIslandPlayers")
+ event.move(31, "$displayConfigPrefix.numberFormat", "$displayPrefix.numberFormat")
+ event.move(31, "$displayConfigPrefix.lineSpacing", "$displayPrefix.lineSpacing")
+ event.move(31, "$displayConfigPrefix.cacheScoreboardOnIslandSwitch", "$displayPrefix.cacheScoreboardOnIslandSwitch")
+ // Categories
+ event.move(31, "$displayConfigPrefix.alignment", "$displayPrefix.alignment")
+ event.move(31, "$displayConfigPrefix.titleAndFooter", "$displayPrefix.titleAndFooter")
+ event.move(31, "$prefix.backgroundConfig", "$prefix.background")
+ event.move(31, "$prefix.informationFilteringConfig", "$prefix.informationFiltering")
+ event.move(31, "$displayConfigPrefix.eventsConfig", "$displayPrefix.events")
+ event.move(31, "$prefix.mayorConfig", "$displayPrefix.mayor")
+ event.move(31, "$prefix.partyConfig", "$displayPrefix.party")
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt
index 74ba89dd6..d93e40503 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/CustomScoreboardUtils.kt
@@ -4,7 +4,7 @@ import at.hannibal2.skyhanni.config.features.gui.customscoreboard.DisplayConfig
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.features.bingo.BingoAPI
-import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.config
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.displayConfig
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble
@@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.utils.TabListData
import java.util.regex.Pattern
object CustomScoreboardUtils {
- private val numberFormat get() = config.displayConfig.numberFormat
internal fun getGroupFromPattern(list: List<String>, pattern: Pattern, group: String) = list.map {
it.removeResets().trimWhiteSpace()
@@ -41,7 +40,7 @@ object CustomScoreboardUtils {
return tabList.footer_skyhanni.formattedText.replace("§r", "")
}
- internal fun Number.formatNum(): String = when (numberFormat) {
+ internal fun Number.formatNum(): String = when (displayConfig.numberFormat) {
DisplayConfig.NumberFormat.SHORT -> NumberUtil.format(this)
DisplayConfig.NumberFormat.LONG -> this.addSeparators()
else -> "0"
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt
index c110e7cf1..5cd86d99e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/RenderBackground.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.GuiEditManager
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsX
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getAbsY
import at.hannibal2.skyhanni.data.GuiEditManager.Companion.getDummySize
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.alignmentConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.backgroundConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.config
import at.hannibal2.skyhanni.utils.RenderUtils
@@ -32,15 +33,15 @@ class RenderBackground {
// Update the position to the alignment options
if (
- config.displayConfig.alignment.alignRight
- || config.displayConfig.alignment.alignCenterVertically
+ alignmentConfig.alignRight
+ || alignmentConfig.alignCenterVertically
) {
position.set(
Position(
- if (config.displayConfig.alignment.alignRight)
+ if (alignmentConfig.alignRight)
scaledWidth - elementWidth - (border * 2)
else x,
- if (config.displayConfig.alignment.alignCenterVertically)
+ if (alignmentConfig.alignCenterVertically)
scaledHeight / 2 - elementHeight / 2
else y,
position.getScale(),
diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt
index 6502b8f74..2800df6aa 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt
@@ -1,6 +1,6 @@
package at.hannibal2.skyhanni.features.gui.customscoreboard
-import at.hannibal2.skyhanni.config.features.gui.customscoreboard.DisplayConfig.ArrowAmountDisplay
+import at.hannibal2.skyhanni.config.features.gui.customscoreboard.ArrowConfig.ArrowAmountDisplay
import at.hannibal2.skyhanni.data.BitsAPI
import at.hannibal2.skyhanni.data.HypixelData
import at.hannibal2.skyhanni.data.HypixelData.Companion.getMaxPlayersForCurrentServer
@@ -15,9 +15,13 @@ import at.hannibal2.skyhanni.data.QuiverAPI.NONE_ARROW_TYPE
import at.hannibal2.skyhanni.data.QuiverAPI.asArrowPercentage
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.data.SlayerAPI
-import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.config
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.arrowConfig
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.devConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.displayConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.informationFilteringConfig
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.maxwellConfig
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.mayorConfig
+import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.Companion.partyConfig
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.formatNum
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboardUtils.getGroupFromPattern
import at.hannibal2.skyhanni.test.command.ErrorManager
@@ -28,10 +32,10 @@ import at.hannibal2.skyhanni.utils.LorenzUtils.inDungeons
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.NumberUtil.percentageColor
import at.hannibal2.skyhanni.utils.RenderUtils.HorizontalAlignment
-import at.hannibal2.skyhanni.utils.StringUtils
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.StringUtils.pluralize
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.TimeUtils.format
import at.hannibal2.skyhanni.utils.TimeUtils.formatted
@@ -537,7 +541,7 @@ private fun getLobbyDisplayPair(): List<ScoreboardElementType> {
private fun getPowerDisplayPair() = listOf(
(MaxwellAPI.currentPower?.let {
- val mp = if (displayConfig.showMagicalPower) "§7(§6${MaxwellAPI.magicalPower?.addSeparators()}§7)" else ""
+ val mp = if (maxwellConfig.showMagicalPower) "§7(§6${MaxwellAPI.magicalPower?.addSeparators()}§7)" else ""
val name = it.replace(" Power", "")
if (displayConfig.displayNumbersFirst) {
"§a$name Power $mp"
@@ -552,8 +556,8 @@ private fun getTuningDisplayPair(): List<Pair<String, HorizontalAlignment>> {
val tunings = MaxwellAPI.tunings ?: return listOf("§cTalk to \"Maxwell\"!" to HorizontalAlignment.LEFT)
if (tunings.isEmpty()) return listOf("§cNo Maxwell Tunings :(" to HorizontalAlignment.LEFT)
- val title = StringUtils.pluralize(tunings.size, "Tuning", "Tunings")
- return if (displayConfig.compactTuning) {
+ val title = pluralize(tunings.size, "Tuning", "Tunings")
+ return if (maxwellConfig.compactTuning) {
val tuning = tunings
.take(3)
.joinToString("§7, ") { tuning ->
@@ -575,7 +579,7 @@ private fun getTuningDisplayPair(): List<Pair<String, HorizontalAlignment>> {
)
} else {
val tuning = tunings
- .take(displayConfig.tuningAmount.coerceAtLeast(1))
+ .take(maxwellConfig.tuningAmount.coerceAtLeast(1))
.map { tuning ->
with(tuning) {
" §7- §f" + if (displayConfig.displayNumbersFirst) {
@@ -663,14 +667,14 @@ private fun getQuiverDisplayPair(): List<ScoreboardElementType> {
if (QuiverAPI.currentArrow == NONE_ARROW_TYPE)
return listOf("No Arrows selected" to HorizontalAlignment.LEFT)
- val amountString = (if (displayConfig.colorArrowAmount) {
+ val amountString = (if (arrowConfig.colorArrowAmount) {
percentageColor(
QuiverAPI.currentAmount.toLong(),
QuiverAPI.MAX_ARROW_AMOUNT.toLong()
).getChatColor()
} else {
""
- }) + when (displayConfig.arrowAmountDisplay) {
+ }) + when (arrowConfig.arrowAmountDisplay) {
ArrowAmountDisplay.NUMBER -> QuiverAPI.currentAmount.addSeparators()
ArrowAmountDisplay.PERCENTAGE -> "${QuiverAPI.currentAmount.asArrowPercentage()}%"
else -> QuiverAPI.currentAmount.addSeparators()
@@ -751,13 +755,13 @@ private fun getMayorDisplayPair() = buildList {
add(
((MayorAPI.currentMayor?.mayorName?.let { MayorAPI.mayorNameWithColorCode(it) }
?: "<hidden>") +
- (if (config.mayorConfig.showTimeTillNextMayor) {
+ (if (mayorConfig.showTimeTillNextMayor) {
"§7 (§e${MayorAPI.timeTillNextMayor.format(maxUnits = 2)}§7)"
} else {
""
})) to HorizontalAlignment.LEFT
)
- if (config.mayorConfig.showMayorPerks) {
+ if (mayorConfig.showMayorPerks) {
MayorAPI.currentMayor?.activePerks?.forEach {
add(" §7- §e${it.perkName}" to HorizontalAlignment.LEFT)
}
@@ -774,7 +778,7 @@ private fun getPartyDisplayPair() =
val title =
if (PartyAPI.partyMembers.isEmpty()) "§9§lParty" else "§9§lParty (${PartyAPI.partyMembers.size})"
val partyList = PartyAPI.partyMembers
- .take(config.partyConfig.maxPartyList.get())
+ .take(partyConfig.maxPartyList.get())
.map {
" §7- §f$it"
}
@@ -785,7 +789,7 @@ private fun getPartyDisplayPair() =
private fun getPartyShowWhen() = if (inDungeons) {
false // Hidden bc the scoreboard lines already exist
} else {
- if (config.partyConfig.showPartyEverywhere) {
+ if (partyConfig.showPartyEverywhere) {
true
} else {
inAnyIsland(
@@ -804,10 +808,10 @@ private fun getFooterDisplayPair() = listOf(
private fun getExtraDisplayPair(): List<ScoreboardElementType> {
if (unknownLines.isEmpty()) return listOf("<hidden>" to HorizontalAlignment.LEFT)
- if (amountOfUnknownLines != unknownLines.size && config.unknownLinesWarning) {
+ if (amountOfUnknownLines != unknownLines.size && devConfig.unknownLinesWarning) {
ErrorManager.logErrorWithData(
- CustomScoreboardUtils.UndetectedScoreboardLines("CustomScoreboard detected ${unknownLines.size} unknown line${if (unknownLines.size > 1) "s" else ""}"),
- "CustomScoreboard detected ${unknownLines.size} unknown line${if (unknownLines.size > 1) "s" else ""}",
+ CustomScoreboardUtils.UndetectedScoreboardLines("CustomScoreboard detected ${pluralize(unknownLines.size, "unknown line", withNumber = true)}"),
+ "CustomScoreboard detected ${pluralize(unknownLines.size, "unknown line", withNumber = true)}",
"Unknown Lines" to unknownLines,
"Island" to HypixelData.skyBlockIsland,
"Area" to HypixelData.skyBlockArea,