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/SideBar.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java16
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java3
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java17
8 files changed, 40 insertions, 14 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
index bda24a2..4652ae0 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -5,7 +5,9 @@ import cc.polyfrost.oneconfig.gui.animations.DummyAnimation;
import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuart;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.gui.pages.CreditsPage;
+import cc.polyfrost.oneconfig.gui.pages.ModConfigPage;
import cc.polyfrost.oneconfig.gui.pages.ModsPage;
+import cc.polyfrost.oneconfig.internal.OneConfig;
import cc.polyfrost.oneconfig.internal.assets.Colors;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
@@ -40,6 +42,7 @@ public class SideBar {
public SideBar() {
buttons.get(0).setClickAction(new CreditsPage());
buttons.get(2).setClickAction(new ModsPage());
+ buttons.get(8).setClickAction(new ModConfigPage(OneConfig.preferences.mod.defaultPage, true));
HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui()));
CloseButton.setClickAction(GuiUtils::closeScreen);
for (BasicButton button : buttons) {
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 e5d187f..ac12f07 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java
@@ -44,6 +44,7 @@ public class ModCard extends BasicElement {
@Override
public void draw(long vg, int x, int y) {
super.update(x, y);
+ String cleanName = modData.name.replaceAll("ยง.", "");
Scissor scissor = ScissorManager.scissor(vg, x, y, width, height);
isHoveredMain = InputUtils.isAreaHovered(x, y, width, 87);
@@ -57,11 +58,11 @@ public class ModCard extends BasicElement {
RenderManager.drawSvg(vg, modData.modIcon, x + 98, y + 19, 48, 48);
else RenderManager.drawImage(vg, modData.modIcon, x + 98, y + 19, 48, 48);
} else {
- RenderManager.drawText(vg, modData.name, x + 122 - RenderManager.getTextWidth(vg, modData.name, 16, Fonts.MINECRAFT_BOLD) / 2f, y + 44, ColorUtils.setAlpha(Colors.WHITE, (int) (colorFrame.getAlpha() * 255)), 16, Fonts.MINECRAFT_BOLD);
+ RenderManager.drawText(vg, cleanName, x + Math.max(0, (244 - RenderManager.getTextWidth(vg, cleanName, 16, Fonts.MINECRAFT_BOLD))) / 2f, y + 44, ColorUtils.setAlpha(Colors.WHITE, (int) (colorFrame.getAlpha() * 255)), 16, Fonts.MINECRAFT_BOLD);
}
favoriteButton.draw(vg, x + 212, y + 87);
favorite = favoriteButton.isToggled();
- RenderManager.drawText(vg, modData.name, x + 12, y + 103, ColorUtils.setAlpha(Colors.WHITE, (int) (colorToggle.getAlpha() * 255)), 14f, Fonts.MEDIUM);
+ RenderManager.drawText(vg, cleanName, x + 12, y + 103, ColorUtils.setAlpha(Colors.WHITE, (int) (colorToggle.getAlpha() * 255)), 14f, Fonts.MEDIUM);
if (favorite) favoriteButton.setLeftIcon(SVGs.HEART_FILL);
else favoriteButton.setLeftIcon(SVGs.HEART_OUTLINE);
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
index 5efebdd..67488d7 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java
@@ -39,7 +39,7 @@ public class ConfigColorElement extends BasicOption {
public void draw(long vg, int x, int y) {
if (!isEnabled()) RenderManager.setAlpha(vg, 0.5f);
hexField.disable(!isEnabled());
- alphaField.disable(!isEnabled() || allowAlpha);
+ alphaField.disable(!isEnabled() || !allowAlpha);
element.disable(!isEnabled());
int x1 = size == 1 ? x : x + 512;
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 b7d1a68..1aa5d66 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
@@ -6,6 +6,7 @@ import cc.polyfrost.oneconfig.config.core.OneKeyBind;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
+import cc.polyfrost.oneconfig.internal.config.core.KeyBindHandler;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
import cc.polyfrost.oneconfig.internal.assets.SVGs;
@@ -22,6 +23,7 @@ public class ConfigKeyBind extends BasicOption {
super(field, parent, name, category, subcategory, size);
button = new BasicButton(256, 32, "", SVGs.KEYSTROKE, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.SECONDARY);
button.setToggleable(true);
+ KeyBindHandler.addKeyBind(getKeyBind());
}
public static ConfigKeyBind create(Field field, Object parent) {
@@ -71,6 +73,7 @@ public class ConfigKeyBind extends BasicOption {
private OneKeyBind getKeyBind() {
OneKeyBind keyBind = new OneKeyBind();
try {
+ field.setAccessible(true);
keyBind = (OneKeyBind) get();
} catch (IllegalAccessException ignored) {
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
index 455a538..a101071 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java
@@ -32,4 +32,9 @@ public class CreditsPage extends Page {
RenderManager.drawText(vg, " - Quiltflower (Quilt Team) - Gradle decompiler", x + 20, y + 415, -1, 12, Fonts.REGULAR);
RenderManager.drawText(vg, " - Seraph (Scherso) - Locraw and Multithreading utilities", x + 20, y + 430, -1, 12, Fonts.REGULAR);
}
+
+ @Override
+ public boolean isBase() {
+ return true;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
index 3e8fbf8..fb04dc2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -3,6 +3,7 @@ package cc.polyfrost.oneconfig.gui.pages;
import cc.polyfrost.oneconfig.config.elements.OptionPage;
import cc.polyfrost.oneconfig.config.elements.OptionSubcategory;
import cc.polyfrost.oneconfig.config.elements.BasicOption;
+import cc.polyfrost.oneconfig.gui.animations.DummyAnimation;
import cc.polyfrost.oneconfig.gui.elements.BasicButton;
import cc.polyfrost.oneconfig.renderer.RenderManager;
import cc.polyfrost.oneconfig.renderer.font.Fonts;
@@ -17,10 +18,12 @@ public class ModConfigPage extends Page {
private final ArrayList<BasicButton> categories = new ArrayList<>();
private String selectedCategory;
private int totalSize = 724;
+ private final boolean base;
- public ModConfigPage(OptionPage page) {
+ public ModConfigPage(OptionPage page, boolean base) {
super(page.name);
this.page = page;
+ this.base = base;
if (page.categories.size() == 0) return;
for (String category : page.categories.keySet()) {
selectedCategory = category;
@@ -36,6 +39,10 @@ public class ModConfigPage extends Page {
}
}
+ public ModConfigPage(OptionPage page) {
+ this(page, false);
+ }
+
@Override
public void draw(long vg, int x, int y) {
if (page.categories.size() == 0) return;
@@ -84,6 +91,8 @@ public class ModConfigPage extends Page {
for (BasicButton button : categories) {
if (button.getText().equals(newCategory)) continue;
button.setToggled(false);
+ scrollTarget = 0;
+ scrollAnimation = null;
}
}
@@ -91,4 +100,9 @@ public class ModConfigPage extends Page {
public int getMaxScrollHeight() {
return totalSize;
}
+
+ @Override
+ public boolean isBase() {
+ return base;
+ }
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
index 797512f..10852ab 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java
@@ -100,8 +100,7 @@ public class ModsPage extends Page {
@Override
public int getMaxScrollHeight() {
- //return size;
- return 3298046;
+ return size;
}
@Override
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
index 882289d..fff9482 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
@@ -16,9 +16,9 @@ import org.lwjgl.input.Mouse;
*/
public abstract class Page {
protected final String title;
- private Animation scrollAnimation;
+ protected Animation scrollAnimation;
private final ColorAnimation colorAnimation = new ColorAnimation(new ColorPalette(Colors.TRANSPARENT, Colors.GRAY_400_60, Colors.GRAY_400_60));
- private float scrollTarget;
+ protected float scrollTarget;
private long scrollTime;
private boolean mouseWasDown, dragging;
private float yStart;
@@ -69,23 +69,24 @@ public abstract class Page {
}
ScissorManager.resetScissor(vg, scissor);
- if(!(scrollBarLength > 727f)) {
+ if (!(scrollBarLength > 727f)) {
final float scrollBarY = (scroll / maxScroll) * 720f;
final boolean isMouseDown = Mouse.isButtonDown(0);
- final boolean scrollHover = InputUtils.isAreaHovered(x + 1042, (int) (y - scrollBarY), 12, (int) scrollBarLength) || (System.currentTimeMillis() - scrollTime < 1000);
- final boolean hovered = scrollHover && Mouse.isButtonDown(0);
- if (hovered && isMouseDown && !mouseWasDown) {
+ final boolean scrollHover = InputUtils.isAreaHovered(x + 1042, (int) (y - scrollBarY), 12, (int) scrollBarLength);
+ final boolean scrollTimePeriod = (System.currentTimeMillis() - scrollTime < 1000);
+ final boolean hovered = (scrollHover || scrollTimePeriod) && Mouse.isButtonDown(0);
+ if (scrollHover && isMouseDown && !mouseWasDown) {
yStart = InputUtils.mouseY();
dragging = true;
}
mouseWasDown = isMouseDown;
- if(dragging) {
+ if (dragging) {
scrollTarget = -(InputUtils.mouseY() - yStart) * maxScroll / 728f;
if (scrollTarget > 0f) scrollTarget = 0f;
else if (scrollTarget < -maxScroll + 728) scrollTarget = -maxScroll + 728;
scrollAnimation = new EaseOutQuad(150, scroll, scrollTarget, false);
}
- RenderManager.drawRoundedRect(vg, x + 1044, y - scrollBarY, 8, scrollBarLength, colorAnimation.getColor(scrollHover, dragging), 4f);
+ RenderManager.drawRoundedRect(vg, x + 1044, y - scrollBarY, 8, scrollBarLength, colorAnimation.getColor(scrollHover || scrollTimePeriod, dragging), 4f);
}
}