aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java15
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java19
3 files changed, 13 insertions, 27 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 97e03a6..7ac0371 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -9,7 +9,6 @@ import cc.polyfrost.oneconfig.gui.pages.Page;
import cc.polyfrost.oneconfig.lwjgl.OneColor;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
-import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.lwjgl.image.SVGs;
import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
@@ -28,8 +27,6 @@ import java.util.ArrayList;
public class OneConfigGui extends UScreen {
public static OneConfigGui INSTANCE;
- public final int x = 320;
- public final int y = 140;
private final SideBar sideBar = new SideBar();
protected Page currentPage;
protected Page prevPage;
@@ -61,6 +58,7 @@ public class OneConfigGui extends UScreen {
try {
return instanceToRestore == null ? new OneConfigGui() : instanceToRestore;
} finally {
+ if (instanceToRestore != null) INSTANCE = instanceToRestore;
instanceToRestore = null;
}
}
@@ -74,7 +72,11 @@ public class OneConfigGui extends UScreen {
currentPage = new HomePage();
parents.add(currentPage);
}
- scale = UResolution.getWindowWidth() / 1920f;
+ scale = Math.min(UResolution.getWindowWidth() / 1920f, UResolution.getWindowHeight() / 1080f);
+ if (scale < 1)
+ scale = Math.min(Math.min(1f, UResolution.getWindowWidth() / 1280f), Math.min(1f, UResolution.getWindowHeight() / 800f));
+ int x = (int) ((UResolution.getWindowWidth() - 1280 * scale) / 2f / scale);
+ int y = (int) ((UResolution.getWindowHeight() - 800 * scale) / 2f / scale);
NanoVG.nvgScale(vg, scale, scale);
if (OneConfigConfig.ROUNDED_CORNERS) {
RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, OneConfigConfig.GRAY_800, OneConfigConfig.CORNER_RADIUS_WIN);
@@ -89,10 +91,6 @@ public class OneConfigGui extends UScreen {
RenderManager.drawString(vg, "OneConfig", x + 69, y + 32, OneConfigConfig.WHITE, 18f, Fonts.BOLD); // added half line height to center text
RenderManager.drawString(vg, "ALPHA - By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.REGULAR);
-
- //RenderManager.drawRect(vg, x + 300, y + 500, 400, 12, OneConfigConfig.ERROR_700);
- //RenderManager.drawString(vg, "MoonTidez is Annoyinhg here is an f |||", x + 300, y + 500, OneConfigConfig.WHITE, 14f, 14,Fonts.INTER_REGULAR);
-
textInputField.draw(vg, x + 1020, y + 16);
sideBar.draw(vg, x, y);
backArrow.draw(vg, x + 240, y + 16);
@@ -254,6 +252,7 @@ public class OneConfigGui extends UScreen {
@Override
public void onScreenClose() {
currentPage.finishUpAndClose();
+ instanceToRestore = this;
INSTANCE = null;
super.onScreenClose();
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
index fcbf647..19d48a1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -42,10 +42,10 @@ public class SideBar {
public void draw(long vg, int x, int y) {
currentY = MathUtils.easeInOutCirc(50, currentY, targetY - currentY, 120);
- RenderManager.drawRoundedRect(vg, x + 16, currentY, 192, 36, OneConfigConfig.BLUE_600, OneConfigConfig.CORNER_RADIUS);
+ RenderManager.drawRoundedRect(vg, x + 16, y + currentY, 192, 36, OneConfigConfig.BLUE_600, OneConfigConfig.CORNER_RADIUS);
int i = 0;
if (targetY == 0) {
- targetY = y + 96;
+ targetY = 96;
currentY = targetY;
}
for (BasicButton btn : btnList) {
@@ -65,7 +65,7 @@ public class SideBar {
}
if (btn.isClicked() && btn.getPage() != null) {
- if (i < 520) targetY = btn.y;
+ if (i < 520) targetY = btn.y - y;
}
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
index 68ebf37..7810d57 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigInfo.java
@@ -13,30 +13,17 @@ import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
import java.lang.reflect.Field;
public class ConfigInfo extends BasicOption {
- private SVGs image;
+ private InfoType type;
public ConfigInfo(Field field, Object parent, String name, int size, InfoType type) {
super(field, parent, name, size);
- switch (type) {
- case INFO:
- image = SVGs.INFO_CIRCLE;
- break;
- case SUCCESS:
- image = SVGs.CHECK_CIRCLE;
- break;
- case WARNING:
- image = SVGs.WARNING;
- break;
- case ERROR:
- image = SVGs.ERROR;
- break;
- }
+ this.type = type;
}
@Override
public void draw(long vg, int x, int y) {
Scissor scissor = ScissorManager.scissor(vg, x, y, size == 1 ? 448 : 960, 32);
- RenderManager.drawSvg(vg, image, x, y + 4, 24, 24);
+ RenderManager.drawInfo(vg, type, x, y + 4, 24);
RenderManager.drawString(vg, name, x + 32, y + 18, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM);
ScissorManager.resetScissor(vg, scissor);
}