aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/gui/pages
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-04-25 13:12:22 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-04-25 13:12:22 +0100
commit89d6576a7777a2949e04b2c6c8d2eb015a733529 (patch)
tree1a6906f9c71591aacbcbf5a32a1a1ed582b95fcb /src/main/java/io/polyfrost/oneconfig/gui/pages
parent29156d83c4213e319149fa5e0a926dd913404528 (diff)
downloadOneConfig-89d6576a7777a2949e04b2c6c8d2eb015a733529.tar.gz
OneConfig-89d6576a7777a2949e04b2c6c8d2eb015a733529.tar.bz2
OneConfig-89d6576a7777a2949e04b2c6c8d2eb015a733529.zip
add size, do some config element stuff, fixes for cards, finish mods page and performance page, cleanup and some more
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui/pages')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java1
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java52
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java74
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java8
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java42
5 files changed, 152 insertions, 25 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java
index d38f565..667b02e 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java
@@ -7,6 +7,7 @@ import io.polyfrost.oneconfig.lwjgl.font.Fonts;
public class HomePage extends Page {
private final BasicButton btn = new BasicButton(184, 36, "Socials", "/assets/oneconfig/textures/share.png", "/assets/oneconfig/textures/share2.png", 1, BasicButton.ALIGNMENT_CENTER);
+
public HomePage() {
super("Home Dashboard");
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
new file mode 100644
index 0000000..357d684
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -0,0 +1,52 @@
+package io.polyfrost.oneconfig.gui.pages;
+
+import io.polyfrost.oneconfig.config.core.ConfigCore;
+import io.polyfrost.oneconfig.config.data.ModData;
+import io.polyfrost.oneconfig.config.interfaces.Option;
+import io.polyfrost.oneconfig.gui.elements.config.OConfigCategory;
+import org.lwjgl.input.Mouse;
+
+import java.util.ArrayList;
+
+public class ModConfigPage extends Page {
+ private final ModData modData;
+ private final ArrayList<Option> options;
+
+ public ModConfigPage(ModData mod) {
+ super("Mod: " + mod.name);
+ this.modData = mod;
+ options = ConfigCore.settings.get(mod);
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ for (Option option : options) {
+ if (option instanceof OConfigCategory) {
+ OConfigCategory category = (OConfigCategory) option;
+ for (Option subOption : category.options) {
+ if (subOption.size == 0) {
+ subOption.draw(vg, x, y, Mouse.getX(), Mouse.getY());
+ }
+ }
+ for (Option subOption : category.options) {
+ if (subOption.size == 1) {
+ subOption.draw(vg, x, y, Mouse.getX(), Mouse.getY());
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void finishUpAndClose() {
+ modData.config.save(); // TODO
+ }
+
+ public ModData getModData() {
+ return modData;
+ }
+
+ protected ArrayList<Option> getOptions() {
+ return options;
+ }
+}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
index 856b2f3..9fc14f7 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
@@ -1,52 +1,80 @@
package io.polyfrost.oneconfig.gui.pages;
import io.polyfrost.oneconfig.OneConfig;
+import io.polyfrost.oneconfig.config.OneConfigConfig;
import io.polyfrost.oneconfig.config.data.ModData;
+import io.polyfrost.oneconfig.config.data.ModType;
import io.polyfrost.oneconfig.gui.elements.BasicButton;
import io.polyfrost.oneconfig.gui.elements.ModCard;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import java.util.ArrayList;
import java.util.List;
public class ModsPage extends Page {
- private final BasicButton allBtn = new BasicButton(49, 40, "All", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton newBtn = new BasicButton(64, 40, "New", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton combatBtn = new BasicButton(104, 40, "Combat", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton hudBtn = new BasicButton(104, 40, "HUD & QoL", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton hypixelBtn = new BasicButton(104, 40, "Hypixel", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton skyblockBtn = new BasicButton(104, 40, "Skyblock", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton utilBtn = new BasicButton(104, 40, "Utility", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
- private final BasicButton customBtn = new BasicButton(104, 40, "Custom", null, null, 0, BasicButton.ALIGNMENT_CENTER, true);
private final List<ModCard> modCards = new ArrayList<>();
+ private final List<BasicButton> modCategories = new ArrayList<>();
public ModsPage() {
super("Mods");
- for(ModData modData : OneConfig.loadedMods) {
+ for (ModData modData : OneConfig.loadedMods) {
modCards.add(new ModCard(modData, null, true, false, false));
}
+ for (ModCard card : modCards) {
+ if (card.isFavorite()) {
+ modCards.remove(card);
+ modCards.add(0, card);
+ }
+ }
+ modCategories.add(new BasicButton(64, 32, "All", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(80, 32, "Combat", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(64, 32, "HUD", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(104, 32, "Utility & QoL", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(80, 32, "Hypixel", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(80, 32, "Skyblock", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.add(new BasicButton(88, 32, "3rd Party", null, null, 0, BasicButton.ALIGNMENT_CENTER, true));
+ modCategories.get(0).setToggled(true);
}
public void draw(long vg, int x, int y) {
- allBtn.draw(vg, x + 16, y + 16);
- newBtn.draw(vg, x + 92, y + 16);
- combatBtn.draw(vg, x + 168, y + 16);
- hudBtn.draw(vg, x + 284, y + 16);
- hypixelBtn.draw(vg, x + 400, y + 16);
- skyblockBtn.draw(vg, x + 516, y + 16);
- utilBtn.draw(vg, x + 632, y + 16);
- customBtn.draw(vg, x + 748, y + 16);
+ int iXCat = x + 16;
+ for (BasicButton btn : modCategories) {
+ btn.draw(vg, iXCat, y + 16);
+ iXCat += btn.getWidth() + 8;
+ }
+ if ((modCategories.get(1).isClicked() || modCategories.get(2).isClicked() || modCategories.get(3).isClicked() || modCategories.get(4).isClicked() || modCategories.get(5).isClicked() || modCategories.get(6).isClicked()) && modCategories.get(0).isToggled()) {
+ modCategories.get(0).setToggled(false);
+ }
+ if (!modCategories.get(0).isToggled() && !modCategories.get(1).isToggled() && !modCategories.get(2).isToggled() && !modCategories.get(3).isToggled() && !modCategories.get(4).isToggled() && !modCategories.get(5).isToggled() && !modCategories.get(6).isToggled()) {
+ modCategories.get(0).setToggled(true);
+ }
+ if (modCategories.get(0).isToggled()) {
+ for (BasicButton btn : modCategories) {
+ if (!btn.getText().equals("All")) {
+ btn.setToggled(false);
+ }
+ }
+ }
+
int iX = x + 16;
int iY = y + 72;
- for(ModCard modCard : modCards) {
- modCard.draw(vg, iX, iY);
- iX += 260;
- if(iX > x + 796) {
- iX = x + 16;
- iY += 135;
+ for (ModCard modCard : modCards) {
+ if (modCategories.get(0).isToggled() || (modCategories.get(1).isToggled() && modCard.getModData().modType == ModType.PVP) || (modCategories.get(2).isToggled() && modCard.getModData().modType == ModType.HUD) || (modCategories.get(3).isToggled() && modCard.getModData().modType == ModType.UTIL_QOL) || (modCategories.get(4).isToggled() && modCard.getModData().modType == ModType.HYPIXEL) || (modCategories.get(5).isToggled() && modCard.getModData().modType == ModType.SKYBLOCK) || (modCategories.get(6).isToggled() && modCard.getModData().modType == ModType.OTHER)) {
+ modCard.draw(vg, iX, iY);
+ iX += 260;
+ if (iX > x + 796) {
+ iX = x + 16;
+ iY += 135;
+ }
}
}
+ if (iX == x + 16 && iY == y + 72) {
+ RenderManager.drawString(vg, "Looks like there is nothing here. Try another category?", x + 16, y + 72, OneConfigConfig.WHITE_60, 14f, Fonts.INTER_MEDIUM);
+ }
}
+
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java
index 492a1f9..58c181f 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java
@@ -6,7 +6,7 @@ import io.polyfrost.oneconfig.lwjgl.font.Fonts;
/**
* A page is a 1056x728 rectangle of the GUI. It is the main content of the gui, and can be switched back and forwards easily. All the content of OneConfig is in a page.
*/
-public class Page {
+public abstract class Page {
protected final String title;
Page(String title) {
@@ -14,7 +14,11 @@ public class Page {
}
public void draw(long vg, int x, int y) {
- RenderManager.drawString(vg, "If you are seeing this, something went quite wrong.", x + 12, y + 12, -1, 24f, Fonts.INTER_BOLD);
+ RenderManager.drawString(vg, "Doesn't appear there is any content to this page :(", x + 12, y + 18, -1, 24f, Fonts.INTER_BOLD);
+ }
+
+ public void finishUpAndClose() {
+
}
public String getTitle() {
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java
new file mode 100644
index 0000000..8dbdea9
--- /dev/null
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java
@@ -0,0 +1,42 @@
+package io.polyfrost.oneconfig.gui.pages;
+
+import io.polyfrost.oneconfig.OneConfig;
+import io.polyfrost.oneconfig.config.OneConfigConfig;
+import io.polyfrost.oneconfig.config.data.ModData;
+import io.polyfrost.oneconfig.config.data.ModType;
+import io.polyfrost.oneconfig.gui.elements.ModCard;
+import io.polyfrost.oneconfig.lwjgl.RenderManager;
+import io.polyfrost.oneconfig.lwjgl.font.Fonts;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PerformanceModsPage extends Page {
+ List<ModCard> modCards = new ArrayList<>();
+
+ public PerformanceModsPage() {
+ super("Performance Mods");
+ for (ModData mod : OneConfig.loadedMods) {
+ if (mod.modType == ModType.PERFORMANCE) {
+ modCards.add(new ModCard(mod, null, true, false, false));
+ }
+ }
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ int iX = x + 16;
+ int iY = y + 16;
+ for (ModCard card : modCards) {
+ card.draw(vg, iX, iY);
+ iX += 260;
+ if (iX > x + 796) {
+ iX = x + 16;
+ iY += 135;
+ }
+ }
+ if (iX == x + 16 && iY == y + 16) {
+ RenderManager.drawString(vg, "Looks like there is nothing here. Try getting some more mods!", x + 16, y + 16, OneConfigConfig.WHITE_60, 14f, Fonts.INTER_MEDIUM);
+ }
+ }
+}