diff options
Diffstat (limited to 'src/main')
9 files changed, 12 insertions, 350 deletions
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<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/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 <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/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<String> 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 |