aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-10 17:48:05 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-05-10 17:48:05 +0200
commite299255d82e69e461893ce8ff0ec945c253d945f (patch)
tree24dea1adb3987d997db37bc3c636a65a55040426 /src/main/java/cc/polyfrost/oneconfig/gui
parentf0aac9cac78fc14e2991741061c67b622c039f37 (diff)
downloadOneConfig-e299255d82e69e461893ce8ff0ec945c253d945f.tar.gz
OneConfig-e299255d82e69e461893ce8ff0ec945c253d945f.tar.bz2
OneConfig-e299255d82e69e461893ce8ff0ec945c253d945f.zip
button
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java36
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java105
3 files changed, 36 insertions, 107 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java
new file mode 100644
index 0000000..fdb0157
--- /dev/null
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java
@@ -0,0 +1,36 @@
+package cc.polyfrost.oneconfig.gui.elements.config;
+
+import cc.polyfrost.oneconfig.config.OneConfigConfig;
+import cc.polyfrost.oneconfig.config.interfaces.BasicOption;
+import cc.polyfrost.oneconfig.gui.elements.BasicButton;
+import cc.polyfrost.oneconfig.lwjgl.RenderManager;
+import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
+
+import java.lang.reflect.Field;
+
+public class ConfigButton extends BasicOption {
+ private final BasicButton button;
+
+ public ConfigButton(Field field, String name, int size, String text) {
+ super(field, name, size);
+ Runnable runnable = () -> {
+ };
+ try {
+ runnable = (Runnable) get();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, null, null, 1, BasicButton.ALIGNMENT_CENTER, runnable);
+ }
+
+ @Override
+ public void draw(long vg, int x, int y) {
+ RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM);
+ button.draw(vg, x + (size == 1 ? 352 : 736), y);
+ }
+
+ @Override
+ public int getHeight() {
+ return 32;
+ }
+}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
index 9daa965..3ef3d06 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigHeader.java
@@ -6,8 +6,6 @@ import cc.polyfrost.oneconfig.lwjgl.RenderManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager;
-import net.minecraftforge.fml.client.FMLClientHandler;
-import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import java.lang.reflect.Field;
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 bdc7242..797f573 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModConfigPage.java
@@ -39,111 +39,6 @@ public class ModConfigPage extends Page {
@Override
public void draw(long vg, int x, int y) {
- /*
- String filter = OneConfigGui.INSTANCE == null ? "" : OneConfigGui.INSTANCE.getSearchValue().toLowerCase().trim();
- LinkedHashMap<String, ArrayList<BasicOption>> filteredSubcategories = new LinkedHashMap<>(page.categories.get(selectedCategory).subcategories);
- if (!filter.equals("")) {
- filteredSubcategories.clear();
- for (String subCategory : page.categories.get(selectedCategory).subcategories.keySet()) {
- if (subCategory.toLowerCase().contains(filter)) {
- filteredSubcategories.put(subCategory, page.categories.get(selectedCategory).subcategories.get(subCategory));
- continue;
- }
- for (BasicOption option : page.categories.get(selectedCategory).subcategories.get(subCategory)) {
- if (!option.getName().toLowerCase().contains(filter)) continue;
- if (!filteredSubcategories.containsKey(subCategory))
- filteredSubcategories.put(subCategory, new ArrayList<>());
- filteredSubcategories.get(subCategory).add(option);
- }
- }
- }
- int optionX = x + 30;
- int optionY = y + (page.categories.size() == 1 ? 16 : 64);
-
- // Top page buttons
- for (ConfigPageButton page : page.categories.get(selectedCategory).topPages) {
- if (!page.getName().toLowerCase().contains(filter) && !page.description.toLowerCase().contains(filter))
- continue;
- page.draw(vg, optionX, optionY);
- optionY += page.getHeight() + 16;
- }
-
- // Background
- if (filteredSubcategories.keySet().size() > 0) {
- int backgroundSize = 16;
- for (String subCategory : filteredSubcategories.keySet()) {
- backgroundSize += 48;
- for (int i = 0; i < filteredSubcategories.get(subCategory).size(); i++) {
- BasicOption option = filteredSubcategories.get(subCategory).get(i);
- if (i + 1 < filteredSubcategories.get(subCategory).size()) {
- BasicOption nextOption = filteredSubcategories.get(subCategory).get(i + 1);
- if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
- backgroundSize += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
- i++;
- continue;
- }
- }
- backgroundSize += option.getHeight() + 16;
- }
- }
- RenderManager.drawRoundedRect(vg, x + 14, optionY, 1024, backgroundSize, OneConfigConfig.GRAY_900, 20);
- }
-
- // draw options
- int optionLastY = optionY + 16;
- if (filteredSubcategories.keySet().size() > 0) {
- optionY += 16;
- for (String subCategory : filteredSubcategories.keySet()) {
- RenderManager.drawString(vg, subCategory, optionX, optionY + 16, OneConfigConfig.WHITE_90, 24f, Fonts.MEDIUM);
- optionY += 48;
- for (int i = 0; i < filteredSubcategories.get(subCategory).size(); i++) {
- BasicOption option = filteredSubcategories.get(subCategory).get(i);
- option.draw(vg, optionX, optionY);
- if (i + 1 < filteredSubcategories.get(subCategory).size()) {
- BasicOption nextOption = filteredSubcategories.get(subCategory).get(i + 1);
- if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
- nextOption.draw(vg, optionX + 512, optionY);
- optionY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
- i++;
- continue;
- }
- }
- optionY += option.getHeight() + 16;
- }
- }
- optionY += 16;
- }
-
- // Bottom page buttons
- for (ConfigPageButton page : page.categories.get(selectedCategory).bottomPages) {
- if (!page.getName().toLowerCase().contains(filter) && !page.description.toLowerCase().contains(filter))
- continue;
- page.draw(vg, optionX, optionY);
- optionY += page.getHeight() + 16;
- }
- totalSize = optionY - y;
-
- // Draw last options
- if (filteredSubcategories.keySet().size() > 0) {
- for (String subCategory : filteredSubcategories.keySet()) {
- optionLastY += 48;
- for (int i = 0; i < filteredSubcategories.get(subCategory).size(); i++) {
- BasicOption option = filteredSubcategories.get(subCategory).get(i);
- option.drawLast(vg, optionX, optionLastY);
- if (i + 1 < filteredSubcategories.get(subCategory).size()) {
- BasicOption nextOption = filteredSubcategories.get(subCategory).get(i + 1);
- if (option.size == 1 && option.hasHalfSize() && nextOption.size == 1 && nextOption.hasHalfSize()) {
- nextOption.drawLast(vg, optionX + 512, optionLastY);
- optionLastY += Math.max(option.getHeight(), nextOption.getHeight()) + 16;
- i++;
- continue;
- }
- }
- optionLastY += option.getHeight() + 16;
- }
- }
- }*/
-
if (page.categories.size() == 0) return;
int optionY = y + (page.categories.size() == 1 ? 16 : 64);
for (OptionSubcategory subCategory : page.categories.get(selectedCategory).subcategories) {