diff options
author | isXander <xandersmith2008@gmail.com> | 2022-11-17 17:18:19 +0000 |
---|---|---|
committer | isXander <xandersmith2008@gmail.com> | 2022-11-17 17:18:19 +0000 |
commit | 3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e (patch) | |
tree | d3617930fed50a945ce4ff9ee76b8dbd7df46968 /src/testmod | |
parent | af4484ecee46300a26952b9b9b41e7a2e80d3f78 (diff) | |
download | YetAnotherConfigLib-3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e.tar.gz YetAnotherConfigLib-3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e.tar.bz2 YetAnotherConfigLib-3a86e9d2ba89466f7f9ef51c29eb5879bcb8a98e.zip |
22w46a
Diffstat (limited to 'src/testmod')
-rw-r--r-- | src/testmod/java/dev/isxander/yacl/test/GuiTest.java (renamed from src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java) | 34 | ||||
-rw-r--r-- | src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java | 26 | ||||
-rw-r--r-- | src/testmod/resources/fabric.mod.json | 13 | ||||
-rw-r--r-- | src/testmod/resources/yet-another-config-lib.test.mixins.json | 11 |
4 files changed, 49 insertions, 35 deletions
diff --git a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java b/src/testmod/java/dev/isxander/yacl/test/GuiTest.java index 596a0bf..449a081 100644 --- a/src/testmod/java/dev/isxander/yacl/test/ModMenuIntegration.java +++ b/src/testmod/java/dev/isxander/yacl/test/GuiTest.java @@ -1,7 +1,5 @@ package dev.isxander.yacl.test; -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import com.terraformersmc.modmenu.api.ModMenuApi; import dev.isxander.yacl.api.*; import dev.isxander.yacl.gui.RequireRestartScreen; import dev.isxander.yacl.gui.controllers.*; @@ -23,10 +21,9 @@ import net.minecraft.text.Text; import java.awt.*; -public class ModMenuIntegration implements ModMenuApi { - @Override - public ConfigScreenFactory<?> getModConfigScreenFactory() { - return (parent) -> Entrypoint.getConfig().buildConfig((config, builder) -> builder +public class GuiTest { + public static Screen getModConfigScreenFactory(Screen parent) { + return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.of("Test Suites")) .category(ConfigCategory.createBuilder() .name(Text.of("Suites")) @@ -55,7 +52,7 @@ public class ModMenuIntegration implements ModMenuApi { .generateScreen(parent); } - private Screen getFullTestSuite(Screen parent) { + private static Screen getFullTestSuite(Screen parent) { return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.of("Test GUI")) .category(ConfigCategory.createBuilder() @@ -340,7 +337,7 @@ public class ModMenuIntegration implements ModMenuApi { .generateScreen(parent); } - private Screen getDisabledTest(Screen parent) { + private static Screen getDisabledTest(Screen parent) { return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.empty()) .category(ConfigCategory.createBuilder() @@ -373,7 +370,7 @@ public class ModMenuIntegration implements ModMenuApi { .generateScreen(parent); } - private Screen getWikiBasic(Screen parent) { + private static Screen getWikiBasic(Screen parent) { return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.of("Mod Name")) .category(ConfigCategory.createBuilder() @@ -394,7 +391,7 @@ public class ModMenuIntegration implements ModMenuApi { .generateScreen(parent); } - private Screen getWikiGroups(Screen parent) { + private static Screen getWikiGroups(Screen parent) { return Entrypoint.getConfig().buildConfig((config, builder) -> builder .title(Text.of("Mod Name")) .category(ConfigCategory.createBuilder() @@ -417,21 +414,4 @@ public class ModMenuIntegration implements ModMenuApi { ) .generateScreen(parent); } - - private ConfigScreenFactory<?> getWikiButton() { - return (parent) -> Entrypoint.getConfig().buildConfig((config, builder) -> builder - .title(Text.of("Mod Name")) - .category(ConfigCategory.createBuilder() - .name(Text.of("My Category")) - .tooltip(Text.of("This displays when you hover over a category button")) // optional - .option(ButtonOption.createBuilder() - .name(Text.of("Pressable Button")) - .tooltip(Text.of("This is so easy!")) // optional - .action(screen -> {}) - .controller(ActionController::new) - .build()) - .build()) - ) - .generateScreen(parent); - } } diff --git a/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java b/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java new file mode 100644 index 0000000..b32a392 --- /dev/null +++ b/src/testmod/java/dev/isxander/yacl/test/mixins/TitleScreenMixin.java @@ -0,0 +1,26 @@ +package dev.isxander.yacl.test.mixins; + +import dev.isxander.yacl.test.GuiTest; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.TitleScreen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(TitleScreen.class) +public abstract class TitleScreenMixin extends Screen { + protected TitleScreenMixin(Text title) { + super(title); + } + + @Inject(method = "init", at = @At("RETURN")) + private void injectTestButton(CallbackInfo ci) { + addDrawableChild(ButtonWidget.createBuilder(Text.of("YACL"), button -> client.setScreen(GuiTest.getModConfigScreenFactory(client.currentScreen))) + .setPosition(0, 0) + .setWidth(50) + .build()); + } +} diff --git a/src/testmod/resources/fabric.mod.json b/src/testmod/resources/fabric.mod.json index 1360a5e..5fe0919 100644 --- a/src/testmod/resources/fabric.mod.json +++ b/src/testmod/resources/fabric.mod.json @@ -11,15 +11,12 @@ "entrypoints": { "client": [ "dev.isxander.yacl.test.config.Entrypoint" - ], - "modmenu": [ - "dev.isxander.yacl.test.ModMenuIntegration" ] }, "depends": { - "fabricloader": ">=0.14.0", - "minecraft": "1.19.x", - "java": ">=17", - "fabric-resource-loader-v0": "*" - } + "yet-another-config-lib": "*" + }, + "mixins": [ + "yet-another-config-lib.test.mixins.json" + ] } diff --git a/src/testmod/resources/yet-another-config-lib.test.mixins.json b/src/testmod/resources/yet-another-config-lib.test.mixins.json new file mode 100644 index 0000000..9287cdd --- /dev/null +++ b/src/testmod/resources/yet-another-config-lib.test.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "dev.isxander.yacl.test.mixins", + "compatibilityLevel": "JAVA_17", + "injectors": { + "defaultRequire": 1 + }, + "client": [ + "TitleScreenMixin" + ] +} |