diff options
84 files changed, 677 insertions, 3761 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index b583027c..1b4a52ae 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -75,11 +75,11 @@ loom { repositories { mavenCentral() mavenLocal() + maven("https://maven.notenoughupdates.org/releases") maven("https://repo.spongepowered.org/maven/") maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1") maven("https://jitpack.io") maven("https://repo.polyfrost.cc/releases") - maven("https://maven.notenoughupdates.org/releases") } val shadowImplementation: Configuration by configurations.creating { @@ -154,11 +154,13 @@ dependencies { annotationProcessor("net.fabricmc:sponge-mixin:0.11.4+mixin.0.8.5") compileOnly("org.jetbrains:annotations:24.0.1") + modImplementation(libs.moulconfig) + shadowOnly(libs.moulconfig) + @Suppress("VulnerableLibrariesLocal") shadowApi("info.bliki.wiki:bliki-core:3.1.0") testImplementation("org.junit.jupiter:junit-jupiter:5.9.2") testAnnotationProcessor("net.fabricmc:sponge-mixin:0.11.4+mixin.0.8.5") - // modImplementation("io.github.notenoughupdates:MoulConfig:0.0.1") detektPlugins("org.notenoughupdates:detektrules:1.0.0") devEnv("me.djtheredstoner:DevAuth-forge-legacy:1.1.0") } @@ -167,7 +169,7 @@ dependencies { java { withSourcesJar() -// toolchain.languageVersion.set(JavaLanguageVersion.of(8)) + toolchain.languageVersion.set(JavaLanguageVersion.of(8)) } // Tasks: @@ -175,8 +177,6 @@ java { tasks.withType(JavaCompile::class) { options.encoding = "UTF-8" options.isFork = true - if (JavaVersion.current().isJava9Compatible) - options.release.set(8) } tasks.named("compileOneconfigJava", JavaCompile::class) { doFirst { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..1df41c95 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,5 @@ +[versions] +moulconfig = "1.2.0" + +[libraries] +moulconfig = { module = "org.notenoughupdates.moulconfig:MoulConfig", version.ref = "moulconfig" } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index f7f0049f..31170dae 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -23,6 +23,7 @@ import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.commands.help.SettingsCommand; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; @@ -38,7 +39,6 @@ import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu; import io.github.moulberry.notenoughupdates.miscgui.NeuSearchCalculator; import io.github.moulberry.notenoughupdates.miscgui.pricegraph.GuiPriceGraph; -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.GuiTextures; import io.github.moulberry.notenoughupdates.util.LerpingFloat; @@ -396,7 +396,7 @@ public class NEUOverlay extends Gui { return; } if (Mouse.getEventButtonState()) { - NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor); + NotEnoughUpdates.INSTANCE.openGui = SettingsCommand.INSTANCE.createConfigScreen(""); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java deleted file mode 100644 index 6bafb1fd..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config; - -public class Config { - public void executeRunnable(int runnableId) {} -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/GuiOptionEditorBlocked.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiOptionEditorBlocked.java index 11112782..5b1caed8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/GuiOptionEditorBlocked.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiOptionEditorBlocked.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -17,9 +17,9 @@ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. */ -package io.github.moulberry.notenoughupdates.core.config.struct; +package io.github.moulberry.notenoughupdates.core.config; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditor; +import io.github.moulberry.moulconfig.gui.GuiOptionEditor; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; import lombok.var; @@ -34,7 +34,7 @@ public class GuiOptionEditorBlocked extends GuiOptionEditor { private final GuiOptionEditor base; public GuiOptionEditorBlocked(GuiOptionEditor base) { - super(base.option); + super(base.getOption()); this.base = base; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java index eac1e5cd..78cefdfb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -19,121 +19,213 @@ package io.github.moulberry.notenoughupdates.core.config; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.overlays.OverlayManager; +import io.github.moulberry.notenoughupdates.overlays.TextOverlay; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.function.Supplier; public class GuiPositionEditor extends GuiScreen { - public PositionNew position = new PositionNew(); + private final ArrayList<Position> positions; + private final ArrayList<Position> originalPositions; + private final ArrayList<Integer> elementWidths; + private final ArrayList<Integer> elementHeights; + private final ArrayList<Supplier<Boolean>> shouldRenderSupplier; + private final Runnable positionChangedCallback; + private final Runnable closedCallback; + private int grabbedX = 0; + private int grabbedY = 0; + private int clickedPos = -1; + private int oldGuiScale = -1; + public static boolean renderDrill = false; + + + public GuiPositionEditor( + LinkedHashMap<TextOverlay, Position> overlayPositions, + Runnable positionChangedCallback, + Runnable closedCallback + ) { + shouldRenderSupplier = new ArrayList<>(); + ArrayList<Position> pos = new ArrayList<>(); + ArrayList<Position> ogPos = new ArrayList<>(); + ArrayList<Integer> width = new ArrayList<>(); + ArrayList<Integer> height = new ArrayList<>(); + for (int i = 0; i < overlayPositions.size(); i++) { + TextOverlay overlay = new ArrayList<>(overlayPositions.keySet()).get(i); + pos.add(overlayPositions.get(overlay)); + ogPos.add(pos.get(i).clone()); + width.add((int) overlay.getDummySize().x); + height.add((int) overlay.getDummySize().y); + shouldRenderSupplier.add(() -> { + if (overlay.isEnabled()) { + overlay.renderDummy(); + OverlayManager.dontRenderOverlay.add(overlay.getClass()); + return true; + } + return false; + }); + } + - public int clickedX; - public int clickedY; + this.positions = pos; + this.originalPositions = ogPos; + this.elementWidths = width; + this.elementHeights = height; + this.positionChangedCallback = positionChangedCallback; + this.closedCallback = closedCallback; + int newGuiScale = NotEnoughUpdates.INSTANCE.config.locationedit.guiScale; + if (newGuiScale != 0) { + if (Minecraft.getMinecraft().gameSettings.guiScale != 0) { + this.oldGuiScale = Minecraft.getMinecraft().gameSettings.guiScale; + } else { + this.oldGuiScale = 4; + } + if (newGuiScale == 4) Minecraft.getMinecraft().gameSettings.guiScale = 0; + else Minecraft.getMinecraft().gameSettings.guiScale = NotEnoughUpdates.INSTANCE.config.locationedit.guiScale; + } + } @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawDefaultBackground(); + public void onGuiClosed() { + super.onGuiClosed(); + closedCallback.run(); + renderDrill = false; + clickedPos = -1; + if (this.oldGuiScale != -1) Minecraft.getMinecraft().gameSettings.guiScale = this.oldGuiScale; + } + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + super.drawScreen(mouseX, mouseY, partialTicks); + GlStateManager.pushMatrix(); ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - int x = position.resolveX(scaledResolution, 200); - int y = position.resolveY(scaledResolution, 100); + this.width = scaledResolution.getScaledWidth(); + this.height = scaledResolution.getScaledHeight(); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - int centerWidth = 176; - int centerHeight = 166; - - float centerWF = centerWidth / 2f / (float) width; - float centerHF = centerHeight / 2f / (float) height; - - float left = 0; - float top = 0; - float right = 0; - float bottom = 0; - - switch (position.getAnchorX()) { - case MIN: { - left = 0; - right = 0.5f - centerWF; - break; + drawDefaultBackground(); + renderDrill = true; + for (Position position : positions) { + if (!shouldRenderSupplier.get(positions.indexOf(position)).get()) { + continue; } - case MID: { - left = 0.5f - centerWF; - right = 0.5f + centerWF; - break; + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + if (position.getClicked()) { + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); } - case MAX: { - left = 0.5f + centerWF; - right = 1; - break; - } - } - switch (position.getAnchorY()) { - case MIN: { - top = 0; - bottom = 0.5f - centerHF; - break; - } - case MID: { - top = 0.5f - centerHF; - bottom = 0.5f + centerHF; - break; - } - case MAX: { - top = 0.5f + centerHF; - bottom = 1; - break; - } - } - Gui.drawRect( - (int) (left * width), - (int) (top * height), - (int) (right * width), - (int) (bottom * height), - 0x40404040 + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); + } + Utils.drawStringCentered("Position Editor", scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff); + Utils.drawStringCentered( + "R to Reset - Arrow keys/mouse to move", + scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff ); - Gui.drawRect(x, y, x + 200, y + 100, 0x80404040); + GlStateManager.popMatrix(); } @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int x = position.resolveX(scaledResolution, 200); - int y = position.resolveY(scaledResolution, 100); - - if (mouseX > x && mouseX < x + 200 && - mouseY > y && mouseY < y + 100) { - clickedX = mouseX; - clickedY = mouseY; - } else { - clickedX = -1; - clickedY = -1; + super.mouseClicked(mouseX, mouseY, mouseButton); + + if (mouseButton == 0) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + for (int i = positions.size() - 1; i >= 0; i--) { + Position position = positions.get(i); + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + if (!position.getClicked()) { + if (mouseX >= x && mouseY >= y && + mouseX <= x + elementWidth && mouseY <= y + elementHeight) { + clickedPos = i; + position.setClicked(true); + grabbedX = mouseX; + grabbedY = mouseY; + break; + } + } + + } + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + if (clickedPos != -1) { + Position position = positions.get(clickedPos); + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + if (keyCode == Keyboard.KEY_R) { + position.set(originalPositions.get(positions.indexOf(position))); + } else if (!position.getClicked()) { + boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + int dist = shiftHeld ? 10 : 1; + if (keyCode == Keyboard.KEY_DOWN) { + position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_UP) { + position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_LEFT) { + position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_RIGHT) { + position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } + } } + super.keyTyped(typedChar, keyCode); } @Override protected void mouseReleased(int mouseX, int mouseY, int state) { - clickedX = -1; - clickedY = -1; + super.mouseReleased(mouseX, mouseY, state); + for (Position position : positions) { + position.setClicked(false); + } } @Override protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { - if (clickedX >= 0 && clickedY >= 0) { - int deltaX = mouseX - clickedX; - int deltaY = mouseY - clickedY; - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - - deltaX = position.moveX(scaledResolution, deltaX, 200); - deltaY = position.moveY(scaledResolution, deltaY, 100); - - clickedX += deltaX; - clickedY += deltaY; + super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + for (Position position : positions) { + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + if (position.getClicked()) { + ScaledResolution scaledResolution = Utils.pushGuiScale(-1); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + positionChangedCallback.run(); + + Utils.pushGuiScale(-1); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditorButForTheDungeonMap.java index 9f2088ed..aeb54f82 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditorButForTheDungeonMap.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -17,9 +17,8 @@ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. */ -package io.github.moulberry.notenoughupdates.core.config.gui; +package io.github.moulberry.notenoughupdates.core.config; -import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/MoulConfigGuiForgeInterop.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/MoulConfigGuiForgeInterop.java index 40887e54..de659bcc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/MoulConfigGuiForgeInterop.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/MoulConfigGuiForgeInterop.java @@ -19,8 +19,8 @@ package io.github.moulberry.notenoughupdates.core.config; -import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; +import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper; +import io.github.moulberry.notenoughupdates.commands.help.SettingsCommand; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; @@ -53,7 +53,7 @@ public class MoulConfigGuiForgeInterop implements IModGuiFactory { private final GuiScreen parent; public WrappedMoulConfig(GuiScreen parent) { - super(NEUConfigEditor.editor); + super(SettingsCommand.INSTANCE.createConfigElement("")); this.parent = parent; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java deleted file mode 100644 index e0a9585a..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Category { - String name(); - - String desc(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java deleted file mode 100644 index b11f7651..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigAccordionId { - int id(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java deleted file mode 100644 index 7491a94f..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorAccordion { - int id(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java deleted file mode 100644 index 8e6f652c..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorBoolean { - int runnableId() default -1; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java deleted file mode 100644 index a2c56dc0..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorButton { - int runnableId(); - - String buttonText() default ""; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java deleted file mode 100644 index 824b2eec..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorColour {} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java deleted file mode 100644 index d9707c9b..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorDraggableList { - String[] exampleText(); - - boolean allowDeleting() default true; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java deleted file mode 100644 index 8d870643..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorDropdown { - String[] values(); - - int initialIndex() default 0; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java deleted file mode 100644 index ba45ae68..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorFSR { - int runnableId(); - - String buttonText() default ""; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java deleted file mode 100644 index f1a3e329..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorKeybind { - int defaultKey(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java deleted file mode 100644 index b8db25bc..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorSlider { - float minValue(); - - float maxValue(); - - float minStep(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java deleted file mode 100644 index b6b32fb2..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorText {} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java deleted file mode 100644 index ddd1e71f..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigOption { - String name(); - - String desc(); - - String[] searchTags() default ""; - - int subcategoryId() default -1; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java deleted file mode 100644 index fd0946c9..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; - -public abstract class GuiOptionEditor { - public final ConfigProcessor.ProcessedOption option; - private static final int HEIGHT = 45; - - public GuiOptionEditor(ConfigProcessor.ProcessedOption option) { - this.option = option; - } - - public void render(int x, int y, int width) { - int height = getHeight(); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - RenderUtils.drawFloatingRectDark(x, y, width, height, true); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - option.name, - x + width / 6, y + 13, true, width / 3 - 10, 0xc0c0c0 - ); - - int maxLines = 5; - float scale = 1; - int lineCount = fr.listFormattedStringToWidth(option.desc, width * 2 / 3 - 10).size(); - - if (lineCount <= 0) return; - - float paraHeight = 9 * lineCount - 1; - - while (paraHeight >= HEIGHT - 10) { - scale -= 1 / 8f; - lineCount = fr.listFormattedStringToWidth(option.desc, (int) (width * 2 / 3 / scale - 10)).size(); - paraHeight = (int) (9 * scale * lineCount - 1 * scale); - } - - GlStateManager.pushMatrix(); - GlStateManager.translate(x + 5 + width / 3f, y + HEIGHT / 2f - paraHeight / 2, 0); - GlStateManager.scale(scale, scale, 1); - - fr.drawSplitString(option.desc, 0, 0, (int) (width * 2 / 3 / scale - 10), 0xc0c0c0); - - GlStateManager.popMatrix(); - } - - public int getHeight() { - return HEIGHT; - } - - public abstract boolean mouseInput(int x, int y, int width, int mouseX, int mouseY); - - public abstract boolean keyboardInput(); - - public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { - return false; - } - - public void renderOverlay(int x, int y, int width) {} -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java deleted file mode 100644 index a422a8ec..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -public class GuiOptionEditorAccordion extends GuiOptionEditor { - private final int accordionId; - - public GuiOptionEditorAccordion(ConfigProcessor.ProcessedOption option, int accordionId) { - super(option); - this.accordionId = accordionId; - } - - @Override - public int getHeight() { - return 20; - } - - public int getAccordionId() { - return accordionId; - } - - public boolean getToggled() { - return (boolean) option.get(); - } - - @Override - public void render(int x, int y, int width) { - int height = getHeight(); - RenderUtils.drawFloatingRectDark(x, y, width, height, true); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.color(1, 1, 1, 1); - worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION); - if (getToggled()) { - worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); - worldrenderer.pos((double) x + 9.75f, (double) y + 13.5f, 0.0D).endVertex(); - worldrenderer.pos((double) x + 13.5f, (double) y + 6, 0.0D).endVertex(); - } else { - worldrenderer.pos((double) x + 6, (double) y + 13.5f, 0.0D).endVertex(); - worldrenderer.pos((double) x + 13.5f, (double) y + 9.75f, 0.0D).endVertex(); - worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); - } - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - - TextRenderUtils.drawStringScaledMaxWidth(option.name, x + 18, y + 6, false, width - 10, 0xc0c0c0); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if (Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && - mouseY > y && mouseY < y + getHeight()) { - option.set(!getToggled()); - return true; - } - - return false; - } - - @Override - public boolean keyboardInput() { - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java deleted file mode 100644 index 00907e9e..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.GuiElementBoolean; -import io.github.moulberry.notenoughupdates.core.config.Config; -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; - -public class GuiOptionEditorBoolean extends GuiOptionEditor { - - private final GuiElementBoolean bool; - private final Config config; - private final int runnableId; - - public GuiOptionEditorBoolean( - ConfigProcessor.ProcessedOption option, - int runnableId, - Config config - ) { - super(option); - this.config = config; - this.runnableId = runnableId; - bool = new GuiElementBoolean(0, 0, () -> (boolean) option.get(), 10, (value) -> onUpdate(option, value)); - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - int height = getHeight(); - - bool.x = x + width / 6 - 24; - bool.y = y + height - 7 - 14; - bool.render(); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); - bool.x = x + width / 6 - 24; - bool.y = y + height - 7 - 14; - return bool.mouseInput(mouseX, mouseY); - } - - @Override - public boolean keyboardInput() { - return false; - } - - private void onUpdate(ConfigProcessor.ProcessedOption option, boolean value) { - if (option.set(value)) { - config.executeRunnable(runnableId); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java deleted file mode 100644 index fb5b58f3..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.config.Config; -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; - -import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex; - -public class GuiOptionEditorButton extends GuiOptionEditor { - private final int runnableId; - private String buttonText; - private final Config config; - - public GuiOptionEditorButton( - ConfigProcessor.ProcessedOption option, - int runnableId, - String buttonText, - Config config - ) { - super(option); - this.runnableId = runnableId; - this.config = config; - - this.buttonText = buttonText; - if (this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null; - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - - int height = getHeight(); - - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); - RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16); - - if (buttonText != null) { - TextRenderUtils.drawStringCenteredScaledMaxWidth( - buttonText, - x + width / 6, y + height - 7 - 6, false, 44, 0xFF303030 - ); - } - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if (Mouse.getEventButtonState()) { - int height = getHeight(); - if (mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && - mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) { - config.executeRunnable(runnableId); - return true; - } - } - - return false; - } - - @Override - public boolean keyboardInput() { - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java deleted file mode 100644 index 359a3e27..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.ChromaColour; -import io.github.moulberry.notenoughupdates.core.GuiElementColour; -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; - -import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_white; - -public class GuiOptionEditorColour extends GuiOptionEditor { - private GuiElementColour colourElement = null; - - public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) { - super(option); - } - - public String getChromaString() { - return (String) option.get(); - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - int height = getHeight(); - - int argb = ChromaColour.specialToChromaRGB(getChromaString()); - int r = (argb >> 16) & 0xFF; - int g = (argb >> 8) & 0xFF; - int b = argb & 0xFF; - GlStateManager.color(r / 255f, g / 255f, b / 255f, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(button_white); - RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16); - } - - @Override - public void renderOverlay(int x, int y, int width) { - if (colourElement != null) { - colourElement.render(); - } - } - - @Override - public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { - return colourElement != null && colourElement.mouseInput(mouseX, mouseY); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); - - if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0 && - mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && - mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) { - colourElement = new GuiElementColour(mouseX, mouseY, () -> (String) option.get(), - option::set, () -> colourElement = null); - } - - return false; - } - - @Override - public boolean keyboardInput() { - return colourElement != null && colourElement.keyboardInput(); - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java deleted file mode 100644 index e080bb28..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.util.ArrayList; -import java.util.List; - -import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex; - -public class GuiOptionEditorDraggableList extends GuiOptionEditor { - private static final ResourceLocation DELETE = new ResourceLocation("notenoughupdates:core/delete.png"); - - private final String[] exampleText; - private final boolean enableDeleting; - private final List<Integer> activeText; - private int currentDragging = -1; - private int dragStartIndex = -1; - - private long trashHoverTime = -1; - - private int dragOffsetX = -1; - private int dragOffsetY = -1; - - private boolean dropdownOpen = false; - - public GuiOptionEditorDraggableList( - ConfigProcessor.ProcessedOption option, - String[] exampleText, - boolean disableDeleting - ) { - super(option); - - this.enableDeleting = disableDeleting; - this.exampleText = exampleText; - this.activeText = (List<Integer>) option.get(); - } - - @Override - public int getHeight() { - int height = super.getHeight() + 13; - - for (int strIndex : activeText) { - if (strIndex >= exampleText.length) { - activeText.remove((Integer) strIndex); - break; - } - String str = exampleText[strIndex]; - height += 10 * str.split("\n").length; - } - - return height; - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - - int height = getHeight(); - - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); - RenderUtils.drawTexturedRect(x + width / 6 - 24, y + 45 - 7 - 14, 48, 16); - - TextRenderUtils.drawStringCenteredScaledMaxWidth("Add", x + width / 6, y + 45 - 7 - 6, false, 44, 0xFF303030); - - long currentTime = System.currentTimeMillis(); - if (trashHoverTime < 0) { - float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime) / 250f); - GlStateManager.color(1, greenBlue, greenBlue, 1); - } else { - float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime) / 250f); - GlStateManager.color(1, greenBlue, greenBlue, 1); - } - - if (enableDeleting) { - Minecraft.getMinecraft().getTextureManager().bindTexture(DELETE); - Utils.drawTexturedRect(x + width / 6 + 27, y + 45 - 7 - 13, 11, 14, GL11.GL_NEAREST); - } - - Gui.drawRect(x + 5, y + 45, x + width - 5, y + height - 5, 0xffdddddd); - Gui.drawRect(x + 6, y + 46, x + width - 6, y + height - 6, 0xff000000); - - int i = 0; - int yOff = 0; - for (int strIndex : activeText) { - if (strIndex >= exampleText.length) continue; - String str = exampleText[strIndex]; - - String[] multilines = str.split("\n"); - - int ySize = multilines.length * 10; - - if (i++ != dragStartIndex) { - for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) { - String line = multilines[multilineIndex]; - Utils.drawStringScaledMaxWidth( - line + EnumChatFormatting.RESET, - x + 20, y + 50 + yOff + multilineIndex * 10, true, width - 20, 0xffffffff - ); - } - Minecraft.getMinecraft().fontRendererObj.drawString( - "\u2261", - x + 10, - y + 50 + yOff + ySize / 2 - 4, - 0xffffff, - true - ); - } - - yOff += ySize; - } - } - - @Override - public void renderOverlay(int x, int y, int width) { - super.renderOverlay(x, y, width); - - if (dropdownOpen) { - List<Integer> remaining = new ArrayList<>(); - for (int i = 0; i < exampleText.length; i++) { - remaining.add(i); - } - remaining.removeAll(activeText); - - int dropdownWidth = Math.min(width / 2 - 10, 150); - int left = dragOffsetX; - int top = dragOffsetY; - - int dropdownHeight = -1 + 12 * remaining.size(); - - int main = 0xff202026; - int outline = 0xff404046; - Gui.drawRect(left, top, left + 1, top + dropdownHeight, outline); //Left - Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, outline); //Top - Gui.drawRect(left + dropdownWidth - 1, top + 1, left + dropdownWidth, top + dropdownHeight, outline); //Right - Gui.drawRect( - left + 1, - top + dropdownHeight - 1, - left + dropdownWidth - 1, - top + dropdownHeight, - outline - ); //Bottom - Gui.drawRect(left + 1, top + 1, left + dropdownWidth - 1, top + dropdownHeight - 1, main); //Middle - - int dropdownY = -1; - for (int strIndex : remaining) { - String str = exampleText[strIndex]; - if (str.isEmpty()) { - str = "<NONE>"; - } - TextRenderUtils.drawStringScaledMaxWidth(str.replaceAll("(\n.*)+", " ..."), - left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0 - ); - dropdownY += 12; - } - } else if (currentDragging >= 0) { - int opacity = 0x80; - long currentTime = System.currentTimeMillis(); - if (trashHoverTime < 0) { - float greenBlue = LerpUtils.clampZeroOne((currentTime + trashHoverTime) / 250f); - opacity = (int) (opacity * greenBlue); - } else { - float greenBlue = LerpUtils.clampZeroOne((250 + trashHoverTime - currentTime) / 250f); - opacity = (int) (opacity * greenBlue); - } - - if (opacity < 20) return; - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int mouseX = Mouse.getX() * scaledResolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth; - int mouseY = scaledResolution.getScaledHeight() - - Mouse.getY() * scaledResolution.getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1; - - String str = exampleText[currentDragging]; - - String[] multilines = str.split("\n"); - - GlStateManager.enableBlend(); - for (int multilineIndex = 0; multilineIndex < multilines.length; multilineIndex++) { - String line = multilines[multilineIndex]; - Utils.drawStringScaledMaxWidth( - line + EnumChatFormatting.RESET, - dragOffsetX + mouseX + 10, - dragOffsetY + mouseY + multilineIndex * 10, - true, - width - 20, - 0xffffff | (opacity << 24) - ); - } - - int ySize = multilines.length * 10; - - Minecraft.getMinecraft().fontRendererObj.drawString("\u2261", - dragOffsetX + mouseX, - dragOffsetY + mouseY + ySize / 2 - 4, 0xffffff, true - ); - } - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if (!Mouse.getEventButtonState() && !dropdownOpen && - dragStartIndex >= 0 && Mouse.getEventButton() == 0 && - mouseX >= x + width / 6 + 27 - 3 && mouseX <= x + width / 6 + 27 + 11 + 3 && - mouseY >= y + 45 - 7 - 13 - 3 && mouseY <= y + 45 - 7 - 13 + 14 + 3) { - if (enableDeleting) { - activeText.remove(dragStartIndex); - } - currentDragging = -1; - dragStartIndex = -1; - return false; - } - - if (!Mouse.isButtonDown(0) || dropdownOpen) { - currentDragging = -1; - dragStartIndex = -1; - if (trashHoverTime > 0 && enableDeleting) trashHoverTime = -System.currentTimeMillis(); - } else if (currentDragging >= 0 && - mouseX >= x + width / 6 + 27 - 3 && mouseX <= x + width / 6 + 27 + 11 + 3 && - mouseY >= y + 45 - 7 - 13 - 3 && mouseY <= y + 45 - 7 - 13 + 14 + 3) { - if (trashHoverTime < 0 && enableDeleting) trashHoverTime = System.currentTimeMillis(); - } else { - if (trashHoverTime > 0 && enableDeleting) trashHoverTime = -System.currentTimeMillis(); - } - - if (Mouse.getEventButtonState()) { - int height = getHeight(); - - if (dropdownOpen) { - List<Integer> remaining = new ArrayList<>(); - for (int i = 0; i < exampleText.length; i++) { - remaining.add(i); - } - remaining.removeAll(activeText); - - int dropdownWidth = Math.min(width / 2 - 10, 150); - int left = dragOffsetX; - int top = dragOffsetY; - - int dropdownHeight = -1 + 12 * remaining.size(); - - if (mouseX > left && mouseX < left + dropdownWidth && - mouseY > top && mouseY < top + dropdownHeight) { - int dropdownY = -1; - for (int strIndex : remaining) { - if (mouseY < top + dropdownY + 12) { - activeText.add(0, strIndex); - if (remaining.size() == 1) dropdownOpen = false; - return true; - } - - dropdownY += 12; - } - } - - dropdownOpen = false; - return true; - } - - if (activeText.size() < exampleText.length && - mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && - mouseY > y + 45 - 7 - 14 && mouseY < y + 45 - 7 + 2) { - dropdownOpen = !dropdownOpen; - dragOffsetX = mouseX; - dragOffsetY = mouseY; - return true; - } - - if (Mouse.getEventButton() == 0 && - mouseX > x + 5 && mouseX < x + width - 5 && - mouseY > y + 45 && mouseY < y + height - 6) { - int yOff = 0; - int i = 0; - for (int strIndex : activeText) { - int ySize = 10 * exampleText[strIndex].split("\n").length; - if (mouseY < y + 50 + yOff + ySize) { - dragOffsetX = x + 10 - mouseX; - dragOffsetY = y + 50 + yOff - mouseY; - - currentDragging = strIndex; - dragStartIndex = i; - break; - } - yOff += ySize; - i++; - } - } - } else if (Mouse.getEventButton() == -1 && currentDragging >= 0) { - int yOff = 0; - int i = 0; - for (int strIndex : activeText) { - if (dragOffsetY + mouseY + 4 < y + 50 + yOff + 10) { - activeText.remove(dragStartIndex); - activeText.add(i, currentDragging); - - dragStartIndex = i; - break; - } - yOff += 10 * exampleText[strIndex].split("\n").length; - i++; - } - } - - return false; - } - - @Override - public boolean keyboardInput() { - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java deleted file mode 100644 index 115b502e..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -public class GuiOptionEditorDropdown extends GuiOptionEditor { - private final String[] values; - private final boolean useOrdinal; - private int selected; - private boolean open = false; - - public GuiOptionEditorDropdown( - ConfigProcessor.ProcessedOption option, - String[] values, - int selected, - boolean useOrdinal - ) { - super(option); - if (selected >= values.length) selected = values.length; - this.values = values; - this.selected = selected; - this.useOrdinal = useOrdinal; - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - if (!open) { - int height = getHeight(); - - int dropdownWidth = Math.min(width / 3 - 10, 80); - int left = x + width / 6 - dropdownWidth / 2; - int top = y + height - 7 - 14; - - String selectedString = " - Select - "; - if (selected >= 0 && selected < values.length) { - selectedString = values[selected]; - } - - RenderUtils.drawFloatingRectDark(left, top, dropdownWidth, 14, false); - TextRenderUtils.drawStringScaled( - "\u25BC", - left + dropdownWidth - 10, - y + height - 7 - 15, - false, - 0xffa0a0a0, - 2 - ); - - TextRenderUtils.drawStringScaledMaxWidth( - selectedString, - left + 3, top + 3, false, dropdownWidth - 16, 0xffa0a0a0); - } - } - - @Override - public void renderOverlay(int x, int y, int width) { - if (open) { - String selectedString = " - Select - "; - if (selected >= 0 && selected < values.length) { - selectedString = values[selected]; - } - - int height = getHeight(); - - int dropdownWidth = Math.min(width / 3 - 10, 80); - int left = x + width / 6 - dropdownWidth / 2; - int top = y + height - 7 - 14; - - int dropdownHeight = 13 + 12 * values.length; - - int main = 0xff202026; - int blue = 0xff2355ad; - - GlStateManager.pushMatrix(); - GL11.glTranslated(0, 0, 100); - Gui.drawRect(left, top, left + 1, top + dropdownHeight, blue); //Left - Gui.drawRect(left + 1, top, left + dropdownWidth, top + 1, blue); //Top - Gui.drawRect(left + dropdownWidth - 1, top + 1, left + dropdownWidth, top + dropdownHeight, blue); //Right - Gui.drawRect(left + 1, top + dropdownHeight - 1, left + dropdownWidth - 1, top + dropdownHeight, blue); //Bottom - Gui.drawRect(left + 1, top + 1, left + dropdownWidth - 1, top + dropdownHeight - 1, main); //Middle - - Gui.drawRect(left + 1, top + 14 - 1, left + dropdownWidth - 1, top + 14, blue); //Bar - int dropdownY = 13; - for (String option : values) { - if (option.isEmpty()) { - option = "<NONE>"; - } - TextRenderUtils.drawStringScaledMaxWidth( - option, - left + 3, top + 3 + dropdownY, false, dropdownWidth - 6, 0xffa0a0a0 - ); - dropdownY += 12; - } - - TextRenderUtils.drawStringScaled("\u25B2", left + dropdownWidth - 10, y + height - 7 - 15, false, 0xffa0a0a0, 2); - - TextRenderUtils.drawStringScaledMaxWidth( - selectedString, - left + 3, top + 3, false, dropdownWidth - 16, 0xffa0a0a0 - ); - GlStateManager.popMatrix(); - } - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); - - int left = x + width / 6 - 40; - int top = y + height - 7 - 14; - - if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if (mouseX >= left && mouseX <= left + 80 && - mouseY >= top && mouseY <= top + 14) { - open = !open; - return true; - } - } - - return false; - } - - @Override - public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); - - int left = x + width / 6 - 40; - int top = y + height - 7 - 14; - - if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if (!(mouseX >= left && mouseX <= left + 80 && - mouseY >= top && mouseY <= top + 14) && open) { - open = false; - if (mouseX >= left && mouseX <= left + 80) { - int dropdownY = 13; - for (int ordinal = 0; ordinal < values.length; ordinal++) { - if (mouseY >= top + 3 + dropdownY && mouseY <= top + 3 + dropdownY + 12) { - selected = ordinal; - if (useOrdinal) { - option.set(selected); - } else { - option.set(values[selected]); - } - return true; - } - dropdownY += 12; - } - } - return true; - } - } - - return false; - } - - @Override - public boolean keyboardInput() { - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java deleted file mode 100644 index db788b95..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.config.Config; -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Mouse; - -import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_fsr; - -public class GuiOptionEditorFSR extends GuiOptionEditor { - private final int runnableId; - private String buttonText; - private final Config config; - - public GuiOptionEditorFSR(ConfigProcessor.ProcessedOption option, int runnableId, String buttonText, Config config) { - super(option); - this.runnableId = runnableId; - this.config = config; - - this.buttonText = buttonText; - if (this.buttonText != null && this.buttonText.isEmpty()) this.buttonText = null; - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - - int height = getHeight(); - - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(button_fsr); - RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16); - - if (buttonText != null) { - TextRenderUtils.drawStringCenteredScaledMaxWidth( - buttonText, - x + width / 6, y + height - 7 - 6, false, 44, 0xFF303030 - ); - } - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if (Mouse.getEventButtonState()) { - int height = getHeight(); - if (mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && - mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) { - config.executeRunnable(runnableId); - return true; - } - } - - return false; - } - - @Override - public boolean keyboardInput() { - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java deleted file mode 100644 index ffad3bc0..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_tex; - -public class GuiOptionEditorKeybind extends GuiOptionEditor { - private static final ResourceLocation RESET = new ResourceLocation("notenoughupdates:itemcustomize/reset.png"); - - private final int defaultKeyCode; - private boolean editingKeycode; - - public GuiOptionEditorKeybind(ConfigProcessor.ProcessedOption option, int defaultKeyCode) { - super(option); - this.defaultKeyCode = defaultKeyCode; - } - - public int getKeyCode() { - return (int) option.get(); - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - - int height = getHeight(); - - GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex); - RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16); - - String keyName = KeybindHelper.getKeyName(getKeyCode()); - String text = editingKeycode ? "> " + keyName + " <" : keyName; - TextRenderUtils.drawStringCenteredScaledMaxWidth(text, x + width / 6, y + height - 7 - 6, false, 40, 0xFF303030); - - Minecraft.getMinecraft().getTextureManager().bindTexture(RESET); - GlStateManager.color(1, 1, 1, 1); - RenderUtils.drawTexturedRect(x + width / 6 - 24 + 48 + 3, y + height - 7 - 14 + 3, 10, 11, GL11.GL_NEAREST); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if (Mouse.getEventButtonState() && Mouse.getEventButton() != -1 && editingKeycode) { - editingKeycode = false; - option.set(Mouse.getEventButton() - 100); - return true; - } - - if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - int height = getHeight(); - if (mouseX > x + width / 6 - 24 && mouseX < x + width / 6 + 24 && - mouseY > y + height - 7 - 14 && mouseY < y + height - 7 + 2) { - editingKeycode = true; - return true; - } - if (mouseX > x + width / 6 - 24 + 48 + 3 && mouseX < x + width / 6 - 24 + 48 + 13 && - mouseY > y + height - 7 - 14 + 3 && mouseY < y + height - 7 - 14 + 3 + 11) { - option.set(defaultKeyCode); - return true; - } - } - - return false; - } - - @Override - public boolean keyboardInput() { - if (editingKeycode) { - editingKeycode = false; - int keyCode = -1; - if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) { - keyCode = 0; - } else if (Keyboard.getEventKey() != 0) { - keyCode = Keyboard.getEventKey(); - } - if (keyCode > 256) keyCode = 0; - if (keyCode != -1) - option.set(keyCode); - return true; - } - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java deleted file mode 100644 index 175dcdc0..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.GuiElementTextField; -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.GuiElementSlider; -import net.minecraft.client.Minecraft; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -public class GuiOptionEditorSlider extends GuiOptionEditor { - private final GuiElementSlider slider; - private final GuiElementTextField textField; - - public GuiOptionEditorSlider(ConfigProcessor.ProcessedOption option, float minValue, float maxValue, float minStep) { - super(option); - if (minStep < 0) minStep = 0.01f; - - float floatVal = getFloatValue(); - textField = new GuiElementTextField( - getStringifiedFloatValue(), - GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT - ); - - slider = new GuiElementSlider(0, 0, 80, minValue, maxValue, minStep, floatVal, (val) -> { - option.set(val); - textField.setText(getStringifiedFloatValue()); - }); - } - - public String getStringifiedFloatValue() { - float floatVal = getFloatValue(); - String strVal; - if (floatVal % 1 == 0) { - strVal = Integer.toString((int) floatVal); - } else { - strVal = Float.toString(floatVal); - strVal = strVal.replaceAll("(\\.\\d\\d\\d)\\d+", "$1"); - strVal = strVal.replaceAll("0+$", ""); - } - return strVal; - } - - public float getFloatValue() { - return ((Number) option.get()).floatValue(); - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - int height = getHeight(); - - int fullWidth = Math.min(width / 3 - 10, 80); - int sliderWidth = (fullWidth - 5) * 3 / 4; - int textFieldWidth = (fullWidth - 5) / 4; - - if (!Mouse.isButtonDown(0)) { - slider.setValue(getFloatValue()); - } - slider.x = x + width / 6 - fullWidth / 2; - slider.y = y + height - 7 - 14; - slider.width = sliderWidth; - slider.render(); - - if (textField.getFocus()) { - textField.setOptions(GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY); - textField.setSize( - Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10, - 16 - ); - } else { - textField.setText(getStringifiedFloatValue()); - textField.setSize(textFieldWidth, 16); - textField.setOptions( - GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT); - } - - textField.render(x + width / 6 - fullWidth / 2 + sliderWidth + 5, y + height - 7 - 14); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); - - int fullWidth = Math.min(width / 3 - 10, 80); - int sliderWidth = (fullWidth - 5) * 3 / 4; - int textFieldWidth = (fullWidth - 5) / 4; - - slider.x = x + width / 6 - fullWidth / 2; - slider.y = y + height - 7 - 14; - slider.width = sliderWidth; - if (slider.mouseInput(mouseX, mouseY)) { - textField.unfocus(); - return true; - } - - if (textField.getFocus()) { - textFieldWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10; - } - - int textFieldX = x + width / 6 - fullWidth / 2 + sliderWidth + 5; - int textFieldY = y + height - 7 - 14; - textField.setSize(textFieldWidth, 16); - - if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) { - if (mouseX > textFieldX && mouseX < textFieldX + textFieldWidth && - mouseY > textFieldY && mouseY < textFieldY + 16) { - textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); - return true; - } - textField.unfocus(); - } - - return false; - } - - @Override - public boolean keyboardInput() { - if (Keyboard.getEventKeyState() && textField.getFocus()) { - textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); - - try { - textField.setCustomBorderColour(0xffffffff); - float f = Float.parseFloat(textField.getText()); - if (option.set(f)) { - slider.setValue(f); - } else { - textField.setCustomBorderColour(0xff0000ff); - } - } catch (Exception e) { - textField.setCustomBorderColour(0xffff0000); - } - - return true; - } - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java deleted file mode 100644 index 48072fbe..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.GuiElementTextField; -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import net.minecraft.client.Minecraft; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -public class GuiOptionEditorText extends GuiOptionEditor { - private final GuiElementTextField textField; - - public GuiOptionEditorText(ConfigProcessor.ProcessedOption option) { - super(option); - - textField = new GuiElementTextField((String) option.get(), 0); - } - - @Override - public void render(int x, int y, int width) { - super.render(x, y, width); - int height = getHeight(); - - int fullWidth = Math.min(width / 3 - 10, 80); - - int textFieldX = x + width / 6 - fullWidth / 2; - if (textField.getFocus()) { - fullWidth = Math.max( - fullWidth, - Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10 - ); - } else { - textField.setText((String) option.get()); - } - - textField.setSize(fullWidth, 16); - - textField.render(textFieldX, y + height - 7 - 14); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - int height = getHeight(); - - int fullWidth = Math.min(width / 3 - 10, 80); - - int textFieldX = x + width / 6 - fullWidth / 2; - - if (textField.getFocus()) { - fullWidth = Math.max( - fullWidth, - Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10 - ); - } - - int textFieldY = y + height - 7 - 14; - textField.setSize(fullWidth, 16); - - if (Mouse.getEventButtonState() && (Mouse.getEventButton() == 0 || Mouse.getEventButton() == 1)) { - if (mouseX > textFieldX && mouseX < textFieldX + fullWidth && - mouseY > textFieldY && mouseY < textFieldY + 16) { - textField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); - return true; - } - textField.unfocus(); - } - - return false; - } - - @Override - public boolean keyboardInput() { - if (Keyboard.getEventKeyState() && textField.getFocus()) { - textField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); - - try { - textField.setCustomBorderColour(0xffffffff); - option.set(textField.getText()); - } catch (Exception e) { - textField.setCustomBorderColour(0xffff0000); - } - - return true; - } - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java deleted file mode 100644 index 055ff8e5..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (C) 2022-2023 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.overlays.OverlayManager; -import io.github.moulberry.notenoughupdates.overlays.TextOverlay; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.function.Supplier; - -public class GuiPositionEditor extends GuiScreen { - private final ArrayList<Position> positions; - private final ArrayList<Position> originalPositions; - private final ArrayList<Integer> elementWidths; - private final ArrayList<Integer> elementHeights; - private final ArrayList<Supplier<Boolean>> shouldRenderSupplier; - private final Runnable positionChangedCallback; - private final Runnable closedCallback; - private int grabbedX = 0; - private int grabbedY = 0; - private int clickedPos = -1; - private int oldGuiScale = -1; - public static boolean renderDrill = false; - - - public GuiPositionEditor( - LinkedHashMap<TextOverlay, Position> overlayPositions, - Runnable positionChangedCallback, - Runnable closedCallback - ) { - shouldRenderSupplier = new ArrayList<>(); - ArrayList<Position> pos = new ArrayList<>(); - ArrayList<Position> ogPos = new ArrayList<>(); - ArrayList<Integer> width = new ArrayList<>(); - ArrayList<Integer> height = new ArrayList<>(); - for (int i = 0; i < overlayPositions.size(); i++) { - TextOverlay overlay = new ArrayList<>(overlayPositions.keySet()).get(i); - pos.add(overlayPositions.get(overlay)); - ogPos.add(pos.get(i).clone()); - width.add((int) overlay.getDummySize().x); - height.add((int) overlay.getDummySize().y); - shouldRenderSupplier.add(() -> { - if (overlay.isEnabled()) { - overlay.renderDummy(); - OverlayManager.dontRenderOverlay.add(overlay.getClass()); - return true; - } - return false; - }); - } - - - this.positions = pos; - this.originalPositions = ogPos; - this.elementWidths = width; - this.elementHeights = height; - this.positionChangedCallback = positionChangedCallback; - this.closedCallback = closedCallback; - int newGuiScale = NotEnoughUpdates.INSTANCE.config.locationedit.guiScale; - if (newGuiScale != 0) { - if (Minecraft.getMinecraft().gameSettings.guiScale != 0) { - this.oldGuiScale = Minecraft.getMinecraft().gameSettings.guiScale; - } else { - this.oldGuiScale = 4; - } - if (newGuiScale == 4) Minecraft.getMinecraft().gameSettings.guiScale = 0; - else Minecraft.getMinecraft().gameSettings.guiScale = NotEnoughUpdates.INSTANCE.config.locationedit.guiScale; - } - } - - @Override - public void onGuiClosed() { - super.onGuiClosed(); - closedCallback.run(); - renderDrill = false; - clickedPos = -1; - if (this.oldGuiScale != -1) Minecraft.getMinecraft().gameSettings.guiScale = this.oldGuiScale; - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawScreen(mouseX, mouseY, partialTicks); - GlStateManager.pushMatrix(); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - - this.width = scaledResolution.getScaledWidth(); - this.height = scaledResolution.getScaledHeight(); - mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - - drawDefaultBackground(); - renderDrill = true; - for (Position position : positions) { - if (!shouldRenderSupplier.get(positions.indexOf(position)).get()) { - continue; - } - int elementHeight = elementHeights.get(positions.indexOf(position)); - int elementWidth = elementWidths.get(positions.indexOf(position)); - if (position.getClicked()) { - grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); - grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); - } - - int x = position.getAbsX(scaledResolution, elementWidth); - int y = position.getAbsY(scaledResolution, elementHeight); - - if (position.isCenterX()) x -= elementWidth / 2; - if (position.isCenterY()) y -= elementHeight / 2; - Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); - } - Utils.drawStringCentered("Position Editor", scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff); - Utils.drawStringCentered( - "R to Reset - Arrow keys/mouse to move", - scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff - ); - GlStateManager.popMatrix(); - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - super.mouseClicked(mouseX, mouseY, mouseButton); - - if (mouseButton == 0) { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - for (int i = positions.size() - 1; i >= 0; i--) { - Position position = positions.get(i); - int elementHeight = elementHeights.get(positions.indexOf(position)); - int elementWidth = elementWidths.get(positions.indexOf(position)); - int x = position.getAbsX(scaledResolution, elementWidth); - int y = position.getAbsY(scaledResolution, elementHeight); - if (position.isCenterX()) x -= elementWidth / 2; - if (position.isCenterY()) y -= elementHeight / 2; - if (!position.getClicked()) { - if (mouseX >= x && mouseY >= y && - mouseX <= x + elementWidth && mouseY <= y + elementHeight) { - clickedPos = i; - position.setClicked(true); - grabbedX = mouseX; - grabbedY = mouseY; - break; - } - } - - } - } - } - - @Override - protected void keyTyped(char typedChar, int keyCode) throws IOException { - if (clickedPos != -1) { - Position position = positions.get(clickedPos); - int elementHeight = elementHeights.get(positions.indexOf(position)); - int elementWidth = elementWidths.get(positions.indexOf(position)); - if (keyCode == Keyboard.KEY_R) { - position.set(originalPositions.get(positions.indexOf(position))); - } else if (!position.getClicked()) { - boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - int dist = shiftHeld ? 10 : 1; - if (keyCode == Keyboard.KEY_DOWN) { - position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); - } else if (keyCode == Keyboard.KEY_UP) { - position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); - } else if (keyCode == Keyboard.KEY_LEFT) { - position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); - } else if (keyCode == Keyboard.KEY_RIGHT) { - position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); - } - } - } - super.keyTyped(typedChar, keyCode); - } - - @Override - protected void mouseReleased(int mouseX, int mouseY, int state) { - super.mouseReleased(mouseX, mouseY, state); - for (Position position : positions) { - position.setClicked(false); - } - } - - @Override - protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { - super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); - for (Position position : positions) { - int elementHeight = elementHeights.get(positions.indexOf(position)); - int elementWidth = elementWidths.get(positions.indexOf(position)); - if (position.getClicked()) { - ScaledResolution scaledResolution = Utils.pushGuiScale(-1); - mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - - grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); - grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); - positionChangedCallback.run(); - - Utils.pushGuiScale(-1); - } - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java deleted file mode 100644 index 62b9b8e2..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.core.config.struct; - -import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.Config; -import io.github.moulberry.notenoughupdates.core.config.annotations.Category; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorText; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditor; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorButton; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorColour; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorText; -import io.github.moulberry.notenoughupdates.miscfeatures.EnforcedConfigValues; - -import java.lang.reflect.Field; -import java.util.LinkedHashMap; -import java.util.List; - -public class ConfigProcessor { - public static class ProcessedCategory { - public final String name; - public final String desc; - public final LinkedHashMap<String, ProcessedOption> options = new LinkedHashMap<>(); - - public ProcessedCategory(String name, String desc) { - this.name = name; - this.desc = desc; - } - } - - public static class ProcessedOption { - public final String name; - public final String desc; - public final int subcategoryId; - public GuiOptionEditor editor; - - public int accordionId = -1; - public final String[] searchTags; - - private final Field field; - private final Object container; - - public ProcessedOption(String name, String desc, int subcategoryId, Field field, Object container, String[] searchTags) { - this.name = name; - this.desc = desc; - this.subcategoryId = subcategoryId; - - this.field = field; - this.container = container; - this.searchTags = searchTags; - } - - public Object get() { - try { - return field.get(container); - } catch (Exception e) { - return null; - } - } - - public boolean set(Object value) { - try { - if (field.getType() == int.class && value instanceof Number) { - field.set(container, ((Number) value).intValue()); - } else { - field.set(container, value); - } - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - } - - public static LinkedHashMap<String, ProcessedCategory> create(Config config) { - LinkedHashMap<String, ProcessedCategory> processedConfig = new LinkedHashMap<>(); - for (Field categoryField : config.getClass().getDeclaredFields()) { - boolean exposePresent = categoryField.isAnnotationPresent(Expose.class); - boolean categoryPresent = categoryField.isAnnotationPresent(Category.class); - - if (exposePresent && categoryPresent) { - Object categoryObj; - try { - categoryObj = categoryField.get(config); - } catch (Exception e) { - //System.err.printf("Failed to load config category %s. Field was not accessible.\n", categoryField.getName()); - continue; - } - - Category categoryAnnotation = categoryField.getAnnotation(Category.class); - ProcessedCategory cat = new ProcessedCategory( - categoryAnnotation.name(), - categoryAnnotation.desc() - ); - processedConfig.put(categoryField.getName(), cat); - - for (Field optionField : categoryObj.getClass().getDeclaredFields()) { - boolean optionPresent = optionField.isAnnotationPresent(ConfigOption.class); - - if (optionPresent) { - String optionPath = categoryField.getName() + "." + optionField.getName(); - ConfigOption optionAnnotation = optionField.getAnnotation(ConfigOption.class); - ProcessedOption option = new ProcessedOption( - optionAnnotation.name(), - optionAnnotation.desc(), - optionAnnotation.subcategoryId(), - optionField, - categoryObj, - optionAnnotation.searchTags() - ); - if (optionField.isAnnotationPresent(ConfigAccordionId.class)) { - ConfigAccordionId annotation = optionField.getAnnotation(ConfigAccordionId.class); - option.accordionId = annotation.id(); - } - - GuiOptionEditor editor = null; - Class<?> optionType = optionField.getType(); - if (optionType.isAssignableFrom(int.class) && - optionField.isAnnotationPresent(ConfigEditorKeybind.class)) { - ConfigEditorKeybind configEditorAnnotation = optionField.getAnnotation(ConfigEditorKeybind.class); - editor = new GuiOptionEditorKeybind(option, configEditorAnnotation.defaultKey()); - } - if (optionField.isAnnotationPresent(ConfigEditorButton.class)) { - ConfigEditorButton configEditorAnnotation = optionField.getAnnotation(ConfigEditorButton.class); - editor = new GuiOptionEditorButton( - option, - configEditorAnnotation.runnableId(), - configEditorAnnotation.buttonText(), - config - ); - } - if (optionField.isAnnotationPresent(ConfigEditorFSR.class)) { - ConfigEditorFSR configEditorAnnotation = optionField.getAnnotation(ConfigEditorFSR.class); - editor = new GuiOptionEditorFSR( - option, - configEditorAnnotation.runnableId(), - configEditorAnnotation.buttonText(), - config - ); - } - if (optionType.isAssignableFrom(boolean.class) && - optionField.isAnnotationPresent(ConfigEditorBoolean.class)) { - ConfigEditorBoolean configEditorAnnotation = optionField.getAnnotation(ConfigEditorBoolean.class); - editor = new GuiOptionEditorBoolean(option, configEditorAnnotation.runnableId(), config); - } - if (optionType.isAssignableFrom(boolean.class) && - optionField.isAnnotationPresent(ConfigEditorAccordion.class)) { - ConfigEditorAccordion configEditorAnnotation = optionField.getAnnotation(ConfigEditorAccordion.class); - editor = new GuiOptionEditorAccordion(option, configEditorAnnotation.id()); - } - if (optionType.isAssignableFrom(int.class)) { - if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { - ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class); - editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), (int) option.get(), true); - } - } - if (optionType.isAssignableFrom(List.class)) { - if (optionField.isAnnotationPresent(ConfigEditorDraggableList.class)) { - ConfigEditorDraggableList configEditorAnnotation = - optionField.getAnnotation(ConfigEditorDraggableList.class); - editor = new GuiOptionEditorDraggableList( - option, - configEditorAnnotation.exampleText(), - configEditorAnnotation.allowDeleting() - ); - } - } - if (optionType.isAssignableFrom(String.class)) { - if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { - ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class); - editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), - configEditorAnnotation.initialIndex(), false - ); - } else if (optionField.isAnnotationPresent(ConfigEditorColour.class)) { - editor = new GuiOptionEditorColour(option); - } else if (optionField.isAnnotationPresent(ConfigEditorText.class)) { - editor = new GuiOptionEditorText(option); - } - } - if (optionType.isAssignableFrom(int.class) || - optionType.isAssignableFrom(float.class) || - optionType.isAssignableFrom(double.class)) { - if (optionField.isAnnotationPresent(ConfigEditorSlider.class)) { - ConfigEditorSlider configEditorAnnotation = optionField.getAnnotation(ConfigEditorSlider.class); - editor = new GuiOptionEditorSlider(option, configEditorAnnotation.minValue(), - configEditorAnnotation.maxValue(), configEditorAnnotation.minStep() - ); - } - } - if (optionType.isAssignableFrom(String.class)) { - if (optionField.isAnnotationPresent(ConfigEditorDropdown.class)) { - ConfigEditorDropdown configEditorAnnotation = optionField.getAnnotation(ConfigEditorDropdown.class); - editor = new GuiOptionEditorDropdown(option, configEditorAnnotation.values(), 0, false); - } - } - if (editor == null) { - //System.err.printf("Failed to load config option %s. Could not find suitable editor.\n", optionField.getName()); - continue; - } - if (EnforcedConfigValues.INSTANCE.isBlockedFromEditing(optionPath)) { - editor = new GuiOptionEditorBlocked(editor); - } - - option.editor = editor; - cat.options.put(optionField.getName(), option); - } - } - } else if (exposePresent || categoryPresent) { - //System.err.printf("Failed to load config category %s. Both @Expose and @Category must be present.\n", categoryField.getName()); - } - } - return processedConfig; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java index dfd0405b..d08f3c07 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -23,9 +23,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.GuiElementColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditorButForTheDungeonMap; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditorButForTheDungeonMap; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/oneconfig/IOneConfigCompat.java b/src/main/java/io/github/moulberry/notenoughupdates/oneconfig/IOneConfigCompat.java index 7afceab9..ea97de29 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/oneconfig/IOneConfigCompat.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/oneconfig/IOneConfigCompat.java @@ -19,7 +19,7 @@ package io.github.moulberry.notenoughupdates.oneconfig; -import io.github.moulberry.notenoughupdates.core.config.Config; +import io.github.moulberry.moulconfig.Config; import net.minecraftforge.fml.common.Loader; import java.util.Optional; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index d431d862..437bd0f9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -22,12 +22,13 @@ package io.github.moulberry.notenoughupdates.options; import com.google.common.collect.Lists; import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.Config; +import io.github.moulberry.moulconfig.Social; +import io.github.moulberry.moulconfig.annotations.Category; +import io.github.moulberry.moulconfig.gui.MoulConfigEditor; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; -import io.github.moulberry.notenoughupdates.core.config.Config; +import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.annotations.Category; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; import io.github.moulberry.notenoughupdates.miscfeatures.IQTest; @@ -74,11 +75,14 @@ import io.github.moulberry.notenoughupdates.overlays.OverlayManager; import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.ClientCommandHandler; import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; @@ -99,12 +103,78 @@ public class NEUConfig extends Config { } @Override + public void saveNow() { + NotEnoughUpdates.INSTANCE.saveConfig(); + } + + private Social social(String name, String iconName, String link) { + return new Social() { + @Override + public void onClick() { + Utils.openUrl(link); + } + + @Override + public List<String> getTooltip() { + return Arrays.asList(name, "§7Open " + link); + } + + @Override + public ResourceLocation getIcon() { + return new ResourceLocation("notenoughupdates:social/" + iconName + ".png"); + } + }; + } + + @Override + public List<Social> getSocials() { + return Arrays.asList( + social( + "Twitch", + "twitch", + "https://twitch.tv/moulberry2" + ), + social( + "Patreon", + "patreon", + "https://patreon.com/moulberry" + ), + social( + "YouTube", + "youtube", + "https://www.youtube.com/channel/UCPh-OKmRSS3IQi9p6YppLcw" + ), + social( + "Twitter", + "twitter", + "https://twitter.com/moulberry/" + ), + social( + "GitHub", + "github", + "https://github.com/NotEnoughUpdates/NotEnoughUpdates" + ), + social( + "Discord", + "discord", + "https://discord.gg/moulberry" + ) + ); + } + + @Override + public String getTitle() { + return "§7NotEnoughUpdates by §5Moulberry"; + } + + @Override public void executeRunnable(int runnableId) { String activeConfigCategory = null; - if (Minecraft.getMinecraft().currentScreen instanceof GuiScreenElementWrapper) { - GuiScreenElementWrapper wrapper = (GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen; - if (wrapper.element instanceof NEUConfigEditor) { - activeConfigCategory = ((NEUConfigEditor) wrapper.element).getSelectedCategoryName(); + if (Minecraft.getMinecraft().currentScreen instanceof io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper) { + io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper wrapper = + (io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper) Minecraft.getMinecraft().currentScreen; + if (wrapper.element instanceof MoulConfigEditor) { + activeConfigCategory = ((MoulConfigEditor) wrapper.element).getSelectedCategory(); } } @@ -163,8 +233,6 @@ public class NEUConfig extends Config { NotEnoughUpdates.INSTANCE.config.apiData.repoUser = "NotEnoughUpdates"; NotEnoughUpdates.INSTANCE.config.apiData.repoName = "NotEnoughUpdates-REPO"; NotEnoughUpdates.INSTANCE.config.apiData.repoBranch = "master"; - NotEnoughUpdates.INSTANCE.openGui = - new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, "apis")); return; case 26: OverlayManager.powderGrindingOverlay.reset(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java deleted file mode 100644 index 62bb730b..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java +++ /dev/null @@ -1,916 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.options; - -import com.google.common.collect.Lists; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.core.GlScissorStack; -import io.github.moulberry.notenoughupdates.core.GuiElement; -import io.github.moulberry.notenoughupdates.core.GuiElementTextField; -import io.github.moulberry.notenoughupdates.core.config.Config; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditor; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; -import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import io.github.moulberry.notenoughupdates.miscfeatures.IQTest; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -import static io.github.moulberry.notenoughupdates.util.GuiTextures.DISCORD; -import static io.github.moulberry.notenoughupdates.util.GuiTextures.GITHUB; -import static io.github.moulberry.notenoughupdates.util.GuiTextures.PATREON; -import static io.github.moulberry.notenoughupdates.util.GuiTextures.TWITCH; -import static io.github.moulberry.notenoughupdates.util.GuiTextures.TWITTER; -import static io.github.moulberry.notenoughupdates.util.GuiTextures.YOUTUBE; - -public class NEUConfigEditor extends GuiElement { - private static final ResourceLocation[] socialsIco = new ResourceLocation[]{ - DISCORD, - GITHUB, - TWITTER, - YOUTUBE, - PATREON, - TWITCH - }; - private static final String[] socialsLink = new String[]{ - "https://discord.gg/moulberry", - "https://github.com/Moulberry/NotEnoughUpdates", - "https://twitter.com/moulberry/", - "https://www.youtube.com/channel/UCPh-OKmRSS3IQi9p6YppLcw", - "https://patreon.com/moulberry", - "https://www.twitch.tv/moulberry2" - }; - private static final ResourceLocation SEARCH_ICON = new ResourceLocation("notenoughupdates:core/search.png"); - public static NEUConfigEditor editor = new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config); - private final long openedMillis; - private final LerpingInteger optionsScroll = new LerpingInteger(0, 150); - private final LerpingInteger categoryScroll = new LerpingInteger(0, 150); - private final LinkedHashMap<String, ConfigProcessor.ProcessedCategory> processedConfig; - private final TreeMap<String, Set<ConfigProcessor.ProcessedOption>> searchOptionMap = new TreeMap<>(); - private final HashMap<ConfigProcessor.ProcessedOption, ConfigProcessor.ProcessedCategory> categoryForOption = - new HashMap<>(); - private final LerpingInteger minimumSearchSize = new LerpingInteger(0, 150); - private final GuiElementTextField searchField = new GuiElementTextField("", 0, 20, 0); - private String selectedCategory = null; - private Set<ConfigProcessor.ProcessedCategory> searchedCategories = null; - private Map<ConfigProcessor.ProcessedCategory, Set<Integer>> searchedAccordions = null; - private Set<ConfigProcessor.ProcessedOption> searchedOptions = null; - private float optionsBarStart; - private float optionsBarend; - private int lastMouseX = 0; - private int keyboardScrollXCutoff = 0; - - public NEUConfigEditor(Config config) { - this(config, null); - } - - public NEUConfigEditor(Config config, String categoryOpen) { - this.openedMillis = System.currentTimeMillis(); - this.processedConfig = ConfigProcessor.create(config); - - for (ConfigProcessor.ProcessedCategory category : processedConfig.values()) { - for (ConfigProcessor.ProcessedOption option : category.options.values()) { - categoryForOption.put(option, category); - - String combined = category.name + " " + category.desc + " " + option.name + " " + option.desc + " " + - Arrays.toString(option.searchTags); - combined = combined.replaceAll("[^a-zA-Z_ ]", "").toLowerCase(); - for (String word : combined.split("[ _]")) { - searchOptionMap.computeIfAbsent(word, k -> new HashSet<>()).add(option); - } - } - } - - if (categoryOpen != null) { - for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) { - if (category.getValue().name.equalsIgnoreCase(categoryOpen)) { - setSelectedCategory(category.getKey()); - break; - } - } - if (selectedCategory == null) { - for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) { - if (category.getValue().name.toLowerCase().startsWith(categoryOpen.toLowerCase())) { - setSelectedCategory(category.getKey()); - break; - } - } - } - if (selectedCategory == null) { - for (Map.Entry<String, ConfigProcessor.ProcessedCategory> category : processedConfig.entrySet()) { - if (category.getValue().name.toLowerCase().contains(categoryOpen.toLowerCase())) { - setSelectedCategory(category.getKey()); - break; - } - } - } - } - - editor = this; - } - - private LinkedHashMap<String, ConfigProcessor.ProcessedCategory> getCurrentConfigEditing() { - LinkedHashMap<String, ConfigProcessor.ProcessedCategory> newMap = new LinkedHashMap<>(processedConfig); - if (searchedCategories != null) newMap.values().retainAll(searchedCategories); - return newMap; - } - - private LinkedHashMap<String, ConfigProcessor.ProcessedOption> getOptionsInCategory(ConfigProcessor.ProcessedCategory cat) { - if (cat.options.containsKey("apiDataUnlocked") && !NotEnoughUpdates.INSTANCE.config.apiData.apiDataUnlocked) { - return IQTest.getOptions(); - } - LinkedHashMap<String, ConfigProcessor.ProcessedOption> newMap = new LinkedHashMap<>(cat.options); - - if (searchedOptions != null) { - Set<ConfigProcessor.ProcessedOption> retain = new HashSet<>(); - retain.addAll(searchedOptions); - - if (searchedAccordions != null) { - Set<Integer> visibleAccordions = searchedAccordions.get(cat); - - if (visibleAccordions != null && !visibleAccordions.isEmpty()) { - for (ConfigProcessor.ProcessedOption option : newMap.values()) { - if (option.editor instanceof GuiOptionEditorAccordion) { - int accordionId = ((GuiOptionEditorAccordion) option.editor).getAccordionId(); - - if (visibleAccordions.contains(accordionId)) { - retain.add(option); - } - } - } - } - - } - - newMap.values().retainAll(retain); - } - return newMap; - } - - public String getSelectedCategory() { - return selectedCategory; - } - - private void setSelectedCategory(String category) { - selectedCategory = category; - optionsScroll.setValue(0); - } - - public String getSelectedCategoryName() { - return processedConfig.get(selectedCategory).name; - } - - public void search() { - String search = searchField.getText().trim().replaceAll("[^a-zA-Z_ ]", "").toLowerCase(); - searchedCategories = null; - searchedOptions = null; - searchedAccordions = null; - - if (!search.isEmpty()) { - searchedCategories = new HashSet<>(); - searchedAccordions = new HashMap<>(); - - for (String word : search.split(" ")) { - if (word.trim().isEmpty()) continue; - - Set<ConfigProcessor.ProcessedOption> options = new HashSet<>(); - - Map<String, Set<ConfigProcessor.ProcessedOption>> map = NotEnoughUpdates.INSTANCE.manager - .subMapWithKeysThatAreSuffixes(word, searchOptionMap); - - map.values().forEach(options::addAll); - - if (!options.isEmpty()) { - if (searchedOptions == null) { - searchedOptions = new HashSet<>(options); - } else { - searchedOptions.retainAll(options); - } - } - } - - if (searchedOptions == null) { - searchedOptions = new HashSet<>(); - } else { - Set<ConfigProcessor.ProcessedOption> searchedOptions2 = new HashSet<>(); - for (ConfigProcessor.ProcessedOption option : searchedOptions) { - ConfigProcessor.ProcessedCategory cat = categoryForOption.get(option); - if (cat == null) continue; - - searchedCategories.add(cat); - for (ConfigProcessor.ProcessedOption catOption : cat.options.values()) { - if (catOption.accordionId == -1 || option.accordionId == -1) continue; - if (catOption.accordionId == option.accordionId) searchedOptions2.add(catOption); - } - searchedAccordions.computeIfAbsent(cat, k -> new HashSet<>()).add(option.accordionId); - } - searchedOptions.addAll(searchedOptions2); - } - } - } - - public void render() { - optionsScroll.tick(); - categoryScroll.tick(); - handleKeyboardPresses(); - - List<String> tooltipToDisplay = null; - - long currentTime = System.currentTimeMillis(); - long delta = currentTime - openedMillis; - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - - float opacityFactor = LerpUtils.sigmoidZeroOne(delta / 500f); - RenderUtils.drawGradientRect(0, 0, 0, width, height, - (int) (0x80 * opacityFactor) << 24 | 0x101010, - (int) (0x90 * opacityFactor) << 24 | 0x101010 - ); - - int xSize = Math.min(scaledResolution.getScaledWidth() - 100 / scaledResolution.getScaleFactor(), 500); - int ySize = Math.min(scaledResolution.getScaledHeight() - 100 / scaledResolution.getScaleFactor(), 400); - - int x = (scaledResolution.getScaledWidth() - xSize) / 2; - int y = (scaledResolution.getScaledHeight() - ySize) / 2; - - int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); - - int openingXSize = xSize; - int openingYSize = ySize; - if (delta < 150) { - openingXSize = (int) (delta * xSize / 150); - openingYSize = 5; - } else if (delta < 300) { - openingYSize = 5 + (int) (delta - 150) * (ySize - 5) / 150; - } - RenderUtils.drawFloatingRectDark( - (scaledResolution.getScaledWidth() - openingXSize) / 2, - (scaledResolution.getScaledHeight() - openingYSize) / 2, - openingXSize, openingYSize - ); - GlScissorStack.clear(); - GlScissorStack.push((scaledResolution.getScaledWidth() - openingXSize) / 2, - (scaledResolution.getScaledHeight() - openingYSize) / 2, - (scaledResolution.getScaledWidth() + openingXSize) / 2, - (scaledResolution.getScaledHeight() + openingYSize) / 2, scaledResolution - ); - - RenderUtils.drawFloatingRectDark(x + 5, y + 5, xSize - 10, 20, false); - - TextRenderUtils.drawStringCenteredScaledMaxWidth( - "NotEnoughUpdates by " + EnumChatFormatting.DARK_PURPLE + "Moulberry", - x + xSize / 2, y + 15, false, 200, 0xa0a0a0 - ); - - RenderUtils.drawFloatingRectDark(x + 4, y + 49 - 20, - 140, ySize - 54 + 20, false - ); - - int innerPadding = 20 / adjScaleFactor; - int innerLeft = x + 4 + innerPadding; - int innerRight = x + 144 - innerPadding; - int innerTop = y + 49 + innerPadding; - int innerBottom = y + ySize - 5 - innerPadding; - Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left - Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top - Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff28282E); //Right - Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff28282E); //Bottom - Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle - - GlScissorStack.push(0, innerTop + 1, scaledResolution.getScaledWidth(), - innerBottom - 1, scaledResolution - ); - - float catBarSize = 1; - int catY = -categoryScroll.getValue(); - - LinkedHashMap<String, ConfigProcessor.ProcessedCategory> currentConfigEditing = getCurrentConfigEditing(); - for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : currentConfigEditing.entrySet()) { - String selectedCategory = getSelectedCategory(); - if (selectedCategory == null || !currentConfigEditing.containsKey(selectedCategory)) { - setSelectedCategory(entry.getKey()); - } - String catName = entry.getValue().name; - if (entry.getKey().equals(getSelectedCategory())) { - catName = EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.UNDERLINE + catName; - } else { - catName = EnumChatFormatting.GRAY + catName; - } - TextRenderUtils.drawStringCenteredScaledMaxWidth(catName, x + 75, y + 70 + catY, false, 100, -1); - catY += 15; - if (catY > 0) { - catBarSize = - LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + categoryScroll.getValue())); - } - } - - float catBarStart = categoryScroll.getValue() / (float) (catY + categoryScroll.getValue()); - float catBarEnd = catBarStart + catBarSize; - if (catBarEnd > 1) { - catBarEnd = 1; - if (categoryScroll.getTarget() / (float) (catY + categoryScroll.getValue()) + catBarSize < 1) { - int target = optionsScroll.getTarget(); - categoryScroll.setValue((int) Math.ceil( - (catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()))); - categoryScroll.setTarget(target); - } else { - categoryScroll.setValue((int) Math.ceil( - (catY + 5 + categoryScroll.getValue()) - catBarSize * (catY + 5 + categoryScroll.getValue()))); - } - } - int catDist = innerBottom - innerTop - 12; - Gui.drawRect(innerLeft + 2, innerTop + 5, innerLeft + 7, innerBottom - 5, 0xff101010); - Gui.drawRect(innerLeft + 3, innerTop + 6 + (int) (catDist * catBarStart), innerLeft + 6, - innerTop + 6 + (int) (catDist * catBarEnd), 0xff303030 - ); - - GlScissorStack.pop(scaledResolution); - - TextRenderUtils.drawStringCenteredScaledMaxWidth("Categories", x + 75, y + 44, false, 120, 0xa368ef); - - RenderUtils.drawFloatingRectDark(x + 149, y + 29, xSize - 154, ySize - 34, false); - - innerLeft = x + 149 + innerPadding; - innerRight = x + xSize - 5 - innerPadding; - innerBottom = y + ySize - 5 - innerPadding; - - Minecraft.getMinecraft().getTextureManager().bindTexture(SEARCH_ICON); - GlStateManager.color(1, 1, 1, 1); - Utils.drawTexturedRect(innerRight - 20, innerTop - (20 + innerPadding) / 2 - 9, 18, 18, GL11.GL_NEAREST); - - minimumSearchSize.tick(); - boolean shouldShow = !searchField.getText().trim().isEmpty() || searchField.getFocus(); - if (shouldShow && minimumSearchSize.getTarget() < 30) { - minimumSearchSize.setTarget(30); - minimumSearchSize.resetTimer(); - } else if (!shouldShow && minimumSearchSize.getTarget() > 0) { - minimumSearchSize.setTarget(0); - minimumSearchSize.resetTimer(); - } - - int rightStuffLen = 20; - if (minimumSearchSize.getValue() > 1) { - int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText()) + 10; - if (!shouldShow) strLen = 0; - - int len = Math.max(strLen, minimumSearchSize.getValue()); - searchField.setSize(len, 18); - searchField.render(innerRight - 25 - len, innerTop - (20 + innerPadding) / 2 - 9); - - rightStuffLen += 5 + len; - } - - if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { - ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); - - TextRenderUtils.drawStringScaledMaxWidth( - cat.desc, - innerLeft + 5, y + 40, true, innerRight - innerLeft - rightStuffLen - 10, 0xb0b0b0 - ); - } - - Gui.drawRect(innerLeft, innerTop, innerLeft + 1, innerBottom, 0xff08080E); //Left - Gui.drawRect(innerLeft + 1, innerTop, innerRight, innerTop + 1, 0xff08080E); //Top - Gui.drawRect(innerRight - 1, innerTop + 1, innerRight, innerBottom, 0xff303036); //Right - Gui.drawRect(innerLeft + 1, innerBottom - 1, innerRight - 1, innerBottom, 0xff303036); //Bottom - Gui.drawRect(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, 0x6008080E); //Middle - - GlScissorStack.push(innerLeft + 1, innerTop + 1, innerRight - 1, innerBottom - 1, scaledResolution); - float barSize = 1; - int optionY = -optionsScroll.getValue(); - if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { - ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); - int optionWidthDefault = innerRight - innerLeft - 20; - GlStateManager.enableDepth(); - HashMap<Integer, Integer> activeAccordions = new HashMap<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { - int optionWidth = optionWidthDefault; - if (option.accordionId >= 0) { - if (!activeAccordions.containsKey(option.accordionId)) { - continue; - } - int accordionDepth = activeAccordions.get(option.accordionId); - optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); - } - - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - int accordionDepth = 0; - if (option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId) + 1; - } - activeAccordions.put(accordion.getAccordionId(), accordionDepth); - } - } - int optionHeight = editor.getHeight(); - if (innerTop + 5 + optionY + optionHeight > innerTop + 1 && innerTop + 5 + optionY < innerBottom - 1) { - editor.render((innerLeft + innerRight - optionWidth) / 2 - 5, innerTop + 5 + optionY, optionWidth); - } - optionY += optionHeight + 5; - } - GlStateManager.disableDepth(); - if (optionY > 0) { - barSize = - LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + optionsScroll.getValue())); - } - } - - GlScissorStack.pop(scaledResolution); - - GL11.glDisable(GL11.GL_SCISSOR_TEST); - if (getSelectedCategory() != null && currentConfigEditing.containsKey(getSelectedCategory())) { - int optionYOverlay = -optionsScroll.getValue(); - ConfigProcessor.ProcessedCategory cat = currentConfigEditing.get(getSelectedCategory()); - int optionWidthDefault = innerRight - innerLeft - 20; - - GlStateManager.translate(0, 0, 10); - GlStateManager.enableDepth(); - HashMap<Integer, Integer> activeAccordions = new HashMap<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { - int optionWidth = optionWidthDefault; - if (option.accordionId >= 0) { - if (!activeAccordions.containsKey(option.accordionId)) { - continue; - } - int accordionDepth = activeAccordions.get(option.accordionId); - optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); - } - - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - int accordionDepth = 0; - if (option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId) + 1; - } - activeAccordions.put(accordion.getAccordionId(), accordionDepth); - } - } - int optionHeight = editor.getHeight(); - if (innerTop + 5 + optionYOverlay + optionHeight > innerTop + 1 && - innerTop + 5 + optionYOverlay < innerBottom - 1) { - editor.renderOverlay( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionYOverlay, - optionWidth - ); - } - optionYOverlay += optionHeight + 5; - } - GlStateManager.disableDepth(); - GlStateManager.translate(0, 0, -10); - } - GL11.glEnable(GL11.GL_SCISSOR_TEST); - - optionsBarStart = optionsScroll.getValue() / (float) (optionY + optionsScroll.getValue()); - optionsBarend = optionsBarStart + barSize; - if (optionsBarend > 1) { - optionsBarend = 1; - if (optionsScroll.getTarget() / (float) (optionY + optionsScroll.getValue()) + barSize < 1) { - int target = optionsScroll.getTarget(); - optionsScroll.setValue((int) Math.ceil( - (optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()))); - optionsScroll.setTarget(target); - } else { - optionsScroll.setValue((int) Math.ceil( - (optionY + 5 + optionsScroll.getValue()) - barSize * (optionY + 5 + optionsScroll.getValue()))); - } - } - int dist = innerBottom - innerTop - 12; - Gui.drawRect(innerRight - 10, innerTop + 5, innerRight - 5, innerBottom - 5, 0xff101010); - Gui.drawRect( - innerRight - 9, - innerTop + 6 + (int) (dist * optionsBarStart), - innerRight - 6, - innerTop + 6 + (int) (dist * optionsBarend), - 0xff303030 - ); - - for (int socialIndex = 0; socialIndex < socialsIco.length; socialIndex++) { - Minecraft.getMinecraft().getTextureManager().bindTexture(socialsIco[socialIndex]); - GlStateManager.color(1, 1, 1, 1); - int socialLeft = x + xSize - 23 - 18 * socialIndex; - RenderUtils.drawTexturedRect(socialLeft, y + 7, 16, 16, GL11.GL_LINEAR); - - if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && - mouseY >= y + 6 && mouseY <= y + 23) { - tooltipToDisplay = Lists.newArrayList( - EnumChatFormatting.YELLOW + "Go to: " + EnumChatFormatting.RESET + socialsLink[socialIndex]); - } - } - - GlScissorStack.clear(); - - if (tooltipToDisplay != null) { - TextRenderUtils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, -1, - Minecraft.getMinecraft().fontRendererObj - ); - } - - GlStateManager.translate(0, 0, -2); - } - - public boolean mouseInput(int mouseX, int mouseY) { - lastMouseX = mouseX; - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - - int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); - int ySize = Math.min(height - 100 / scaledResolution.getScaleFactor(), 400); - - int x = (scaledResolution.getScaledWidth() - xSize) / 2; - int y = (scaledResolution.getScaledHeight() - ySize) / 2; - - int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); - - int innerPadding = 20 / adjScaleFactor; - int innerTop = y + 49 + innerPadding; - int innerBottom = y + ySize - 5 - innerPadding; - int innerLeft = x + 149 + innerPadding; - int innerRight = x + xSize - 5 - innerPadding; - - int dist = innerBottom - innerTop - 12; - int optionsBarStartY = innerTop + 6 + (int) (dist * optionsBarStart); - int optionsBarEndY = innerTop + 6 + (int) (dist * optionsBarend); - int optionsBarStartX = innerRight - 12; - int optionsBarEndX = innerRight - 3; - - int categoryY = -categoryScroll.getValue(); - categoryY += 15 * getCurrentConfigEditing().size(); - int catDist = innerBottom - innerTop - 12; - float catBarStart = categoryScroll.getValue() / (float) (categoryY + categoryScroll.getValue()); - float categoryBarSize = LerpUtils.clampZeroOne( - (float) (innerBottom - innerTop - 2) / (categoryY + 5 + categoryScroll.getValue())); - float catBarEnd = catBarStart + categoryBarSize; - int categoryBarStartY = innerTop + 6 + (int) (catDist * catBarStart); - int categoryBarEndY = innerTop + 6 + (int) (catDist * catBarEnd); - int categoryBarStartX = x + innerPadding + 7; - int categoryBarEndX = x + innerPadding + 12; - keyboardScrollXCutoff = innerLeft - 10; - if (Mouse.getEventButtonState()) { - if ((mouseY < optionsBarStartY || mouseY > optionsBarEndY) && - (mouseX >= optionsBarStartX && mouseX <= optionsBarEndX) && mouseY > innerTop + 6 && mouseY < innerBottom - 6) { - optionsScroll.setTimeToReachTarget(200); - optionsScroll.resetTimer(); - optionsScroll.setTarget(mouseY - innerTop); - return true; - } else if ((mouseY < categoryBarStartY || mouseY > categoryBarEndY) && - (mouseX >= categoryBarStartX && mouseX <= categoryBarEndX) && mouseY > innerTop + 6 && - mouseY < innerBottom - 6) { - categoryScroll.setTimeToReachTarget(200); - categoryScroll.resetTimer(); - categoryScroll.setTarget(mouseY - innerTop); - return true; - } - - searchField.setFocus(mouseX >= innerRight - 20 && mouseX <= innerRight - 2 && - mouseY >= innerTop - (20 + innerPadding) / 2 - 9 && mouseY <= innerTop - (20 + innerPadding) / 2 + 9); - - if (minimumSearchSize.getValue() > 1) { - int strLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchField.getText()) + 10; - int len = Math.max(strLen, minimumSearchSize.getValue()); - - if (mouseX >= innerRight - 25 - len && mouseX <= innerRight - 25 && - mouseY >= innerTop - (20 + innerPadding) / 2 - 9 && mouseY <= innerTop - (20 + innerPadding) / 2 + 9) { - String old = searchField.getText(); - searchField.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); - - if (!searchField.getText().equals(old)) search(); - } - } - } - - int dWheel = Mouse.getEventDWheel(); - if (mouseY > innerTop && mouseY < innerBottom && dWheel != 0) { - if (dWheel < 0) { - dWheel = -1; - } - if (dWheel > 0) { - dWheel = 1; - } - if (mouseX < innerLeft) { - int newTarget = categoryScroll.getTarget() - dWheel * 30; - if (newTarget < 0) { - newTarget = 0; - } - - float catBarSize = 1; - int catY = -newTarget; - for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) { - if (getSelectedCategory() == null) { - setSelectedCategory(entry.getKey()); - } - - catY += 15; - if (catY > 0) { - catBarSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (catY + 5 + newTarget)); - } - } - - int barMax = (int) Math.floor((catY + 5 + newTarget) - catBarSize * (catY + 5 + newTarget)); - if (newTarget > barMax) { - newTarget = barMax; - } - categoryScroll.resetTimer(); - categoryScroll.setTarget(newTarget); - } else { - int newTarget = optionsScroll.getTarget() - dWheel * 30; - if (newTarget < 0) { - newTarget = 0; - } - - float barSize = 1; - int optionY = -newTarget; - if (getSelectedCategory() != null && getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory())) { - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - HashMap<Integer, Integer> activeAccordions = new HashMap<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { - if (option.accordionId >= 0) { - if (!activeAccordions.containsKey(option.accordionId)) { - continue; - } - } - - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - int accordionDepth = 0; - if (option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId) + 1; - } - activeAccordions.put(accordion.getAccordionId(), accordionDepth); - } - } - optionY += editor.getHeight() + 5; - - if (optionY > 0) { - barSize = LerpUtils.clampZeroOne((float) (innerBottom - innerTop - 2) / (optionY + 5 + newTarget)); - } - } - } - - int barMax = (int) Math.floor((optionY + 5 + newTarget) - barSize * (optionY + 5 + newTarget)); - if (newTarget > barMax) { - newTarget = barMax; - } - optionsScroll.setTimeToReachTarget(Math.min( - 150, - Math.max(10, 5 * Math.abs(newTarget - optionsScroll.getValue())) - )); - optionsScroll.resetTimer(); - optionsScroll.setTarget(newTarget); - } - } else if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) { - if (getCurrentConfigEditing() != null) { - int catY = -categoryScroll.getValue(); - for (Map.Entry<String, ConfigProcessor.ProcessedCategory> entry : getCurrentConfigEditing().entrySet()) { - if (getSelectedCategory() == null) { - setSelectedCategory(entry.getKey()); - } - if (mouseX >= x + 5 && mouseX <= x + 145 && - mouseY >= y + 70 + catY - 7 && mouseY <= y + 70 + catY + 7) { - setSelectedCategory(entry.getKey()); - return true; - } - catY += 15; - } - } - - for (int socialIndex = 0; socialIndex < socialsLink.length; socialIndex++) { - int socialLeft = x + xSize - 23 - 18 * socialIndex; - - if (mouseX >= socialLeft && mouseX <= socialLeft + 16 && - mouseY >= y + 6 && mouseY <= y + 23) { - Utils.openUrl(socialsLink[socialIndex]); - return true; - } - } - } - - int optionY = -optionsScroll.getValue(); - if (getSelectedCategory() != null && getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory())) { - int optionWidthDefault = innerRight - innerLeft - 20; - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - HashMap<Integer, Integer> activeAccordions = new HashMap<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { - int optionWidth = optionWidthDefault; - if (option.accordionId >= 0) { - if (!activeAccordions.containsKey(option.accordionId)) { - continue; - } - int accordionDepth = activeAccordions.get(option.accordionId); - optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); - } - - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - int accordionDepth = 0; - if (option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId) + 1; - } - activeAccordions.put(accordion.getAccordionId(), accordionDepth); - } - } - if (editor.mouseInputOverlay( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionY, - optionWidth, - mouseX, - mouseY - )) { - return true; - } - optionY += editor.getHeight() + 5; - } - } - - if (mouseX > innerLeft && mouseX < innerRight && - mouseY > innerTop && mouseY < innerBottom) { - optionY = -optionsScroll.getValue(); - if (getSelectedCategory() != null && getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory())) { - int optionWidthDefault = innerRight - innerLeft - 20; - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - HashMap<Integer, Integer> activeAccordions = new HashMap<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { - int optionWidth = optionWidthDefault; - if (option.accordionId >= 0) { - if (!activeAccordions.containsKey(option.accordionId)) { - continue; - } - int accordionDepth = activeAccordions.get(option.accordionId); - optionWidth = optionWidthDefault - (2 * innerPadding) * (accordionDepth + 1); - } - - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - int accordionDepth = 0; - if (option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId) + 1; - } - activeAccordions.put(accordion.getAccordionId(), accordionDepth); - } - } - if (editor.mouseInput( - (innerLeft + innerRight - optionWidth) / 2 - 5, - innerTop + 5 + optionY, - optionWidth, - mouseX, - mouseY - )) { - return true; - } - optionY += editor.getHeight() + 5; - } - } - } - - return true; - } - - public boolean keyboardInput() { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledResolution.getScaledWidth(); - - int xSize = Math.min(width - 100 / scaledResolution.getScaleFactor(), 500); - - int adjScaleFactor = Math.max(2, scaledResolution.getScaleFactor()); - - int innerPadding = 20 / adjScaleFactor; - int innerWidth = xSize - 154 - innerPadding * 2; - - if (Keyboard.getEventKeyState()) { - if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && Keyboard.isKeyDown(Keyboard.KEY_F)) { - searchField.setFocus(!searchField.getFocus()); - return true; - } - - String old = searchField.getText(); - searchField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); - searchField.setText(Minecraft.getMinecraft().fontRendererObj.trimStringToWidth( - searchField.getText(), - innerWidth / 2 - 20 - )); - - if (!searchField.getText().equals(old)) search(); - } - - if (getSelectedCategory() != null && getCurrentConfigEditing() != null && - getCurrentConfigEditing().containsKey(getSelectedCategory())) { - ConfigProcessor.ProcessedCategory cat = getCurrentConfigEditing().get(getSelectedCategory()); - HashMap<Integer, Integer> activeAccordions = new HashMap<>(); - for (ConfigProcessor.ProcessedOption option : getOptionsInCategory(cat).values()) { - if (option.accordionId >= 0) { - if (!activeAccordions.containsKey(option.accordionId)) { - continue; - } - } - - GuiOptionEditor editor = option.editor; - if (editor == null) { - continue; - } - if (editor instanceof GuiOptionEditorAccordion) { - GuiOptionEditorAccordion accordion = (GuiOptionEditorAccordion) editor; - if (accordion.getToggled()) { - int accordionDepth = 0; - if (option.accordionId >= 0) { - accordionDepth = activeAccordions.get(option.accordionId) + 1; - } - activeAccordions.put(accordion.getAccordionId(), accordionDepth); - } - } - if (editor.keyboardInput()) { - return true; - } - } - } - - return true; - } - - private void handleKeyboardPresses() { - LerpingInteger target = lastMouseX < keyboardScrollXCutoff ? categoryScroll : optionsScroll; - if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { - target.setTimeToReachTarget(50); - target.resetTimer(); - target.setTarget(target.getTarget() + 5); - } else if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { - target.setTimeToReachTarget(50); - target.resetTimer(); - if (target.getTarget() >= 0) { - target.setTarget(target.getTarget() - 5); - } - } - if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { - NotEnoughUpdates.INSTANCE.saveConfig(); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHGraph.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHGraph.java index ff5bdf62..213fa976 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHGraph.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHGraph.java @@ -20,21 +20,20 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorText; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigEditorText; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import org.lwjgl.input.Keyboard; public class AHGraph { @Expose @ConfigOption( name = "Enable AH/BZ Price Graph", - desc = "Enable or disable the graph.", - searchTags = {"auction", "bazaar"} + desc = "Enable or disable the graph." ) @ConfigEditorBoolean public boolean graphEnabled = true; @@ -70,8 +69,7 @@ public class AHGraph { @Expose @ConfigOption( name = "Graph Colour", - desc = "Set a custom colour for the graph.", - searchTags = "color" + desc = "Set a custom colour for the graph." ) @ConfigEditorColour public String graphColor = "0:255:0:255:0"; @@ -79,8 +77,7 @@ public class AHGraph { @Expose @ConfigOption( name = "Secondary Graph Colour", - desc = "Set a custom colour for the second graph line.", - searchTags = "color" + desc = "Set a custom colour for the second graph line." ) @ConfigEditorColour public String graphColor2 = "0:255:255:255:0"; @@ -109,8 +106,7 @@ public class AHGraph { @Expose @ConfigOption( name = "Moving Average Colour", - desc = "Set a custom colour for the graph's moving average line.", - searchTags = "color" + desc = "Set a custom colour for the graph's moving average line." ) @ConfigEditorColour public String movingAverageColor = "0:255:0:255:171"; @@ -118,8 +114,7 @@ public class AHGraph { @Expose @ConfigOption( name = "Secondary Moving Average Colour", - desc = "Set a custom colour for the second graph's secondary moving average line line.", - searchTags = "color" + desc = "Set a custom colour for the second graph's secondary moving average line line." ) @ConfigEditorColour public String movingAverageColor2 = "0:255:255:109:0"; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHTweaks.java index f6aac507..7edb6c7d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AHTweaks.java @@ -20,11 +20,11 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class AHTweaks { @ConfigOption( diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AccessoryBag.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AccessoryBag.java index b87db1d6..2726b1af 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AccessoryBag.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/AccessoryBag.java @@ -20,8 +20,8 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class AccessoryBag { @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ApiData.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ApiData.java index 9cf302aa..80370ba9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ApiData.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ApiData.java @@ -20,12 +20,12 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorText; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; +import io.github.moulberry.moulconfig.annotations.ConfigEditorText; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class ApiData { @@ -40,8 +40,7 @@ public class ApiData { @Expose @ConfigOption( name = "Api Key", - desc = "Hypixel API key.", - searchTags = "apikey" + desc = "Hypixel API key." ) @ConfigEditorText public String apiKey = ""; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/BazaarTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/BazaarTweaks.java index 954af02d..4004920f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/BazaarTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/BazaarTweaks.java @@ -20,10 +20,10 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class BazaarTweaks { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Calendar.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Calendar.java index 8aef92d8..1c753b00 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Calendar.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Calendar.java @@ -20,16 +20,15 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class Calendar { @Expose @ConfigOption( name = "Event Notifications", - desc = "Display notifications for SkyBlock calendar events", - searchTags = {"jacob", "dark", "farming"} + desc = "Display notifications for SkyBlock calendar events" ) @ConfigEditorBoolean public boolean eventNotifications = true; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java index 0d33172d..e9ec26e8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/CustomArmour.java @@ -20,9 +20,9 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class CustomArmour { @@ -30,8 +30,7 @@ public class CustomArmour { @ConfigOption( name = "Enable Equipment Hud", desc = "Shows an overlay in your inventory showing your 4 extra armour slots\n" + - "\u00A7cRequires Hide Potion Effects to be enabled", - searchTags = "armor" + "\u00A7cRequires Hide Potion Effects to be enabled" ) @ConfigEditorBoolean public boolean enableArmourHud = true; @@ -47,8 +46,7 @@ public class CustomArmour { @Expose @ConfigOption( name = "GUI Style", - desc = "Change the colour of the GUI", - searchTags = "color" + desc = "Change the colour of the GUI" ) @ConfigEditorDropdown( values = {"Minecraft", "Grey", "PacksHQ Dark", "Transparent", "FSR"} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/DungeonMapConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/DungeonMapConfig.java index eb7bdca1..b276f8f8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/DungeonMapConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/DungeonMapConfig.java @@ -21,8 +21,8 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class DungeonMapConfig { @Expose @@ -127,16 +127,14 @@ public class DungeonMapConfig { @Expose @ConfigOption( name = "Background Colour", - desc = "Colour of the map background. Supports opacity & chroma", - searchTags = "color" + desc = "Colour of the map background. Supports opacity & chroma" ) public String dmBackgroundColour = "00:170:75:75:75"; @Expose @ConfigOption( name = "Border Colour", - desc = "Colour of the map border. Supports opacity & chroma. Turn off custom borders to see", - searchTags = "color" + desc = "Colour of the map border. Supports opacity & chroma. Turn off custom borders to see" ) public String dmBorderColour = "00:0:0:0:0"; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java index cbe7af1a..4d8010c6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java @@ -20,15 +20,15 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class Dungeons { @@ -162,18 +162,14 @@ public class Dungeons { desc = "You need Fast Render and Antialiasing off for these settings to work\n" + "You can find these in your video settings" ) - @ConfigEditorFSR( - runnableId = 12, - buttonText = "" - ) + @ConfigEditorInfoText() @ConfigAccordionId(id = 2) public boolean dungeonBlockWarning = false; @Expose @ConfigOption( name = "Enable Block Overlay", - desc = "Change the colour of certain blocks / entities while inside dungeons, but keeps the normal texture outside of dungeons", - searchTags = "color" + desc = "Change the colour of certain blocks / entities while inside dungeons, but keeps the normal texture outside of dungeons" ) @ConfigEditorBoolean @ConfigAccordionId(id = 2) @@ -193,8 +189,7 @@ public class Dungeons { name = "Slow Update", desc = "Updates the colour every second instead of every tick.\n" + "\u00A7cWARNING: This will cause all texture animations (eg. flowing water) to update slowly.\n" + - "This should only be used on low-end machines", - searchTags = "color" + "This should only be used on low-end machines" ) @ConfigEditorBoolean @ConfigAccordionId(id = 2) @@ -203,8 +198,7 @@ public class Dungeons { @Expose @ConfigOption( name = "Cracked Bricks", - desc = "Change the colour of: Cracked Bricks", - searchTags = "color" + desc = "Change the colour of: Cracked Bricks" ) @ConfigEditorColour @ConfigAccordionId(id = 2) @@ -213,8 +207,7 @@ public class Dungeons { @Expose @ConfigOption( name = "Dispensers", - desc = "Change the colour of: Dispensers", - searchTags = "color" + desc = "Change the colour of: Dispensers" ) @ConfigEditorColour @ConfigAccordionId(id = 2) @@ -223,8 +216,7 @@ public class Dungeons { @Expose @ConfigOption( name = "Levers", - desc = "Change the colour of: Levers", - searchTags = "color" + desc = "Change the colour of: Levers" ) @ConfigEditorColour @ConfigAccordionId(id = 2) @@ -233,8 +225,7 @@ public class Dungeons { @Expose @ConfigOption( name = "Tripwire String", - desc = "Change the colour of: Tripwire String", - searchTags = "color" + desc = "Change the colour of: Tripwire String" ) @ConfigEditorColour @ConfigAccordionId(id = 2) @@ -243,8 +234,7 @@ public class Dungeons { @Expose @ConfigOption( name = "Normal Chests", - desc = "Change the colour of: Normal Chests", - searchTags = "color" + desc = "Change the colour of: Normal Chests" ) @ConfigEditorColour @ConfigAccordionId(id = 2) @@ -253,8 +243,7 @@ public class Dungeons { @Expose @ConfigOption( name = "Trapped Chests", - desc = "Change the colour of: Trapped Chests", - searchTags = "color" + desc = "Change the colour of: Trapped Chests" ) @ConfigEditorColour @ConfigAccordionId(id = 2) @@ -263,8 +252,7 @@ public class Dungeons { @Expose @ConfigOption( name = "Bats", - desc = "Change the colour of: Bats", - searchTags = "color" + desc = "Change the colour of: Bats" ) @ConfigEditorColour @ConfigAccordionId(id = 2) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java index c2ac4bb4..fd8e50e2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Enchanting.java @@ -20,17 +20,16 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class Enchanting { @ConfigOption( name = "Enchant Table / Hex GUI", - desc = "", - searchTags = "et" + desc = "" ) @ConfigEditorAccordion(id = 1) public boolean tableGUIAccordion = false; @@ -160,8 +159,7 @@ public class Enchanting { @Expose @ConfigOption( name = "Ultrasequencer Next", - desc = "Set the colour of the glass pane shown behind the element in the ultrasequencer which is next", - searchTags = "color" + desc = "Set the colour of the glass pane shown behind the element in the ultrasequencer which is next" ) @ConfigEditorDropdown( values = { @@ -175,8 +173,7 @@ public class Enchanting { @Expose @ConfigOption( name = "Ultrasequencer Upcoming", - desc = "Set the colour of the glass pane shown behind the element in the ultrasequencer which is coming after \"next\"", - searchTags = "color" + desc = "Set the colour of the glass pane shown behind the element in the ultrasequencer which is coming after \"next\"" ) @ConfigEditorDropdown( values = { @@ -190,8 +187,7 @@ public class Enchanting { @Expose @ConfigOption( name = "Superpairs Matched", - desc = "Set the colour of the glass pane shown behind successfully matched pairs", - searchTags = "color" + desc = "Set the colour of the glass pane shown behind successfully matched pairs" ) @ConfigEditorDropdown( values = { @@ -205,8 +201,7 @@ public class Enchanting { @Expose @ConfigOption( name = "Superpairs Possible", - desc = "Set the colour of the glass pane shown behind pairs which can be matched, but have not yet", - searchTags = "color" + desc = "Set the colour of the glass pane shown behind pairs which can be matched, but have not yet" ) @ConfigEditorDropdown( values = { @@ -220,8 +215,7 @@ public class Enchanting { @Expose @ConfigOption( name = "Superpairs Unmatched", - desc = "Set the colour of the glass pane shown behind pairs which have been previously uncovered", - searchTags = "color" + desc = "Set the colour of the glass pane shown behind pairs which have been previously uncovered" ) @ConfigEditorDropdown( values = { @@ -235,8 +229,7 @@ public class Enchanting { @Expose @ConfigOption( name = "Superpairs Powerups", - desc = "Set the colour of the glass pane shown behind powerups", - searchTags = "color" + desc = "Set the colour of the glass pane shown behind powerups" ) @ConfigEditorDropdown( values = { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java index 9d7a0775..a987f498 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java @@ -20,13 +20,13 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class Fishing { @Expose @@ -144,8 +144,7 @@ public class Fishing { name = "Particle Type", desc = "Change the type of the particle that is spawned\n" + "Particle types with (RGB) support custom colours\n" + - "Set to 'NONE' to disable particles", - searchTags = "color" + "Set to 'NONE' to disable particles" ) @ConfigEditorDropdown( values = {"Default", "None", "Spark (RGB)", "Swirl (RGB)", "Dust (RGB)", "Flame", "Crit", "Magic Crit"} @@ -157,8 +156,7 @@ public class Fishing { @ConfigOption( name = "Custom Colour", desc = "Set a custom colour for the particle\n" + - "Only works for particle types with (RGB)", - searchTags = "color" + "Only works for particle types with (RGB)" ) @ConfigEditorColour @ConfigAccordionId(id = 1) @@ -177,8 +175,7 @@ public class Fishing { name = "Particle Type", desc = "Change the type of the particle that is spawned\n" + "Particle types with (RGB) support custom colours\n" + - "Set to 'NONE' to disable particles", - searchTags = "color" + "Set to 'NONE' to disable particles" ) @ConfigEditorDropdown( values = {"Default", "None", "Spark (RGB)", "Swirl (RGB)", "Dust (RGB)", "Flame", "Crit", "Magic Crit"} @@ -190,8 +187,7 @@ public class Fishing { @ConfigOption( name = "Custom Colour", desc = "Set a custom colour for the particle\n" + - "Only works for particle types with (RGB)", - searchTags = "color" + "Only works for particle types with (RGB)" ) @ConfigEditorColour @ConfigAccordionId(id = 2) @@ -199,8 +195,7 @@ public class Fishing { @ConfigOption( name = "Rod Line Colours", - desc = "", - searchTags = "color" + desc = "" ) @ConfigEditorAccordion(id = 4) public boolean rodAccordion = false; @@ -254,8 +249,7 @@ public class Fishing { @Expose @ConfigOption( name = "Fishing timer colour", - desc = "Colour of the fishing timer", - searchTags = "color" + desc = "Colour of the fishing timer" ) @ConfigEditorColour @ConfigAccordionId(id = 6) @@ -264,8 +258,7 @@ public class Fishing { @Expose @ConfigOption( name = "Fishing timer colour (20s)", - desc = "Colour of the fishing timer after 20 seconds or more have passed", - searchTags = "color" + desc = "Colour of the fishing timer after 20 seconds or more have passed" ) @ConfigEditorColour @ConfigAccordionId(id = 6) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Garden.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Garden.java index b5f11906..6ba99dcf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Garden.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Garden.java @@ -20,8 +20,8 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class Garden { @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ImprovedSBMenu.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ImprovedSBMenu.java index bdb73fa9..db0571e1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ImprovedSBMenu.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ImprovedSBMenu.java @@ -20,9 +20,9 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class ImprovedSBMenu { @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/InventoryButtons.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/InventoryButtons.java index 36dd1a01..0709aadc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/InventoryButtons.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/InventoryButtons.java @@ -20,11 +20,11 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class InventoryButtons { @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java index 36f9e76c..917c7205 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java @@ -20,16 +20,16 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import java.util.ArrayList; import java.util.Arrays; @@ -38,8 +38,7 @@ import java.util.List; public class ItemOverlays { @ConfigOption( name = "Treecapitator Overlay", - desc = "", - searchTags = "jungle" + desc = "Jungle Axe" ) @ConfigEditorAccordion(id = 0) public boolean treecapAccordion = false; @@ -65,8 +64,7 @@ public class ItemOverlays { @Expose @ConfigOption( name = "Overlay Colour", - desc = "Change the colour of the overlay", - searchTags = "color" + desc = "Change the colour of the overlay" ) @ConfigEditorColour @ConfigAccordionId(id = 0) @@ -109,8 +107,7 @@ public class ItemOverlays { @Expose @ConfigOption( name = "Overlay Colour", - desc = "Change the colour of the ghost block outline", - searchTags = "color" + desc = "Change the colour of the ghost block outline" ) @ConfigEditorColour @ConfigAccordionId(id = 1) @@ -135,8 +132,7 @@ public class ItemOverlays { @Expose @ConfigOption( name = "Overlay Colour", - desc = "Change the colour of the ghost block outline", - searchTags = "color" + desc = "Change the colour of the ghost block outline" ) @ConfigEditorColour @ConfigAccordionId(id = 2) @@ -248,8 +244,7 @@ public class ItemOverlays { @Expose @ConfigOption( name = "Highlight Colour", - desc = "Change the colour of the etherwarp target block outline", - searchTags = "color" + desc = "Change the colour of the etherwarp target block outline" ) @ConfigEditorColour @ConfigAccordionId(id = 4) @@ -464,9 +459,7 @@ public class ItemOverlays { name = "\u00A7aInspiration:", desc = "\u00A76u/Sori0612 \u00A77on \u00A7cReddit\n\n\u00A78https://tinyurl.com/creeperveil" ) - @ConfigEditorFSR( - runnableId = 12 - ) + @ConfigEditorInfoText() public boolean customWitherCloakCredit = false; @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java index 17ac7acd..871c92d9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Itemlist.java @@ -20,11 +20,11 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class Itemlist { @Expose @@ -119,8 +119,7 @@ public class Itemlist { @Expose @ConfigOption( name = "Foreground Colour", - desc = "Change the colour of foreground elements in the Itemlist", - searchTags = "color" + desc = "Change the colour of foreground elements in the Itemlist" ) @ConfigEditorColour public String foregroundColour = "00:255:100:100:100"; @@ -128,8 +127,7 @@ public class Itemlist { @Expose @ConfigOption( name = "Favourite Colour", - desc = "Change the colour of favourited elements in the Itemlist", - searchTags = "color" + desc = "Change the colour of favourited elements in the Itemlist" ) @ConfigEditorColour public String favouriteColour = "00:255:200:150:50"; @@ -137,8 +135,7 @@ public class Itemlist { @Expose @ConfigOption( name = "Pane Background Colour", - desc = "Change the colour of the Itemlist background", - searchTags = "color" + desc = "Change the colour of the Itemlist background" ) @ConfigEditorColour public String backgroundColour = "15:6:0:0:255"; @@ -146,8 +143,7 @@ public class Itemlist { @Expose @ConfigOption( name = "Always show Monsters", - desc = "Always show Monster Items in the item list", - searchTags = "mob" + desc = "Always show Monster Items in the item list" ) @ConfigEditorBoolean( runnableId = 21 diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java index 52fd0c4a..187287fb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java @@ -20,12 +20,12 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; public class LocationEdit { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java index e1b2662a..daff7e1a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java @@ -21,14 +21,14 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import java.util.ArrayList; import java.util.Arrays; @@ -49,8 +49,7 @@ public class Mining { "Use \"Commissions Only\" to only show active commission locations" ) @ConfigEditorDropdown( - values = {"Hide", "Commissions Only", "Always"}, - initialIndex = 1 + values = {"Hide", "Commissions Only", "Always"} ) @ConfigAccordionId(id = 0) public int locWaypoints = 1; @@ -72,8 +71,7 @@ public class Mining { "Use \"Commission End\" to only show after finishing commissions" ) @ConfigEditorDropdown( - values = {"Hide", "Commission End", "Always"}, - initialIndex = 1 + values = {"Hide", "Commission End", "Always"} ) @ConfigAccordionId(id = 0) public int emissaryWaypoints = 1; @@ -421,8 +419,7 @@ public class Mining { @ConfigOption( name = "Colours", - desc = "", - searchTags = "color" + desc = "" ) @ConfigEditorAccordion(id = 6) @ConfigAccordionId(id = 4) @@ -460,9 +457,7 @@ public class Mining { @Expose @ConfigOption( name = "Done Color", - desc = "Change the colour when the part is given to the NPC.", - searchTags = "color" - + desc = "Change the colour when the part is given to the NPC." ) @ConfigEditorDropdown( values = { @@ -804,8 +799,7 @@ public class Mining { desc = "When the Powder Grinding Tracker should be reset" ) @ConfigEditorDropdown( - values = {"On World Change", "On Restart", "Never"}, - initialIndex = 2 + values = {"On World Change", "On Restart", "Never"} ) @ConfigAccordionId(id = 9) public int powderGrindingTrackerResetMode = 2; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MinionHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MinionHelper.java index 089b2ae7..17ff9a7f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MinionHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MinionHelper.java @@ -20,8 +20,8 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; //TODO jani rename message format public class MinionHelper { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java index 02630df9..f4ee27df 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java @@ -20,14 +20,14 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import org.lwjgl.input.Keyboard; public class Misc { @@ -170,8 +170,7 @@ public class Misc { @Expose @ConfigOption( name = "Edit Enchant Colours", - desc = "Change the colours of certain SkyBlock enchants (/neuec)", - searchTags = "color" + desc = "Change the colours of certain SkyBlock enchants (/neuec)" ) @ConfigEditorButton(runnableId = 8, buttonText = "Open") @ConfigAccordionId(id = 1) @@ -180,8 +179,7 @@ public class Misc { @Expose @ConfigOption( name = "Chroma Text Speed", - desc = "Change the speed of chroma text for items names (/neucustomize) and enchant colours (/neuec) with the chroma colour code (&z)", - searchTags = "color" + desc = "Change the speed of chroma text for items names (/neucustomize) and enchant colours (/neuec) with the chroma colour code (&z)" ) @ConfigEditorSlider( minValue = 10, diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java index 9a8c3514..01111988 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java @@ -21,12 +21,12 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import java.util.ArrayList; import java.util.Arrays; @@ -262,8 +262,7 @@ public class MiscOverlays { @ConfigOption( name = "Colours", - desc = "", - searchTags = "color" + desc = "" ) @ConfigEditorAccordion(id = 2) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java index 6f03c2bb..80ee7eb0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Museum.java @@ -20,10 +20,10 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class Museum { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java index 543ace07..0bc6bc11 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Notifications.java @@ -20,13 +20,13 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class Notifications { @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java index 9d88e8f1..0021da6f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java @@ -21,10 +21,10 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import java.util.ArrayList; import java.util.Arrays; @@ -99,8 +99,7 @@ public class PetOverlay { @Expose @ConfigOption( name = "GUI Style", - desc = "Change the colour of the GUI", - searchTags = "color" + desc = "Change the colour of the GUI" ) @ConfigEditorDropdown( values = {"Minecraft", "Grey", "PacksHQ Dark", "Transparent", "FSR"} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java index 61ca6bb4..cdd5ec89 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ProfileViewer.java @@ -21,11 +21,10 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; import io.github.moulberry.notenoughupdates.BuildFlags; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java index a7c2658c..321c3ddd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java @@ -20,16 +20,16 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; import org.lwjgl.input.Keyboard; import java.util.ArrayList; @@ -45,10 +45,7 @@ public class SkillOverlays { "For the overlays to show you need a \u00A7bmathematical hoe\u00A77 or an axe with \u00A7bcultivating\u00A77 " + "enchant for farming, a pickaxe with \u00A7bcompact\u00A77 for mining or a rod with \u00A7bexpertise\u00A77" ) - @ConfigEditorFSR( - runnableId = 12, - buttonText = "" - ) + @ConfigEditorInfoText() public boolean skillInfo = false; @ConfigOption( @@ -341,18 +338,14 @@ public class SkillOverlays { name = "\u00A7cWarning", desc = "The combat display will only show if you have a Book of Stats or the Champion enchant" ) - @ConfigEditorFSR( - runnableId = 12, - buttonText = "" - ) + @ConfigEditorInfoText() @ConfigAccordionId(id = 4) public boolean combatInfo = false; @Expose @ConfigOption( name = "Enable Combat Overlay", - desc = "Show an overlay while Combat with useful information", - searchTags = "champion" + desc = "Show an overlay while Combat with useful information" ) @ConfigEditorBoolean @ConfigAccordionId(id = 4) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java index 25bd680b..aad7afe7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java @@ -20,13 +20,12 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import java.util.ArrayList; import java.util.Arrays; @@ -38,9 +37,7 @@ public class SlayerOverlay { name = "\u00A7cWarning", desc = "You may have to do 2 bosses before everything shows" ) - @ConfigEditorFSR( - runnableId = 12 - ) + @ConfigEditorInfoText() public boolean slayerWarning = false; @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlotLocking.java index 22286808..a75d69e0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlotLocking.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlotLocking.java @@ -20,11 +20,11 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import org.lwjgl.input.Keyboard; public class SlotLocking { @@ -33,9 +33,7 @@ public class SlotLocking { name = "\u00A7cWarning", desc = "Make sure you have SBA's locked slots off before you turn NEU's on" ) - @ConfigEditorFSR( - runnableId = 12 - ) + @ConfigEditorInfoText() public boolean slotLockWarning = false; @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java index c8fba1fb..a0abc49e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/StorageGUI.java @@ -20,22 +20,21 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import org.lwjgl.input.Keyboard; public class StorageGUI { @ConfigOption( name = "Storage Overlay", - desc = "", - searchTags = {"ec", "enderchest", "st", "backpack"} + desc = "Ender Chest / Backpack" ) @ConfigEditorAccordion(id = 1) public boolean storageOverlayAccordion = false; @@ -47,10 +46,7 @@ public class StorageGUI { desc = "You need Fast Render and Antialiasing off for these settings to work\n" + "You can find these in your video settings" ) - @ConfigEditorFSR( - runnableId = 12, - buttonText = "" - ) + @ConfigEditorInfoText() @ConfigAccordionId(id = 1) public boolean storageGUIWarning = false; @Expose @@ -146,8 +142,7 @@ public class StorageGUI { @Expose @ConfigOption( name = "Selected Storage Colour", - desc = "Change the colour used to draw the selected backpack border", - searchTags = "color" + desc = "Change the colour used to draw the selected backpack border" ) @ConfigEditorColour @ConfigAccordionId(id = 1) @@ -156,8 +151,7 @@ public class StorageGUI { @Expose @ConfigOption( name = "Custom Text Colour", - desc = "Use a custom default text colour.\nOverrides the colour set by the overlay style.\nCan be overridden by using colour codes in the page title.", - searchTags = "color" + desc = "Use a custom default text colour.\nOverrides the colour set by the overlay style.\nCan be overridden by using colour codes in the page title." ) @ConfigEditorBoolean @ConfigAccordionId(id = 1) @@ -166,8 +160,7 @@ public class StorageGUI { @Expose @ConfigOption( name = "Custom Text Colour", - desc = "Requires the above option to be set to true", - searchTags = "color" + desc = "Requires the above option to be set to true" ) @ConfigEditorColour @ConfigAccordionId(id = 1) @@ -194,8 +187,7 @@ public class StorageGUI { @ConfigOption( name = "Inventory Backpacks", - desc = "", - searchTags = "hotbar" + desc = "" ) @ConfigEditorAccordion(id = 0) public boolean inventorySlotAccordion = false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java index d8fe91d5..0905bc6f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Toolbar.java @@ -20,13 +20,13 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class Toolbar { @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java index 078a8a90..c9a5810a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TooltipTweaks.java @@ -20,14 +20,14 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import org.lwjgl.input.Keyboard; import java.util.ArrayList; @@ -222,8 +222,7 @@ public class TooltipTweaks { @Expose @ConfigOption( name = "Tooltip Border Colours", - desc = "Make the borders of tooltips match the rarity of the item (NEU Tooltips Only)", - searchTags = "color" + desc = "Make the borders of tooltips match the rarity of the item (NEU Tooltips Only)" ) @ConfigEditorBoolean public boolean tooltipBorderColours = true; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java index 88f713c4..55a535e6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/TradeMenu.java @@ -20,8 +20,8 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class TradeMenu { @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WardrobeKeybinds.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WardrobeKeybinds.java index 48d1b434..5bbc52bd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WardrobeKeybinds.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WardrobeKeybinds.java @@ -20,11 +20,11 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import org.lwjgl.input.Keyboard; public class WardrobeKeybinds { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java index e509634e..2f8adc0f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/WorldConfig.java @@ -20,11 +20,11 @@ package io.github.moulberry.notenoughupdates.options.seperateSections; import com.google.gson.annotations.Expose; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; +import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigOption; public class WorldConfig { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java index 942eee8b..0c4b11df 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/AuctionSearchOverlay.java @@ -22,10 +22,9 @@ package io.github.moulberry.notenoughupdates.overlays; import com.google.common.base.Splitter; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.commands.help.SettingsCommand; import io.github.moulberry.notenoughupdates.core.GuiElementTextField; -import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiEditSign; -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -598,8 +597,7 @@ public class AuctionSearchOverlay { searchStringExtra = ""; close(); Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(Minecraft.getMinecraft().thePlayer.openContainer.windowId)); - NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(new NEUConfigEditor( - NotEnoughUpdates.INSTANCE.config, "AH Tweaks")); + NotEnoughUpdates.INSTANCE.openGui = SettingsCommand.INSTANCE.createConfigScreen("AH Tweaks"); } } } else if (Mouse.getEventButton() == 0) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/BazaarSearchOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/BazaarSearchOverlay.java index dab9156e..6ad33e74 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/BazaarSearchOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/BazaarSearchOverlay.java @@ -22,10 +22,10 @@ package io.github.moulberry.notenoughupdates.overlays; import com.google.common.base.Splitter; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.commands.help.SettingsCommand; import io.github.moulberry.notenoughupdates.core.GuiElementTextField; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.mixins.AccessorGuiEditSign; -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -511,8 +511,7 @@ public class BazaarSearchOverlay { searchStringExtra = ""; close(); Minecraft.getMinecraft().thePlayer.sendQueue.addToSendQueue(new C0DPacketCloseWindow(Minecraft.getMinecraft().thePlayer.openContainer.windowId)); - NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(new NEUConfigEditor( - NotEnoughUpdates.INSTANCE.config, "Bazaar Tweaks")); + NotEnoughUpdates.INSTANCE.openGui = SettingsCommand.INSTANCE.createConfigScreen("Bazaar Tweaks"); } } } else if (Mouse.getEventButton() == 0) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java index 9212eb6f..3ad42ed2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java @@ -22,7 +22,7 @@ package io.github.moulberry.notenoughupdates.overlays; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; +import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java index d0ca5d1d..b30fc3ae 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java @@ -21,7 +21,7 @@ package io.github.moulberry.notenoughupdates.overlays; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; +import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor; import org.lwjgl.util.vector.Vector2f; import java.util.List; diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt index 3c45d1e1..b318a80e 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/dev/DevTestCommand.kt @@ -23,7 +23,6 @@ import com.mojang.brigadier.arguments.StringArgumentType import io.github.moulberry.notenoughupdates.BuildFlags import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe -import io.github.moulberry.notenoughupdates.core.config.GuiPositionEditor import io.github.moulberry.notenoughupdates.core.util.MiscUtils import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent import io.github.moulberry.notenoughupdates.miscfeatures.FishingHelper @@ -189,9 +188,6 @@ class DevTestCommand { ) ) }.withHelp("Display information about the special block zone at your cursor (Custom Texture Regions)") - thenLiteralExecute("positiontest") { - NotEnoughUpdates.INSTANCE.openGui = GuiPositionEditor() - }.withHelp("Open the gui position editor") thenLiteral("pt") { thenArgument("particle", EnumArgumentType.enum<EnumParticleTypes>()) { particle -> thenExecute { diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt index fe58c807..eb5d51b1 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt @@ -19,35 +19,119 @@ package io.github.moulberry.notenoughupdates.commands.help +import io.github.moulberry.moulconfig.GuiTextures +import io.github.moulberry.moulconfig.annotations.ConfigOption +import io.github.moulberry.moulconfig.gui.GuiOptionEditor +import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper +import io.github.moulberry.moulconfig.gui.MoulConfigEditor +import io.github.moulberry.moulconfig.processor.* import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe -import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor +import io.github.moulberry.notenoughupdates.core.config.GuiOptionEditorBlocked import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor +import io.github.moulberry.notenoughupdates.miscfeatures.EnforcedConfigValues +import io.github.moulberry.notenoughupdates.miscfeatures.IQTest +import io.github.moulberry.notenoughupdates.options.NEUConfig import io.github.moulberry.notenoughupdates.util.brigadier.* +import net.minecraft.client.gui.GuiScreen +import net.minecraft.util.ResourceLocation import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.lang.reflect.Field @NEUAutoSubscribe -class SettingsCommand { +object SettingsCommand { @SubscribeEvent fun onCommands(event: RegisterBrigadierCommandEvent) { event.command("neu", "neusettings") { thenArgument("search", RestArgumentType) { search -> - suggestsList(ConfigProcessor.create(NotEnoughUpdates.INSTANCE.config).keys.toList()) + val searchSpace = mutableListOf<String>() + ConfigProcessorDriver.processConfig( + NotEnoughUpdates.INSTANCE.config.javaClass, + NotEnoughUpdates.INSTANCE.config, + object : ConfigStructureReader { + override fun beginCategory(p0: Any?, p1: Field?, p2: String, p3: String) { + searchSpace.add(p2) + searchSpace.add(p3) + } + + override fun endCategory() { + } + + override fun beginAccordion(p0: Any?, p1: Field?, p2: ConfigOption, p3: Int) { + searchSpace.add(p2.name) + searchSpace.add(p2.desc) + } + + override fun endAccordion() { + } + + override fun emitOption(p0: Any?, p1: Field?, p2: ConfigOption) { + searchSpace.add(p2.name) + searchSpace.add(p2.desc) + } + + override fun emitGuiOverlay(p0: Any?, p1: Field?, p2: ConfigOption?) { + } + + } + ) + suggestsList(searchSpace) thenExecute { - NotEnoughUpdates.INSTANCE.openGui = GuiScreenElementWrapper( - NEUConfigEditor( - NotEnoughUpdates.INSTANCE.config, - this[search] - ) - ) + NotEnoughUpdates.INSTANCE.openGui = createConfigScreen(this[search]) } }.withHelp("Search the NEU settings") thenExecute { - NotEnoughUpdates.INSTANCE.openGui = - GuiScreenElementWrapper(NEUConfigEditor(NotEnoughUpdates.INSTANCE.config)) + NotEnoughUpdates.INSTANCE.openGui = createConfigScreen("") } }.withHelp("Open the NEU settings") } + + class BlockingMoulConfigProcessor : MoulConfigProcessor<NEUConfig>(NotEnoughUpdates.INSTANCE.config) { + override fun createOptionGui( + processedOption: ProcessedOption, + field: Field, + option: ConfigOption + ): GuiOptionEditor? { + val default = super.createOptionGui(processedOption, field, option) ?: return null + if (EnforcedConfigValues.isBlockedFromEditing(processedOption.path)) { + return GuiOptionEditorBlocked(default) + } + return default + } + + var iqTestCopy: LinkedHashMap<String, ProcessedCategory>? = null + override fun getAllCategories(): LinkedHashMap<String, ProcessedCategory> { + val s = super.getAllCategories() + if (iqTestCopy == null) { + iqTestCopy = s.clone() as LinkedHashMap<String, ProcessedCategory> + } + iqTestCopy!!["apiData"] = IQTest.options + if (NotEnoughUpdates.INSTANCE.config.apiData.apiDataUnlocked) { + return s + } + return iqTestCopy!! + } + } + + var lastEditor = null as MoulConfigEditor<NEUConfig>? + fun createConfigScreen(search: String): GuiScreen { + return object : GuiScreenElementWrapper(createConfigElement(search)) { + } + } + fun createConfigElement(search: String): MoulConfigEditor<NEUConfig> { + val processor = BlockingMoulConfigProcessor() + BuiltinMoulConfigGuis.addProcessors(processor) + ConfigProcessorDriver.processConfig( + NotEnoughUpdates.INSTANCE.config.javaClass, + NotEnoughUpdates.INSTANCE.config, + processor + ) + val editor = MoulConfigEditor(processor) + editor.search(search) + lastEditor = editor + return editor + } + init { + GuiTextures.setTextureRoot(ResourceLocation("notenoughupdates:core")) + } } diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/IQTest.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/IQTest.kt index 157050b3..8817dac1 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/IQTest.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscfeatures/IQTest.kt @@ -19,11 +19,13 @@ package io.github.moulberry.notenoughupdates.miscfeatures +import io.github.moulberry.moulconfig.gui.editors.GuiOptionEditorButton +import io.github.moulberry.moulconfig.gui.editors.GuiOptionEditorInfoText +import io.github.moulberry.moulconfig.gui.editors.GuiOptionEditorText +import io.github.moulberry.moulconfig.processor.ProcessedCategory +import io.github.moulberry.moulconfig.processor.ProcessedOption import io.github.moulberry.notenoughupdates.NotEnoughUpdates -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorButton -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorFSR -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditorText -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor.ProcessedOption +import io.github.moulberry.notenoughupdates.commands.help.SettingsCommand import io.github.moulberry.notenoughupdates.util.Calculator import io.github.moulberry.notenoughupdates.util.Calculator.CalculatorException import java.math.BigDecimal @@ -40,6 +42,7 @@ object IQTest { Calculator.calculate(answer) } catch (e: CalculatorException) { wrongAnswer() + SettingsCommand.lastEditor?.updateSearchResults() return } val realAnswer = Calculator.calculate(question) @@ -49,6 +52,7 @@ object IQTest { } else { wrongAnswer() } + SettingsCommand.lastEditor?.updateSearchResults() } private fun wrongAnswer() { @@ -64,46 +68,51 @@ object IQTest { @JvmField var answer = "" + val cat = ProcessedCategory(javaClass.getField("answer"), "IQ Test", "IQ Test") val answerOption = ProcessedOption( "IQ Test Question", "Please type out the answer to §a$question", - -1, + "", javaClass.getField("answer"), + cat, this, - arrayOf() + NotEnoughUpdates.INSTANCE.config ).also { it.editor = GuiOptionEditorText(it) } val warningOption = ProcessedOption( "§4§lWARNING", "§4§lThis page is dangerous. Please make sure you know what you are doing!", - -1, + "", javaClass.getField("buttonPlaceHolder"), + cat, this, - arrayOf() + NotEnoughUpdates.INSTANCE.config ).also { it.editor = GuiOptionEditorButton(it, 27, "SUBMIT", NotEnoughUpdates.INSTANCE.config) } val wrongOption = ProcessedOption( "§4Wrong Answer", "§4Please think twice before accessing it.", - -1, + "", javaClass.getField("buttonPlaceHolder"), + cat, this, - arrayOf() + NotEnoughUpdates.INSTANCE.config ).also { - it.editor = GuiOptionEditorFSR(it, -1, "", NotEnoughUpdates.INSTANCE.config) + it.editor = GuiOptionEditorInfoText(it, "") } @get:JvmStatic - val options - get() = LinkedHashMap<String, ProcessedOption>().also { - it["iqTestAnswer"] = answerOption - it["iqTestSubmit"] = warningOption - + val options: ProcessedCategory + get() { + cat.options.clear() if (System.currentTimeMillis() - lastAnsweredTimestamp < 10_000L) { - it["iqTestWrong"] = wrongOption + cat.options.addAll(listOf(answerOption, warningOption, wrongOption)) + } else { + cat.options.addAll(listOf(answerOption, warningOption)) } + return cat } } diff --git a/src/main/resources/assets/notenoughupdates/core/button.png b/src/main/resources/assets/notenoughupdates/core/button.png Binary files differnew file mode 100644 index 00000000..e96f4284 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/core/button.png diff --git a/src/main/resources/assets/notenoughupdates/core/button_white.png b/src/main/resources/assets/notenoughupdates/core/button_white.png Binary files differnew file mode 100644 index 00000000..7763716d --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/core/button_white.png diff --git a/src/main/resources/assets/notenoughupdates/core/reset.png b/src/main/resources/assets/notenoughupdates/core/reset.png Binary files differnew file mode 100644 index 00000000..018b094f --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/core/reset.png diff --git a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java index b80db70a..9023ce65 100644 --- a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java +++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java @@ -21,14 +21,8 @@ package io.github.moulberry.notenoughupdates.compat.oneconfig; import cc.polyfrost.oneconfig.config.data.Mod; import cc.polyfrost.oneconfig.config.data.ModType; -import io.github.moulberry.notenoughupdates.core.config.Config; import io.github.moulberry.notenoughupdates.oneconfig.IOneConfigCompat; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.reflect.Field; -import java.util.ArrayList; - public class OneConfigCompat extends IOneConfigCompat { Mod mod = new Mod("NotEnoughUpdates", ModType.SKYBLOCK, "/assets/notenoughupdates/logo.png"); diff --git a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java index 59aa25d1..3e37f12a 100644 --- a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java +++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java @@ -26,21 +26,20 @@ import cc.polyfrost.oneconfig.config.elements.OptionSubcategory; import cc.polyfrost.oneconfig.gui.elements.config.ConfigButton; import cc.polyfrost.oneconfig.gui.elements.config.ConfigDropdown; import cc.polyfrost.oneconfig.gui.elements.config.ConfigInfo; -import cc.polyfrost.oneconfig.gui.elements.config.ConfigSlider; import cc.polyfrost.oneconfig.gui.elements.config.ConfigSwitch; import cc.polyfrost.oneconfig.gui.elements.config.ConfigTextBox; -import io.github.moulberry.notenoughupdates.core.config.Config; -import io.github.moulberry.notenoughupdates.core.config.annotations.Category; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDraggableList; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorFSR; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorKeybind; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorText; -import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; +import io.github.moulberry.moulconfig.Config; +import io.github.moulberry.moulconfig.annotations.Category; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorButton; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText; +import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigEditorText; +import io.github.moulberry.moulconfig.annotations.ConfigOption; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import java.lang.reflect.Field; @@ -48,25 +47,23 @@ import java.lang.reflect.Field; public class OneMoulConfig extends cc.polyfrost.oneconfig.config.Config { final Config moulConfig; - private final Runnable saveCallback; - public OneMoulConfig(Mod modData, Config moulConfig, Runnable saveCallback) { + public OneMoulConfig(Mod modData, Config moulConfig) { super(modData, "_SHOULD_NOT_BE_WRITTEN.json"); if (moulConfig == null) throw new IllegalArgumentException("mfw no moulconfig"); this.moulConfig = moulConfig; - this.saveCallback = saveCallback; initialize(); } @Override public void initialize() { - mod.config = this; + mod.config = this; - try { - processMoulConfig(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } + try { + processMoulConfig(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } cc.polyfrost.oneconfig.config.Config.register(mod); } @@ -86,8 +83,8 @@ public class OneMoulConfig extends cc.polyfrost.oneconfig.config.Config { if (annotation == null) continue; String cat = category.getName(); String subcategory = ""; - String annotationName = StringUtils.cleanColour( annotation.name()); - String annotationDesc = StringUtils.cleanColour( annotation.desc()); + String annotationName = StringUtils.cleanColour(annotation.name()); + String annotationDesc = StringUtils.cleanColour(annotation.desc()); ConfigEditorBoolean configEditorBoolean = optionField.getAnnotation(ConfigEditorBoolean.class); if (configEditorBoolean != null) { category.options.add(new ConfigSwitch( @@ -174,7 +171,7 @@ public class OneMoulConfig extends cc.polyfrost.oneconfig.config.Config { cat, subcategory, 2, InfoType.ERROR )); } - ConfigEditorFSR configEditorFSR = optionField.getAnnotation(ConfigEditorFSR.class); + ConfigEditorInfoText configEditorFSR = optionField.getAnnotation(ConfigEditorInfoText.class); if (configEditorFSR != null) { category.options.add(new ConfigInfo( optionField, categoryInstance, @@ -186,7 +183,7 @@ public class OneMoulConfig extends cc.polyfrost.oneconfig.config.Config { @Override public void save() { - saveCallback.run(); + moulConfig.saveNow(); } @Override |