From 776dadb050b4e7d76de9fa16161d2cda4dd66e5b Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sun, 3 Sep 2023 16:36:08 -0400 Subject: YACL Config --- .../utils/discord/DiscordRPCManager.java | 3 +- .../utils/render/title/TitleContainer.java | 25 ++++++++-------- .../render/title/TitleContainerConfigScreen.java | 35 +++++++++++----------- 3 files changed, 32 insertions(+), 31 deletions(-) (limited to 'src/main/java/me/xmrvizzy/skyblocker/utils') diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/discord/DiscordRPCManager.java b/src/main/java/me/xmrvizzy/skyblocker/utils/discord/DiscordRPCManager.java index 58408944..5360741d 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/discord/DiscordRPCManager.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/discord/DiscordRPCManager.java @@ -1,7 +1,6 @@ package me.xmrvizzy.skyblocker.utils.discord; -import me.shedaniel.autoconfig.AutoConfig; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import me.xmrvizzy.skyblocker.utils.SkyblockEvents; import me.xmrvizzy.skyblocker.utils.Utils; @@ -41,7 +40,7 @@ public class DiscordRPCManager { // If the custom message is empty, discord will keep the last message, this is can serve as a default if the user doesn't want a custom message if (SkyblockerConfig.get().richPresence.customMessage.isEmpty()) { SkyblockerConfig.get().richPresence.customMessage = "Playing Skyblock"; - AutoConfig.getConfigHolder(SkyblockerConfig.class).save(); + SkyblockerConfig.save(); } if (SkyblockerConfig.get().richPresence.cycleMode) cycleCount = (cycleCount + 1) % 3; initAndUpdatePresence(); diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java index 2555572c..5044b814 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java @@ -1,5 +1,6 @@ package me.xmrvizzy.skyblocker.utils.render.title; +import me.xmrvizzy.skyblocker.config.ConfigModel; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import me.xmrvizzy.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; @@ -92,8 +93,8 @@ public class TitleContainer { float scale = 3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F); // Grab direction and alignment values - SkyblockerConfig.Direction direction = SkyblockerConfig.get().general.titleContainer.direction; - SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; + ConfigModel.Direction direction = SkyblockerConfig.get().general.titleContainer.direction; + ConfigModel.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; // x/y refer to the starting position for the text // y always starts at yPos float x = 0; @@ -105,8 +106,8 @@ public class TitleContainer { width += textRenderer.getWidth(title.getText()) * scale + 10; } - if (alignment == SkyblockerConfig.Alignment.MIDDLE) { - if (direction == SkyblockerConfig.Direction.HORIZONTAL) { + if (alignment == ConfigModel.Alignment.MIDDLE) { + if (direction == ConfigModel.Direction.HORIZONTAL) { //If middle aligned horizontally, start the xPosition at half of the width to the left. x = xPos - (width / 2); } else { @@ -114,7 +115,7 @@ public class TitleContainer { x = xPos; } } - if (alignment == SkyblockerConfig.Alignment.LEFT || alignment == SkyblockerConfig.Alignment.RIGHT) { + if (alignment == ConfigModel.Alignment.LEFT || alignment == ConfigModel.Alignment.RIGHT) { //If left or right aligned, start at xPos, we will shift each text later x = xPos; } @@ -123,14 +124,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 == ConfigModel.Direction.HORIZONTAL) { + xToUse = alignment == ConfigModel.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 == ConfigModel.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 == ConfigModel.Alignment.RIGHT ? x - (textRenderer.getWidth(title.getText()) * scale) : //if right aligned we need the text position to be aligned on the right side. x; } @@ -155,13 +156,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 == ConfigModel.Direction.HORIZONTAL) { + if (alignment == ConfigModel.Alignment.MIDDLE || alignment == ConfigModel.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 == ConfigModel.Alignment.RIGHT) { //Move to the left if right aligned x -= textRenderer.getWidth(title.getText()) * scale + 10; } diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java index 29f87961..bd5f19f2 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java @@ -1,6 +1,7 @@ package me.xmrvizzy.skyblocker.utils.render.title; import me.shedaniel.autoconfig.AutoConfig; +import me.xmrvizzy.skyblocker.config.ConfigModel; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import me.xmrvizzy.skyblocker.utils.render.RenderHelper; import net.minecraft.client.gui.DrawContext; @@ -30,8 +31,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 = SkyblockerConfig.get().general.titleContainer.direction; - SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; + ConfigModel.Direction direction = SkyblockerConfig.get().general.titleContainer.direction; + ConfigModel.Alignment alignment = SkyblockerConfig.get().general.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()); @@ -50,7 +51,7 @@ public class TitleContainerConfigScreen extends Screen { } private Pair getSelectionBoundingBox() { - SkyblockerConfig.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; + ConfigModel.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; float midWidth = getSelectionWidth() / 2F; float x1 = 0; @@ -76,14 +77,14 @@ public class TitleContainerConfigScreen extends Screen { private float getSelectionHeight() { float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? + return SkyblockerConfig.get().general.titleContainer.direction == ConfigModel.Direction.HORIZONTAL ? (textRenderer.fontHeight * scale) : (textRenderer.fontHeight + 10F) * 3F * scale; } private float getSelectionWidth() { float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfig.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? + return SkyblockerConfig.get().general.titleContainer.direction == ConfigModel.Direction.HORIZONTAL ? (textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale : textRenderer.getWidth("Testing1234") * scale; } @@ -123,26 +124,26 @@ public class TitleContainerConfigScreen extends Screen { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (keyCode == GLFW.GLFW_KEY_Q) { - SkyblockerConfig.Alignment current = SkyblockerConfig.get().general.titleContainer.alignment; + ConfigModel.Alignment current = SkyblockerConfig.get().general.titleContainer.alignment; SkyblockerConfig.get().general.titleContainer.alignment = switch (current) { - case LEFT -> SkyblockerConfig.Alignment.MIDDLE; - case MIDDLE -> SkyblockerConfig.Alignment.RIGHT; - case RIGHT -> SkyblockerConfig.Alignment.LEFT; + case LEFT -> ConfigModel.Alignment.MIDDLE; + case MIDDLE -> ConfigModel.Alignment.RIGHT; + case RIGHT -> ConfigModel.Alignment.LEFT; }; } if (keyCode == GLFW.GLFW_KEY_E) { - SkyblockerConfig.Alignment current = SkyblockerConfig.get().general.titleContainer.alignment; + ConfigModel.Alignment current = SkyblockerConfig.get().general.titleContainer.alignment; SkyblockerConfig.get().general.titleContainer.alignment = switch (current) { - case LEFT -> SkyblockerConfig.Alignment.RIGHT; - case MIDDLE -> SkyblockerConfig.Alignment.LEFT; - case RIGHT -> SkyblockerConfig.Alignment.MIDDLE; + case LEFT -> ConfigModel.Alignment.RIGHT; + case MIDDLE -> ConfigModel.Alignment.LEFT; + case RIGHT -> ConfigModel.Alignment.MIDDLE; }; } if (keyCode == GLFW.GLFW_KEY_R) { - SkyblockerConfig.Direction current = SkyblockerConfig.get().general.titleContainer.direction; + ConfigModel.Direction current = SkyblockerConfig.get().general.titleContainer.direction; SkyblockerConfig.get().general.titleContainer.direction = switch (current) { - case HORIZONTAL -> SkyblockerConfig.Direction.VERTICAL; - case VERTICAL -> SkyblockerConfig.Direction.HORIZONTAL; + case HORIZONTAL -> ConfigModel.Direction.VERTICAL; + case VERTICAL -> ConfigModel.Direction.HORIZONTAL; }; } if (keyCode == GLFW.GLFW_KEY_EQUAL) { @@ -158,7 +159,7 @@ public class TitleContainerConfigScreen extends Screen { public void close() { SkyblockerConfig.get().general.titleContainer.x = (int) hudX; SkyblockerConfig.get().general.titleContainer.y = (int) hudY; - AutoConfig.getConfigHolder(SkyblockerConfig.class).save(); + SkyblockerConfig.save(); super.close(); } } -- cgit From 04f97400a0216d7fdd1154b8c8fa64ac65df63cb Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:49:48 -0400 Subject: Functionality Tweaks --- .../utils/render/title/TitleContainerConfigScreen.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main/java/me/xmrvizzy/skyblocker/utils') diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java index bd5f19f2..d8e3b43c 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java @@ -1,6 +1,5 @@ package me.xmrvizzy.skyblocker.utils.render.title; -import me.shedaniel.autoconfig.AutoConfig; import me.xmrvizzy.skyblocker.config.ConfigModel; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; import me.xmrvizzy.skyblocker.utils.render.RenderHelper; @@ -21,9 +20,15 @@ public class TitleContainerConfigScreen extends Screen { private final Title example3 = new Title(Text.literal("Testing1234").formatted(Formatting.DARK_GREEN)); private float hudX = SkyblockerConfig.get().general.titleContainer.x; private float hudY = SkyblockerConfig.get().general.titleContainer.y; - + private final Screen parent; + protected TitleContainerConfigScreen() { - super(Text.of("Title Container HUD Config")); + this(null); + } + + public TitleContainerConfigScreen(Screen parent) { + super(Text.of("Title Container HUD Config")); + this.parent = parent; } @Override @@ -160,6 +165,6 @@ public class TitleContainerConfigScreen extends Screen { SkyblockerConfig.get().general.titleContainer.x = (int) hudX; SkyblockerConfig.get().general.titleContainer.y = (int) hudY; SkyblockerConfig.save(); - super.close(); + this.client.setScreen(parent); } } -- cgit From 84aedfe464bc648cbb18b4f2a7eaeb695091b2b5 Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:58:40 -0400 Subject: Rename Config Files --- .../utils/discord/DiscordRPCManager.java | 30 +++++------ .../utils/render/title/TitleContainer.java | 30 +++++------ .../render/title/TitleContainerConfigScreen.java | 60 +++++++++++----------- 3 files changed, 60 insertions(+), 60 deletions(-) (limited to 'src/main/java/me/xmrvizzy/skyblocker/utils') diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/discord/DiscordRPCManager.java b/src/main/java/me/xmrvizzy/skyblocker/utils/discord/DiscordRPCManager.java index 5360741d..39d91bba 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/discord/DiscordRPCManager.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/discord/DiscordRPCManager.java @@ -1,7 +1,7 @@ package me.xmrvizzy.skyblocker.utils.discord; -import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.config.SkyblockerConfigManager; import me.xmrvizzy.skyblocker.utils.SkyblockEvents; import me.xmrvizzy.skyblocker.utils.Utils; import meteordevelopment.discordipc.DiscordIPC; @@ -34,15 +34,15 @@ public class DiscordRPCManager { } /** - * Checks the {@link SkyblockerConfig.RichPresence#customMessage custom message}, updates {@link #cycleCount} if enabled, and updates rich presence. + * Checks the {@link SkyblockerConfigManager.RichPresence#customMessage custom message}, updates {@link #cycleCount} if enabled, and updates rich presence. */ public static void updateDataAndPresence() { // If the custom message is empty, discord will keep the last message, this is can serve as a default if the user doesn't want a custom message - if (SkyblockerConfig.get().richPresence.customMessage.isEmpty()) { - SkyblockerConfig.get().richPresence.customMessage = "Playing Skyblock"; - SkyblockerConfig.save(); + if (SkyblockerConfigManager.get().richPresence.customMessage.isEmpty()) { + SkyblockerConfigManager.get().richPresence.customMessage = "Playing Skyblock"; + SkyblockerConfigManager.save(); } - if (SkyblockerConfig.get().richPresence.cycleMode) cycleCount = (cycleCount + 1) % 3; + if (SkyblockerConfigManager.get().richPresence.cycleMode) cycleCount = (cycleCount + 1) % 3; initAndUpdatePresence(); } @@ -58,21 +58,21 @@ public class DiscordRPCManager { *

* When the {@link #updateTask previous update} does not exist or {@link CompletableFuture#isDone() has completed}: *

- * Connects to discord if {@link SkyblockerConfig.RichPresence#enableRichPresence rich presence is enabled}, + * Connects to discord if {@link SkyblockerConfigManager.RichPresence#enableRichPresence rich presence is enabled}, * the player {@link Utils#isOnSkyblock() is on Skyblock}, and {@link DiscordIPC#isConnected() discord is not already connected}. - * Updates the presence if {@link SkyblockerConfig.RichPresence#enableRichPresence rich presence is enabled} + * Updates the presence if {@link SkyblockerConfigManager.RichPresence#enableRichPresence rich presence is enabled} * and the player {@link Utils#isOnSkyblock() is on Skyblock}. - * Stops the connection if {@link SkyblockerConfig.RichPresence#enableRichPresence rich presence is disabled} + * Stops the connection if {@link SkyblockerConfigManager.RichPresence#enableRichPresence rich presence is disabled} * or the player {@link Utils#isOnSkyblock() is not on Skyblock} and {@link DiscordIPC#isConnected() discord is connected}. * Saves the update task in {@link #updateTask} * * @param initialization whether this is the first time the presence is being updates. If {@code true}, a message will be logged - * if {@link SkyblockerConfig.RichPresence#enableRichPresence rich presence is disabled}. + * if {@link SkyblockerConfigManager.RichPresence#enableRichPresence rich presence is disabled}. */ private static void initAndUpdatePresence(boolean initialization) { if (updateTask == null || updateTask.isDone()) { updateTask = CompletableFuture.runAsync(() -> { - if (SkyblockerConfig.get().richPresence.enableRichPresence && Utils.isOnSkyblock()) { + if (SkyblockerConfigManager.get().richPresence.enableRichPresence && Utils.isOnSkyblock()) { if (!DiscordIPC.isConnected()) { if (DiscordIPC.start(934607927837356052L, null)) { LOGGER.info("Discord RPC started successfully"); @@ -96,20 +96,20 @@ public class DiscordRPCManager { RichPresence presence = new RichPresence(); presence.setLargeImage("skyblocker-default", null); presence.setStart(startTimeStamp); - presence.setDetails(SkyblockerConfig.get().richPresence.customMessage); + presence.setDetails(SkyblockerConfigManager.get().richPresence.customMessage); presence.setState(getInfo()); return presence; } public static String getInfo() { String info = null; - if (!SkyblockerConfig.get().richPresence.cycleMode) { - switch (SkyblockerConfig.get().richPresence.info) { + if (!SkyblockerConfigManager.get().richPresence.cycleMode) { + switch (SkyblockerConfigManager.get().richPresence.info) { case BITS -> info = "Bits: " + DECIMAL_FORMAT.format(Utils.getBits()); case PURSE -> info = "Purse: " + DECIMAL_FORMAT.format(Utils.getPurse()); case LOCATION -> info = Utils.getLocation(); } - } else if (SkyblockerConfig.get().richPresence.cycleMode) { + } else if (SkyblockerConfigManager.get().richPresence.cycleMode) { switch (cycleCount) { case 0 -> info = "Bits: " + DECIMAL_FORMAT.format(Utils.getBits()); case 1 -> info = "Purse: " + DECIMAL_FORMAT.format(Utils.getPurse()); diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java index 5044b814..a55965dc 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java @@ -1,7 +1,7 @@ package me.xmrvizzy.skyblocker.utils.render.title; -import me.xmrvizzy.skyblocker.config.ConfigModel; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.config.SkyblockerConfigManager; import me.xmrvizzy.skyblocker.utils.scheduler.Scheduler; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; @@ -82,7 +82,7 @@ public class TitleContainer { } private static void render(DrawContext context, float tickDelta) { - render(context, titles, SkyblockerConfig.get().general.titleContainer.x, SkyblockerConfig.get().general.titleContainer.y, tickDelta); + render(context, titles, SkyblockerConfigManager.get().general.titleContainer.x, SkyblockerConfigManager.get().general.titleContainer.y, tickDelta); } protected static void render(DrawContext context, Set titles, int xPos, int yPos, float tickDelta) { @@ -90,11 +90,11 @@ public class TitleContainer { TextRenderer textRenderer = client.textRenderer; // Calculate Scale to use - float scale = 3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F); + float scale = 3F * (SkyblockerConfigManager.get().general.titleContainer.titleContainerScale / 100F); // Grab direction and alignment values - ConfigModel.Direction direction = SkyblockerConfig.get().general.titleContainer.direction; - ConfigModel.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; + SkyblockerConfig.Direction direction = SkyblockerConfigManager.get().general.titleContainer.direction; + SkyblockerConfig.Alignment alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; // x/y refer to the starting position for the text // y always starts at yPos float x = 0; @@ -106,8 +106,8 @@ public class TitleContainer { width += textRenderer.getWidth(title.getText()) * scale + 10; } - if (alignment == ConfigModel.Alignment.MIDDLE) { - if (direction == ConfigModel.Direction.HORIZONTAL) { + if (alignment == SkyblockerConfig.Alignment.MIDDLE) { + if (direction == SkyblockerConfig.Direction.HORIZONTAL) { //If middle aligned horizontally, start the xPosition at half of the width to the left. x = xPos - (width / 2); } else { @@ -115,7 +115,7 @@ public class TitleContainer { x = xPos; } } - if (alignment == ConfigModel.Alignment.LEFT || alignment == ConfigModel.Alignment.RIGHT) { + if (alignment == SkyblockerConfig.Alignment.LEFT || alignment == SkyblockerConfig.Alignment.RIGHT) { //If left or right aligned, start at xPos, we will shift each text later x = xPos; } @@ -124,14 +124,14 @@ public class TitleContainer { //Calculate which x the text should use float xToUse; - if (direction == ConfigModel.Direction.HORIZONTAL) { - xToUse = alignment == ConfigModel.Alignment.RIGHT ? + if (direction == SkyblockerConfig.Direction.HORIZONTAL) { + xToUse = alignment == SkyblockerConfig.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 == ConfigModel.Alignment.MIDDLE ? + xToUse = alignment == SkyblockerConfig.Alignment.MIDDLE ? x - (textRenderer.getWidth(title.getText()) * scale) / 2 : //if middle aligned we need the text position to be aligned in the middle. - alignment == ConfigModel.Alignment.RIGHT ? + alignment == SkyblockerConfig.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 +156,13 @@ public class TitleContainer { context.getMatrices().pop(); //Calculate the x and y positions for the next title - if (direction == ConfigModel.Direction.HORIZONTAL) { - if (alignment == ConfigModel.Alignment.MIDDLE || alignment == ConfigModel.Alignment.LEFT) { + if (direction == SkyblockerConfig.Direction.HORIZONTAL) { + if (alignment == SkyblockerConfig.Alignment.MIDDLE || alignment == SkyblockerConfig.Alignment.LEFT) { //Move to the right if middle or left aligned x += textRenderer.getWidth(title.getText()) * scale + 10; } - if (alignment == ConfigModel.Alignment.RIGHT) { + if (alignment == SkyblockerConfig.Alignment.RIGHT) { //Move to the left if right aligned x -= textRenderer.getWidth(title.getText()) * scale + 10; } diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java index d8e3b43c..caf9fbf0 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java @@ -1,7 +1,7 @@ package me.xmrvizzy.skyblocker.utils.render.title; -import me.xmrvizzy.skyblocker.config.ConfigModel; import me.xmrvizzy.skyblocker.config.SkyblockerConfig; +import me.xmrvizzy.skyblocker.config.SkyblockerConfigManager; import me.xmrvizzy.skyblocker.utils.render.RenderHelper; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; @@ -18,8 +18,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 = SkyblockerConfig.get().general.titleContainer.x; - private float hudY = SkyblockerConfig.get().general.titleContainer.y; + private float hudX = SkyblockerConfigManager.get().general.titleContainer.x; + private float hudY = SkyblockerConfigManager.get().general.titleContainer.y; private final Screen parent; protected TitleContainerConfigScreen() { @@ -36,8 +36,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); - ConfigModel.Direction direction = SkyblockerConfig.get().general.titleContainer.direction; - ConfigModel.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; + SkyblockerConfig.Direction direction = SkyblockerConfigManager.get().general.titleContainer.direction; + SkyblockerConfig.Alignment alignment = SkyblockerConfigManager.get().general.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()); @@ -56,7 +56,7 @@ public class TitleContainerConfigScreen extends Screen { } private Pair<Vector2f, Vector2f> getSelectionBoundingBox() { - ConfigModel.Alignment alignment = SkyblockerConfig.get().general.titleContainer.alignment; + SkyblockerConfig.Alignment alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; float midWidth = getSelectionWidth() / 2F; float x1 = 0; @@ -81,15 +81,15 @@ public class TitleContainerConfigScreen extends Screen { } private float getSelectionHeight() { - float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfig.get().general.titleContainer.direction == ConfigModel.Direction.HORIZONTAL ? + float scale = (3F * (SkyblockerConfigManager.get().general.titleContainer.titleContainerScale / 100F)); + return SkyblockerConfigManager.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? (textRenderer.fontHeight * scale) : (textRenderer.fontHeight + 10F) * 3F * scale; } private float getSelectionWidth() { - float scale = (3F * (SkyblockerConfig.get().general.titleContainer.titleContainerScale / 100F)); - return SkyblockerConfig.get().general.titleContainer.direction == ConfigModel.Direction.HORIZONTAL ? + float scale = (3F * (SkyblockerConfigManager.get().general.titleContainer.titleContainerScale / 100F)); + return SkyblockerConfigManager.get().general.titleContainer.direction == SkyblockerConfig.Direction.HORIZONTAL ? (textRenderer.getWidth("Test1") + 10 + textRenderer.getWidth("Test23") + 10 + textRenderer.getWidth("Testing1234")) * scale : textRenderer.getWidth("Testing1234") * scale; } @@ -98,7 +98,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 = SkyblockerConfig.get().general.titleContainer.alignment; + var alignment = SkyblockerConfigManager.get().general.titleContainer.alignment; Pair<Vector2f, Vector2f> boundingBox = getSelectionBoundingBox(); float x1 = boundingBox.getLeft().getX(); @@ -129,42 +129,42 @@ public class TitleContainerConfigScreen extends Screen { @Override public boolean keyPressed(int keyCode, int scanCode, int modifiers) { if (keyCode == GLFW.GLFW_KEY_Q) { - ConfigModel.Alignment current = SkyblockerConfig.get().general.titleContainer.alignment; - SkyblockerConfig.get().general.titleContainer.alignment = switch (current) { - case LEFT -> ConfigModel.Alignment.MIDDLE; - case MIDDLE -> ConfigModel.Alignment.RIGHT; - case RIGHT -> ConfigModel.Alignment.LEFT; + 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; }; } if (keyCode == GLFW.GLFW_KEY_E) { - ConfigModel.Alignment current = SkyblockerConfig.get().general.titleContainer.alignment; - SkyblockerConfig.get().general.titleContainer.alignment = switch (current) { - case LEFT -> ConfigModel.Alignment.RIGHT; - case MIDDLE -> ConfigModel.Alignment.LEFT; - case RIGHT -> ConfigModel.Alignment.MIDDLE; + 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; }; } if (keyCode == GLFW.GLFW_KEY_R) { - ConfigModel.Direction current = SkyblockerConfig.get().general.titleContainer.direction; - SkyblockerConfig.get().general.titleContainer.direction = switch (current) { - case HORIZONTAL -> ConfigModel.Direction.VERTICAL; - case VERTICAL -> ConfigModel.Direction.HORIZONTAL; + 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; }; } if (keyCode == GLFW.GLFW_KEY_EQUAL) { - SkyblockerConfig.get().general.titleContainer.titleContainerScale += 10; + SkyblockerConfigManager.get().general.titleContainer.titleContainerScale += 10; } if (keyCode == GLFW.GLFW_KEY_MINUS) { - SkyblockerConfig.get().general.titleContainer.titleContainerScale -= 10; + SkyblockerConfigManager.get().general.titleContainer.titleContainerScale -= 10; } return super.keyPressed(keyCode, scanCode, modifiers); } @Override public void close() { - SkyblockerConfig.get().general.titleContainer.x = (int) hudX; - SkyblockerConfig.get().general.titleContainer.y = (int) hudY; - SkyblockerConfig.save(); + SkyblockerConfigManager.get().general.titleContainer.x = (int) hudX; + SkyblockerConfigManager.get().general.titleContainer.y = (int) hudY; + SkyblockerConfigManager.save(); this.client.setScreen(parent); } } -- cgit