Skip to content

Commit

Permalink
Merge pull request #337 from AzureAaron/yacl3
Browse files Browse the repository at this point in the history
Fix some HUD options resetting sometimes
  • Loading branch information
LifeIsAParadox authored Oct 21, 2023
2 parents a2dde4f + 65257e0 commit cb13f32
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,6 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.locations.dungeons.mapScaling = newValue)
.controller(FloatFieldControllerBuilder::create)
.build())
.option(Option.<Integer>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.mapX"))
.binding(defaults.locations.dungeons.mapX,
() -> config.locations.dungeons.mapX,
newValue -> config.locations.dungeons.mapX = newValue)
.controller(IntegerFieldControllerBuilder::create)
.build())
.option(Option.<Integer>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.mapY"))
.binding(defaults.locations.dungeons.mapY,
() -> config.locations.dungeons.mapY,
newValue -> config.locations.dungeons.mapY = newValue)
.controller(IntegerFieldControllerBuilder::create)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow"))
.description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow.@Tooltip")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.OptionDescription;
import dev.isxander.yacl3.api.OptionGroup;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import de.hysky.skyblocker.skyblock.dwarven.DwarvenHudConfigScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -74,20 +73,6 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.locations.dwarvenMines.dwarvenHud.enableBackground = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Integer>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.x"))
.binding(defaults.locations.dwarvenMines.dwarvenHud.x,
() -> config.locations.dwarvenMines.dwarvenHud.x,
newValue -> config.locations.dwarvenMines.dwarvenHud.x = newValue)
.controller(IntegerFieldControllerBuilder::create)
.build())
.option(Option.<Integer>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.y"))
.binding(defaults.locations.dwarvenMines.dwarvenHud.y,
() -> config.locations.dwarvenMines.dwarvenHud.y,
newValue -> config.locations.dwarvenMines.dwarvenHud.y = newValue)
.controller(IntegerFieldControllerBuilder::create)
.build())
.build())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
import de.hysky.skyblocker.skyblock.shortcut.ShortcutsConfigScreen;
import de.hysky.skyblocker.utils.render.title.TitleContainerConfigScreen;
Expand Down Expand Up @@ -443,34 +442,6 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.general.titleContainer.titleContainerScale = newValue)
.controller(opt -> FloatFieldControllerBuilder.create(opt).range(30f, 140f))
.build())
.option(Option.<Integer>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.titleContainer.x"))
.binding(defaults.general.titleContainer.x,
() -> config.general.titleContainer.x,
newValue -> config.general.titleContainer.x = newValue)
.controller(IntegerFieldControllerBuilder::create)
.build())
.option(Option.<Integer>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.titleContainer.y"))
.binding(defaults.general.titleContainer.y,
() -> config.general.titleContainer.y,
newValue -> config.general.titleContainer.y = newValue)
.controller(IntegerFieldControllerBuilder::create)
.build())
.option(Option.<SkyblockerConfig.Direction>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.titleContainer.direction"))
.binding(defaults.general.titleContainer.direction,
() -> config.general.titleContainer.direction,
newValue -> config.general.titleContainer.direction = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(Option.<SkyblockerConfig.Alignment>createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.titleContainer.alignment"))
.binding(defaults.general.titleContainer.alignment,
() -> config.general.titleContainer.alignment,
newValue -> config.general.titleContainer.alignment = newValue)
.controller(ConfigUtils::createEnumCyclingListController)
.build())
.option(ButtonOption.createBuilder()
.name(Text.translatable("text.autoconfig.skyblocker.option.general.titleContainer.config"))
.text(Text.translatable("text.skyblocker.open"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void close() {
SkyblockerConfigManager.get().locations.dungeons.mapX = hudX;
SkyblockerConfigManager.get().locations.dungeons.mapY = hudY;
SkyblockerConfigManager.save();

this.client.setScreen(parent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void close() {
SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.x = hudX;
SkyblockerConfigManager.get().locations.dwarvenMines.dwarvenHud.y = hudY;
SkyblockerConfigManager.save();

client.setScreen(parent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.render.RenderHelper;
import dev.isxander.yacl3.api.ConfigCategory;
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.OptionGroup;
import dev.isxander.yacl3.gui.YACLScreen;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.Vector2f;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand All @@ -21,6 +26,7 @@ public class TitleContainerConfigScreen extends Screen {
private float hudX = SkyblockerConfigManager.get().general.titleContainer.x;
private float hudY = SkyblockerConfigManager.get().general.titleContainer.y;
private final Screen parent;
private boolean changedScale;

protected TitleContainerConfigScreen() {
this(null);
Expand Down Expand Up @@ -153,17 +159,32 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
}
if (keyCode == GLFW.GLFW_KEY_EQUAL) {
SkyblockerConfigManager.get().general.titleContainer.titleContainerScale += 10;
changedScale = true;
}
if (keyCode == GLFW.GLFW_KEY_MINUS) {
SkyblockerConfigManager.get().general.titleContainer.titleContainerScale -= 10;
changedScale = true;
}
return super.keyPressed(keyCode, scanCode, modifiers);
}


@Override
public void close() {
SkyblockerConfigManager.get().general.titleContainer.x = (int) hudX;
SkyblockerConfigManager.get().general.titleContainer.y = (int) hudY;

//TODO Come up with a better, less hacky solution for this in the future (:
if (parent instanceof YACLScreen yaclScreen) {
ConfigCategory category = yaclScreen.config.categories().stream().filter(cat -> cat.name().getString().equals(I18n.translate("text.autoconfig.skyblocker.category.general"))).findFirst().orElseThrow();
OptionGroup group = category.groups().stream().filter(grp -> grp.name().getString().equals(I18n.translate("text.autoconfig.skyblocker.option.general.titleContainer"))).findFirst().orElseThrow();

Option<?> scaleOpt = group.options().get(0);

// Refresh the value in the config with the bound value
if (changedScale) scaleOpt.forgetPendingValue();
}

SkyblockerConfigManager.save();
this.client.setScreen(parent);
}
Expand Down
8 changes: 0 additions & 8 deletions src/main/resources/assets/skyblocker/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@
"text.autoconfig.skyblocker.option.general.titleContainer": "Title Container",
"text.autoconfig.skyblocker.option.general.titleContainer.@Tooltip": "Used to display multiple titles at once, Example use: Vampire Slayer",
"text.autoconfig.skyblocker.option.general.titleContainer.titleContainerScale": "Title Container Scale",
"text.autoconfig.skyblocker.option.general.titleContainer.x": "Title Container X Position",
"text.autoconfig.skyblocker.option.general.titleContainer.y": "Title Container Y Position",
"text.autoconfig.skyblocker.option.general.titleContainer.direction": "Title Container Orientation",
"text.autoconfig.skyblocker.option.general.titleContainer.alignment": "Title Container Horizontal Alignment",
"text.autoconfig.skyblocker.option.general.titleContainer.config": "Title Container Placement Config...",
"text.autoconfig.skyblocker.option.general.teleportOverlay": "Teleport Overlay",
"text.autoconfig.skyblocker.option.general.teleportOverlay.enableTeleportOverlays": "Enable Teleport Overlays",
Expand Down Expand Up @@ -185,8 +181,6 @@
"text.autoconfig.skyblocker.option.locations.dungeons.enableMap": "Enable Map",
"text.autoconfig.skyblocker.option.locations.dungeons.mapScreen": "Dungeon Map Placement Config...",
"text.autoconfig.skyblocker.option.locations.dungeons.mapScaling": "Map Scaling",
"text.autoconfig.skyblocker.option.locations.dungeons.mapX": "Map X",
"text.autoconfig.skyblocker.option.locations.dungeons.mapY": "Map Y",
"text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow": "Starred Mob Glow",
"text.autoconfig.skyblocker.option.locations.dungeons.starredMobGlow.@Tooltip": "Applies the glowing effect to starred mobs that are visible.",
"text.autoconfig.skyblocker.option.locations.dungeons.solveThreeWeirdos": "Solve Three Weirdos Puzzle",
Expand Down Expand Up @@ -218,8 +212,6 @@
"text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.style.@Tooltip[2]": "\nClassic: Shows name and percentage in a very simple box.",
"text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.screen": "Dwarven HUD Config...",
"text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.enableBackground": "Enable Background",
"text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.x": "X",
"text.autoconfig.skyblocker.option.locations.dwarvenMines.dwarvenHud.y": "Y",

"text.autoconfig.skyblocker.option.locations.rift": "The Rift",
"text.autoconfig.skyblocker.option.locations.rift.mirrorverseWaypoints": "Enable Mirrorverse Waypoints",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"depends": {
"fabricloader": ">=0.14.22",
"fabric-api": ">=0.89.1+1.20.2",
"yet_another_config_lib_v3": ">=3.2.0+1.20.2",
"yet_another_config_lib_v3": ">=3.2.1+1.20.2",
"minecraft": "~1.20.2"
},
"conflicts": {
Expand Down

0 comments on commit cb13f32

Please sign in to comment.