aboutsummaryrefslogtreecommitdiff
path: root/src/testmod/java/dev/isxander
diff options
context:
space:
mode:
Diffstat (limited to 'src/testmod/java/dev/isxander')
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/ExampleMod.java11
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/config/Entrypoint.java20
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java (renamed from src/testmod/java/dev/isxander/yacl/test/config/ConfigData.java)7
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java (renamed from src/testmod/java/dev/isxander/yacl/test/GuiTest.java)19
-rw-r--r--src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java6
5 files changed, 31 insertions, 32 deletions
diff --git a/src/testmod/java/dev/isxander/yacl/test/ExampleMod.java b/src/testmod/java/dev/isxander/yacl/test/ExampleMod.java
new file mode 100644
index 0000000..46c5225
--- /dev/null
+++ b/src/testmod/java/dev/isxander/yacl/test/ExampleMod.java
@@ -0,0 +1,11 @@
+package dev.isxander.yacl.test;
+
+import dev.isxander.yacl.test.config.ExampleConfig;
+import net.fabricmc.api.ClientModInitializer;
+
+public class ExampleMod implements ClientModInitializer {
+ @Override
+ public void onInitializeClient() {
+ ExampleConfig.INSTANCE.load();
+ }
+}
diff --git a/src/testmod/java/dev/isxander/yacl/test/config/Entrypoint.java b/src/testmod/java/dev/isxander/yacl/test/config/Entrypoint.java
deleted file mode 100644
index c71f592..0000000
--- a/src/testmod/java/dev/isxander/yacl/test/config/Entrypoint.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package dev.isxander.yacl.test.config;
-
-import dev.isxander.yacl.config.ConfigInstance;
-import dev.isxander.yacl.config.GsonConfigInstance;
-import net.fabricmc.api.ClientModInitializer;
-import net.fabricmc.loader.api.FabricLoader;
-
-public class Entrypoint implements ClientModInitializer {
- private static ConfigInstance<ConfigData> config;
-
- @Override
- public void onInitializeClient() {
- config = new GsonConfigInstance<>(ConfigData.class, FabricLoader.getInstance().getConfigDir().resolve("yacl-test.json"));
- config.load();
- }
-
- public static ConfigInstance<ConfigData> getConfig() {
- return config;
- }
-}
diff --git a/src/testmod/java/dev/isxander/yacl/test/config/ConfigData.java b/src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java
index 4eedd9f..c7ea46c 100644
--- a/src/testmod/java/dev/isxander/yacl/test/config/ConfigData.java
+++ b/src/testmod/java/dev/isxander/yacl/test/config/ExampleConfig.java
@@ -1,10 +1,15 @@
package dev.isxander.yacl.test.config;
import dev.isxander.yacl.config.ConfigEntry;
+import dev.isxander.yacl.config.ConfigInstance;
+import dev.isxander.yacl.config.GsonConfigInstance;
import java.awt.*;
+import java.nio.file.Path;
+
+public class ExampleConfig {
+ public static final ConfigInstance<ExampleConfig> INSTANCE = new GsonConfigInstance<>(ExampleConfig.class, Path.of("./config/yacl-test.json"));
-public class ConfigData {
@ConfigEntry public boolean booleanToggle = false;
@ConfigEntry public boolean customBooleanToggle = false;
@ConfigEntry public boolean tickbox = false;
diff --git a/src/testmod/java/dev/isxander/yacl/test/GuiTest.java b/src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java
index 492a573..7295f2c 100644
--- a/src/testmod/java/dev/isxander/yacl/test/GuiTest.java
+++ b/src/testmod/java/dev/isxander/yacl/test/config/GuiTest.java
@@ -1,4 +1,4 @@
-package dev.isxander.yacl.test;
+package dev.isxander.yacl.test.config;
import dev.isxander.yacl.api.*;
import dev.isxander.yacl.gui.RequireRestartScreen;
@@ -13,8 +13,7 @@ import dev.isxander.yacl.gui.controllers.string.number.DoubleFieldController;
import dev.isxander.yacl.gui.controllers.string.number.FloatFieldController;
import dev.isxander.yacl.gui.controllers.string.number.IntegerFieldController;
import dev.isxander.yacl.gui.controllers.string.number.LongFieldController;
-import dev.isxander.yacl.test.config.ConfigData;
-import dev.isxander.yacl.test.config.Entrypoint;
+import dev.isxander.yacl.test.ExampleMod;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.option.GraphicsMode;
@@ -27,7 +26,7 @@ import java.awt.*;
public class GuiTest {
public static Screen getModConfigScreenFactory(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.of("Test Suites"))
.category(ConfigCategory.createBuilder()
.name(Text.of("Suites"))
@@ -57,7 +56,7 @@ public class GuiTest {
}
private static Screen getFullTestSuite(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.of("Test GUI"))
.category(ConfigCategory.createBuilder()
.name(Text.of("Control Examples"))
@@ -202,7 +201,7 @@ public class GuiTest {
.build())
.group(OptionGroup.createBuilder()
.name(Text.of("Enum Controllers"))
- .option(Option.createBuilder(ConfigData.Alphabet.class)
+ .option(Option.createBuilder(ExampleConfig.Alphabet.class)
.name(Text.of("Enum Cycler"))
.binding(
defaults.enumOption,
@@ -374,14 +373,14 @@ public class GuiTest {
.build())
.save(() -> {
MinecraftClient.getInstance().options.write();
- Entrypoint.getConfig().save();
+ ExampleConfig.INSTANCE.save();
})
)
.generateScreen(parent);
}
private static Screen getDisabledTest(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.empty())
.category(ConfigCategory.createBuilder()
.name(Text.of("Disabled Test"))
@@ -414,7 +413,7 @@ public class GuiTest {
}
private static Screen getWikiBasic(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.of("Mod Name"))
.category(ConfigCategory.createBuilder()
.name(Text.of("My Category"))
@@ -435,7 +434,7 @@ public class GuiTest {
}
private static Screen getWikiGroups(Screen parent) {
- return YetAnotherConfigLib.create(Entrypoint.getConfig(), (defaults, config, builder) -> builder
+ return YetAnotherConfigLib.create(ExampleConfig.INSTANCE, (defaults, config, builder) -> builder
.title(Text.of("Mod Name"))
.category(ConfigCategory.createBuilder()
.name(Text.of("My Category"))
diff --git a/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java b/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java
index 2635eaf..2f65b96 100644
--- a/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java
+++ b/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java
@@ -1,6 +1,6 @@
package dev.isxander.yacl.test.mixins;
-import dev.isxander.yacl.test.GuiTest;
+import dev.isxander.yacl.test.config.GuiTest;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
@@ -10,6 +10,10 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+/**
+ * For testing purposes! If you are using this as
+ * an example, ignore this class!
+ */
@Mixin(TitleScreen.class)
public abstract class TitleScreenMixin extends Screen {
protected TitleScreenMixin(Text title) {