Skip to content

Commit

Permalink
BetterMap-style dungeon score estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
Ownwn committed Jun 15, 2024
1 parent 039cb1b commit 8605fc5
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 50 deletions.
19 changes: 15 additions & 4 deletions src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,25 @@ object Config : Vigilant(
var showScoreCalculation = false

@Property(
type = PropertyType.SWITCH, name = "Minimized Dungeon Score Estimate",
description = "Only shows the dungeon score.",
type = PropertyType.SELECTOR, name = "Dungeon Score Estimate Style",
description = "Change the style of the Score Estimate",
category = "Dungeons", subcategory = "Score Calculation",
i18nName = "skytils.config.dungeons.score_calculation.minimized_dungeon_score_estimate",
options = ["Standard", "Minimized", "Bettermap"],
i18nName = "skytils.config.dungeons.score_calculation.dungeon_score_estimate_style",
i18nCategory = "skytils.config.dungeons",
i18nSubcategory = "skytils.config.dungeons.score_calculation"
)
var minimizedScoreCalculation = false
var scoreCalculationStyle = 0

@Property(
type = PropertyType.SWITCH, name = "Hide Score Estimate In Boss",
description = "Hides the score estimate when in a dungeon boss room",
category = "Dungeons", subcategory = "Score Calculation",
i18nName = "skytils.config.dungeons.score_calculation.hide_score_estimate_in_boss",
i18nCategory = "skytils.config.dungeons",
i18nSubcategory = "skytils.config.dungeons.score_calculation"
)
var hideScoreEstimateBoss = false

@Property(
type = PropertyType.SWITCH, name = "Score Calculation Party Assist",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,48 +260,62 @@ object ScoreCalculation {
Utils.checkThreadAndQueue {
ScoreCalculationElement.text.clear()
if (!Utils.inDungeons) return@checkThreadAndQueue
if (Skytils.config.minimizedScoreCalculation) {
val color = when {
score < 270 -> 'c'
score < 300 -> 'e'
else -> 'a'
}
ScoreCalculationElement.text.add("§eScore: §$color$score §7($rank§7)")
} else {
ScoreCalculationElement.text.add("§9Dungeon Status")
ScoreCalculationElement.text.add("§f• §eDeaths:§c ${deaths.get()} ${if (firstDeathHadSpirit.get()) "§7(§6Spirit§7)" else ""}")
ScoreCalculationElement.text.add("§f• §eMissing Puzzles:§c ${missingPuzzles.get()}")
ScoreCalculationElement.text.add("§f• §eFailed Puzzles:§c ${failedPuzzles.get()}")
if (foundSecrets.get() > 0) ScoreCalculationElement.text.add(
"§f• §eSecrets: ${if (foundSecrets.get() >= totalSecretsNeeded.get()) "§a" else "§c"}${foundSecrets.get()}§7/§a${totalSecretsNeeded.get()} " +
if (floorReq.get().secretPercentage != 1.0) "§7(§6Total: ${totalSecrets.get()}§7)" else ""
)
ScoreCalculationElement.text.add("§f• §eCrypts:§a ${crypts.get()}")
if (dungeonFloorNumber?.let { it >= 6 } == true) {
ScoreCalculationElement.text.add("§f• §eMimic:§l${if (mimicKilled.get()) "§a ✔" else "§c ✘"}")

when (Skytils.config.scoreCalculationStyle) {
2 -> { // bm style
val scoreColor = when {
totalScore.get() < 270 -> "§c"
totalScore.get() < 300 -> "§e"
else -> "§a"
}

val cryptColor = if (crypts.get() >= 5) "§a" else "§c"

ScoreCalculationElement.text.add("$scoreColor${totalScore.get()} $cryptColor${crypts.get()}c ${if (mimicKilled.get()) "§a✔" else "§c✘"}")
}
ScoreCalculationElement.text.add("")
ScoreCalculationElement.text.add("§6Score")
if (DungeonFeatures.dungeonFloor == "E")
ScoreCalculationElement.text.add("§f• §eSkill Score:§a ${skillScore.get().coerceIn(14, 70)}")
else
ScoreCalculationElement.text.add("§f• §eSkill Score:§a ${skillScore.get().coerceIn(20, 100)}")
ScoreCalculationElement.text.add(
"§f• §eExplore Score:§a ${discoveryScore.get()} §7(§e${
roomClearScore.get().toInt()
} §7+ §6${secretScore.get().toInt()}§7)"
)
ScoreCalculationElement.text.add("§f• §eSpeed Score:§a ${speedScore.get()}")

if (DungeonFeatures.dungeonFloor == "E") {
ScoreCalculationElement.text.add("§f• §eBonus Score:§a ${(bonusScore.get() * 0.7).toInt()}")
ScoreCalculationElement.text.add("§f• §eTotal Score:§a $score" + if (isPaul.get()) " §7(§6+7§7)" else "")
} else {
ScoreCalculationElement.text.add("§f• §eBonus Score:§a ${bonusScore.get()}")
ScoreCalculationElement.text.add("§f• §eTotal Score:§a $score" + if (isPaul.get()) " §7(§6+10§7)" else "")
1 -> { // minimized style
val color = when {
score < 270 -> 'c'
score < 300 -> 'e'
else -> 'a'
}
ScoreCalculationElement.text.add("§eScore: §$color$score §7($rank§7)")
}
ScoreCalculationElement.text.add("§f• §eRank: $rank")
else -> { // standard style
ScoreCalculationElement.text.add("§9Dungeon Status")
ScoreCalculationElement.text.add("§f• §eDeaths:§c ${deaths.get()} ${if (firstDeathHadSpirit.get()) "§7(§6Spirit§7)" else ""}")
ScoreCalculationElement.text.add("§f• §eMissing Puzzles:§c ${missingPuzzles.get()}")
ScoreCalculationElement.text.add("§f• §eFailed Puzzles:§c ${failedPuzzles.get()}")
if (foundSecrets.get() > 0) ScoreCalculationElement.text.add(
"§f• §eSecrets: ${if (foundSecrets.get() >= totalSecretsNeeded.get()) "§a" else "§c"}${foundSecrets.get()}§7/§a${totalSecretsNeeded.get()} " +
if (floorReq.get().secretPercentage != 1.0) "§7(§6Total: ${totalSecrets.get()}§7)" else ""
)
ScoreCalculationElement.text.add("§f• §eCrypts:§a ${crypts.get()}")
if (dungeonFloorNumber?.let { it >= 6 } == true) {
ScoreCalculationElement.text.add("§f• §eMimic:§l${if (mimicKilled.get()) "§a ✔" else "§c ✘"}")
}
ScoreCalculationElement.text.add("")
ScoreCalculationElement.text.add("§6Score")
if (DungeonFeatures.dungeonFloor == "E")
ScoreCalculationElement.text.add("§f• §eSkill Score:§a ${skillScore.get().coerceIn(14, 70)}")
else
ScoreCalculationElement.text.add("§f• §eSkill Score:§a ${skillScore.get().coerceIn(20, 100)}")
ScoreCalculationElement.text.add(
"§f• §eExplore Score:§a ${discoveryScore.get()} §7(§e${
roomClearScore.get().toInt()
} §7+ §6${secretScore.get().toInt()}§7)"
)
ScoreCalculationElement.text.add("§f• §eSpeed Score:§a ${speedScore.get()}")

if (DungeonFeatures.dungeonFloor == "E") {
ScoreCalculationElement.text.add("§f• §eBonus Score:§a ${(bonusScore.get() * 0.7).toInt()}")
ScoreCalculationElement.text.add("§f• §eTotal Score:§a $score" + if (isPaul.get()) " §7(§6+7§7)" else "")
} else {
ScoreCalculationElement.text.add("§f• §eBonus Score:§a ${bonusScore.get()}")
ScoreCalculationElement.text.add("§f• §eTotal Score:§a $score" + if (isPaul.get()) " §7(§6+10§7)" else "")
}
ScoreCalculationElement.text.add("§f• §eRank: $rank")
}
}
}
}
Expand Down Expand Up @@ -533,16 +547,18 @@ object ScoreCalculation {
class ScoreCalculationElement : GuiElement("Dungeon Score Estimate", x = 200, y = 100) {
override fun render() {
if (toggled && Utils.inDungeons) {
if (Skytils.config.hideScoreEstimateBoss && DungeonTimer.bossEntryTime != -1L) return // don't render in boss (config)
RenderUtil.drawAllInList(this, text)
}
}

override fun demoRender() {
if (Skytils.config.minimizedScoreCalculation) {
RenderUtil.drawAllInList(this, demoMin)
} else {
RenderUtil.drawAllInList(this, demoText)
val scoreStyle = when (Skytils.config.scoreCalculationStyle) {
2 -> demoBM
1 -> demoMin
else -> demoText
}
RenderUtil.drawAllInList(this, scoreStyle)
}

companion object {
Expand All @@ -564,13 +580,21 @@ object ScoreCalculation {
"§f• §eRank: §6§lS+"
)
private val demoMin = listOf("§eScore: §e300 §7(§6§lS+§7)")
private val demoBM = listOf("§a301 §c4c §a✔")
val text = ArrayList<String>()
}

override val height: Int
get() = if (Skytils.config.minimizedScoreCalculation) ScreenRenderer.fontRenderer.FONT_HEIGHT else ScreenRenderer.fontRenderer.FONT_HEIGHT * demoText.size
get() = ScreenRenderer.fontRenderer.FONT_HEIGHT * when (Skytils.config.scoreCalculationStyle) {
0 -> demoText.size
else -> 1 // if demo is more than 1 line multiply by its size, otherwise multiply by 1
}
override val width: Int
get() = demoText.maxOf { ScreenRenderer.fontRenderer.getStringWidth(it) }
get() = (when (Skytils.config.scoreCalculationStyle) {
2 -> demoBM
1 -> demoMin
else -> demoText
}).maxOf { ScreenRenderer.fontRenderer.getStringWidth(it) }

override val toggled: Boolean
get() = Skytils.config.showScoreCalculation
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/skytils/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ skytils.config.dungeons.miscellaneous.red_screen_fix=Red Screen Fix
skytils.config.dungeons.miscellaneous.show_decimal_seconds_on_timers=Show Decimal Seconds on Timers
skytils.config.dungeons.miscellaneous.sadan_phase_timer=Sadan Phase Timer
skytils.config.dungeons.score_calculation.show_dungeon_score_estimate=Show Dungeon Score Estimate
skytils.config.dungeons.score_calculation.minimized_dungeon_score_estimate=Minimized Dungeon Score Estimate
skytils.config.dungeons.score_calculation.dungeon_score_estimate_style=Dungeon Score Estimate Style
skytils.config.dungeons.score_calculation.hide_score_estimate_in_boss=Hide Score Estimate In Boss
skytils.config.dungeons.score_calculation.score_calculation_party_assist=Score Calculation Party Assist
skytils.config.dungeons.score_calculation.receive_score_calculation_party_assist=Receive Score Calculation Party Assist
skytils.config.dungeons.score_calculation.allow_mimic_dead_from_other_mods=Allow Mimic Dead! from other Mods
Expand Down

0 comments on commit 8605fc5

Please sign in to comment.