From b5d2f791e7ca6e071060e717fda49da37398a625 Mon Sep 17 00:00:00 2001 From: MystWraith <77246251+MystWraith@users.noreply.github.com> Date: Wed, 20 Dec 2023 15:31:23 -0700 Subject: [PATCH] Make ModMenu Cleaner --- .../config/ModMenuIntergrationImpl.java | 103 ++++++++++-------- 1 file changed, 56 insertions(+), 47 deletions(-) diff --git a/src/main/java/tech/showierdata/pickaxe/config/ModMenuIntergrationImpl.java b/src/main/java/tech/showierdata/pickaxe/config/ModMenuIntergrationImpl.java index 6561518..7b8183b 100644 --- a/src/main/java/tech/showierdata/pickaxe/config/ModMenuIntergrationImpl.java +++ b/src/main/java/tech/showierdata/pickaxe/config/ModMenuIntergrationImpl.java @@ -154,27 +154,31 @@ public void createItemConfig(YetAnotherConfigLib.@NotNull Builder builder) { ); } - public void createCCTConfig(YetAnotherConfigLib.@NotNull Builder builder) { + public void createTimerConfig(YetAnotherConfigLib.@NotNull Builder builder) { + builder.category(ConfigCategory.createBuilder() - .name(Text.literal("Chest Cooldown Timer")) - .option(Option.createBuilder() - .name(Text.literal("Enabled")) - .binding(true, () -> Options.getInstance().cctconfig.enabled, e -> Options.getInstance().cctconfig.enabled = e) - .controller(BooleanControllerBuilder::create) - .build() - ) - .option(Option.createBuilder() - .name(Text.literal("Play Sound When Chest Ready")) - .binding(false, () -> Options.getInstance().cctconfig.soundEnabled, e -> Options.getInstance().cctconfig.soundEnabled = e) - .controller(BooleanControllerBuilder::create) - .build() - ) - .option(Option.createBuilder() - .name(Text.literal("Function Outside Pickaxe")) - .binding(false, () -> Options.getInstance().cctconfig.enabledOutsidePickaxe, e -> Options.getInstance().cctconfig.enabledOutsidePickaxe = e) - .controller(BooleanControllerBuilder::create) - .build() - ) + .name(Text.literal("Timers")) + + .group(OptionGroup.createBuilder() + .name(Text.literal("Chest Cooldown Timer")) + .option(Option.createBuilder() + .name(Text.literal("Enabled")) + .binding(true, () -> Options.getInstance().cctconfig.enabled, e -> Options.getInstance().cctconfig.enabled = e) + .controller(BooleanControllerBuilder::create) + .build() + ) + .option(Option.createBuilder() + .name(Text.literal("Play Sound When Chest Ready")) + .binding(false, () -> Options.getInstance().cctconfig.soundEnabled, e -> Options.getInstance().cctconfig.soundEnabled = e) + .controller(BooleanControllerBuilder::create) + .build() + ) + .option(Option.createBuilder() + .name(Text.literal("Function Outside Pickaxe")) + .binding(false, () -> Options.getInstance().cctconfig.enabledOutsidePickaxe, e -> Options.getInstance().cctconfig.enabledOutsidePickaxe = e) + .controller(BooleanControllerBuilder::create) + .build() + ) .option(Option.createBuilder() .name(Text.literal("CCT Location")) .binding(TimerLocation.TOPRIGHT, () -> Options.getInstance().cctconfig.location, e -> Options.getInstance().cctconfig.location = e) @@ -184,39 +188,45 @@ public void createCCTConfig(YetAnotherConfigLib.@NotNull Builder builder) { .build() ) - - .build() - ); - } - - public void createMDTConfig(YetAnotherConfigLib.@NotNull Builder builder) { - builder.category(ConfigCategory.createBuilder() - .name(Text.literal("Moon Door Timer")) - .option(Option.createBuilder() - .name(Text.literal("Enabled")) - .binding(true, () -> Options.getInstance().mdtConfig.enabled, e -> Options.getInstance().mdtConfig.enabled = e) - .controller(BooleanControllerBuilder::create) .build() ) - .option(Option.createBuilder() - .name(Text.literal("Play Sound When Door Ready")) - .binding(false, () -> Options.getInstance().mdtConfig.soundEnabled, e -> Options.getInstance().mdtConfig.soundEnabled = e) - .controller(BooleanControllerBuilder::create) - .build() - ) - .option(Option.createBuilder() - .name(Text.literal("MDT Location")) - .binding(TimerLocation.TOPRIGHT, () -> Options.getInstance().mdtConfig.location, e -> Options.getInstance().mdtConfig.location = e) - .controller((opt) -> EnumControllerBuilder.create(opt) - .enumClass(TimerLocation.class) + + .group(OptionGroup.createBuilder() + .name(Text.literal("Moon Door Timer")) + .option(Option.createBuilder() + .name(Text.literal("Enabled")) + .binding(true, () -> Options.getInstance().mdtConfig.enabled, e -> Options.getInstance().mdtConfig.enabled = e) + .controller(BooleanControllerBuilder::create) + .build() + ) + .option(Option.createBuilder() + .name(Text.literal("Play Sound When Door Ready")) + .binding(false, () -> Options.getInstance().mdtConfig.soundEnabled, e -> Options.getInstance().mdtConfig.soundEnabled = e) + .controller(BooleanControllerBuilder::create) + .build() ) + .option(Option.createBuilder() + .name(Text.literal("MDT Location")) + .binding(TimerLocation.TOPRIGHT, () -> Options.getInstance().mdtConfig.location, e -> Options.getInstance().mdtConfig.location = e) + .controller((opt) -> EnumControllerBuilder.create(opt) + .enumClass(TimerLocation.class) + ) + .build() + ) .build() ) + .option(Option.createBuilder() - .name(Text.literal("Swap MDT and CCT")) + .name(Text.literal("Order")) .binding(false, () -> Options.getInstance().mdtConfig.reverseCCTOrder, e -> Options.getInstance().mdtConfig.reverseCCTOrder = e) - .controller(BooleanControllerBuilder::create) + .controller((opt) -> BooleanControllerBuilder.create(opt) + .formatValue((state) -> + state + ? Text.literal("MDT on top") + : Text.literal("CCT on top") + ) + ) .build() ) @@ -278,8 +288,7 @@ public Screen getConfigScreen(Screen parent) { createGeneralScreen(builder); createItemConfig(builder); - createCCTConfig(builder); - createMDTConfig(builder); + createTimerConfig(builder); createPOIConfig(builder); createMessageStackingConfig(builder, parent);