Skip to content

Commit 516f37f

Browse files
committed
Internal refactors and cleanup, added descriptions for any features missing them
1 parent d6d6035 commit 516f37f

6 files changed

Lines changed: 64 additions & 38 deletions

File tree

src/main/java/mrfast/sbt/apis/AccessoryApi.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ object AccessoryApi {
5757
private fun registerAccessories() {
5858
ItemApi.getSkyblockItems().entrySet().forEach { item ->
5959
val lore = item.value.asJsonObject?.get("lore")?.asJsonArray ?: return@forEach
60+
val line = lore.lastOrNull()?.toString() ?: return@forEach
6061

61-
if(lore.last().asString.contains("ACCESSORY")) {
62+
if(line.contains("ACCESSORY")) {
6263
val combined = JsonArray()
6364
combined.add(JsonPrimitive(item.key))
6465

src/main/java/mrfast/sbt/config/categories/GeneralConfig.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ object GeneralConfig : Config() {
101101
@ConfigProperty(
102102
type = ConfigType.TOGGLE,
103103
name = "Health Bar",
104-
description = "Moveable Health Bar that adjusts depending on absorption and damage taken",
104+
description = "Health Bar that adjusts depending on absorption and damage taken",
105105
category = "General",
106106
subcategory = "Stat Displays",
107107
isParent = true
@@ -147,7 +147,7 @@ object GeneralConfig : Config() {
147147
@ConfigProperty(
148148
type = ConfigType.TOGGLE,
149149
name = "Mana Bar",
150-
description = "Moveable Mana Bar that adjusts depending on abilities and overflow mana",
150+
description = "Mana Bar that adjusts depending on abilities and overflow mana",
151151
category = "General",
152152
subcategory = "Stat Displays",
153153
isParent = true
@@ -202,7 +202,7 @@ object GeneralConfig : Config() {
202202
@ConfigProperty(
203203
type = ConfigType.TOGGLE,
204204
name = "Drill Fuel Bar",
205-
description = "Moveable Fuel Bar that shows your drills fuel status",
205+
description = "Fuel Bar that shows your drills fuel status",
206206
category = "General",
207207
subcategory = "Stat Displays",
208208
isParent = true
@@ -230,6 +230,7 @@ object GeneralConfig : Config() {
230230
@ConfigProperty(
231231
type = ConfigType.TOGGLE,
232232
name = "Health Number",
233+
description = "Shows your current health",
233234
category = "General",
234235
subcategory = "Stat Displays",
235236
isParent = true
@@ -267,6 +268,7 @@ object GeneralConfig : Config() {
267268
@ConfigProperty(
268269
type = ConfigType.TOGGLE,
269270
name = "Speed Number",
271+
description = "Shows your current speed",
270272
category = "General",
271273
subcategory = "Stat Displays",
272274
isParent = true
@@ -276,6 +278,7 @@ object GeneralConfig : Config() {
276278
@ConfigProperty(
277279
type = ConfigType.TOGGLE,
278280
name = "Secret Number",
281+
description = "Shows the amount of secrets you have found in a dungeon room",
279282
category = "General",
280283
subcategory = "Stat Displays",
281284
isParent = true
@@ -304,6 +307,7 @@ object GeneralConfig : Config() {
304307
@ConfigProperty(
305308
type = ConfigType.TOGGLE,
306309
name = "Effective Health Number",
310+
description = "Shows your effective health, which is a combination of health + defense",
307311
category = "General",
308312
subcategory = "Stat Displays",
309313
isParent = true
@@ -331,6 +335,7 @@ object GeneralConfig : Config() {
331335
@ConfigProperty(
332336
type = ConfigType.TOGGLE,
333337
name = "Drill Fuel Number",
338+
description = "Shows the current fuel of your drill",
334339
category = "General",
335340
subcategory = "Stat Displays",
336341
isParent = true
@@ -349,6 +354,7 @@ object GeneralConfig : Config() {
349354
@ConfigProperty(
350355
type = ConfigType.TOGGLE,
351356
name = "Mana Number",
357+
description = "Shows your current and max mana",
352358
category = "General",
353359
subcategory = "Stat Displays",
354360
isParent = true
@@ -367,6 +373,7 @@ object GeneralConfig : Config() {
367373
@ConfigProperty(
368374
type = ConfigType.TOGGLE,
369375
name = "Overflow Mana Number",
376+
description = "Shows your overflow mana",
370377
category = "General",
371378
subcategory = "Stat Displays",
372379
isParent = true
@@ -385,6 +392,7 @@ object GeneralConfig : Config() {
385392
@ConfigProperty(
386393
type = ConfigType.TOGGLE,
387394
name = "Defense Number",
395+
description = "Shows your current defense",
388396
category = "General",
389397
subcategory = "Stat Displays",
390398
isParent = true

src/main/java/mrfast/sbt/features/jerryIsland/GiftHighlight.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package mrfast.sbt.features.jerryIsland
22

33
import mrfast.sbt.SkyblockTweaks
44
import mrfast.sbt.config.categories.RenderingConfig
5-
import mrfast.sbt.utils.ChatUtils
65
import mrfast.sbt.utils.ItemUtils.getSkyblockId
76
import mrfast.sbt.utils.RenderUtils
87
import mrfast.sbt.utils.Utils
@@ -14,7 +13,6 @@ import net.minecraft.util.BlockPos
1413
import net.minecraftforge.client.event.RenderWorldLastEvent
1514
import net.minecraftforge.event.entity.player.AttackEntityEvent
1615
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
17-
import java.awt.Color
1816

1917

2018
@SkyblockTweaks.EventComponent
@@ -59,6 +57,8 @@ object GiftHighlight {
5957

6058
@SubscribeEvent
6159
fun onAttack(event: AttackEntityEvent) {
60+
if(!RenderingConfig.highlightGiftLocations) return
61+
6262
if(event.target is EntityArmorStand && isGift(event.target as EntityArmorStand)) {
6363
val armorStand = event.target as EntityArmorStand
6464
val blockPos = armorStand.position.up()

src/main/java/mrfast/sbt/guis/ConfigGui.kt

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,10 @@ class ConfigGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2, drawDefaultB
492492

493493
if (!showAll && !shouldFeatureAppear(feature)) continue
494494

495-
val featureElement = createFeatureElement(feature, subcategoryComponent)
495+
// Create the feature element, containing the title, description and config type
496+
createFeatureElement(feature, subcategoryComponent)
496497

497-
if (featureElement != null) {
498-
drawnFeatures++
499-
}
498+
drawnFeatures++
500499
}
501500
// Don't draw subcategory title if no features
502501
if (drawnFeatures != 0) {
@@ -506,7 +505,7 @@ class ConfigGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2, drawDefaultB
506505
}
507506
}
508507

509-
// Populate the feature-options after all features have been created
508+
// After all features have been loaded, go back through and populate the parent features with their options
510509

511510
// Loop through all categories
512511
for (category in ConfigManager.categories) {
@@ -515,6 +514,7 @@ class ConfigGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2, drawDefaultB
515514
// Loop through all features in subcategory
516515
for (feature in subcategory.features.values) {
517516
if (!showAll && feature.parentName.isEmpty()) continue
517+
518518
// Ensure that the features option has a real parent
519519
if (feature.parentFeature == null) {
520520
if (feature.parentName.isNotEmpty()) {
@@ -533,8 +533,9 @@ class ConfigGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2, drawDefaultB
533533
if (featureOption != null) {
534534
// Add feature to parent's reference so it can be hidden / unhidden in future
535535
feature.parentFeature!!.optionElements[feature.name] = featureOption
536-
// Hide suboptions by default
537-
featureOption.featureComponent.hide(true)
536+
537+
// Hide sub options so original height is not affected
538+
featureOption.featureAndOptionsComponent.hide(true)
538539
}
539540
}
540541
}
@@ -575,55 +576,60 @@ class ConfigGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2, drawDefaultB
575576
return false
576577
}
577578

579+
// Used to create main feature, which contains the title, description and config type
578580
private fun createFeatureElement(
579581
feature: ConfigManager.Feature,
580582
subcategoryComponent: UIComponent
581-
): ConfigManager.Feature? {
582-
583-
val featureContainer = UIContainer().constrain {
583+
): ConfigManager.Feature {
584+
// This is the main ui element, everything else is a child of this, and when options are present, they are cut off by this element when not expanded
585+
val featureAndOptionsContainer = UIContainer().constrain {
584586
x = CenterConstraint()
585587
y = SiblingConstraintFixed(6f)
586588
width = 99.percent
587589
height = ChildBasedSizeConstraint(2f)
588590
} childOf subcategoryComponent effect ScissorEffect()
589591

590-
val featureBackground =
592+
// Create the background for the feature and options container
593+
val featureAndOptionsBackground =
591594
OutlinedRoundedRectangle(featureBorderColorState.get().colorState.constraint, 1f, 6f).constrain {
592595
x = CenterConstraint()
593596
y = SiblingConstraintFixed(6f)
594597
width = if (feature.parentName.isEmpty()) 100.percent else 90.percent
595598
height = ChildBasedSizeConstraint(2f)
596599
color = featureBackgroundColorState.get().colorState.constraint
597-
} childOf featureContainer
600+
} childOf featureAndOptionsContainer
598601

599-
val secondContainer = UIContainer().constrain {
602+
// The feature container, which contains the title, description
603+
val featureContainer = UIContainer().constrain {
600604
x = PixelConstraint(0f)
601605
y = SiblingConstraintFixed(6f)
602606
width = 100.percent
603607
height = ChildBasedSizeConstraint(2f)
604-
} childOf featureBackground
608+
} childOf featureAndOptionsBackground
605609

606610
val featureTitle = CustomUIText(feature.name, scale = 1.5f).constrain {
607611
x = 3.pixels
608612
y = 3.pixels
609-
} childOf secondContainer
613+
} childOf featureContainer
610614

611615
if (feature.description != "") {
612616
val featureDescription = CustomUIWrappedText(feature.description).constrain {
613617
x = 3.pixels
614618
y = SiblingConstraintFixed(2f)
615619
width = 80.percent - 2.pixels
616620
color = Color.GRAY.constraint
617-
} childOf secondContainer
621+
} childOf featureContainer
618622
}
619623

620-
populateFeature(feature, secondContainer)
624+
// Populate the feature with its config type, ie toggle, text input, etc.
625+
populateFeature(feature, featureContainer)
621626

622-
feature.featureComponent = featureContainer
627+
feature.featureAndOptionsComponent = featureAndOptionsContainer
623628

624629
return feature
625630
}
626631

632+
// Create a feature option element, which is a child of the parent feature, and contains the title, description and config type
627633
private fun createFeatureOptionElement(
628634
feature: ConfigManager.Feature
629635
): ConfigManager.Feature? {
@@ -632,7 +638,7 @@ class ConfigGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2, drawDefaultB
632638
return null
633639
}
634640

635-
val parentComponent = feature.parentFeature!!.featureComponent
641+
val parentComponent = feature.parentFeature!!.featureAndOptionsComponent
636642

637643
val parentFeatureBackground = parentComponent.children.getOrNull(0) ?: return null
638644

@@ -662,7 +668,7 @@ class ConfigGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2, drawDefaultB
662668

663669
populateFeature(feature, featureContainer)
664670

665-
feature.featureComponent = featureContainer
671+
feature.featureAndOptionsComponent = featureContainer
666672

667673
return feature
668674
}
@@ -940,6 +946,7 @@ class ConfigGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2, drawDefaultB
940946
ignoredHeights.add(button)
941947
}
942948

949+
// Give parents a settings gear if they have options, allowing for expanding and collapsing of options
943950
if (feature.isParent) {
944951
val unhovered = Color(200, 200, 200)
945952
val hovered = Color(255, 255, 255)
@@ -962,33 +969,45 @@ class ConfigGui : WindowScreen(ElementaVersion.V2, newGuiScale = 2, drawDefaultB
962969
setColorAnimation(Animations.OUT_EXP, 0.5f, unhovered.constraint)
963970
}
964971
}
965-
var orignalHeight = 0.pixels
972+
973+
// Calculate the height of the feature, waits 500ms because the components must be rendered first
974+
var smallSizeHeight = 0.pixels
966975

967976
Utils.setTimeout({
968-
orignalHeight = feature.featureComponent.getHeight().pixels
977+
smallSizeHeight = feature.featureAndOptionsComponent.getHeight().pixels
969978
}, 500)
970979

980+
// Hides the color picker if it is open
971981
clearPopup()
972982

983+
// On click, toggle the options hidden state
973984
settingsGear.onMouseClick {
974985
feature.optionsHidden = !feature.optionsHidden
986+
987+
// Rotate the settings gear
975988
settingsGear.setTargetAngle(if (feature.optionsHidden) 0f else 90f)
976989

990+
// Hides the color picker if it is open
977991
clearPopup()
978992

979-
val parentFeatureBackground = feature.featureComponent.children.getOrNull(0)
993+
val featureBackground = feature.featureAndOptionsComponent.children.getOrNull(0)
994+
980995
if (!feature.optionsHidden) {
981-
parentFeatureBackground?.setHeight(orignalHeight)
982-
parentFeatureBackground?.animate {
996+
// If the feature is being expanded, set the height to the small size height, then animate to the full height
997+
featureBackground?.setHeight(smallSizeHeight)
998+
featureBackground?.animate {
983999
setHeightAnimation(Animations.IN_OUT_EXP, 0.35f, ChildBasedSizeConstraint(2f), 0f)
9841000
}
1001+
1002+
// Unhide all the options in the feature
9851003
feature.optionElements.values.forEach {
986-
it.featureComponent.unhide(true)
1004+
it.featureAndOptionsComponent.unhide(true)
9871005
}
9881006
} else {
989-
parentFeatureBackground?.setHeight(feature.featureComponent.getHeight().pixels)
990-
parentFeatureBackground?.animate {
991-
setHeightAnimation(Animations.IN_OUT_EXP, 0.35f, orignalHeight, 0f)
1007+
// If the feature is being collapsed, set the height to the full height, then animate to the small size height
1008+
featureBackground?.setHeight(feature.featureAndOptionsComponent.getHeight().pixels)
1009+
featureBackground?.animate {
1010+
setHeightAnimation(Animations.IN_OUT_EXP, 0.35f, smallSizeHeight, 0f)
9921011
}
9931012
}
9941013
}

src/main/java/mrfast/sbt/guis/components/RotatingUIImage.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ class RotatingUIImage(
1313
// Update rotation
1414
updateRotation()
1515

16-
beforeDrawCompat(matrixStack)
17-
1816
val x = this.getLeft().toDouble()
1917
val y = this.getTop().toDouble()
2018
val width = this.getWidth().toDouble()

src/main/java/mrfast/sbt/managers/ConfigManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ abstract class ConfigManager {
4747
var dropdownOptions: Array<String> = arrayOf(),
4848
val parentName: String = "",
4949
var parentFeature: Feature? = null,
50-
var featureComponent: UIComponent = UIContainer(),
50+
var featureAndOptionsComponent: UIComponent = UIContainer(),
5151
var subcategory: Subcategory = Subcategory(""),
5252
var optionElements: MutableMap<String, Feature> = mutableMapOf(),
5353
var optionsHidden: Boolean = true

0 commit comments

Comments
 (0)