aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/utils/render/title
diff options
context:
space:
mode:
authorAaron <51387595+AzureAaron@users.noreply.github.com>2023-09-03 16:36:08 -0400
committerAaron <51387595+AzureAaron@users.noreply.github.com>2023-09-23 23:00:52 -0400
commit776dadb050b4e7d76de9fa16161d2cda4dd66e5b (patch)
tree0abddad881fb5df86ef3adbe9b6630164bef320d /src/main/java/me/xmrvizzy/skyblocker/utils/render/title
parentdbdb0598086a4d31018294f87026da517ceb0ce2 (diff)
downloadSkyblocker-776dadb050b4e7d76de9fa16161d2cda4dd66e5b.tar.gz
Skyblocker-776dadb050b4e7d76de9fa16161d2cda4dd66e5b.tar.bz2
Skyblocker-776dadb050b4e7d76de9fa16161d2cda4dd66e5b.zip
YACL Config
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/utils/render/title')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainer.java25
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/render/title/TitleContainerConfigScreen.java35
2 files changed, 31 insertions, 29 deletions
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<Vector2f, Vector2f> 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();
}
}