aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/OneConfig.java4
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java1
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java8
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/data/ModType.java1
-rw-r--r--src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java4
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/SideBar.java7
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java21
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java17
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java10
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java35
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java42
-rw-r--r--src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java14
13 files changed, 65 insertions, 101 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/OneConfig.java b/src/main/java/io/polyfrost/oneconfig/OneConfig.java
index 658536a..0715f4a 100644
--- a/src/main/java/io/polyfrost/oneconfig/OneConfig.java
+++ b/src/main/java/io/polyfrost/oneconfig/OneConfig.java
@@ -55,8 +55,8 @@ public class OneConfig {
}
public static void reloadModsList() {
- loadedMods.addAll(ConfigCore.settings.keySet());
- LinkedHashSet<Mod> modData = new LinkedHashSet<>(ConfigCore.settings.keySet());
+ loadedMods.addAll(ConfigCore.oneConfigMods);
+ LinkedHashSet<Mod> modData = new LinkedHashSet<>(ConfigCore.oneConfigMods);
for (ModContainer mod : Loader.instance().getActiveModList()) {
ModMetadata metadata = mod.getMetadata();
loadedOtherMods.add(metadata);
diff --git a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java
index f10111c..955f7a4 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java
@@ -33,6 +33,7 @@ public class OneConfigConfig extends Config {
public static final int BLUE_600 = new Color(20, 82, 204, 255).getRGB(); // Blue 600 // button blue normal
public static final int BLUE_600_80 = new Color(20, 82, 204, 204).getRGB(); // Blue 600 80% // button blue click
public static final int BLUE_500 = new Color(25, 103, 255, 255).getRGB(); // Blue 500 // button blue hover
+ public static final int WHITE_50 = new Color(255, 255, 255, 127).getRGB(); // White 60%
public static final int WHITE_60 = new Color(255, 255, 255, 153).getRGB(); // White 60%
public static final int WHITE_80 = new Color(255, 255, 255, 204).getRGB(); // White 80%
public static final int WHITE_90 = new Color(255, 255, 255, 229).getRGB(); // White 90%
diff --git a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java
index 9be25e9..6cce197 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java
@@ -6,17 +6,17 @@ import io.polyfrost.oneconfig.hud.HudCore;
import java.util.ArrayList;
public class ConfigCore {
- public static ArrayList<Mod> OneConfigMods = new ArrayList<>();
+ public static ArrayList<Mod> oneConfigMods = new ArrayList<>();
public static void saveAll() {
- for (Mod modData : OneConfigMods) {
+ for (Mod modData : oneConfigMods) {
modData.config.save();
}
}
public static void reInitAll() {
- ArrayList<Mod> data = new ArrayList<>(OneConfigMods);
- OneConfigMods.clear();
+ ArrayList<Mod> data = new ArrayList<>(oneConfigMods);
+ oneConfigMods.clear();
HudCore.huds.clear();
for (Mod modData : data) {
modData.config.init(modData);
diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java b/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java
index d2c5549..9769584 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java
@@ -1,7 +1,6 @@
package io.polyfrost.oneconfig.config.data;
public enum ModType {
- PERFORMANCE,
PVP,
HUD,
UTIL_QOL,
diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
index c68162e..0539d5f 100644
--- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
+++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java
@@ -2,6 +2,7 @@ package io.polyfrost.oneconfig.config.interfaces;
import com.google.gson.*;
import io.polyfrost.oneconfig.config.annotations.Option;
+import io.polyfrost.oneconfig.config.core.ConfigCore;
import io.polyfrost.oneconfig.config.data.Mod;
import io.polyfrost.oneconfig.config.data.OptionPage;
import io.polyfrost.oneconfig.config.profiles.Profiles;
@@ -34,6 +35,7 @@ public class Config {
else save();
mod.config = this;
generateOptionList(this.getClass(), mod.defaultPage);
+ ConfigCore.oneConfigMods.add(mod);
}
/**
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
index fd0ef47..67ddc21 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java
@@ -28,7 +28,7 @@ public class OneConfigGui extends GuiScreen {
protected Page prevPage;
private float pageProgress = -224f;
- private final TextInputField textInputField = new TextInputField(776, 32, "Search all of OneConfig...", false, false);
+ private final TextInputField textInputField = new TextInputField(248, 40, "Search all of OneConfig...", false, false);
public OneConfigGui() {
@@ -57,7 +57,7 @@ public class OneConfigGui extends GuiScreen {
RenderManager.drawImage(vg, "/assets/oneconfig/textures/icon.png", x + 19, y + 19, 42, 42);
RenderManager.drawString(vg, "OneConfig", x + 69, y + 32, OneConfigConfig.WHITE, 18f, Fonts.INTER_BOLD); // added half line height to center text
RenderManager.drawString(vg, "By Polyfrost", x + 69, y + 51, OneConfigConfig.WHITE, 12f, Fonts.INTER_REGULAR);
- textInputField.draw(vg, x + 400, y + 200);
+ textInputField.draw(vg, x + 1020, y + 16);
//element.setColorPalette(0);
sideBar.draw(vg, x, y);
nvgScissor(vg, x + 224, y + 72, 1056, 728);
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
index f6ec15f..60f2a93 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/SideBar.java
@@ -4,7 +4,6 @@ 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.ModsPage;
-import io.polyfrost.oneconfig.gui.pages.PerformanceModsPage;
import io.polyfrost.oneconfig.lwjgl.RenderManager;
import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.utils.MathUtils;
@@ -22,7 +21,7 @@ public class 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 Mods", "/assets/oneconfig/textures/share.png", null, -3, BasicButton.ALIGNMENT_LEFT, new PerformanceModsPage()));
+ 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));
@@ -58,11 +57,9 @@ public class SideBar {
i = 518;
}
- if (btn.isClicked()) {
+ if (btn.isClicked() && btn.getPage() != null) {
if (i < 520) targetY = btn.y;
}
}
-
-
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
index 3ded1b1..a87e412 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java
@@ -16,13 +16,10 @@ public class BasicButton extends BasicElement {
private final int thisAlignment;
private final float fontSize;
private final int colorPalette;
-
public int x, y;
public static final int ALIGNMENT_LEFT = 0;
public static final int ALIGNMENT_CENTER = 1;
-
private boolean toggleable;
-
private Page page;
private Runnable runnable;
@@ -66,6 +63,11 @@ public class BasicButton extends BasicElement {
this.runnable = runnable;
}
+ public BasicButton(int width, int height, @NotNull String text, @Nullable String fileNameLeftIco, @Nullable String fileNameRightIco, int colorPalette, int alignment, boolean toggleable, Runnable runnable) {
+ this(width, height, text, fileNameLeftIco, fileNameRightIco, colorPalette, alignment, runnable);
+ this.toggleable = toggleable;
+ }
+
@Override
public void draw(long vg, int x, int y) {
this.x = x;
@@ -84,6 +86,7 @@ public class BasicButton extends BasicElement {
textColor = OneConfigConfig.WHITE_80;
if (hovered) textColor = OneConfigConfig.WHITE;
if (clicked) textColor = OneConfigConfig.WHITE_80;
+ if (page == null) textColor = OneConfigConfig.WHITE_50;
}
if (thisAlignment == ALIGNMENT_CENTER) {
@@ -98,7 +101,7 @@ public class BasicButton extends BasicElement {
}
if (thisAlignment == ALIGNMENT_LEFT) {
if (fileNameLeftIco != null) {
- RenderManager.drawImage(vg, fileNameLeftIco, x + 12, y + 8, 20, 20);
+ RenderManager.drawImage(vg, fileNameLeftIco, x + 12, y + 8, 20, 20, textColor);
RenderManager.drawString(vg, text, x + 40, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.INTER_MEDIUM);
} else {
RenderManager.drawString(vg, text, x + 12, y + ((float) height / 2) + 1, textColor, fontSize, Fonts.INTER_MEDIUM);
@@ -133,10 +136,20 @@ public class BasicButton extends BasicElement {
}
}
+ @Override
+ public void update(int x, int y) {
+ if (toggleable && toggled) return;
+ super.update(x, y);
+ }
+
public void setToggled(boolean state) {
this.toggled = state;
}
+ public Page getPage() {
+ return page;
+ }
+
public String getText() {
return text;
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
index 09c6aa0..bb8b830 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -11,6 +11,8 @@ import io.polyfrost.oneconfig.lwjgl.font.Fonts;
import io.polyfrost.oneconfig.utils.ColorUtils;
import io.polyfrost.oneconfig.utils.InputUtils;
import net.minecraft.client.Minecraft;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.ModMetadata;
import org.jetbrains.annotations.NotNull;
@@ -94,15 +96,12 @@ public class ModCard extends BasicElement {
if (mod.name.equalsIgnoreCase(modData.name)) {
System.out.println("Attempting to run command for a mod that isn't OneConfig: " + mod.name);
for (String commands : ClientCommandHandler.instance.getCommands().keySet()) {
- if (commands.equalsIgnoreCase(mod.name)) {
- System.out.println("Found command for mod: /" + commands);
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + commands);
- //Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + mod.name.toLowerCase());
- break;
- }
- if (commands.equalsIgnoreCase(mod.modId)) {
- System.out.println("Found command for mod: /" + commands);
- Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + commands);
+ if (commands.equalsIgnoreCase(mod.name) || commands.equalsIgnoreCase(mod.modId)) {
+ try {
+ ClientCommandHandler.instance.getCommands().get(commands).processCommand(Minecraft.getMinecraft().thePlayer, new String[]{});
+ } catch (CommandException e) {
+ throw new RuntimeException(e);
+ }
break;
}
}
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 6d24f4a..04b2ce7 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -1,19 +1,13 @@
package io.polyfrost.oneconfig.gui.pages;
-import io.polyfrost.oneconfig.config.core.ConfigCore;
import io.polyfrost.oneconfig.config.data.Mod;
-import io.polyfrost.oneconfig.config.interfaces.BasicOption;
-
-import java.util.ArrayList;
public class ModConfigPage extends Page {
private final Mod modData;
- private final ArrayList<BasicOption> options;
public ModConfigPage(Mod mod) {
super("Mod: " + mod.name);
this.modData = mod;
- options = ConfigCore.settings.get(mod);
}
@Override
@@ -29,8 +23,4 @@ public class ModConfigPage extends Page {
public Mod getModData() {
return modData;
}
-
- protected ArrayList<BasicOption> 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 b45facb..7834e0b 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java
@@ -28,13 +28,13 @@ public class ModsPage extends Page {
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.add(new BasicButton(64, 32, "All", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(0)));
+ modCategories.add(new BasicButton(80, 32, "Combat", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(1)));
+ modCategories.add(new BasicButton(64, 32, "HUD", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(2)));
+ modCategories.add(new BasicButton(104, 32, "Utility & QoL", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(3)));
+ modCategories.add(new BasicButton(80, 32, "Hypixel", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(4)));
+ modCategories.add(new BasicButton(80, 32, "Skyblock", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(5)));
+ modCategories.add(new BasicButton(88, 32, "3rd Party", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(6)));
modCategories.get(0).setToggled(true);
}
@@ -44,20 +44,6 @@ public class ModsPage extends Page {
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;
@@ -74,7 +60,12 @@ public class ModsPage extends Page {
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);
}
-
}
+ private void unselect(int index) {
+ for (int i = 0; i < modCategories.size(); i++) {
+ if (index == i) continue;
+ modCategories.get(i).setToggled(false);
+ }
+ }
}
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java b/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java
deleted file mode 100644
index 43cc423..0000000
--- a/src/main/java/io/polyfrost/oneconfig/gui/pages/PerformanceModsPage.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package io.polyfrost.oneconfig.gui.pages;
-
-import io.polyfrost.oneconfig.OneConfig;
-import io.polyfrost.oneconfig.config.OneConfigConfig;
-import io.polyfrost.oneconfig.config.data.Mod;
-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 (Mod 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);
- }
- }
-}
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
index 87e3d03..e9bbf47 100644
--- a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -193,6 +193,20 @@ public final class RenderManager {
}
}
+ public static void drawImage(long vg, String fileName, float x, float y, float width, float height, int color) {
+ if (ImageLoader.INSTANCE.loadImage(vg, fileName)) {
+ NVGPaint imagePaint = NVGPaint.calloc();
+ Image image = ImageLoader.INSTANCE.getImage(fileName);
+ nvgBeginPath(vg);
+ nvgImagePattern(vg, x, y, width, height, 0, image.getReference(), 1, imagePaint);
+ nvgRGBA((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), (byte) (color >> 24 & 0xFF), imagePaint.innerColor());
+ nvgRect(vg, x, y, width, height);
+ nvgFillPaint(vg, imagePaint);
+ nvgFill(vg);
+ imagePaint.free();
+ }
+ }
+
public static void drawSVGImage(long vg, String fileName, float x, float y, float width, float height) {
if (ImageLoader.INSTANCE.loadSVGImage(fileName)) {
try {