aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/gui
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-01 11:23:06 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-01 11:23:06 +0200
commitfe8261cf7c10af90c0154633a6a8f18b3e5bfb12 (patch)
tree0435f70db77ef7c965211a3d4d577ffe978334e6 /src/main/java/io/polyfrost/oneconfig/gui
parent5514e4b97ab2a7a37bf25cf4a4a57baf8f94e052 (diff)
downloadOneConfig-fe8261cf7c10af90c0154633a6a8f18b3e5bfb12.tar.gz
OneConfig-fe8261cf7c10af90c0154633a6a8f18b3e5bfb12.tar.bz2
OneConfig-fe8261cf7c10af90c0154633a6a8f18b3e5bfb12.zip
icons sidebar, categories in config, fix some other issues
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/SideBar.java31
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java20
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java39
4 files changed, 66 insertions, 30 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
index 0a4acd6..1f7da18 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -1,7 +1,6 @@
package io.polyfrost.oneconfig.gui;
import io.polyfrost.oneconfig.config.OneConfigConfig;
-import io.polyfrost.oneconfig.gui.elements.BasicElement;
import io.polyfrost.oneconfig.gui.elements.TextInputField;
import io.polyfrost.oneconfig.gui.pages.HomePage;
import io.polyfrost.oneconfig.gui.pages.Page;
@@ -36,6 +35,11 @@ public class OneConfigGui extends GuiScreen {
INSTANCE = this;
}
+ public OneConfigGui(Page page) {
+ INSTANCE = this;
+ currentPage = page;
+ }
+
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
index 60f2a93..dc136a7 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
@@ -3,7 +3,9 @@ package io.polyfrost.oneconfig.gui;
import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.gui.elements.BasicButton;
import io.polyfrost.oneconfig.gui.pages.HomePage;
+import io.polyfrost.oneconfig.gui.pages.ModConfigPage;
import io.polyfrost.oneconfig.gui.pages.ModsPage;
+import io.polyfrost.oneconfig.gui.pages.Page;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.utils.MathUtils;
@@ -18,18 +20,19 @@ public class SideBar {
private float targetY = 0, currentY = 0;
public SideBar() {
- btnList.add(new BasicButton(192, 36, "Dashboard", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage()));
- btnList.add(new BasicButton(192, 36, "Global Search", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Mods", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage()));
- btnList.add(new BasicButton(192, 36, "Performance", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Profiles", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Updates", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Screenshots", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "HUD Settings", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "General", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Close", "/assets/oneconfig/textures/share.png", null, -1, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(null)));
- btnList.add(new BasicButton(192, 36, "Minimize", "/assets/oneconfig/textures/share.png", null, -1, BasicButton.ALIGNMENT_LEFT));
- btnList.add(new BasicButton(192, 36, "Edit HUD", "/assets/oneconfig/textures/share.png", null, 0, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(new HudGui())));
+ btnList.add(new BasicButton(192, 36, "Dashboard", "/assets/oneconfig/textures/Dashboard.png", null, -3, BasicButton.ALIGNMENT_LEFT, new HomePage()));
+ btnList.add(new BasicButton(192, 36, "Global Search", "/assets/oneconfig/textures/search.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Mods", "/assets/oneconfig/textures/Mods.png", null, -3, BasicButton.ALIGNMENT_LEFT, new ModsPage()));
+ btnList.add(new BasicButton(192, 36, "Performance", "/assets/oneconfig/textures/Performance.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Profiles", "/assets/oneconfig/textures/Profiles.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Updates", "/assets/oneconfig/textures/Update.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Theme", "/assets/oneconfig/textures/Theme.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Screenshots", "/assets/oneconfig/textures/Image.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "HUD Settings", "/assets/oneconfig/textures/HUDSettings.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Preferences", "/assets/oneconfig/textures/Settings.png", null, -3, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Close", "/assets/oneconfig/textures/XCircle.png", null, -1, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(null)));
+ btnList.add(new BasicButton(192, 36, "Minimize", "/assets/oneconfig/textures/Minimise.png", null, -1, BasicButton.ALIGNMENT_LEFT));
+ btnList.add(new BasicButton(192, 36, "Edit HUD", "/assets/oneconfig/textures/HUD.png", null, 0, BasicButton.ALIGNMENT_LEFT, () -> Minecraft.getMinecraft().displayGuiScreen(new HudGui())));
}
public void draw(long vg, int x, int y) {
@@ -53,8 +56,8 @@ public class SideBar {
RenderManager.drawString(vg, "PERSONALIZATION", x + 16, y + 420, OneConfigConfig.WHITE_90, 12f, Fonts.INTER_SEMIBOLD);
i = 342;
}
- if (i == 474) {
- i = 518;
+ if (i == 518) {
+ i = 562;
}
if (btn.isClicked() && btn.getPage() != null) {
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
index 6832236..93f4378 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java
@@ -26,10 +26,10 @@ public class ConfigCheckbox extends BasicOption {
toggled = (boolean) get();
} catch (IllegalAccessException ignored) {
}
- boolean hover = InputUtils.isAreaHovered(x, y, 24, 24);
+ boolean hover = InputUtils.isAreaHovered(x, y + 4, 24, 24);
boolean clicked = InputUtils.isClicked() && hover;
- if(clicked) {
+ if (clicked) {
toggled = !toggled;
try {
set(toggled);
@@ -38,18 +38,18 @@ public class ConfigCheckbox extends BasicOption {
e.printStackTrace();
}
}
- if(percentOn != 1f) { // performance
- RenderManager.drawRoundedRect(vg, x, y, 24, 24, color, 6f);
- RenderManager.drawHollowRoundRect(vg, x, y, 23.5f, 23.5f, OneConfigConfig.GRAY_300, 6f, 1f); // the 0.5f is to make it look better ok
+ if (percentOn != 1f) { // performance
+ RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, color, 6f);
+ RenderManager.drawHollowRoundRect(vg, x, y + 4, 23.5f, 23.5f, OneConfigConfig.GRAY_300, 6f, 1f); // the 0.5f is to make it look better ok
}
color = ColorUtils.smoothColor(color, OneConfigConfig.GRAY_600, OneConfigConfig.GRAY_400, hover, 40f);
- RenderManager.drawString(vg, name, x + 32, y + 14, OneConfigConfig.WHITE_90, 18f, Fonts.INTER_MEDIUM);
+ RenderManager.drawString(vg, name, x + 32, y + 17, OneConfigConfig.WHITE_90, 18f, Fonts.INTER_MEDIUM);
percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 5f));
- if(percentOn == 0f) return;
- if(percentOn != 1f) {
- RenderManager.drawImage(vg, "/assets/oneconfig/textures/check.png", x, y, 24, 24, new Color(1f, 1f, 1f, percentOn).getRGB());
+ if (percentOn == 0f) return;
+ if (percentOn != 1f) {
+ RenderManager.drawImage(vg, "/assets/oneconfig/textures/check.png", x, y + 4, 24, 24, new Color(1f, 1f, 1f, percentOn).getRGB());
} else { // performance, that color could cause havoc am I right definitely
- RenderManager.drawImage(vg, "/assets/oneconfig/textures/check.png", x, y, 24, 24);
+ RenderManager.drawImage(vg, "/assets/oneconfig/textures/check.png", x, y + 4, 24, 24);
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
index f3224b5..6bdf9d9 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -3,25 +3,46 @@ package io.polyfrost.oneconfig.gui.pages;
import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.config.data.OptionPage;
import io.polyfrost.oneconfig.config.interfaces.BasicOption;
+import io.polyfrost.oneconfig.gui.elements.BasicButton;
import io.polyfrost.oneconfig.gui.elements.config.ConfigPageButton;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+import java.util.ArrayList;
+
public class ModConfigPage extends Page {
private final OptionPage page;
+ private final ArrayList<BasicButton> categories = new ArrayList<>();
+ private String selectedCategory;
public ModConfigPage(OptionPage page) {
super("Mod: " + page.mod.name);
this.page = page;
+ if (page.categories.size() == 0) return;
+ selectedCategory = page.categories.keySet().stream().findFirst().get();
+ if (page.categories.size() < 2) return;
+ for (String category : page.categories.keySet()) {
+ BasicButton button = new BasicButton(0, 32, category, null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> switchCategory(category));
+ if (category.equals(selectedCategory)) button.setToggled(true);
+ categories.add(button);
+ }
}
@Override
public void draw(long vg, int x, int y) {
if (page.categories.size() == 0) return;
- String selectedCategory = page.categories.keySet().stream().findFirst().get();
int optionX = x + 30;
int optionY = y + (page.categories.size() == 1 ? 16 : 64);
+ // Category buttons
+ int buttonX = x + 16;
+ for (BasicButton button : categories) {
+ if (button.getWidth() == 0)
+ button.setWidth((int) (Math.ceil(RenderManager.getTextWidth(vg, button.getText(), 14f, Fonts.INTER_MEDIUM) / 8f) * 8 + 16));
+ button.draw(vg, buttonX, y + 16);
+ buttonX += button.getWidth() + 16;
+ }
+
// Top page buttons
for (ConfigPageButton page : page.categories.get(selectedCategory).topPages) {
page.draw(vg, optionX, optionY);
@@ -29,9 +50,9 @@ public class ModConfigPage extends Page {
}
// Background
- int backgroundSize = 48;
+ int backgroundSize = 16;
for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) {
- backgroundSize += 32;
+ backgroundSize += 48;
for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) {
BasicOption option = page.categories.get(selectedCategory).subcategories.get(subCategory).get(i);
if (i + 1 < page.categories.get(selectedCategory).subcategories.get(subCategory).size()) {
@@ -49,7 +70,7 @@ public class ModConfigPage extends Page {
// draw options
optionY += 16;
- int optionLastY = optionX;
+ int optionLastY = optionY;
for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) {
RenderManager.drawString(vg, subCategory, optionX, optionY + 16, OneConfigConfig.WHITE_90, 24f, Fonts.INTER_MEDIUM);
optionY += 48;
@@ -104,11 +125,19 @@ public class ModConfigPage extends Page {
@Override
public void keyTyped(char key, int keyCode) {
if (page.categories.size() == 0) return;
- String selectedCategory = page.categories.keySet().stream().findFirst().get();
for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) {
for (int i = 0; i < page.categories.get(selectedCategory).subcategories.get(subCategory).size(); i++) {
page.categories.get(selectedCategory).subcategories.get(subCategory).get(i).keyTyped(key, keyCode);
}
}
}
+
+ public void switchCategory(String newCategory) {
+ if (!page.categories.containsKey(newCategory)) return;
+ selectedCategory = newCategory;
+ for (BasicButton button : categories) {
+ if (button.getText().equals(newCategory)) continue;
+ button.setToggled(false);
+ }
+ }
}