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/HudGui.java48
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java36
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java7
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java44
6 files changed, 76 insertions, 67 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
index a0f1e6c..e81fb86 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java
@@ -1,17 +1,19 @@
package cc.polyfrost.oneconfig.gui;
import cc.polyfrost.oneconfig.config.core.ConfigCore;
-import cc.polyfrost.oneconfig.hud.HudCore;
import cc.polyfrost.oneconfig.hud.BasicHud;
+import cc.polyfrost.oneconfig.hud.HudCore;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
-import net.minecraft.client.gui.GuiScreen;
-import org.lwjgl.input.Keyboard;
+import gg.essential.universal.UKeyboard;
+import gg.essential.universal.UMatrixStack;
+import gg.essential.universal.UScreen;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.awt.*;
-import java.io.IOException;
import java.util.ArrayList;
-public class HudGui extends GuiScreen {
+public class HudGui extends UScreen {
private BasicHud editingHud;
private boolean isDragging;
private boolean isScaling;
@@ -19,13 +21,14 @@ public class HudGui extends GuiScreen {
private int yOffset;
@Override
- public void initGui() {
+ public void initScreen(int width, int height) {
HudCore.editing = true;
- Keyboard.enableRepeatEvents(true);
+ UKeyboard.allowRepeatEvents(true);
+ super.initScreen(width, height);
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
+ public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
RenderManager.drawGlRect(0, 0, this.width, this.height, new Color(80, 80, 80, 50).getRGB());
if (isDragging) {
@@ -78,9 +81,7 @@ public class HudGui extends GuiScreen {
});
if (hud == editingHud && !isDragging) {
- RenderManager.setupAndDraw(true, (vg) -> {
- RenderManager.drawCircle(vg, x + width, y + height, 3, new Color(43, 159, 235).getRGB());
- });
+ RenderManager.setupAndDraw(true, (vg) -> RenderManager.drawCircle(vg, x + width, y + height, 3, new Color(43, 159, 235).getRGB()));
}
if (hud.childBottom != null) processHud(hud.childBottom, mouseX);
@@ -255,7 +256,8 @@ public class HudGui extends GuiScreen {
}
@Override
- protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ public void onMouseClicked(double mouseX, double mouseY, int mouseButton) {
+ super.onMouseClicked(mouseX, mouseY, mouseButton);
if (mouseButton == 0) {
if (editingHud != null) {
int width = (int) (editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale);
@@ -270,7 +272,7 @@ public class HudGui extends GuiScreen {
editingHud = null;
for (BasicHud hud : HudCore.huds) {
if (!hud.enabled) continue;
- if (mouseClickedHud(hud, mouseX, mouseY))
+ if (mouseClickedHud(hud, (int) mouseX, (int) mouseY))
break;
}
}
@@ -292,38 +294,40 @@ public class HudGui extends GuiScreen {
}
@Override
- protected void mouseReleased(int mouseX, int mouseY, int state) {
+ public void onMouseReleased(double mouseX, double mouseY, int state) {
+ super.onMouseReleased(mouseX, mouseY, state);
isDragging = false;
isScaling = false;
}
@Override
- protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ public void onKeyPressed(int keyCode, char typedChar, @Nullable UKeyboard.Modifiers modifiers) {
if (editingHud != null) {
float x = editingHud.getXScaled(this.width);
float y = editingHud.getYScaled(this.height);
switch (keyCode) {
- case Keyboard.KEY_UP:
+ case UKeyboard.KEY_UP:
setPosition(x, y - 1, false);
break;
- case Keyboard.KEY_DOWN:
+ case UKeyboard.KEY_DOWN:
setPosition(x, y + 1, false);
break;
- case Keyboard.KEY_LEFT:
+ case UKeyboard.KEY_LEFT:
setPosition(x - 1, y, false);
break;
- case Keyboard.KEY_RIGHT:
+ case UKeyboard.KEY_RIGHT:
setPosition(x + 1, y, false);
break;
}
}
- super.keyTyped(typedChar, keyCode);
+ super.onKeyPressed(keyCode, typedChar, modifiers);
}
@Override
- public void onGuiClosed() {
+ public void onScreenClose() {
+ super.onScreenClose();
HudCore.editing = false;
- Keyboard.enableRepeatEvents(false);
+ UKeyboard.allowRepeatEvents(false);
ConfigCore.saveAll();
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
index 468f59e..db32c92 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -1,6 +1,5 @@
package cc.polyfrost.oneconfig.gui;
-import cc.polyfrost.oneconfig.OneConfig;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.gui.elements.BasicElement;
import cc.polyfrost.oneconfig.gui.elements.ColorSelector;
@@ -9,21 +8,24 @@ import cc.polyfrost.oneconfig.gui.pages.HomePage;
import cc.polyfrost.oneconfig.gui.pages.Page;
import cc.polyfrost.oneconfig.lwjgl.OneColor;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
-import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
-import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
+import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
+import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.MathUtils;
-import net.minecraft.client.gui.GuiScreen;
+import gg.essential.universal.UKeyboard;
+import gg.essential.universal.UMatrixStack;
+import gg.essential.universal.UResolution;
+import gg.essential.universal.UScreen;
import org.jetbrains.annotations.NotNull;
-import org.lwjgl.input.Keyboard;
+import org.jetbrains.annotations.Nullable;
import org.lwjgl.input.Mouse;
import org.lwjgl.nanovg.NanoVG;
import java.util.ArrayList;
-public class OneConfigGui extends GuiScreen {
+public class OneConfigGui extends UScreen {
public static OneConfigGui INSTANCE;
public final int x = 320;
public final int y = 140;
@@ -63,15 +65,15 @@ public class OneConfigGui extends GuiScreen {
}
@Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- super.drawScreen(mouseX, mouseY, partialTicks);
+ public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
+ super.onDrawScreen(matrixStack, mouseX, mouseY, partialTicks);
long start = System.nanoTime();
RenderManager.setupAndDraw((vg) -> {
if (currentPage == null) {
currentPage = new HomePage();
parents.add(currentPage);
}
- scale = OneConfig.getDisplayWidth() / 1920f;
+ scale = UResolution.getWindowWidth() / 1920f;
NanoVG.nvgScale(vg, scale, scale);
if (OneConfigConfig.ROUNDED_CORNERS) {
RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, OneConfigConfig.GRAY_800, OneConfigConfig.CORNER_RADIUS_WIN);
@@ -172,13 +174,14 @@ public class OneConfigGui extends GuiScreen {
mouseDown = Mouse.isButtonDown(0);
}
- protected void keyTyped(char key, int keyCode) {
- Keyboard.enableRepeatEvents(true);
+ @Override
+ public void onKeyPressed(int keyCode, char typedChar, @Nullable UKeyboard.Modifiers modifiers) {
+ UKeyboard.allowRepeatEvents(true);
try {
- if (allowClose) super.keyTyped(key, keyCode);
- textInputField.keyTyped(key, keyCode);
- if (currentColorSelector != null) currentColorSelector.keyTyped(key, keyCode);
- currentPage.keyTyped(key, keyCode);
+ if (allowClose) super.onKeyPressed(keyCode, typedChar, modifiers);
+ textInputField.keyTyped(typedChar, keyCode);
+ if (currentColorSelector != null) currentColorSelector.keyTyped(typedChar, keyCode);
+ currentPage.keyTyped(typedChar, keyCode);
} catch (Exception e) {
e.printStackTrace();
System.out.println("this should literally never happen");
@@ -250,8 +253,9 @@ public class OneConfigGui extends GuiScreen {
}
@Override
- public void onGuiClosed() {
+ public void onScreenClose() {
currentPage.finishUpAndClose();
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 c3e99e0..85d88f9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -8,6 +8,7 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.utils.MathUtils;
+import gg.essential.universal.UScreen;
import java.util.ArrayList;
import java.util.List;
@@ -30,12 +31,12 @@ public class SideBar {
btnList.add(new BasicButton(192, 36, "Themes Browser", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Packs Library", Images.MOD_BOX, null, -3, BasicButton.ALIGNMENT_LEFT));
btnList.add(new BasicButton(192, 36, "Packs Browser", Images.SEARCH, null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Close", Images.CLOSE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> RenderManager.displayGuiScreen(null)));
+ btnList.add(new BasicButton(192, 36, "Close", Images.CLOSE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> UScreen.displayScreen(null)));
btnList.add(new BasicButton(192, 36, "Minimize", Images.MINIMIZE, null, -1, BasicButton.ALIGNMENT_LEFT, () -> {
OneConfigGui.instanceToRestore = OneConfigGui.INSTANCE;
- RenderManager.displayGuiScreen(null);
+ UScreen.displayScreen(null);
}));
- btnList.add(new BasicButton(192, 36, "Edit HUD", Images.HUD, null, 0, BasicButton.ALIGNMENT_LEFT, () -> RenderManager.displayGuiScreen(new HudGui())));
+ btnList.add(new BasicButton(192, 36, "Edit HUD", Images.HUD, null, 0, BasicButton.ALIGNMENT_LEFT, () -> UScreen.displayScreen(new HudGui())));
}
public void draw(long vg, int x, int y) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
index b18502f..9af35f1 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -11,7 +11,7 @@ import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.utils.ColorUtils;
import cc.polyfrost.oneconfig.utils.InputUtils;
-import net.minecraft.client.Minecraft;
+import gg.essential.universal.wrappers.UPlayer;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.ModMetadata;
import org.jetbrains.annotations.NotNull;
@@ -107,7 +107,7 @@ public class ModCard extends BasicElement {
for (String command : ClientCommandHandler.instance.getCommands().keySet()) {
if (possibleCommands.contains(command)) {
try {
- ClientCommandHandler.instance.getCommands().get(command).processCommand(Minecraft.getMinecraft().thePlayer, new String[]{});
+ ClientCommandHandler.instance.getCommands().get(command).processCommand(UPlayer.getPlayer(), new String[]{});
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
index f8669a2..01a2bd2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java
@@ -8,7 +8,7 @@ import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
-import org.lwjgl.input.Keyboard;
+import gg.essential.universal.UKeyboard;
import org.lwjgl.nanovg.NanoVG;
import java.lang.reflect.Field;
@@ -53,7 +53,7 @@ public class ConfigKeyBind extends BasicOption {
public void keyTyped(char key, int keyCode) {
if (!button.isToggled()) return;
OneKeyBind keyBind = getKeyBind();
- if (keyCode == Keyboard.KEY_ESCAPE) {
+ if (keyCode == UKeyboard.KEY_ESCAPE) {
keyBind.clearKeys();
button.setToggled(false);
OneConfigGui.INSTANCE.allowClose = true;
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
index 349e7af..9d87717 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java
@@ -3,11 +3,11 @@ package cc.polyfrost.oneconfig.gui.elements.text;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.gui.elements.BasicElement;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
+import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
-import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.utils.InputUtils;
-import net.minecraft.client.gui.GuiScreen;
+import gg.essential.universal.UKeyboard;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -195,13 +195,13 @@ public class TextInputField extends BasicElement {
public void keyTyped(char c, int key) {
try {
if (toggled) {
- if (GuiScreen.isKeyComboCtrlC(key)) {
+ if (UKeyboard.isKeyComboCtrlC(key)) {
if (selectedText != null && start != 0f && end != 0f) {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(selectedText), null);
}
return;
}
- if (GuiScreen.isKeyComboCtrlV(key) || key == Keyboard.KEY_INSERT) {
+ if (UKeyboard.isKeyComboCtrlV(key) || key == Keyboard.KEY_INSERT) { //todo find the UKeyboard equivalent for insert
try {
String clip = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor).toString();
input = input.substring(0, caretPos) + clip + input.substring(caretPos);
@@ -211,13 +211,13 @@ public class TextInputField extends BasicElement {
e.printStackTrace();
}
}
- if (key == Keyboard.KEY_DELETE) {
+ if (key == UKeyboard.KEY_DELETE) {
input = "";
}
- if (GuiScreen.isCtrlKeyDown()) {
- if (key == Keyboard.KEY_BACK && !GuiScreen.isKeyComboCtrlX(key)) {
+ if (UKeyboard.isCtrlKeyDown()) {
+ if (key == UKeyboard.KEY_BACKSPACE && !UKeyboard.isKeyComboCtrlX(key)) {
try {
input = input.substring(0, input.lastIndexOf(" "));
caretPos = input.length();
@@ -227,7 +227,7 @@ public class TextInputField extends BasicElement {
}
return;
}
- if (GuiScreen.isKeyComboCtrlA(key)) {
+ if (UKeyboard.isKeyComboCtrlA(key)) {
prevCaret = 0;
caretPos = input.length();
start = !centered ? x + 12 : x + this.width / 2f - this.getTextWidth(vg, input) / 2f;
@@ -235,22 +235,22 @@ public class TextInputField extends BasicElement {
end = this.getTextWidth(vg, input);
return;
}
- if (GuiScreen.isKeyComboCtrlX(key)) {
+ if (UKeyboard.isKeyComboCtrlX(key)) {
if (selectedText != null && start != 0f && end != 0f) {
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(selectedText), null);
- key = Keyboard.KEY_BACK;
+ key = UKeyboard.KEY_BACKSPACE;
} else return;
}
- if (key == Keyboard.KEY_LEFT) {
+ if (key == UKeyboard.KEY_LEFT) {
caretPos = input.substring(0, caretPos).lastIndexOf(' ') + 1;
}
- if (key == Keyboard.KEY_RIGHT) {
+ if (key == UKeyboard.KEY_RIGHT) {
caretPos = input.indexOf(' ', caretPos);
if (caretPos == -1) caretPos = input.length();
}
}
- if (key == Keyboard.KEY_BACK) {
+ if (key == UKeyboard.KEY_BACKSPACE) {
if (input.length() > 0) {
if (start != 0f && end != 0f) {
start = 0f;
@@ -273,14 +273,14 @@ public class TextInputField extends BasicElement {
}
return;
}
- if (key == Keyboard.KEY_TAB) {
+ if (key == UKeyboard.KEY_TAB) {
if (onlyNums) return;
input += " ";
caretPos += 4;
return;
}
- if (key == Keyboard.KEY_RIGHT) {
+ if (key == UKeyboard.KEY_RIGHT) {
caretPos++;
if (caretPos > input.length()) {
caretPos = input.length();
@@ -291,7 +291,7 @@ public class TextInputField extends BasicElement {
}
return;
}
- if (key == Keyboard.KEY_LEFT) {
+ if (key == UKeyboard.KEY_LEFT) {
caretPos--;
if (caretPos < 0) {
caretPos = 0;
@@ -302,7 +302,7 @@ public class TextInputField extends BasicElement {
}
return;
}
- if (key == Keyboard.KEY_UP || key == 201) { // 201 = page up
+ if (key == UKeyboard.KEY_UP || key == 201) { // 201 = page up
caretPos = 0;
if (start != 0f && end != 0f) {
start = 0f;
@@ -310,7 +310,7 @@ public class TextInputField extends BasicElement {
}
return;
}
- if (key == Keyboard.KEY_DOWN || key == 209) { // 209 = page down
+ if (key == UKeyboard.KEY_DOWN || key == 209) { // 209 = page down
caretPos = input.length();
if (start != 0f && end != 0f) {
start = 0f;
@@ -320,7 +320,7 @@ public class TextInputField extends BasicElement {
}
- if (key == Keyboard.KEY_RETURN) {
+ if (key == UKeyboard.KEY_ENTER) {
onClose();
toggled = false;
if (start != 0f && end != 0f) {
@@ -328,13 +328,13 @@ public class TextInputField extends BasicElement {
end = 0f;
}
}
- if (key == Keyboard.KEY_END) {
+ if (key == UKeyboard.KEY_END) {
onClose();
toggled = false;
}
- if (key == Keyboard.KEY_LCONTROL || key == Keyboard.KEY_RCONTROL || key == Keyboard.KEY_LMENU || key == Keyboard.KEY_RMENU || key == Keyboard.KEY_LMETA || key == Keyboard.KEY_RMETA || key == Keyboard.KEY_LSHIFT || key == Keyboard.KEY_RSHIFT || key == Keyboard.KEY_RETURN || key == Keyboard.KEY_CAPITAL || key == 221 || key == Keyboard.KEY_HOME) {
+ if (key == UKeyboard.KEY_LCONTROL || key == UKeyboard.KEY_RCONTROL || key == UKeyboard.KEY_LMENU || key == UKeyboard.KEY_RMENU || key == UKeyboard.KEY_LMETA || key == UKeyboard.KEY_RMETA || key == UKeyboard.KEY_LSHIFT || key == UKeyboard.KEY_RSHIFT || key == UKeyboard.KEY_ENTER || key == UKeyboard.KEY_CAPITAL || key == 221 || key == UKeyboard.KEY_HOME) {
return;
}
if (onlyNums) {
@@ -342,7 +342,7 @@ public class TextInputField extends BasicElement {
}
if (!Character.isDefined(key)) return;
if (!Character.isDefined(c)) return;
- if (GuiScreen.isCtrlKeyDown()) return;
+ if (UKeyboard.isCtrlKeyDown()) return;
if (isAllowedCharacter(c)) {
if (selectedText != null) {
if (caretPos > prevCaret) {