diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-03 06:22:16 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-07-03 06:22:16 +0700 |
commit | 74ec27a1d7208d7b22f715206ea143b399238e83 (patch) | |
tree | 7d4059d36a7ef306c92406cec632a5bb83bc9196 /versions/src/main/java/cc/polyfrost | |
parent | a81bc67e90df2fddb8e2b8ad5ac6e13cf7c81032 (diff) | |
download | OneConfig-74ec27a1d7208d7b22f715206ea143b399238e83.tar.gz OneConfig-74ec27a1d7208d7b22f715206ea143b399238e83.tar.bz2 OneConfig-74ec27a1d7208d7b22f715206ea143b399238e83.zip |
ignore test package
allow enabled property in Config to be set at constructor
Diffstat (limited to 'versions/src/main/java/cc/polyfrost')
9 files changed, 362 insertions, 0 deletions
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<BasicButton> row1 = new ArrayList<BasicButton>() {{ + 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<BasicButton> row2 = new ArrayList<BasicButton>() {{ + 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<BasicButton> row3 = new ArrayList<BasicButton>() {{ + 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 <a> <b> <c> + 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 <a> <b> <c> + 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 <a> <b> <c> + 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<String> 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 |