aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java11
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage.java55
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java4
5 files changed, 69 insertions, 11 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
index bd449cf..050d8dd 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java
@@ -10,6 +10,7 @@ import cc.polyfrost.oneconfig.gui.pages.ModsPage;
import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.SVGs;
+import cc.polyfrost.oneconfig.test.ButtonTestPage;
import cc.polyfrost.oneconfig.utils.GuiUtils;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
@@ -40,11 +41,12 @@ public class SideBar {
public SideBar() {
buttons.get(0).setClickAction(new CreditsPage());
buttons.get(2).setClickAction(new ModsPage());
+ buttons.get(8).setClickAction(new ButtonTestPage());
HUDButton.setClickAction(() -> GuiUtils.displayScreen(new HudGui()));
CloseButton.setClickAction(GuiUtils::closeScreen);
- for (int i = 0; i < buttons.size(); i++) {
- if (i == 0 || i == 2) continue;
- buttons.get(i).disable(true);
+ for (BasicButton button : buttons) {
+ if (button.hasClickAction()) continue;
+ button.disable(true);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
index d7e5c9e..c240afd 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicButton.java
@@ -63,12 +63,13 @@ public class BasicButton extends BasicElement {
this.y = y;
this.update(x, y);
if (disabled) RenderManager.setAlpha(vg, 0.5f);
- RenderManager.drawRoundedRect(vg, x, y, this.width, this.height, colorPalette == ColorPalette.TERTIARY || colorPalette == ColorPalette.TERTIARY_DESTRUCTIVE ? OneConfigConfig.TRANSPARENT : currentColor, this.cornerRadius);
float contentWidth = 0f;
int color = -1;
- if (colorPalette == ColorPalette.TERTIARY || colorPalette == ColorPalette.TERTIARY_DESTRUCTIVE) {
+ if (colorPalette == ColorPalette.TERTIARY || colorPalette == ColorPalette.TERTIARY_DESTRUCTIVE)
color = currentColor;
- }
+ else
+ RenderManager.drawRoundedRect(vg, x, y, this.width, this.height, currentColor, this.cornerRadius);
+
final float middle = x + width / 2f;
final float middleYIcon = y + height / 2f - iconSize / 2f;
final float middleYText = y + height / 2f + fontSize / 8f;
@@ -163,4 +164,8 @@ public class BasicButton extends BasicElement {
public void setRightIcon(SVGs icon) {
icon2 = icon;
}
+
+ public boolean hasClickAction() {
+ return page != null || runnable != null;
+ }
}
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 4a3cfa6..4e85cf5 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java
@@ -17,7 +17,7 @@ public abstract class Page {
protected final String title;
- Page(String title) {
+ protected Page(String title) {
this.title = title;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage.java b/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage.java
new file mode 100644
index 0000000..5e2a864
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage.java
@@ -0,0 +1,55 @@
+package cc.polyfrost.oneconfig.test;
+
+import cc.polyfrost.oneconfig.gui.elements.BasicButton;
+import cc.polyfrost.oneconfig.gui.pages.Page;
+import cc.polyfrost.oneconfig.lwjgl.image.SVGs;
+import cc.polyfrost.oneconfig.utils.color.ColorPalette;
+
+import java.util.ArrayList;
+
+public class ButtonTestPage extends Page {
+ private final ArrayList<BasicButton> row1 = new ArrayList<BasicButton>() {{
+ add(new BasicButton(254, 48, "Primary", BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY));
+ add(new BasicButton(254, 48, "Primary Destructive", BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY_DESTRUCTIVE));
+ add(new BasicButton(254, 48, "Secondary", BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY));
+ add(new BasicButton(254, 48, "Secondary Destructive", BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY_DESTRUCTIVE));
+ add(new BasicButton(254, 48, "Tertiary", BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY));
+ add(new BasicButton(254, 48, "Tertiary Destructive", BasicButton.ALIGNMENT_CENTER, ColorPalette.TERTIARY_DESTRUCTIVE));
+ }};
+
+ private final ArrayList<BasicButton> row2 = new ArrayList<BasicButton>() {{
+ add(new BasicButton(170, 32, "32", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY));
+ add(new BasicButton(193, 36, "36", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY));
+ add(new BasicButton(208, 40, "40", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY));
+ add(new BasicButton(254, 48, "48", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY));
+ }};
+
+ private final ArrayList<BasicButton> row3 = new ArrayList<BasicButton>() {{
+ add(new BasicButton(254, 48, "Left", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY));
+ add(new BasicButton(254, 48, "Center", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY));
+ add(new BasicButton(254, 48, "Justified", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.PRIMARY));
+ }};
+
+ public ButtonTestPage() {
+ super("Buttons");
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ int buttonY = y + 16;
+ for (BasicButton button : row1) {
+ button.draw(vg, x + 16, buttonY);
+ buttonY += 64;
+ }
+ buttonY = y + 16;
+ for (BasicButton button : row2) {
+ button.draw(vg, x + 286, buttonY);
+ buttonY += 64;
+ }
+ buttonY = y + 16;
+ for (BasicButton button : row3) {
+ button.draw(vg, x + 556, buttonY);
+ buttonY += 64;
+ }
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java
index 08d1796..a73e9ff 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorPalette.java
@@ -22,10 +22,6 @@ public class ColorPalette {
*/
public static final ColorPalette SECONDARY = new ColorPalette(OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, OneConfigConfig.GRAY_400_80);
/**
- * <h1>Secondary (Transparent) Color Scheme</h1> Normal: Transparent,<br> Hover: Gray rgba(229, 229, 229, 77),<br> Clicked: Gray rgba(229, 229, 229, 51)
- */
- public static final ColorPalette SECONDARY_TRANSPARENT = new ColorPalette(OneConfigConfig.TRANSPARENT, new Color(229, 229, 229, 77).getRGB(), new Color(229, 229, 229, 51).getRGB());
- /**
* <h1>Tertiary Color Scheme</h1> Normal: Transparent (Text=White 90%),<br> Hover: Transparent (Text=White 100%),<br> Clicked: Transparent (Text=White 80%)
* <h2>NOTICE this returns the text colors as it is always transparent.</h2>
*/