diff options
author | Yasin <a.piri@hotmail.de> | 2024-05-08 00:07:04 +0200 |
---|---|---|
committer | Yasin <a.piri@hotmail.de> | 2024-05-08 00:07:04 +0200 |
commit | 15bf2503e0147aeb06ebae2922ecede237983d5c (patch) | |
tree | 827bb279c18a6394959008a661290c94d3d0e7a7 /src/main/java/de/hysky/skyblocker/utils/render/title | |
parent | 9807bacfb9b2d7ef6a84e158ec21efea343128a7 (diff) | |
download | Skyblocker-15bf2503e0147aeb06ebae2922ecede237983d5c.tar.gz Skyblocker-15bf2503e0147aeb06ebae2922ecede237983d5c.tar.bz2 Skyblocker-15bf2503e0147aeb06ebae2922ecede237983d5c.zip |
debloat SkyblockerConfig.java + translate change
removed text.autoconfig. prefix
new way is skyblocker.option.
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils/render/title')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java | 29 | ||||
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java | 63 |
2 files changed, 47 insertions, 45 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java index a115bb2b..7a2ea60a 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainer.java @@ -2,6 +2,7 @@ package de.hysky.skyblocker.utils.render.title; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.config.configs.UiAndVisualsConfig; import de.hysky.skyblocker.events.HudRenderEvents; import de.hysky.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; @@ -82,7 +83,7 @@ public class TitleContainer { } private static void render(DrawContext context, float tickDelta) { - render(context, titles, SkyblockerConfigManager.get().general.titleContainer.x, SkyblockerConfigManager.get().general.titleContainer.y, tickDelta); + render(context, titles, SkyblockerConfigManager.get().uiAndVisuals.titleContainer.x, SkyblockerConfigManager.get().uiAndVisuals.titleContainer.y, tickDelta); } protected static void render(DrawContext context, Set<Title> titles, int xPos, int yPos, float tickDelta) { @@ -90,11 +91,11 @@ public class TitleContainer { TextRenderer textRenderer = client.textRenderer; // Calculate Scale to use - float scale = 3F * (SkyblockerConfigManager.get().general.titleContainer.titleContainerScale / 100F); + float scale = 3F * (SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale / 100F); // Grab direction and alignment values - SkyblockerConfig.Direction direction = SkyblockerConfigManager.get().general.titleContainer.direction; - SkyblockerConfig.Alignment alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; + UiAndVisualsConfig.Direction direction = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; + UiAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; // x/y refer to the starting position for the text // y always starts at yPos float x = 0; @@ -106,8 +107,8 @@ public class TitleContainer { width += textRenderer.getWidth(title.getText()) * scale + 10; } - if (alignment == SkyblockerConfig.Alignment.MIDDLE) { - if (direction == SkyblockerConfig.Direction.HORIZONTAL) { + if (alignment == UiAndVisualsConfig.Alignment.MIDDLE) { + if (direction == UiAndVisualsConfig.Direction.HORIZONTAL) { //If middle aligned horizontally, start the xPosition at half of the width to the left. x = xPos - (width / 2); } else { @@ -115,7 +116,7 @@ public class TitleContainer { x = xPos; } } - if (alignment == SkyblockerConfig.Alignment.LEFT || alignment == SkyblockerConfig.Alignment.RIGHT) { + if (alignment == UiAndVisualsConfig.Alignment.LEFT || alignment == UiAndVisualsConfig.Alignment.RIGHT) { //If left or right aligned, start at xPos, we will shift each text later x = xPos; } @@ -124,14 +125,14 @@ public class TitleContainer { //Calculate which x the text should use float xToUse; - if (direction == SkyblockerConfig.Direction.HORIZONTAL) { - xToUse = alignment == SkyblockerConfig.Alignment.RIGHT ? + if (direction == UiAndVisualsConfig.Direction.HORIZONTAL) { + xToUse = alignment == UiAndVisualsConfig.Alignment.RIGHT ? x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side. x; } else { - xToUse = alignment == SkyblockerConfig.Alignment.MIDDLE ? + xToUse = alignment == UiAndVisualsConfig.Alignment.MIDDLE ? x - (textRenderer.getWidth(title.getText()) * scale) / 2 : //if middle aligned we need the text position to be aligned in the middle. - alignment == SkyblockerConfig.Alignment.RIGHT ? + alignment == UiAndVisualsConfig.Alignment.RIGHT ? x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side. x; } @@ -156,13 +157,13 @@ public class TitleContainer { context.getMatrices().pop(); //Calculate the x and y positions for the next title - if (direction == SkyblockerConfig.Direction.HORIZONTAL) { - if (alignment == SkyblockerConfig.Alignment.MIDDLE || alignment == SkyblockerConfig.Alignment.LEFT) { + if (direction == UiAndVisualsConfig.Direction.HORIZONTAL) { + if (alignment == UiAndVisualsConfig.Alignment.MIDDLE || alignment == UiAndVisualsConfig.Alignment.LEFT) { //Move to the right if middle or left aligned x += textRenderer.getWidth(title.getText()) * scale + 10; } - if (alignment == SkyblockerConfig.Alignment.RIGHT) { + if (alignment == UiAndVisualsConfig.Alignment.RIGHT) { //Move to the left if right aligned x -= textRenderer.getWidth(title.getText()) * scale + 10; } diff --git a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java index cc80f74c..6a66faad 100644 --- a/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/utils/render/title/TitleContainerConfigScreen.java @@ -2,6 +2,7 @@ package de.hysky.skyblocker.utils.render.title; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.config.SkyblockerConfigManager; +import de.hysky.skyblocker.config.configs.UiAndVisualsConfig; import de.hysky.skyblocker.utils.render.RenderHelper; import dev.isxander.yacl3.api.ConfigCategory; import dev.isxander.yacl3.api.Option; @@ -23,8 +24,8 @@ public class TitleContainerConfigScreen extends Screen { private final Title example1 = new Title(Text.literal("Test1").formatted(Formatting.RED)); private final Title example2 = new Title(Text.literal("Test23").formatted(Formatting.AQUA)); private final Title example3 = new Title(Text.literal("Testing1234").formatted(Formatting.DARK_GREEN)); - private float hudX = SkyblockerConfigManager.get().general.titleContainer.x; - private float hudY = SkyblockerConfigManager.get().general.titleContainer.y; + private float hudX = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.x; + private float hudY = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.y; private final Screen parent; private boolean changedScale; @@ -42,8 +43,8 @@ public class TitleContainerConfigScreen extends Screen { super.render(context, mouseX, mouseY, delta); renderBackground(context, mouseX, mouseY, delta); TitleContainer.render(context, Set.of(example1, example2, example3), (int) hudX, (int) hudY, delta); - SkyblockerConfig.Direction direction = SkyblockerConfigManager.get().general.titleContainer.direction; - SkyblockerConfig.Alignment alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; + UiAndVisualsConfig.Direction direction = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; + UiAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; context.drawCenteredTextWithShadow(textRenderer, "Press Q/E to change Alignment: " + alignment, width / 2, textRenderer.fontHeight * 2, Color.WHITE.getRGB()); context.drawCenteredTextWithShadow(textRenderer, "Press R to change Direction: " + direction, width / 2, textRenderer.fontHeight * 3 + 5, Color.WHITE.getRGB()); context.drawCenteredTextWithShadow(textRenderer, "Press +/- to change Scale", width / 2, textRenderer.fontHeight * 4 + 10, Color.WHITE.getRGB()); @@ -62,7 +63,7 @@ public class TitleContainerConfigScreen extends Screen { } private Pair<Vector2f, Vector2f> getSelectionBoundingBox() { - SkyblockerConfig.Alignment alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; + UiAndVisualsConfig.Alignment alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; float midWidth = getSelectionWidth() / 2F; float x1 = 0; @@ -87,15 +88,15 @@ public class TitleContainerConfigScreen extends Screen { } private float getSelectionHeight() { - float scale = (3F * (SkyblockerConfigManager.get().general.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfigManager.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? + float scale = (3F * (SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale / 100F)); + return SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction == UiAndVisualsConfig.Direction.HORIZONTAL ? (textRenderer.fontHeight * scale) : (textRenderer.fontHeight + 10F) * 3F * scale; } private float getSelectionWidth() { - float scale = (3F * (SkyblockerConfigManager.get().general.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfigManager.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? + float scale = (3F * (SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale / 100F)); + return SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction == UiAndVisualsConfig.Direction.HORIZONTAL ? (textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale : textRenderer.getWidth("Testing1234") * scale; } @@ -104,7 +105,7 @@ public class TitleContainerConfigScreen extends Screen { public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { float midWidth = getSelectionWidth() / 2; float midHeight = getSelectionHeight() / 2; - var alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; + var alignment = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; Pair<Vector2f, Vector2f> boundingBox = getSelectionBoundingBox(); float x1 = boundingBox.getLeft().getX(); @@ -135,34 +136,34 @@ public class TitleContainerConfigScreen extends Screen { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (keyCode == GLFW.GLFW_KEY_Q) { - SkyblockerConfig.Alignment current = SkyblockerConfigManager.get().general.titleContainer.alignment; - SkyblockerConfigManager.get().general.titleContainer.alignment = switch (current) { - case LEFT -> SkyblockerConfig.Alignment.MIDDLE; - case MIDDLE -> SkyblockerConfig.Alignment.RIGHT; - case RIGHT -> SkyblockerConfig.Alignment.LEFT; + UiAndVisualsConfig.Alignment current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment = switch (current) { + case LEFT -> UiAndVisualsConfig.Alignment.MIDDLE; + case MIDDLE -> UiAndVisualsConfig.Alignment.RIGHT; + case RIGHT -> UiAndVisualsConfig.Alignment.LEFT; }; } if (keyCode == GLFW.GLFW_KEY_E) { - SkyblockerConfig.Alignment current = SkyblockerConfigManager.get().general.titleContainer.alignment; - SkyblockerConfigManager.get().general.titleContainer.alignment = switch (current) { - case LEFT -> SkyblockerConfig.Alignment.RIGHT; - case MIDDLE -> SkyblockerConfig.Alignment.LEFT; - case RIGHT -> SkyblockerConfig.Alignment.MIDDLE; + UiAndVisualsConfig.Alignment current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.alignment = switch (current) { + case LEFT -> UiAndVisualsConfig.Alignment.RIGHT; + case MIDDLE -> UiAndVisualsConfig.Alignment.LEFT; + case RIGHT -> UiAndVisualsConfig.Alignment.MIDDLE; }; } if (keyCode == GLFW.GLFW_KEY_R) { - SkyblockerConfig.Direction current = SkyblockerConfigManager.get().general.titleContainer.direction; - SkyblockerConfigManager.get().general.titleContainer.direction = switch (current) { - case HORIZONTAL -> SkyblockerConfig.Direction.VERTICAL; - case VERTICAL -> SkyblockerConfig.Direction.HORIZONTAL; + UiAndVisualsConfig.Direction current = SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.direction = switch (current) { + case HORIZONTAL -> UiAndVisualsConfig.Direction.VERTICAL; + case VERTICAL -> UiAndVisualsConfig.Direction.HORIZONTAL; }; } if (keyCode == GLFW.GLFW_KEY_EQUAL) { - SkyblockerConfigManager.get().general.titleContainer.titleContainerScale += 10; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale += 10; changedScale = true; } if (keyCode == GLFW.GLFW_KEY_MINUS) { - SkyblockerConfigManager.get().general.titleContainer.titleContainerScale -= 10; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.titleContainerScale -= 10; changedScale = true; } return super.keyPressed(keyCode, scanCode, modifiers); @@ -171,15 +172,15 @@ public class TitleContainerConfigScreen extends Screen { @Override public void close() { - SkyblockerConfigManager.get().general.titleContainer.x = (int) hudX; - SkyblockerConfigManager.get().general.titleContainer.y = (int) hudY; + SkyblockerConfigManager.get().uiAndVisuals.titleContainer.x = (int) hudX; + SkyblockerConfigManager.get().uiAndVisuals.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(); + ConfigCategory category = yaclScreen.config.categories().stream().filter(cat -> cat.name().getString().equals(I18n.translate("skyblocker.category.general"))).findFirst().orElseThrow(); + OptionGroup group = category.groups().stream().filter(grp -> grp.name().getString().equals(I18n.translate("skyblocker.option.general.titleContainer"))).findFirst().orElseThrow(); - Option<?> scaleOpt = group.options().get(0); + Option<?> scaleOpt = group.options().getFirst(); // Refresh the value in the config with the bound value if (changedScale) scaleOpt.forgetPendingValue(); |