Skip to content

Commit

Permalink
toggle and remove visible buttons for waypointgui
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Dec 23, 2021
1 parent 1322fe5 commit f3fd1ed
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ tasks {
withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn")
}
kotlinDaemonJvmArguments.set(listOf("-Xmx4G", "-Dkotlin.enableCacheBuilding=true", "-Dkotlin.useParallelTasks=true", "-Dkotlin.enableFastIncremental=true"))
kotlinDaemonJvmArguments.set(listOf("-Xmx2G", "-Dkotlin.enableCacheBuilding=true", "-Dkotlin.useParallelTasks=true", "-Dkotlin.enableFastIncremental=true"))
}
named<TaskSingleReobf>("reobfJar") {
enabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object ScoreCalculation {
"F4" to FloorRequirement(.6, 12 * 60),
"F5" to FloorRequirement(.7),
"F6" to FloorRequirement(.85, 12 * 60),
"F7" to FloorRequirement(speed = 12 * 60),
"F7" to FloorRequirement(speed = 14 * 60),
"M1" to FloorRequirement(speed = 8 * 60),
"M2" to FloorRequirement(speed = 8 * 60),
"M3" to FloorRequirement(speed = 8 * 60),
Expand Down Expand Up @@ -297,17 +297,8 @@ object ScoreCalculation {
)
val speedScore: Double
val bonusScore = (if (mimicKilled) 2 else 0) + crypts.coerceAtMost(5) + if (isPaul) 10 else 0
val countedSeconds = secondsElapsed
// no idea how speed score works soooo
speedScore = (if (countedSeconds <= floorReq.speed) {
100.0
} else if (countedSeconds < floorReq.speed + 100) {
232 - 0.1 * countedSeconds
} else if (countedSeconds < floorReq.speed + 400) {
161 - 0.05 * countedSeconds
} else if (countedSeconds < floorReq.speed + 2600) {
392 / 3f - 1 / 30f * countedSeconds
} else 0.0).coerceIn(0.0, 100.0)
speedScore = 100 - ((secondsElapsed - floorReq.speed) / 3f).coerceIn(0.0, 100.0)
if (deaths != 0) text.add("§6Deaths:§a $deaths")
if (missingPuzzles != 0) text.add("§6Missing Puzzles:§a $missingPuzzles")
if (failedPuzzles != 0) text.add("§6Failed Puzzles:§a $failedPuzzles")
Expand Down
45 changes: 44 additions & 1 deletion src/main/kotlin/skytils/skytilsmod/gui/WaypointsGui.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import skytils.skytilsmod.features.impl.handlers.Waypoints
import skytils.skytilsmod.gui.components.SimpleButton
import skytils.skytilsmod.utils.SBInfo
import skytils.skytilsmod.utils.SkyblockIsland
import skytils.skytilsmod.utils.toggle
import java.awt.Color

class WaypointsGui : WindowScreen(newGuiScale = 2), ReopenableGUI {
Expand All @@ -67,7 +68,7 @@ class WaypointsGui : WindowScreen(newGuiScale = 2), ReopenableGUI {
x = 0.pixels()
y = 5.percent()
width = 100.percent()
height = ChildBasedSizeConstraint()
height = 50.pixels()
}

islandDropdown = DropDown(SkyblockIsland.values().indexOfFirst {
Expand Down Expand Up @@ -116,6 +117,48 @@ class WaypointsGui : WindowScreen(newGuiScale = 2), ReopenableGUI {
}
}

SimpleButton("Toggle Visible").childOf(topButtons).constrain {
x = 2.pixels()
y = 20.pixels()
width = 100.pixels()
height = 20.pixels()
}.apply {
onLeftClick {
val valid = scrollComponent.allChildren.mapNotNull { c ->
c as UIContainer
val entry = entries[c] ?: error("no entry found for child")
if (entry.name.getText().contains(searchBar.getText())) return@mapNotNull entry
else return@mapNotNull null
}
if (valid.any { it.enabled.checked }) {
valid.forEach {
if (it.enabled.checked) it.enabled.toggle()
}
} else {
valid.forEach {
if (!it.enabled.checked) it.enabled.toggle()
}
}
}
}

SimpleButton("Remove Visible").childOf(topButtons).constrain {
x = 107.pixels()
y = 20.pixels()
width = 100.pixels()
height = 20.pixels()
}.apply {
onLeftClick {
scrollComponent.allChildren.forEach { c ->
c as UIContainer
val entry = entries[c] ?: error("no entry found for child")
if (entry.name.getText().contains(searchBar.getText())) {
scrollComponent.removeChild(c)
entries.remove(c)
}
}
}
}

UIText("Waypoints").childOf(window).constrain {
x = CenterConstraint()
Expand Down

0 comments on commit f3fd1ed

Please sign in to comment.