From 74ec27a1d7208d7b22f715206ea143b399238e83 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sun, 3 Jul 2022 06:22:16 +0700 Subject: ignore test package allow enabled property in Config to be set at constructor --- api/OneConfig.api | 40 +----- build.gradle.kts | 1 + .../java/cc/polyfrost/oneconfig/config/Config.java | 14 ++- .../oneconfig/test/ButtonTestPage_Test.java | 70 ----------- .../polyfrost/oneconfig/test/TestCommand_Test.java | 63 ---------- .../polyfrost/oneconfig/test/TestConfig_Test.java | 135 --------------------- .../cc/polyfrost/oneconfig/test/TestHud_Test.java | 22 ---- .../oneconfig/test/TestMultilineHud_Test.java | 16 --- .../oneconfig/test/TestNanoVGGui_Test.java | 26 ---- .../cc/polyfrost/oneconfig/test/TestPage_Test.java | 11 -- .../cc/polyfrost/oneconfig/test/package-info.java | 5 - .../oneconfig/test/ButtonTestPage_Test.java | 70 +++++++++++ .../polyfrost/oneconfig/test/TestCommand_Test.java | 63 ++++++++++ .../polyfrost/oneconfig/test/TestConfig_Test.java | 135 +++++++++++++++++++++ .../cc/polyfrost/oneconfig/test/TestHud_Test.java | 22 ++++ .../cc/polyfrost/oneconfig/test/TestMod_Test.java | 14 +++ .../oneconfig/test/TestMultilineHud_Test.java | 16 +++ .../oneconfig/test/TestNanoVGGui_Test.java | 26 ++++ .../cc/polyfrost/oneconfig/test/TestPage_Test.java | 11 ++ .../cc/polyfrost/oneconfig/test/package-info.java | 5 + 20 files changed, 376 insertions(+), 389 deletions(-) delete mode 100644 src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java delete mode 100644 src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java delete mode 100644 src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java delete mode 100644 src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java delete mode 100644 src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java delete mode 100644 src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java delete mode 100644 src/main/java/cc/polyfrost/oneconfig/test/TestPage_Test.java delete mode 100644 src/main/java/cc/polyfrost/oneconfig/test/package-info.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/TestMod_Test.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/TestPage_Test.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/test/package-info.java diff --git a/api/OneConfig.api b/api/OneConfig.api index fa4e477..eea861a 100644 --- a/api/OneConfig.api +++ b/api/OneConfig.api @@ -7,6 +7,7 @@ public class cc/polyfrost/oneconfig/config/Config { protected final field nonProfileSpecificGson Lcom/google/gson/Gson; public final field optionNames Ljava/util/HashMap; public fun (Lcc/polyfrost/oneconfig/config/data/Mod;Ljava/lang/String;)V + public fun (Lcc/polyfrost/oneconfig/config/data/Mod;Ljava/lang/String;Z)V protected fun addDependency (Ljava/lang/String;Ljava/lang/String;)V protected fun addDependency (Ljava/lang/String;Ljava/util/function/Supplier;)V protected fun addDependency (Ljava/lang/String;Z)V @@ -1134,45 +1135,6 @@ public class cc/polyfrost/oneconfig/renderer/scissor/ScissorManager { public static fun scissor (JFFFF)Lcc/polyfrost/oneconfig/renderer/scissor/Scissor; } -public class cc/polyfrost/oneconfig/test/ButtonTestPage_Test : cc/polyfrost/oneconfig/gui/pages/Page { - public fun ()V - public fun draw (JII)V -} - -public class cc/polyfrost/oneconfig/test/TestCommand_Test { - public fun ()V -} - -public class cc/polyfrost/oneconfig/test/TestConfig_Test : cc/polyfrost/oneconfig/config/Config { - public field hud Lcc/polyfrost/oneconfig/test/TestHud_Test; - public field multilineHud Lcc/polyfrost/oneconfig/test/TestMultilineHud_Test; - public static field testCheckBox Z - public field testPage Lcc/polyfrost/oneconfig/test/TestPage_Test; - public field testPage2 Lcc/polyfrost/oneconfig/test/TestPage_Test; - public field testSwitch Z - public fun ()V -} - -public class cc/polyfrost/oneconfig/test/TestHud_Test : cc/polyfrost/oneconfig/hud/SingleTextHud { - public field yes Z - public fun ()V - public fun getText ()Ljava/lang/String; -} - -public class cc/polyfrost/oneconfig/test/TestMultilineHud_Test : cc/polyfrost/oneconfig/hud/TextHud { - public fun ()V - protected fun getLines (Ljava/util/List;)V -} - -public class cc/polyfrost/oneconfig/test/TestNanoVGGui_Test : cc/polyfrost/oneconfig/libs/universal/UScreen { - public fun ()V - public fun onDrawScreen (Lcc/polyfrost/oneconfig/libs/universal/UMatrixStack;IIF)V -} - -public class cc/polyfrost/oneconfig/test/TestPage_Test { - public fun ()V -} - public final class cc/polyfrost/oneconfig/utils/IOUtils { public fun ()V public static fun copyImageToClipboard (Ljava/awt/Image;)V diff --git a/build.gradle.kts b/build.gradle.kts index 62254b3..8d888c4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -147,4 +147,5 @@ apiValidation { ignoredProjects.add("lwjgl") ignoredPackages.add("cc.polyfrost.oneconfig.libs") ignoredPackages.add("cc.polyfrost.oneconfig.internal") + ignoredPackages.add("cc.polyfrost.oneconfig.test") } \ No newline at end of file diff --git a/src/main/java/cc/polyfrost/oneconfig/config/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/Config.java index c2661fa..dd5a578 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/Config.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/Config.java @@ -42,15 +42,25 @@ public class Config { transient protected final Gson nonProfileSpecificGson = new GsonBuilder().setExclusionStrategies(new NonProfileSpecificExclusionStrategy()).excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting().create(); transient public Mod mod; public transient boolean hasBeenInitialized = false; - public boolean enabled = true; + public boolean enabled; /** * @param modData information about the mod * @param configFile file where config is stored + * @param enabled whether the mod is enabled or not */ - public Config(Mod modData, String configFile) { + public Config(Mod modData, String configFile, boolean enabled) { this.configFile = configFile; this.mod = modData; + this.enabled = enabled; + } + + /** + * @param modData information about the mod + * @param configFile file where config is stored + */ + public Config(Mod modData, String configFile) { + this(modData, configFile, true); } public void initialize() { diff --git a/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java deleted file mode 100644 index fe25477..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java +++ /dev/null @@ -1,70 +0,0 @@ -package cc.polyfrost.oneconfig.test; - -import cc.polyfrost.oneconfig.gui.elements.BasicButton; -import cc.polyfrost.oneconfig.gui.pages.Page; -import cc.polyfrost.oneconfig.internal.assets.SVGs; -import cc.polyfrost.oneconfig.utils.color.ColorPalette; - -import java.util.ArrayList; - -public class ButtonTestPage_Test extends Page { - private final ArrayList row1 = new ArrayList() {{ - add(new BasicButton(254, 48, "Primary", BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); - add(new BasicButton(254, 48, "Primary Destructive", BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY_DESTRUCTIVE)); - add(new BasicButton(254, 48, "Secondary", BasicButton.ALIGNMENT_LEFT, ColorPalette.SECONDARY)); - add(new BasicButton(254, 48, "Secondary Destructive", BasicButton.ALIGNMENT_LEFT, ColorPalette.SECONDARY_DESTRUCTIVE)); - add(new BasicButton(254, 48, "Tertiary", BasicButton.ALIGNMENT_LEFT, ColorPalette.TERTIARY)); - add(new BasicButton(254, 48, "Tertiary Destructive", BasicButton.ALIGNMENT_LEFT, ColorPalette.TERTIARY_DESTRUCTIVE)); - add(new BasicButton(254, 48, "LeftIconLA", SVGs.BOX, null, BasicButton.ALIGNMENT_LEFT, ColorPalette.SECONDARY)); - add(new BasicButton(254, 48, "RightIconLA", null, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.SECONDARY)); - add(new BasicButton(254, 48, "LeftIconCA", SVGs.BOX, null, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); - add(new BasicButton(254, 48, "RightIconCA", null, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); - }}; - - private final ArrayList row2 = new ArrayList() {{ - add(new BasicButton(170, 32, "32", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); - add(new BasicButton(193, 36, "36", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); - add(new BasicButton(208, 40, "40", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); - add(new BasicButton(254, 48, "48", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); - add(new BasicButton(254, 48, "JustifiedRight", null, SVGs.BOX, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.SECONDARY_DESTRUCTIVE)); - add(new BasicButton(254, 48, "JustifiedLeft", SVGs.BOX, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.SECONDARY_DESTRUCTIVE)); - add(new BasicButton(254, 48, "JustifiedNoIcon", null, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.PRIMARY)); - add(new BasicButton(254, 48, "TertiaryIcon", SVGs.BOX, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.TERTIARY_DESTRUCTIVE)); - - }}; - - private final ArrayList row3 = new ArrayList() {{ - add(new BasicButton(254, 48, "Left", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); - add(new BasicButton(254, 48, "Center", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY)); - add(new BasicButton(254, 48, "Justified", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.PRIMARY)); - add(new BasicButton(254, 48, "Disabled :(", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); - add(new BasicButton(254, 48, "Disabled :(", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY)); - add(new BasicButton(254, 48, "Disabled :(", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.PRIMARY)); - }}; - - public ButtonTestPage_Test() { - super("Buttons"); - row3.get(3).disable(true); - row3.get(4).disable(true); - row3.get(5).disable(true); - } - - @Override - public void draw(long vg, int x, int y) { - int buttonY = y + 16; - for (BasicButton button : row1) { - button.draw(vg, x + 16, buttonY); - buttonY += 64; - } - buttonY = y + 16; - for (BasicButton button : row2) { - button.draw(vg, x + 286, buttonY); - buttonY += 64; - } - buttonY = y + 16; - for (BasicButton button : row3) { - button.draw(vg, x + 556, buttonY); - buttonY += 64; - } - } -} diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java deleted file mode 100644 index 33ed5b7..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java +++ /dev/null @@ -1,63 +0,0 @@ -package cc.polyfrost.oneconfig.test; - -import cc.polyfrost.oneconfig.utils.commands.annotations.Command; -import cc.polyfrost.oneconfig.utils.commands.annotations.Main; -import cc.polyfrost.oneconfig.utils.commands.annotations.Name; -import cc.polyfrost.oneconfig.utils.commands.annotations.SubCommand; -import cc.polyfrost.oneconfig.libs.universal.UChat; - -@Command(value = "test", aliases = {"t"}, description = "Description of the test command") -public class TestCommand_Test { - - @Main(description = "The main command.") - private static void main() { // /test - UChat.chat("Main command"); - } - - @SubCommand(value = "subcommand", aliases = {"s"}, description = "Subcommand 1.") - private static class TestSubCommand { - - @Main(priority = 999, description = "Description of method") - private static void main(int a, float b, @Name("named c") String c) { // /test subcommand - UChat.chat("Integer main: " + a + " " + b + " " + c); - } - - @Main(priority = 10001) - private static void main(double a, double b, @Name("named c") String c) { // /test subcommand - UChat.chat("Double main: " + a + " " + b + " " + c); - } - - @SubCommand(value = "subsubcommand", aliases = {"ss"}) - private static class TestSubSubCommand { - - @Main - private static void main(String a, String b, @Name("named c") String c) { // /test subcommand subsubcommand - joinAndChat(a, b, c); - } - } - } - - @SubCommand(value = "subcommand2", aliases = {"s2"}) - private static class TestSubCommand2 { - @Main - private static void main(boolean a, boolean b, boolean c, boolean d, boolean e, boolean f, int hgshrs, boolean jrwjhrw) { - joinAndChat(a, b, c, d, e, f, hgshrs, jrwjhrw); - } - } - - @SubCommand(value = "subcommand3", aliases = {"s3"}) - private static class TestSubCommand3 { - @Main - private static void main() { - UChat.chat("subcommand 3"); - } - } - - private static void joinAndChat(Object... stuff) { - StringBuilder builder = new StringBuilder(); - for (Object thing : stuff) { - builder.append(thing).append(" "); - } - UChat.chat(builder.toString().trim()); - } -} diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java deleted file mode 100644 index 772bba7..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java +++ /dev/null @@ -1,135 +0,0 @@ -package cc.polyfrost.oneconfig.test; - -import cc.polyfrost.oneconfig.config.annotations.*; -import cc.polyfrost.oneconfig.config.core.OneColor; -import cc.polyfrost.oneconfig.config.core.OneKeyBind; -import cc.polyfrost.oneconfig.config.data.*; -import cc.polyfrost.oneconfig.config.Config; -import cc.polyfrost.oneconfig.config.data.ModType; -import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator; -import cc.polyfrost.oneconfig.libs.universal.UChat; -import cc.polyfrost.oneconfig.libs.universal.UKeyboard; - -public class TestConfig_Test extends Config { - - @NonProfileSpecific - @Switch( - name = "Test Switch", - size = OptionSize.DUAL - ) - public boolean testSwitch = false; - - @Checkbox( - name = "Check box", - size = OptionSize.DUAL - ) - public static boolean testCheckBox = true; - - @Info( - text = "Test Info", - type = InfoType.ERROR, - size = OptionSize.DUAL - ) - boolean ignored; - - @Header( - text = "Test Header", - size = OptionSize.DUAL - ) - boolean ignored1; - - @Dropdown( - name = "Test Dropdown", - options = {"option1", "option2", "option3"}, - size = OptionSize.DUAL - ) - private static int testDropdown = 0; - - @Color( - name = "Test Color", - size = OptionSize.DUAL - ) - OneColor testColor = new OneColor(0, 255, 255); - - @Text( - name = "Test Text", - size = OptionSize.DUAL - ) - private static String testText = "Epic Text"; - - @Button( - name = "Test Button", - text = "Say hi" - ) - Runnable runnable = () -> UChat.chat("HI!!!!"); - - @Slider( - name = "Test Slider", - min = 25, - max = 50 - ) - float testSlider = 50; - - @KeyBind( - name = "Test KeyBind", - size = OptionSize.DUAL - ) - OneKeyBind testKeyBind = new OneKeyBind(UKeyboard.KEY_LSHIFT, UKeyboard.KEY_S); - - @DualOption( - name = "Test Dual Option", - left = "YES", - right = "NO", - size = OptionSize.DUAL - ) - boolean testDualOption = false; - - @Page( - name = "Test Page", - location = PageLocation.TOP - - ) - public TestPage_Test testPage = new TestPage_Test(); - - @Page( - name = "Test Page", - description = "Test Description", - location = PageLocation.BOTTOM - - ) - public TestPage_Test testPage2 = new TestPage_Test(); - - @Switch( - name = "Test Switch", - size = OptionSize.DUAL, - category = "Category 2" - ) - boolean testSwitch1 = false; - - @Switch( - name = "Test Switch", - size = OptionSize.DUAL, - category = "Category 2", - subcategory = "Test Subcategory" - ) - boolean testSwitch2 = false; - - @HUD( - name = "Test HUD", - category = "HUD" - ) - public TestHud_Test hud = new TestHud_Test(); - - @HUD( - name = "Test Multiline HUD", - category = "HUD" - ) - public TestMultilineHud_Test multilineHud = new TestMultilineHud_Test(); - - public TestConfig_Test() { - super(new Mod("Test Mod", ModType.UTIL_QOL, new VigilanceMigrator("./config/testConfig.toml")), "hacksConfig.json"); - initialize(); - addDependency("testCheckBox", "testSwitch"); - } -} - diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java deleted file mode 100644 index ae557c7..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java +++ /dev/null @@ -1,22 +0,0 @@ -package cc.polyfrost.oneconfig.test; - -import cc.polyfrost.oneconfig.config.annotations.Switch; -import cc.polyfrost.oneconfig.hud.SingleTextHud; - -public class TestHud_Test extends SingleTextHud { - int times = 0; - @Switch( - name = "Custom Option" - ) - public boolean yes; - - public TestHud_Test() { - super("Time", true); - } - - @Override - public String getText() { - times++; - return String.valueOf(times); - } -} diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java deleted file mode 100644 index 1665062..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package cc.polyfrost.oneconfig.test; - -import cc.polyfrost.oneconfig.hud.TextHud; - -import java.util.List; - -public class TestMultilineHud_Test extends TextHud { - public TestMultilineHud_Test() { - super(true); - } - - @Override - protected void getLines(List lines) { - lines.add(String.valueOf(System.currentTimeMillis())); - } -} diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java deleted file mode 100644 index e8b6b91..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java +++ /dev/null @@ -1,26 +0,0 @@ -package cc.polyfrost.oneconfig.test; - -import cc.polyfrost.oneconfig.renderer.RenderManager; -import cc.polyfrost.oneconfig.renderer.font.Fonts; -import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; -import cc.polyfrost.oneconfig.libs.universal.UScreen; -import org.jetbrains.annotations.NotNull; - -import java.awt.*; - -public class TestNanoVGGui_Test extends UScreen { - - @Override - public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { - super.onDrawScreen(matrixStack, mouseX, mouseY, partialTicks); - long startTime = System.nanoTime(); - RenderManager.setupAndDraw((vg) -> { - RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB()); - RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); - RenderManager.drawText(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.BOLD); - RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB()); - RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB()); - RenderManager.drawText(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.BOLD); - }); - } -} diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestPage_Test.java b/src/main/java/cc/polyfrost/oneconfig/test/TestPage_Test.java deleted file mode 100644 index 0f8f692..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestPage_Test.java +++ /dev/null @@ -1,11 +0,0 @@ -package cc.polyfrost.oneconfig.test; - -import cc.polyfrost.oneconfig.config.annotations.Switch; - -public class TestPage_Test { - - @Switch( - name = "Epic Test Switch" - ) - boolean test = false; -} diff --git a/src/main/java/cc/polyfrost/oneconfig/test/package-info.java b/src/main/java/cc/polyfrost/oneconfig/test/package-info.java deleted file mode 100644 index ef38b37..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/test/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Test package for the OneConfig library. - * Classes in this package that end with {@code _Test} are excluded from actual builds. - */ -package cc.polyfrost.oneconfig.test; \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java new file mode 100644 index 0000000..fe25477 --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/ButtonTestPage_Test.java @@ -0,0 +1,70 @@ +package cc.polyfrost.oneconfig.test; + +import cc.polyfrost.oneconfig.gui.elements.BasicButton; +import cc.polyfrost.oneconfig.gui.pages.Page; +import cc.polyfrost.oneconfig.internal.assets.SVGs; +import cc.polyfrost.oneconfig.utils.color.ColorPalette; + +import java.util.ArrayList; + +public class ButtonTestPage_Test extends Page { + private final ArrayList row1 = new ArrayList() {{ + add(new BasicButton(254, 48, "Primary", BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); + add(new BasicButton(254, 48, "Primary Destructive", BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY_DESTRUCTIVE)); + add(new BasicButton(254, 48, "Secondary", BasicButton.ALIGNMENT_LEFT, ColorPalette.SECONDARY)); + add(new BasicButton(254, 48, "Secondary Destructive", BasicButton.ALIGNMENT_LEFT, ColorPalette.SECONDARY_DESTRUCTIVE)); + add(new BasicButton(254, 48, "Tertiary", BasicButton.ALIGNMENT_LEFT, ColorPalette.TERTIARY)); + add(new BasicButton(254, 48, "Tertiary Destructive", BasicButton.ALIGNMENT_LEFT, ColorPalette.TERTIARY_DESTRUCTIVE)); + add(new BasicButton(254, 48, "LeftIconLA", SVGs.BOX, null, BasicButton.ALIGNMENT_LEFT, ColorPalette.SECONDARY)); + add(new BasicButton(254, 48, "RightIconLA", null, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.SECONDARY)); + add(new BasicButton(254, 48, "LeftIconCA", SVGs.BOX, null, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); + add(new BasicButton(254, 48, "RightIconCA", null, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.SECONDARY)); + }}; + + private final ArrayList row2 = new ArrayList() {{ + add(new BasicButton(170, 32, "32", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); + add(new BasicButton(193, 36, "36", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); + add(new BasicButton(208, 40, "40", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); + add(new BasicButton(254, 48, "48", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); + add(new BasicButton(254, 48, "JustifiedRight", null, SVGs.BOX, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.SECONDARY_DESTRUCTIVE)); + add(new BasicButton(254, 48, "JustifiedLeft", SVGs.BOX, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.SECONDARY_DESTRUCTIVE)); + add(new BasicButton(254, 48, "JustifiedNoIcon", null, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.PRIMARY)); + add(new BasicButton(254, 48, "TertiaryIcon", SVGs.BOX, null, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.TERTIARY_DESTRUCTIVE)); + + }}; + + private final ArrayList row3 = new ArrayList() {{ + add(new BasicButton(254, 48, "Left", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); + add(new BasicButton(254, 48, "Center", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY)); + add(new BasicButton(254, 48, "Justified", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.PRIMARY)); + add(new BasicButton(254, 48, "Disabled :(", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_LEFT, ColorPalette.PRIMARY)); + add(new BasicButton(254, 48, "Disabled :(", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_CENTER, ColorPalette.PRIMARY)); + add(new BasicButton(254, 48, "Disabled :(", SVGs.BOX, SVGs.BOX, BasicButton.ALIGNMENT_JUSTIFIED, ColorPalette.PRIMARY)); + }}; + + public ButtonTestPage_Test() { + super("Buttons"); + row3.get(3).disable(true); + row3.get(4).disable(true); + row3.get(5).disable(true); + } + + @Override + public void draw(long vg, int x, int y) { + int buttonY = y + 16; + for (BasicButton button : row1) { + button.draw(vg, x + 16, buttonY); + buttonY += 64; + } + buttonY = y + 16; + for (BasicButton button : row2) { + button.draw(vg, x + 286, buttonY); + buttonY += 64; + } + buttonY = y + 16; + for (BasicButton button : row3) { + button.draw(vg, x + 556, buttonY); + buttonY += 64; + } + } +} diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java new file mode 100644 index 0000000..33ed5b7 --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestCommand_Test.java @@ -0,0 +1,63 @@ +package cc.polyfrost.oneconfig.test; + +import cc.polyfrost.oneconfig.utils.commands.annotations.Command; +import cc.polyfrost.oneconfig.utils.commands.annotations.Main; +import cc.polyfrost.oneconfig.utils.commands.annotations.Name; +import cc.polyfrost.oneconfig.utils.commands.annotations.SubCommand; +import cc.polyfrost.oneconfig.libs.universal.UChat; + +@Command(value = "test", aliases = {"t"}, description = "Description of the test command") +public class TestCommand_Test { + + @Main(description = "The main command.") + private static void main() { // /test + UChat.chat("Main command"); + } + + @SubCommand(value = "subcommand", aliases = {"s"}, description = "Subcommand 1.") + private static class TestSubCommand { + + @Main(priority = 999, description = "Description of method") + private static void main(int a, float b, @Name("named c") String c) { // /test subcommand + UChat.chat("Integer main: " + a + " " + b + " " + c); + } + + @Main(priority = 10001) + private static void main(double a, double b, @Name("named c") String c) { // /test subcommand + UChat.chat("Double main: " + a + " " + b + " " + c); + } + + @SubCommand(value = "subsubcommand", aliases = {"ss"}) + private static class TestSubSubCommand { + + @Main + private static void main(String a, String b, @Name("named c") String c) { // /test subcommand subsubcommand + joinAndChat(a, b, c); + } + } + } + + @SubCommand(value = "subcommand2", aliases = {"s2"}) + private static class TestSubCommand2 { + @Main + private static void main(boolean a, boolean b, boolean c, boolean d, boolean e, boolean f, int hgshrs, boolean jrwjhrw) { + joinAndChat(a, b, c, d, e, f, hgshrs, jrwjhrw); + } + } + + @SubCommand(value = "subcommand3", aliases = {"s3"}) + private static class TestSubCommand3 { + @Main + private static void main() { + UChat.chat("subcommand 3"); + } + } + + private static void joinAndChat(Object... stuff) { + StringBuilder builder = new StringBuilder(); + for (Object thing : stuff) { + builder.append(thing).append(" "); + } + UChat.chat(builder.toString().trim()); + } +} diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java new file mode 100644 index 0000000..772bba7 --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestConfig_Test.java @@ -0,0 +1,135 @@ +package cc.polyfrost.oneconfig.test; + +import cc.polyfrost.oneconfig.config.annotations.*; +import cc.polyfrost.oneconfig.config.core.OneColor; +import cc.polyfrost.oneconfig.config.core.OneKeyBind; +import cc.polyfrost.oneconfig.config.data.*; +import cc.polyfrost.oneconfig.config.Config; +import cc.polyfrost.oneconfig.config.data.ModType; +import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator; +import cc.polyfrost.oneconfig.libs.universal.UChat; +import cc.polyfrost.oneconfig.libs.universal.UKeyboard; + +public class TestConfig_Test extends Config { + + @NonProfileSpecific + @Switch( + name = "Test Switch", + size = OptionSize.DUAL + ) + public boolean testSwitch = false; + + @Checkbox( + name = "Check box", + size = OptionSize.DUAL + ) + public static boolean testCheckBox = true; + + @Info( + text = "Test Info", + type = InfoType.ERROR, + size = OptionSize.DUAL + ) + boolean ignored; + + @Header( + text = "Test Header", + size = OptionSize.DUAL + ) + boolean ignored1; + + @Dropdown( + name = "Test Dropdown", + options = {"option1", "option2", "option3"}, + size = OptionSize.DUAL + ) + private static int testDropdown = 0; + + @Color( + name = "Test Color", + size = OptionSize.DUAL + ) + OneColor testColor = new OneColor(0, 255, 255); + + @Text( + name = "Test Text", + size = OptionSize.DUAL + ) + private static String testText = "Epic Text"; + + @Button( + name = "Test Button", + text = "Say hi" + ) + Runnable runnable = () -> UChat.chat("HI!!!!"); + + @Slider( + name = "Test Slider", + min = 25, + max = 50 + ) + float testSlider = 50; + + @KeyBind( + name = "Test KeyBind", + size = OptionSize.DUAL + ) + OneKeyBind testKeyBind = new OneKeyBind(UKeyboard.KEY_LSHIFT, UKeyboard.KEY_S); + + @DualOption( + name = "Test Dual Option", + left = "YES", + right = "NO", + size = OptionSize.DUAL + ) + boolean testDualOption = false; + + @Page( + name = "Test Page", + location = PageLocation.TOP + + ) + public TestPage_Test testPage = new TestPage_Test(); + + @Page( + name = "Test Page", + description = "Test Description", + location = PageLocation.BOTTOM + + ) + public TestPage_Test testPage2 = new TestPage_Test(); + + @Switch( + name = "Test Switch", + size = OptionSize.DUAL, + category = "Category 2" + ) + boolean testSwitch1 = false; + + @Switch( + name = "Test Switch", + size = OptionSize.DUAL, + category = "Category 2", + subcategory = "Test Subcategory" + ) + boolean testSwitch2 = false; + + @HUD( + name = "Test HUD", + category = "HUD" + ) + public TestHud_Test hud = new TestHud_Test(); + + @HUD( + name = "Test Multiline HUD", + category = "HUD" + ) + public TestMultilineHud_Test multilineHud = new TestMultilineHud_Test(); + + public TestConfig_Test() { + super(new Mod("Test Mod", ModType.UTIL_QOL, new VigilanceMigrator("./config/testConfig.toml")), "hacksConfig.json"); + initialize(); + addDependency("testCheckBox", "testSwitch"); + } +} + diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java new file mode 100644 index 0000000..ae557c7 --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestHud_Test.java @@ -0,0 +1,22 @@ +package cc.polyfrost.oneconfig.test; + +import cc.polyfrost.oneconfig.config.annotations.Switch; +import cc.polyfrost.oneconfig.hud.SingleTextHud; + +public class TestHud_Test extends SingleTextHud { + int times = 0; + @Switch( + name = "Custom Option" + ) + public boolean yes; + + public TestHud_Test() { + super("Time", true); + } + + @Override + public String getText() { + times++; + return String.valueOf(times); + } +} diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMod_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMod_Test.java new file mode 100644 index 0000000..ab7587e --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMod_Test.java @@ -0,0 +1,14 @@ +package cc.polyfrost.oneconfig.test; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; + +@net.minecraftforge.fml.common.Mod(modid = "oneconfig-test-mod", name = "Test Mod", version = "0") +public class TestMod_Test { + private TestConfig_Test config; + + @Mod.EventHandler + public void init(FMLInitializationEvent event) { + config = new TestConfig_Test(); + } +} \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java new file mode 100644 index 0000000..1665062 --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestMultilineHud_Test.java @@ -0,0 +1,16 @@ +package cc.polyfrost.oneconfig.test; + +import cc.polyfrost.oneconfig.hud.TextHud; + +import java.util.List; + +public class TestMultilineHud_Test extends TextHud { + public TestMultilineHud_Test() { + super(true); + } + + @Override + protected void getLines(List lines) { + lines.add(String.valueOf(System.currentTimeMillis())); + } +} diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java new file mode 100644 index 0000000..e8b6b91 --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui_Test.java @@ -0,0 +1,26 @@ +package cc.polyfrost.oneconfig.test; + +import cc.polyfrost.oneconfig.renderer.RenderManager; +import cc.polyfrost.oneconfig.renderer.font.Fonts; +import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; +import cc.polyfrost.oneconfig.libs.universal.UScreen; +import org.jetbrains.annotations.NotNull; + +import java.awt.*; + +public class TestNanoVGGui_Test extends UScreen { + + @Override + public void onDrawScreen(@NotNull UMatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { + super.onDrawScreen(matrixStack, mouseX, mouseY, partialTicks); + long startTime = System.nanoTime(); + RenderManager.setupAndDraw((vg) -> { + RenderManager.drawRect(vg, 0, 0, 100, 100, Color.BLUE.getRGB()); + RenderManager.drawRoundedRect(vg, 305, 305, 100, 100, Color.YELLOW.getRGB(), 8); + RenderManager.drawText(vg, "Hello!", 100, 100, Color.WHITE.getRGB(), 50, Fonts.BOLD); + RenderManager.drawLine(vg, 0, 0, 100, 100, 7, Color.PINK.getRGB()); + RenderManager.drawCircle(vg, 200, 200, 50, Color.WHITE.getRGB()); + RenderManager.drawText(vg, (float) (System.nanoTime() - startTime) / 1000000f + "ms", 500, 500, Color.WHITE.getRGB(), 100, Fonts.BOLD); + }); + } +} diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/TestPage_Test.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestPage_Test.java new file mode 100644 index 0000000..0f8f692 --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/TestPage_Test.java @@ -0,0 +1,11 @@ +package cc.polyfrost.oneconfig.test; + +import cc.polyfrost.oneconfig.config.annotations.Switch; + +public class TestPage_Test { + + @Switch( + name = "Epic Test Switch" + ) + boolean test = false; +} diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/test/package-info.java b/versions/src/main/java/cc/polyfrost/oneconfig/test/package-info.java new file mode 100644 index 0000000..ef38b37 --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/test/package-info.java @@ -0,0 +1,5 @@ +/** + * Test package for the OneConfig library. + * Classes in this package that end with {@code _Test} are excluded from actual builds. + */ +package cc.polyfrost.oneconfig.test; \ No newline at end of file -- cgit