aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle.kts32
-rw-r--r--gradle.properties2
-rw-r--r--oneconfigquarantine/build.gradle.kts45
-rw-r--r--settings.gradle.kts1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java7
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java24
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java49
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java13
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java20
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java50
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/loader/NEUDelegatingTweaker.java38
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java19
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/oneconfig/IOneConfigCompat.java52
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java2
-rw-r--r--src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java42
-rw-r--r--src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneFancyColor.java113
-rw-r--r--src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneFancyKeybind.java52
-rw-r--r--src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java201
-rw-r--r--src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneWrappedKeyBind.java58
-rw-r--r--src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/WrappedConfigSlider.java52
28 files changed, 768 insertions, 134 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 04207cf2..e9e769a8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -75,6 +75,7 @@ repositories {
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")
}
lombok {
@@ -86,8 +87,12 @@ val shadowImplementation by configurations.creating {
configurations.implementation.get().extendsFrom(this)
}
+val shadowOnly by configurations.creating {
+
+}
+
val shadowApi by configurations.creating {
- configurations.implementation.get().extendsFrom(this)
+ configurations.api.get().extendsFrom(this)
}
val devEnv by configurations.creating {
@@ -101,6 +106,14 @@ val kotlinDependencies by configurations.creating {
configurations.implementation.get().extendsFrom(this)
}
+val oneconfigQuarantineSourceSet = sourceSets.create("oneconfig") {
+ java {
+ srcDir(layout.projectDirectory.dir("src/main/oneconfig"))
+ }
+ kotlin {
+ }
+}
+
dependencies {
implementation("org.projectlombok:lombok:1.18.22")
minecraft("com.mojang:minecraft:1.8.9")
@@ -108,6 +121,16 @@ dependencies {
forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
+ if (project.findProperty("neu.buildflags.oneconfig") == "true") {
+ shadowOnly("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-alpha+") // Should be included in jar
+ runtimeOnly("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-alpha+") // Should be included in jar
+ }
+
+ "oneconfigImplementation"(sourceSets.main.get().output)
+ "oneconfigImplementation"(sourceSets.main.get().compileClasspath)
+ "oneconfigCompileOnly"(project(":oneconfigquarantine", configuration = "namedElements"))
+ "runtimeOnly"(oneconfigQuarantineSourceSet.output)
+
// Please keep this version in sync with KotlinLoadingTweaker
implementation(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:1.7.21"))
kotlinDependencies(kotlin("stdlib"))
@@ -141,6 +164,10 @@ tasks.named<Test>("test") {
useJUnitPlatform()
}
+tasks.named("jar", Jar::class) {
+ from(oneconfigQuarantineSourceSet.output)
+}
+
tasks.withType(Jar::class) {
archiveBaseName.set("NotEnoughUpdates")
manifest.attributes.run {
@@ -174,8 +201,8 @@ val kotlinDependencyCollectionJar by tasks.creating(Zip::class) {
tasks.shadowJar {
archiveClassifier.set("dep-dev")
+ configurations = listOf(shadowImplementation, shadowApi, shadowOnly)
archiveBaseName.set("NotEnoughUpdates")
- configurations = listOf(shadowImplementation, shadowApi)
exclude("**/module-info.class", "LICENSE.txt")
dependencies {
exclude {
@@ -183,6 +210,7 @@ tasks.shadowJar {
listOf("logback-classic", "commons-logging", "commons-codec", "logback-core")
}
}
+ from(oneconfigQuarantineSourceSet.output)
from(kotlinDependencyCollectionJar)
dependsOn(kotlinDependencyCollectionJar)
fun relocate(name: String) = relocate(name, "io.github.moulberry.notenoughupdates.deps.$name")
diff --git a/gradle.properties b/gradle.properties
index f596b2d7..0009739e 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -4,3 +4,5 @@ loom.platform=forge
# See BuildFlags.java for usages of these values.
# Build with Pronouns in PV by default
# neu.buildflags.pronouns=true
+# Build with Oneconfig support
+# neu.buildflags.oneconfig=true
diff --git a/oneconfigquarantine/build.gradle.kts b/oneconfigquarantine/build.gradle.kts
new file mode 100644
index 00000000..32bc3b7c
--- /dev/null
+++ b/oneconfigquarantine/build.gradle.kts
@@ -0,0 +1,45 @@
+/*
+ * 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/>.
+ */
+
+/**
+ * This subproject is a stub project to hold oneconfig dependencies, to prevent those dependencies bleeding over into
+ * our the normal NEU codebase. Usually this could be done using just another source set, however due to using legacy
+ * arch loom (for now!!!!) we cannot depend on remapped dependencies from only in one source set.
+ * */
+plugins {
+ java
+ id("gg.essential.loom")
+ id("dev.architectury.architectury-pack200")
+}
+
+loom.forge.pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
+
+repositories {
+ mavenCentral()
+ maven("https://repo.polyfrost.cc/releases")
+}
+
+dependencies {
+ minecraft("com.mojang:minecraft:1.8.9")
+ mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
+ forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
+
+ modApi("cc.polyfrost:oneconfig-1.8.9-forge:0.1.0-alpha+") // Don't you just love 0.1.0-alpha+
+}
+
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 408d0f75..a910edd3 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -39,4 +39,5 @@ pluginManagement {
}
}
+include("oneconfigquarantine")
rootProject.name = "NotEnoughUpdates"
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java b/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java
index d997d980..2091496d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/BuildFlags.java
@@ -50,6 +50,7 @@ public class BuildFlags {
}
public static final boolean ENABLE_PRONOUNS_IN_PV_BY_DEFAULT = getBuildFlag("pronouns");
+ public static final boolean ENABLE_ONECONFIG_COMPAT_LAYER = getBuildFlag("oneconfig");
private static class Holder {
static Map<String, Boolean> ALL_FLAGS = new HashMap<>();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index f10db528..d6ae6219 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -79,6 +79,7 @@ import io.github.moulberry.notenoughupdates.miscgui.SignCalculator;
import io.github.moulberry.notenoughupdates.miscgui.TrophyRewardOverlay;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager;
import io.github.moulberry.notenoughupdates.mixins.AccessorMinecraft;
+import io.github.moulberry.notenoughupdates.oneconfig.IOneConfigCompat;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.overlays.EquipmentOverlay;
import io.github.moulberry.notenoughupdates.overlays.FuelBar;
@@ -294,6 +295,8 @@ public class NotEnoughUpdates {
if (config.mining.powderGrindingTrackerResetMode == 2)
OverlayManager.powderGrindingOverlay.load();
+ IOneConfigCompat.getInstance().ifPresent(it -> it.initConfig(config, this::saveConfig));
+
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(new NEUEventListener(this));
MinecraftForge.EVENT_BUS.register(new RecipeGenerator(this));
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java
index 05a9a65e..fb7b2abe 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/ChromaColour.java
@@ -38,7 +38,8 @@ public class ChromaColour {
return sb.toString();
}
- private static int[] decompose(String csv) {
+ @Deprecated
+ public static int[] decompose(String csv) {
String[] split = csv.split(":");
int[] arr = new int[split.length];
@@ -68,6 +69,10 @@ public class ChromaColour {
return (255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS;
}
+ public static int getSpeedForSeconds(float seconds) {
+ return (int) (255 - (seconds - MIN_CHROMA_SECS) * 254f / (MAX_CHROMA_SECS - MIN_CHROMA_SECS));
+ }
+
private static final int MIN_CHROMA_SECS = 1;
private static final int MAX_CHROMA_SECS = 60;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java
index 11547aaa..ab176933 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementBoolean.java
@@ -28,11 +28,12 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse;
import java.util.function.Consumer;
+import java.util.function.Supplier;
public class GuiElementBoolean extends GuiElement {
public int x;
public int y;
- private boolean value;
+ private Supplier<Boolean> value;
private final int clickRadius;
private final Consumer<Boolean> toggleCallback;
@@ -43,20 +44,20 @@ public class GuiElementBoolean extends GuiElement {
private static final int xSize = 48;
private static final int ySize = 14;
- public GuiElementBoolean(int x, int y, boolean value, Consumer<Boolean> toggleCallback) {
+ public GuiElementBoolean(int x, int y, Supplier<Boolean> value, Consumer<Boolean> toggleCallback) {
this(x, y, value, 0, toggleCallback);
}
- public GuiElementBoolean(int x, int y, boolean value, int clickRadius, Consumer<Boolean> toggleCallback) {
+ public GuiElementBoolean(int x, int y, Supplier<Boolean> value, int clickRadius, Consumer<Boolean> toggleCallback) {
this.x = x;
this.y = y;
this.value = value;
- this.previewValue = value;
+ this.previewValue = value.get();
this.clickRadius = clickRadius;
this.toggleCallback = toggleCallback;
this.lastMillis = System.currentTimeMillis();
- if (value) animation = 36;
+ if (previewValue) animation = 36;
}
@Override
@@ -70,7 +71,7 @@ public class GuiElementBoolean extends GuiElement {
long deltaMillis = currentMillis - lastMillis;
lastMillis = currentMillis;
boolean passedLimit = false;
- if (previewValue != value) {
+ if (previewValue != value.get()) {
if ((previewValue && animation > 12) ||
(!previewValue && animation < 24)) {
passedLimit = true;
@@ -83,7 +84,7 @@ public class GuiElementBoolean extends GuiElement {
}
lastMillis -= deltaMillis % 10;
- if (previewValue == value) {
+ if (previewValue == value.get()) {
animation = Math.max(0, Math.min(36, animation));
} else if (!passedLimit) {
if (previewValue) {
@@ -120,14 +121,13 @@ public class GuiElementBoolean extends GuiElement {
mouseY > y - clickRadius && mouseY < y + ySize + clickRadius) {
if (Mouse.getEventButton() == 0) {
if (Mouse.getEventButtonState()) {
- previewValue = !value;
- } else if (previewValue == !value) {
- value = !value;
- toggleCallback.accept(value);
+ previewValue = !value.get();
+ } else if (previewValue == !value.get()) {
+ toggleCallback.accept(!value.get());
}
}
} else {
- previewValue = value;
+ previewValue = value.get();
}
return false;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
index 1f655aaf..1802a1a4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
@@ -35,6 +35,7 @@ import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.function.Consumer;
+import java.util.function.Supplier;
public class GuiElementColour extends GuiElement {
public static final ResourceLocation colour_selector_dot = new ResourceLocation(
@@ -68,20 +69,20 @@ public class GuiElementColour extends GuiElement {
private final Consumer<String> colourChangedCallback;
private final Runnable closeCallback;
- private String colour;
+ private Supplier<String> colour;
private final boolean opacitySlider;
private final boolean valueSlider;
public GuiElementColour(
- int x, int y, String initialColour, Consumer<String> colourChangedCallback,
+ int x, int y, Supplier<String> colour, Consumer<String> colourChangedCallback,
Runnable closeCallback
) {
- this(x, y, initialColour, colourChangedCallback, closeCallback, true, true);
+ this(x, y, colour, colourChangedCallback, closeCallback, true, true);
}
public GuiElementColour(
- int x, int y, String initialColour, Consumer<String> colourChangedCallback,
+ int x, int y, Supplier<String> colour, Consumer<String> colourChangedCallback,
Runnable closeCallback, boolean opacitySlider, boolean valueSlider
) {
final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
@@ -89,12 +90,12 @@ public class GuiElementColour extends GuiElement {
this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight() - ySize - 10, y));
this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth() - xSize - 10, x));
- this.colour = initialColour;
+ this.colour = colour;
this.colourChangedCallback = colourChangedCallback;
this.closeCallback = closeCallback;
- int colour = ChromaColour.specialToSimpleRGB(initialColour);
- Color c = new Color(colour);
+ int icolour = ChromaColour.specialToSimpleRGB(colour.get());
+ Color c = new Color(icolour);
float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
updateAngleAndRadius(hsv);
@@ -113,7 +114,7 @@ public class GuiElementColour extends GuiElement {
public void render() {
RenderUtils.drawFloatingRectDark(x, y, xSize, ySize);
- int currentColour = ChromaColour.specialToSimpleRGB(colour);
+ int currentColour = ChromaColour.specialToSimpleRGB(colour.get());
Color c = new Color(currentColour, true);
float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
@@ -200,8 +201,8 @@ public class GuiElementColour extends GuiElement {
RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + valueOffset, y + 5, 10, 64, GL11.GL_NEAREST);
}
- int chromaSpeed = ChromaColour.getSpeed(colour);
- int currentColourChroma = ChromaColour.specialToChromaRGB(colour);
+ int chromaSpeed = ChromaColour.getSpeed(colour.get());
+ int currentColourChroma = ChromaColour.specialToChromaRGB(colour.get());
Color cChroma = new Color(currentColourChroma, true);
float[] hsvChroma = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null);
@@ -343,7 +344,7 @@ public class GuiElementColour extends GuiElement {
}
}
- int chromaSpeed = ChromaColour.getSpeed(colour);
+ int chromaSpeed = ChromaColour.getSpeed(colour.get());
int xChroma = mouseX - (x + 5 + 64 + valueOffset + opacityOffset + 5);
if (xChroma > 0 && xChroma < 10) {
if (chromaSpeed > 0) {
@@ -351,10 +352,9 @@ public class GuiElementColour extends GuiElement {
clickedComponent = 3;
}
} else if (mouseY > this.y + 5 + 27 && mouseY < this.y + 5 + 37) {
- int currentColour = ChromaColour.specialToSimpleRGB(colour);
+ int currentColour = ChromaColour.specialToSimpleRGB(colour.get());
Color c = new Color(currentColour, true);
- colour = ChromaColour.special(200, c.getAlpha(), currentColour);
- colourChangedCallback.accept(colour);
+ colourChangedCallback.accept(ChromaColour.special(200, c.getAlpha(), currentColour));
}
}
} else {
@@ -364,7 +364,7 @@ public class GuiElementColour extends GuiElement {
}
}
if (Mouse.isButtonDown(0) && clickedComponent >= 0) {
- int currentColour = ChromaColour.specialToSimpleRGB(colour);
+ int currentColour = ChromaColour.specialToSimpleRGB(colour.get());
Color c = new Color(currentColour, true);
float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
@@ -381,8 +381,7 @@ public class GuiElementColour extends GuiElement {
this.wheelAngle = angle;
this.wheelRadius = (float) Math.pow(Math.min(1, radius), 1.5f);
int rgb = Color.getHSBColor(angle / 360f, wheelRadius, hsv[2]).getRGB();
- colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb);
- colourChangedCallback.accept(colour);
+ colourChangedCallback.accept(ChromaColour.special(ChromaColour.getSpeed(colour.get()), c.getAlpha(), rgb));
return true;
}
@@ -392,22 +391,19 @@ public class GuiElementColour extends GuiElement {
if (clickedComponent == 1) {
int rgb = Color.getHSBColor(wheelAngle / 360, wheelRadius, 1 - y / 64f).getRGB();
- colour = ChromaColour.special(ChromaColour.getSpeed(colour), c.getAlpha(), rgb);
- colourChangedCallback.accept(colour);
+ colourChangedCallback.accept(ChromaColour.special(ChromaColour.getSpeed(colour.get()), c.getAlpha(), rgb));
return true;
}
if (clickedComponent == 2) {
- colour = ChromaColour.special(ChromaColour.getSpeed(colour),
+ colourChangedCallback.accept(ChromaColour.special(ChromaColour.getSpeed(colour.get()),
255 - Math.round(y / 64f * 255), currentColour
- );
- colourChangedCallback.accept(colour);
+ ));
return true;
}
if (clickedComponent == 3) {
- colour = ChromaColour.special(255 - Math.round(y / 64f * 255), c.getAlpha(), currentColour);
- colourChangedCallback.accept(colour);
+ colourChangedCallback.accept(ChromaColour.special(255 - Math.round(y / 64f * 255), c.getAlpha(), currentColour));
}
return true;
}
@@ -431,9 +427,8 @@ public class GuiElementColour extends GuiElement {
String text = hexField.getText().toLowerCase();
int rgb = Integer.parseInt(text, 16);
- int alpha = (ChromaColour.specialToSimpleRGB(colour) >> 24) & 0xFF;
- colour = ChromaColour.special(ChromaColour.getSpeed(colour), alpha, rgb);
- colourChangedCallback.accept(colour);
+ int alpha = (ChromaColour.specialToSimpleRGB(colour.get()) >> 24) & 0xFF;
+ colourChangedCallback.accept(ChromaColour.special(ChromaColour.getSpeed(colour.get()), alpha, rgb));
Color c = new Color(rgb);
float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
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
index dc1173ef..91515259 100644
--- 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
@@ -32,11 +32,9 @@ import org.lwjgl.opengl.GL11;
public class GuiOptionEditorAccordion extends GuiOptionEditor {
private final int accordionId;
- private boolean accordionToggled;
public GuiOptionEditorAccordion(ConfigProcessor.ProcessedOption option, int accordionId) {
super(option);
- this.accordionToggled = (boolean) option.get();
this.accordionId = accordionId;
}
@@ -50,7 +48,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor {
}
public boolean getToggled() {
- return accordionToggled;
+ return (boolean) option.get();
}
@Override
@@ -65,7 +63,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor {
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.color(1, 1, 1, 1);
worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION);
- if (accordionToggled) {
+ 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();
@@ -87,7 +85,7 @@ public class GuiOptionEditorAccordion extends GuiOptionEditor {
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()) {
- accordionToggled = !accordionToggled;
+ option.set(!getToggled());
return true;
}
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
index d12ec8e7..00907e9e 100644
--- 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
@@ -37,7 +37,7 @@ public class GuiOptionEditorBoolean extends GuiOptionEditor {
super(option);
this.config = config;
this.runnableId = runnableId;
- bool = new GuiElementBoolean(0, 0, (boolean) option.get(), 10, (value) -> onUpdate(option, value));
+ bool = new GuiElementBoolean(0, 0, () -> (boolean) option.get(), 10, (value) -> onUpdate(option, value));
}
@Override
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
index ca4087b5..359a3e27 100644
--- 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
@@ -30,13 +30,14 @@ import org.lwjgl.input.Mouse;
import static io.github.moulberry.notenoughupdates.util.GuiTextures.button_white;
public class GuiOptionEditorColour extends GuiOptionEditor {
- private String chromaColour;
private GuiElementColour colourElement = null;
public GuiOptionEditorColour(ConfigProcessor.ProcessedOption option) {
super(option);
+ }
- this.chromaColour = (String) option.get();
+ public String getChromaString() {
+ return (String) option.get();
}
@Override
@@ -44,7 +45,7 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
super.render(x, y, width);
int height = getHeight();
- int argb = ChromaColour.specialToChromaRGB(chromaColour);
+ int argb = ChromaColour.specialToChromaRGB(getChromaString());
int r = (argb >> 16) & 0xFF;
int g = (argb >> 8) & 0xFF;
int b = argb & 0xFF;
@@ -72,10 +73,8 @@ public class GuiOptionEditorColour extends GuiOptionEditor {
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(), (val) -> {
- option.set(val);
- chromaColour = val;
- }, () -> colourElement = null);
+ colourElement = new GuiElementColour(mouseX, mouseY, () -> (String) option.get(),
+ option::set, () -> colourElement = null);
}
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
index 6eb71d1e..b7d70db8 100644
--- 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
@@ -35,16 +35,18 @@ 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 int keyCode;
private final int defaultKeyCode;
private boolean editingKeycode;
- public GuiOptionEditorKeybind(ConfigProcessor.ProcessedOption option, int keyCode, int defaultKeyCode) {
+ public GuiOptionEditorKeybind(ConfigProcessor.ProcessedOption option, int defaultKeyCode) {
super(option);
- this.keyCode = keyCode;
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);
@@ -55,7 +57,7 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor {
Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
RenderUtils.drawTexturedRect(x + width / 6 - 24, y + height - 7 - 14, 48, 16);
- String keyName = KeybindHelper.getKeyName(keyCode);
+ String keyName = KeybindHelper.getKeyName(getKeyCode());
String text = editingKeycode ? "> " + keyName + " <" : keyName;
TextRenderUtils.drawStringCenteredScaledMaxWidth(text,
Minecraft.getMinecraft().fontRendererObj,
@@ -72,8 +74,7 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor {
public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) {
if (Mouse.getEventButtonState() && Mouse.getEventButton() != -1 && editingKeycode) {
editingKeycode = false;
- keyCode = Mouse.getEventButton() - 100;
- option.set(keyCode);
+ option.set(Mouse.getEventButton() - 100);
return true;
}
@@ -86,8 +87,7 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor {
}
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) {
- keyCode = defaultKeyCode;
- option.set(keyCode);
+ option.set(defaultKeyCode);
return true;
}
}
@@ -99,13 +99,15 @@ public class GuiOptionEditorKeybind extends GuiOptionEditor {
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;
- option.set(keyCode);
+ 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
index 7fceb92d..175dcdc0 100644
--- 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
@@ -34,35 +34,35 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
super(option);
if (minStep < 0) minStep = 0.01f;
- float floatVal = ((Number) option.get()).floatValue();
- {
- String strVal;
- if (floatVal % 1 == 0) {
- strVal = Integer.toString((int) floatVal);
- } else {
- strVal = Float.toString(floatVal);
- }
- textField = new GuiElementTextField(
- strVal,
- GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT
- );
- }
+ 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);
-
- String strVal;
- if (val % 1 == 0) {
- strVal = Integer.toString(val.intValue());
- } else {
- strVal = Float.toString(val);
- strVal = strVal.replaceAll("(\\.\\d\\d\\d)(?:\\d)+", "$1");
- strVal = strVal.replaceAll("0+$", "");
- }
- textField.setText(strVal);
+ 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);
@@ -72,6 +72,9 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
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;
@@ -84,6 +87,7 @@ public class GuiOptionEditorSlider extends GuiOptionEditor {
16
);
} else {
+ textField.setText(getStringifiedFloatValue());
textField.setSize(textFieldWidth, 16);
textField.setOptions(
GuiElementTextField.NO_SPACE | GuiElementTextField.NUM_ONLY | GuiElementTextField.SCALE_TEXT);
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
index ad2fa4db..48072fbe 100644
--- 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
@@ -47,6 +47,8 @@ public class GuiOptionEditorText extends GuiOptionEditor {
fullWidth,
Minecraft.getMinecraft().fontRendererObj.getStringWidth(textField.getText()) + 10
);
+ } else {
+ textField.setText((String) option.get());
}
textField.setSize(fullWidth, 16);
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
index efdeab01..9a75ec19 100644
--- 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
@@ -152,7 +152,7 @@ public class ConfigProcessor {
if (optionType.isAssignableFrom(int.class) &&
optionField.isAnnotationPresent(ConfigEditorKeybind.class)) {
ConfigEditorKeybind configEditorAnnotation = optionField.getAnnotation(ConfigEditorKeybind.class);
- editor = new GuiOptionEditorKeybind(option, (int) option.get(), configEditorAnnotation.defaultKey());
+ editor = new GuiOptionEditorKeybind(option, configEditorAnnotation.defaultKey());
}
if (optionField.isAnnotationPresent(ConfigEditorButton.class)) {
ConfigEditorButton configEditorAnnotation = optionField.getAnnotation(ConfigEditorButton.class);
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 98d36f2b..025e11b2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java
@@ -744,7 +744,7 @@ public class GuiDungeonMapEditor extends GuiScreen {
ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft());
mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth;
mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1;
- activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBackgroundColour,
+ activeColourEditor = new GuiElementColour(mouseX, mouseY, () -> options.dmBackgroundColour,
(col) -> options.dmBackgroundColour = col, () -> activeColourEditor = null
);
}
@@ -753,7 +753,7 @@ public class GuiDungeonMapEditor extends GuiScreen {
ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft());
mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth;
mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1;
- activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBorderColour,
+ activeColourEditor = new GuiElementColour(mouseX, mouseY, () -> options.dmBorderColour,
(col) -> options.dmBorderColour = col, () -> activeColourEditor = null
);
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/loader/NEUDelegatingTweaker.java b/src/main/java/io/github/moulberry/notenoughupdates/loader/NEUDelegatingTweaker.java
index 1d91ca76..d7759c9a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/loader/NEUDelegatingTweaker.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/loader/NEUDelegatingTweaker.java
@@ -19,14 +19,15 @@
package io.github.moulberry.notenoughupdates.loader;
+import io.github.moulberry.notenoughupdates.BuildFlags;
import io.github.moulberry.notenoughupdates.envcheck.EnvironmentScan;
import net.minecraft.launchwrapper.ITweaker;
+import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
import org.spongepowered.asm.launch.MixinTweaker;
import java.io.File;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
/**
@@ -48,7 +49,7 @@ public class NEUDelegatingTweaker implements ITweaker {
EnvironmentScan.checkEnvironmentOnce();
}
- List<ITweaker> delegates = new ArrayList<>();
+ List<String> delegates = new ArrayList<>();
public NEUDelegatingTweaker() {
discoverTweakers();
@@ -56,45 +57,32 @@ public class NEUDelegatingTweaker implements ITweaker {
}
private void discoverTweakers() {
- delegates.add(new MixinTweaker());
- delegates.add(new ModLoadingTweaker());
- delegates.add(new KotlinLoadingTweaker());
+ if (BuildFlags.ENABLE_ONECONFIG_COMPAT_LAYER) {
+ delegates.add("cc.polyfrost.oneconfigwrapper.OneConfigWrapper");
+ }
+ delegates.add(MixinTweaker.class.getName());
+ delegates.add(ModLoadingTweaker.class.getName());
+ delegates.add(KotlinLoadingTweaker.class.getName());
}
@Override
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
- for (ITweaker delegate : delegates) {
- delegate.acceptOptions(args, gameDir, assetsDir, profile);
- }
+ List<String> tweakClasses = (List<String>) Launch.blackboard.get("TweakClasses");
+ tweakClasses.addAll(delegates);
}
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
- for (ITweaker delegate : delegates) {
- delegate.injectIntoClassLoader(classLoader);
- }
}
@Override
public String getLaunchTarget() {
- String target = null;
- for (ITweaker delegate : delegates) {
- String launchTarget = delegate.getLaunchTarget();
- if (launchTarget != null)
- target = launchTarget;
- }
- return target;
+ return null;
}
@Override
public String[] getLaunchArguments() {
- List<String> launchArguments = new ArrayList<>();
- for (ITweaker delegate : delegates) {
- String[] delegateLaunchArguments = delegate.getLaunchArguments();
- if (delegateLaunchArguments != null)
- launchArguments.addAll(Arrays.asList(delegateLaunchArguments));
- }
- return launchArguments.toArray(new String[0]);
+ return new String[0];
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
index 674e4068..129699da 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java
@@ -92,7 +92,7 @@ public class GuiItemCustomize extends GuiScreen {
((ItemArmor) stack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER;
enchantGlintCustomColourAnimation.setValue(enchantGlint ? 17 : 0);
- this.enchantGlintButton = new GuiElementBoolean(0, 0, enchantGlint, (bool) -> {
+ this.enchantGlintButton = new GuiElementBoolean(0, 0, () -> enchantGlint, (bool) -> {
enchantGlint = bool;
updateData();
});
@@ -443,7 +443,7 @@ public class GuiItemCustomize extends GuiScreen {
editor = new GuiElementColour(
mouseX,
mouseY,
- customGlintColour == null ? ItemCustomizeManager.DEFAULT_GLINT_COLOR : customGlintColour,
+ () -> customGlintColour == null ? ItemCustomizeManager.DEFAULT_GLINT_COLOR : customGlintColour,
(colour) -> {
customGlintColour = colour;
updateData();
@@ -464,7 +464,7 @@ public class GuiItemCustomize extends GuiScreen {
updateData();
} else {
editor = new GuiElementColour(mouseX, mouseY,
- customLeatherColour == null ? getChromaStrFromLeatherColour() : customLeatherColour,
+ () -> customLeatherColour == null ? getChromaStrFromLeatherColour() : customLeatherColour,
(colour) -> {
customLeatherColour = colour;
updateData();
@@ -473,19 +473,6 @@ public class GuiItemCustomize extends GuiScreen {
}
}
- /*if(mouseX >= xCenter-90 && mouseX <= xCenter+90 &&
- mouseY >= belowEnchGlint+65 && mouseY <= belowEnchGlint+80) {
- if(true) {
- String userName = Minecraft.getMinecraft().thePlayer.getName();
- String serverId = "1872398172739";
- try {
- Desktop.getDesktop().browse(new URL("https://moulberry.codes/purchaseitemtag?uniqueId="+serverId+"&username="+userName).toURI());
- } catch(Exception ignored) {}
- } else {
-
- }
- }*/
-
super.mouseClicked(mouseX, mouseY, mouseButton);
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/oneconfig/IOneConfigCompat.java b/src/main/java/io/github/moulberry/notenoughupdates/oneconfig/IOneConfigCompat.java
new file mode 100644
index 00000000..7afceab9
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/oneconfig/IOneConfigCompat.java
@@ -0,0 +1,52 @@
+/*
+ * 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.oneconfig;
+
+import io.github.moulberry.notenoughupdates.core.config.Config;
+import net.minecraftforge.fml.common.Loader;
+
+import java.util.Optional;
+
+public abstract class IOneConfigCompat {
+ private static final Object sentinelFailure = new Object();
+ private static final Object lock = new Object();
+ private static Object INSTANCE = null;
+
+ public static Optional<IOneConfigCompat> getInstance() {
+ if (INSTANCE == null && Loader.isModLoaded("oneconfig")) {
+ synchronized (lock) {
+ if (INSTANCE == null)
+ try {
+ Class<?> aClass = Class.forName("io.github.moulberry.notenoughupdates.compat.oneconfig.OneConfigCompat");
+ INSTANCE = aClass.newInstance();
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
+ System.err.println("Critical failure in OneConfigCompat initialization");
+ e.printStackTrace();
+ INSTANCE = sentinelFailure;
+ }
+ }
+ }
+ if (INSTANCE == sentinelFailure) return Optional.empty();
+ return Optional.ofNullable((IOneConfigCompat) INSTANCE);
+ }
+
+ public abstract void initConfig(Config moulConfig, Runnable saveCallback);
+
+}
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 129f973b..371d657e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -73,6 +73,8 @@ import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
import io.github.moulberry.notenoughupdates.util.NotificationHandler;
import io.github.moulberry.notenoughupdates.util.SBInfo;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.client.ClientCommandHandler;
import java.util.ArrayList;
@@ -88,10 +90,11 @@ public class NEUConfig extends Config {
for (TextOverlay overlay : OverlayManager.textOverlays) {
overlayPositions.put(overlay, overlay.getPosition());
}
+ GuiScreen savedGui = Minecraft.getMinecraft().currentScreen;
Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(overlayPositions, () -> {
}, () -> {
}, () -> {
- NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor);
+ NotEnoughUpdates.INSTANCE.openGui = savedGui;
}));
}
@@ -109,8 +112,9 @@ public class NEUConfig extends Config {
case -1:
return;
case 0:
+ GuiScreen savedGui = Minecraft.getMinecraft().currentScreen;
NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(() -> {
- NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor);
+ NotEnoughUpdates.INSTANCE.openGui = savedGui;
});
return;
case 1:
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
index a1b15b82..59c78dda 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ExtraPage.java
@@ -51,7 +51,7 @@ import java.util.TimeZone;
import java.util.TreeMap;
public class ExtraPage extends GuiProfileViewerPage {
-
+// Hehe
private static final ResourceLocation pv_extra = new ResourceLocation("notenoughupdates:pv_extra.png");
private TreeMap<Integer, Set<String>> topKills = null;
private TreeMap<Integer, Set<String>> topDeaths = null;
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
new file mode 100644
index 00000000..b80db70a
--- /dev/null
+++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneConfigCompat.java
@@ -0,0 +1,42 @@
+/*
+ * 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.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");
+
+ OneMoulConfig omc;
+
+ @Override
+ public void initConfig(Config moulConfig, Runnable saveCallback) {
+ omc = new OneMoulConfig(mod, moulConfig, saveCallback);
+ }
+}
diff --git a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneFancyColor.java b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneFancyColor.java
new file mode 100644
index 00000000..3c70f483
--- /dev/null
+++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneFancyColor.java
@@ -0,0 +1,113 @@
+/*
+ * 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.compat.oneconfig;
+
+import cc.polyfrost.oneconfig.config.core.OneColor;
+import cc.polyfrost.oneconfig.gui.elements.config.ConfigColorElement;
+import io.github.moulberry.notenoughupdates.core.ChromaColour;
+import lombok.var;
+
+import java.awt.*;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.reflect.Field;
+
+public class OneFancyColor extends ConfigColorElement {
+ public OneFancyColor(
+ Field field,
+ Object parent,
+ String name,
+ String description,
+ String category,
+ String subcategory,
+ int size,
+ boolean allowAlpha
+ ) {
+ super(field, parent, name, description, category, subcategory, size, allowAlpha);
+ }
+
+ @Override
+ public Object get() throws IllegalAccessException {
+ String chromaString = (String) super.get();
+
+ int[] decompose = ChromaColour.decompose(chromaString);
+ int r = decompose[2];
+ int g = decompose[1];
+ int b = decompose[0];
+ int a = decompose[3];
+ int chr = decompose[4];
+
+ short[] hsba = OneColor.ARGBtoHSBA(new Color(r, g, b, a).getRGB());
+ if (chr > 0) {
+ return new OneColor(hsba[0], hsba[1], hsba[2], hsba[3], (int) ChromaColour.getSecondsForSpeed(chr));
+ }
+
+ return new OneColor(r, g, b, a);
+ }
+
+ private static MethodHandle hsbaAccessor;
+ private static MethodHandle databitAccessor;
+
+ static {
+ try {
+ Field f = OneColor.class.getDeclaredField("hsba");
+ Field f2 = OneColor.class.getDeclaredField("dataBit");
+ f.setAccessible(true);
+ f2.setAccessible(true);
+ var lookup = MethodHandles.lookup();
+ hsbaAccessor = lookup.unreflectGetter(f);
+ databitAccessor = lookup.unreflectGetter(f2);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static short[] getHsba(OneColor color) {
+ try {
+ return (short[]) hsbaAccessor.invokeExact(color);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static int getDataBit(OneColor color) {
+ try {
+ return (int) databitAccessor.invokeExact(color);
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ protected void set(Object object) throws IllegalAccessException {
+ OneColor color = (OneColor) object;
+ float dataBit = getDataBit(color) / 1000F;
+ short[] hsba = getHsba(color);
+ int argb = OneColor.HSBAtoARGB(hsba[0], hsba[1], hsba[2], hsba[3]);
+ Color color1 = new Color(argb, true);
+ super.set(ChromaColour.special(
+ dataBit > 0 ? ChromaColour.getSpeedForSeconds(dataBit) : 0, // TODO chroma still sucks
+ color1.getAlpha(),
+ color1.getRed(),
+ color1.getGreen(),
+ color1.getBlue()
+ ));
+ }
+}
diff --git a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneFancyKeybind.java b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneFancyKeybind.java
new file mode 100644
index 00000000..823d90ea
--- /dev/null
+++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneFancyKeybind.java
@@ -0,0 +1,52 @@
+/*
+ * 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.compat.oneconfig;
+
+import cc.polyfrost.oneconfig.config.core.OneKeyBind;
+import cc.polyfrost.oneconfig.gui.elements.config.ConfigKeyBind;
+
+import java.lang.reflect.Field;
+
+public class OneFancyKeybind extends ConfigKeyBind {
+ public OneFancyKeybind(
+ Field field,
+ Object parent,
+ String name,
+ String description,
+ String category,
+ String subcategory,
+ int size
+ ) {
+ super(field, parent, name, description, category, subcategory, size);
+ }
+
+ @Override
+ public Object get() throws IllegalAccessException {
+ OneWrappedKeyBind owk = new OneWrappedKeyBind();
+ owk.value = (int) super.get();
+ return owk;
+ }
+
+ @Override
+ protected void set(Object object) throws IllegalAccessException {
+ OneWrappedKeyBind keyBind = (OneWrappedKeyBind) object;
+ super.set(keyBind.value);
+ }
+}
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
new file mode 100644
index 00000000..59aa25d1
--- /dev/null
+++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneMoulConfig.java
@@ -0,0 +1,201 @@
+/*
+ * 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.compat.oneconfig;
+
+import cc.polyfrost.oneconfig.config.core.ConfigUtils;
+import cc.polyfrost.oneconfig.config.data.InfoType;
+import cc.polyfrost.oneconfig.config.data.Mod;
+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.notenoughupdates.core.util.StringUtils;
+
+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) {
+ 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;
+
+ try {
+ processMoulConfig();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ cc.polyfrost.oneconfig.config.Config.register(mod);
+ }
+
+ private void processMoulConfig() throws IllegalAccessException {
+ for (Field categoryField : moulConfig.getClass().getDeclaredFields()) {
+ Category annotation = categoryField.getAnnotation(Category.class);
+ if (annotation == null) continue;
+ Object categoryInstance = categoryField.get(moulConfig);
+ OptionSubcategory subCategory = ConfigUtils.getSubCategory(mod.defaultPage, annotation.name(), "");
+ createPageForCategory(subCategory, categoryInstance);
+ }
+ }
+
+ private void createPageForCategory(OptionSubcategory category, Object categoryInstance) {
+ for (Field optionField : categoryInstance.getClass().getDeclaredFields()) {
+ ConfigOption annotation = optionField.getAnnotation(ConfigOption.class);
+ if (annotation == null) continue;
+ String cat = category.getName();
+ String subcategory = "";
+ 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(
+ optionField,
+ categoryInstance,
+ annotationName,
+ annotationDesc,
+ cat, subcategory, 2
+ ));
+ }
+ ConfigEditorText configEditorText = optionField.getAnnotation(ConfigEditorText.class);
+ if (configEditorText != null) {
+ category.options.add(new ConfigTextBox(
+ optionField,
+ categoryInstance,
+ annotationName,
+ annotationDesc,
+ cat, subcategory, 2,
+ annotationName, false, false
+ ));
+ }
+ ConfigEditorKeybind configEditorKeybind = optionField.getAnnotation(ConfigEditorKeybind.class);
+ if (configEditorKeybind != null) {
+ category.options.add(new OneFancyKeybind(
+ optionField,
+ categoryInstance,
+ annotationName,
+ annotationDesc,
+ cat, subcategory, 2
+ ));
+ }
+ ConfigEditorColour configEditorColour = optionField.getAnnotation(ConfigEditorColour.class);
+ if (configEditorColour != null) {
+ category.options.add(new OneFancyColor(
+ optionField,
+ categoryInstance,
+ annotationName,
+ annotationDesc,
+ cat, subcategory, 2, true
+ ));
+ }
+ ConfigEditorSlider configEditorSlider = optionField.getAnnotation(ConfigEditorSlider.class);
+ if (configEditorSlider != null) {
+ category.options.add(new WrappedConfigSlider(
+ optionField,
+ categoryInstance,
+ annotationName,
+ annotationDesc,
+ cat,
+ subcategory,
+ configEditorSlider.minValue(),
+ configEditorSlider.maxValue(),
+ (int) configEditorSlider.minStep()
+ ));
+ }
+ ConfigEditorButton configEditorButton = optionField.getAnnotation(ConfigEditorButton.class);
+ if (configEditorButton != null) {
+ category.options.add(new ConfigButton(
+ () -> moulConfig.executeRunnable(configEditorButton.runnableId()),
+ categoryInstance,
+ annotationName,
+ annotationDesc,
+ cat,
+ subcategory,
+ 2, configEditorButton.buttonText()
+ ));
+ }
+ ConfigEditorDropdown configEditorDropdown = optionField.getAnnotation(ConfigEditorDropdown.class);
+ if (configEditorDropdown != null) {
+ category.options.add(new ConfigDropdown(
+ optionField,
+ categoryInstance,
+ annotationName,
+ annotationDesc,
+ cat, subcategory,
+ 2, configEditorDropdown.values()
+ ));
+ }
+ ConfigEditorDraggableList configEditorDraggableList = optionField.getAnnotation(ConfigEditorDraggableList.class);
+ if (configEditorDraggableList != null) {
+ category.options.add(new ConfigInfo(
+ optionField, categoryInstance,
+ "This option (" + annotationName + ") is not available via the oneconfig gui",
+ cat, subcategory, 2, InfoType.ERROR
+ ));
+ }
+ ConfigEditorFSR configEditorFSR = optionField.getAnnotation(ConfigEditorFSR.class);
+ if (configEditorFSR != null) {
+ category.options.add(new ConfigInfo(
+ optionField, categoryInstance,
+ annotationDesc, cat, subcategory, 2, InfoType.WARNING
+ ));
+ }
+ }
+ }
+
+ @Override
+ public void save() {
+ saveCallback.run();
+ }
+
+ @Override
+ public void load() {
+ }
+
+ @Override
+ public boolean supportsProfiles() {
+ return false;
+ }
+
+}
diff --git a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneWrappedKeyBind.java b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneWrappedKeyBind.java
new file mode 100644
index 00000000..fa29eaf8
--- /dev/null
+++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/OneWrappedKeyBind.java
@@ -0,0 +1,58 @@
+/*
+ * 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.compat.oneconfig;
+
+import cc.polyfrost.oneconfig.config.core.OneKeyBind;
+import org.lwjgl.input.Keyboard;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class OneWrappedKeyBind extends OneKeyBind {
+
+ public int value = Keyboard.KEY_NONE;
+
+ @Override
+ public String getDisplay() {
+ keyBinds.clear();
+ keyBinds.addAll(getKeyBinds());
+ return super.getDisplay();
+ }
+
+ @Override
+ public void addKey(int key) {
+ value = key;
+ }
+
+ @Override
+ public void clearKeys() {
+ value = Keyboard.KEY_NONE;
+ }
+
+ @Override
+ public int getSize() {
+ return getKeyBinds().size();
+ }
+
+ @Override
+ public ArrayList<Integer> getKeyBinds() {
+ return value == Keyboard.KEY_NONE ? new ArrayList<>() : new ArrayList<>(Arrays.asList(value));
+ }
+}
diff --git a/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/WrappedConfigSlider.java b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/WrappedConfigSlider.java
new file mode 100644
index 00000000..98b6a289
--- /dev/null
+++ b/src/oneconfig/java/io/github/moulberry/notenoughupdates/compat/oneconfig/WrappedConfigSlider.java
@@ -0,0 +1,52 @@
+/*
+ * 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.compat.oneconfig;
+
+import cc.polyfrost.oneconfig.gui.elements.config.ConfigSlider;
+
+import java.lang.reflect.Field;
+
+public class WrappedConfigSlider extends ConfigSlider {
+ public WrappedConfigSlider(
+ Field field,
+ Object parent,
+ String name,
+ String description,
+ String category,
+ String subcategory,
+ float min,
+ float max,
+ int step
+ ) {
+ super(field, parent, name, description, category, subcategory, min, max, step);
+ }
+
+ @Override
+ public Object get() throws IllegalAccessException {
+ Object g = super.get();
+ if (g instanceof Double) {
+ return (float) (double) g;
+ }
+ if (g instanceof Long) {
+ return (int) (long) g;
+ }
+ return g;
+ }
+}