From a0ff501947a84b268e099524a06b56a6b900dad2 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Tue, 3 May 2022 18:25:32 +0200 Subject: move to cc.polyfrost --- .../java/io/polyfrost/oneconfig/OneConfig.java | 81 ---- .../oneconfig/command/OneConfigCommand.java | 55 --- .../oneconfig/config/OneConfigConfig.java | 81 ---- .../oneconfig/config/annotations/ConfigPage.java | 32 -- .../oneconfig/config/annotations/Option.java | 85 ----- .../oneconfig/config/core/ConfigCore.java | 25 -- .../polyfrost/oneconfig/config/data/InfoType.java | 8 - .../io/polyfrost/oneconfig/config/data/Mod.java | 26 -- .../polyfrost/oneconfig/config/data/ModType.java | 10 - .../oneconfig/config/data/OptionCategory.java | 13 - .../oneconfig/config/data/OptionPage.java | 19 - .../oneconfig/config/data/OptionType.java | 36 -- .../oneconfig/config/data/PageLocation.java | 6 - .../oneconfig/config/interfaces/BasicOption.java | 81 ---- .../oneconfig/config/interfaces/Config.java | 180 --------- .../config/interfaces/OneConfigTypeAdapter.java | 51 --- .../interfaces/OneConfigTypeAdapterFactory.java | 30 -- .../oneconfig/config/interfaces/Size.java | 6 - .../oneconfig/config/profiles/Profiles.java | 87 ----- .../java/io/polyfrost/oneconfig/gui/HudGui.java | 326 ---------------- .../io/polyfrost/oneconfig/gui/OneConfigGui.java | 234 ------------ .../java/io/polyfrost/oneconfig/gui/SideBar.java | 67 ---- .../oneconfig/gui/elements/BasicButton.java | 157 -------- .../oneconfig/gui/elements/BasicElement.java | 107 ------ .../oneconfig/gui/elements/ColorSelector.java | 250 ------------ .../polyfrost/oneconfig/gui/elements/ModCard.java | 146 ------- .../oneconfig/gui/elements/SearchField.java | 14 - .../oneconfig/gui/elements/TextInputField.java | 418 --------------------- .../gui/elements/config/ConfigCheckbox.java | 61 --- .../gui/elements/config/ConfigColorElement.java | 115 ------ .../gui/elements/config/ConfigDropdown.java | 167 -------- .../gui/elements/config/ConfigDualOption.java | 53 --- .../gui/elements/config/ConfigPageButton.java | 57 --- .../gui/elements/config/ConfigSlider.java | 184 --------- .../gui/elements/config/ConfigSwitch.java | 54 --- .../gui/elements/config/ConfigTextBox.java | 61 --- .../gui/elements/config/ConfigUniSelector.java | 78 ---- .../io/polyfrost/oneconfig/gui/pages/HomePage.java | 28 -- .../oneconfig/gui/pages/ModConfigPage.java | 152 -------- .../io/polyfrost/oneconfig/gui/pages/ModsPage.java | 76 ---- .../io/polyfrost/oneconfig/gui/pages/Page.java | 34 -- .../java/io/polyfrost/oneconfig/hud/HudCore.java | 23 -- .../oneconfig/hud/interfaces/BasicHud.java | 111 ------ .../oneconfig/hud/interfaces/TextHud.java | 94 ----- .../io/polyfrost/oneconfig/lwjgl/BlurHandler.java | 159 -------- .../java/io/polyfrost/oneconfig/lwjgl/IOUtil.java | 56 --- .../oneconfig/lwjgl/Lwjgl2FunctionProvider.java | 39 -- .../polyfrost/oneconfig/lwjgl/RenderManager.java | 306 --------------- .../java/io/polyfrost/oneconfig/lwjgl/Scissor.java | 22 -- .../polyfrost/oneconfig/lwjgl/ScissorManager.java | 40 -- .../io/polyfrost/oneconfig/lwjgl/font/Font.java | 39 -- .../oneconfig/lwjgl/font/FontManager.java | 31 -- .../io/polyfrost/oneconfig/lwjgl/font/Fonts.java | 15 - .../io/polyfrost/oneconfig/lwjgl/image/Image.java | 21 -- .../oneconfig/lwjgl/image/ImageLoader.java | 45 --- .../io/polyfrost/oneconfig/lwjgl/image/Images.java | 47 --- .../oneconfig/lwjgl/plugin/ClassTransformer.java | 55 --- .../oneconfig/lwjgl/plugin/LoadingPlugin.java | 52 --- .../io/polyfrost/oneconfig/test/TestConfig.java | 128 ------- .../java/io/polyfrost/oneconfig/test/TestHud.java | 23 -- .../io/polyfrost/oneconfig/test/TestNanoVGGui.java | 26 -- .../java/io/polyfrost/oneconfig/test/TestPage.java | 44 --- .../io/polyfrost/oneconfig/utils/ColorUtils.java | 86 ----- .../io/polyfrost/oneconfig/utils/InputUtils.java | 34 -- .../io/polyfrost/oneconfig/utils/MathUtils.java | 30 -- .../io/polyfrost/oneconfig/utils/TickDelay.java | 40 -- 66 files changed, 5317 deletions(-) delete mode 100644 src/main/java/io/polyfrost/oneconfig/OneConfig.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/command/OneConfigCommand.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/ConfigPage.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/InfoType.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/Mod.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/ModType.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/OptionCategory.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/data/PageLocation.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapter.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapterFactory.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/interfaces/Size.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/HudGui.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/SideBar.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/BasicButton.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/BasicElement.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/ColorSelector.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/SearchField.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/TextInputField.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/pages/HomePage.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/pages/ModConfigPage.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/pages/ModsPage.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/gui/pages/Page.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/hud/HudCore.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/hud/interfaces/BasicHud.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/hud/interfaces/TextHud.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/BlurHandler.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/IOUtil.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/Scissor.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/ScissorManager.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/font/Font.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/font/FontManager.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/font/Fonts.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/image/Image.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/image/Images.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/lwjgl/plugin/LoadingPlugin.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/test/TestConfig.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/test/TestHud.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/test/TestNanoVGGui.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/test/TestPage.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java delete mode 100644 src/main/java/io/polyfrost/oneconfig/utils/TickDelay.java (limited to 'src/main/java/io') diff --git a/src/main/java/io/polyfrost/oneconfig/OneConfig.java b/src/main/java/io/polyfrost/oneconfig/OneConfig.java deleted file mode 100644 index dedf6b8..0000000 --- a/src/main/java/io/polyfrost/oneconfig/OneConfig.java +++ /dev/null @@ -1,81 +0,0 @@ -package io.polyfrost.oneconfig; - -import io.polyfrost.oneconfig.command.OneConfigCommand; -import io.polyfrost.oneconfig.config.OneConfigConfig; -import io.polyfrost.oneconfig.config.core.ConfigCore; -import io.polyfrost.oneconfig.config.data.Mod; -import io.polyfrost.oneconfig.config.data.ModType; -import io.polyfrost.oneconfig.hud.HudCore; -import io.polyfrost.oneconfig.lwjgl.BlurHandler; -import io.polyfrost.oneconfig.lwjgl.RenderManager; -import io.polyfrost.oneconfig.lwjgl.font.Fonts; -import io.polyfrost.oneconfig.lwjgl.image.Images; -import io.polyfrost.oneconfig.test.TestConfig; -import net.minecraft.client.Minecraft; -import net.minecraftforge.client.ClientCommandHandler; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.ModMetadata; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -import java.io.File; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; - -@net.minecraftforge.fml.common.Mod(modid = "@ID@", name = "@NAME@", version = "@VER@") -public class OneConfig { - private static final Minecraft mc = Minecraft.getMinecraft(); - public static File jarFile; - public static File oneConfigDir = new File(mc.mcDataDir, "OneConfig/"); - public static File themesDir = new File(oneConfigDir, "themes/"); - public static OneConfigConfig config; - public static TestConfig testConfig; - public static List loadedMods = new ArrayList<>(); - public static List loadedOtherMods = new ArrayList<>(); - - @net.minecraftforge.fml.common.Mod.EventHandler - public void onPreFMLInit(FMLPreInitializationEvent event) { - jarFile = event.getSourceFile(); - oneConfigDir.mkdirs(); - themesDir.mkdirs(); - config = new OneConfigConfig(); - } - - @net.minecraftforge.fml.common.Mod.EventHandler - public void onFMLInitialization(FMLInitializationEvent event) { - BlurHandler.INSTANCE.load(); - testConfig = new TestConfig(); - ClientCommandHandler.instance.registerCommand(new OneConfigCommand()); - MinecraftForge.EVENT_BUS.register(this); - MinecraftForge.EVENT_BUS.register(new HudCore()); - RenderManager.setupAndDraw((vg) -> { - RenderManager.drawRoundedRect(vg, -100, -100, 50, 50, -1, 12f); - RenderManager.drawString(vg, "OneConfig loading...", -100, -100, -1, 12f, Fonts.INTER_MEDIUM); - RenderManager.drawImage(vg, Images.LOGO, -100, -100, 50, 50); - }); - } - - @net.minecraftforge.fml.common.Mod.EventHandler - public void onPostFMLInit(FMLPostInitializationEvent event) { - reloadModsList(); - } - - public static void reloadModsList() { - loadedMods.addAll(ConfigCore.oneConfigMods); - LinkedHashSet modData = new LinkedHashSet<>(ConfigCore.oneConfigMods); - for (ModContainer mod : Loader.instance().getActiveModList()) { - ModMetadata metadata = mod.getMetadata(); - loadedOtherMods.add(metadata); - String author = metadata.authorList.size() > 0 ? metadata.authorList.get(0) : ""; - Mod newMod = new Mod(metadata.name, ModType.OTHER, author, metadata.version); - if (newMod.name.equals("Minecraft Coder Pack") || newMod.name.equals("Forge Mod Loader") || newMod.name.equals("Minecraft Forge")) { // TODO add oneconfig - continue; - } - if (modData.add(newMod)) loadedMods.add(newMod); // anti duplicate fix - } - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/command/OneConfigCommand.java b/src/main/java/io/polyfrost/oneconfig/command/OneConfigCommand.java deleted file mode 100644 index f792ee7..0000000 --- a/src/main/java/io/polyfrost/oneconfig/command/OneConfigCommand.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.polyfrost.oneconfig.command; - -import io.polyfrost.oneconfig.gui.HudGui; -import io.polyfrost.oneconfig.gui.OneConfigGui; -import io.polyfrost.oneconfig.test.TestNanoVGGui; -import io.polyfrost.oneconfig.utils.TickDelay; -import net.minecraft.client.Minecraft; -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; - -import java.util.ArrayList; -import java.util.List; - -public class OneConfigCommand extends CommandBase { - - private static final Minecraft mc = Minecraft.getMinecraft(); - - @Override - public String getCommandName() { - return "oneconfig"; - } - - @Override - public String getCommandUsage(ICommandSender sender) { - return "oneconfig <>"; - } - - @Override - public List getCommandAliases() { - return new ArrayList() {{ - add("oneconfig"); - add("ocfg"); - }}; - } - - @Override - public void processCommand(ICommandSender sender, String[] args) { - if (args.length == 0) new TickDelay(() -> mc.displayGuiScreen(new OneConfigGui()), 1); - else { - switch (args[0]) { - case "hud": - new TickDelay(() -> mc.displayGuiScreen(new HudGui()), 1); - break; - case "lwjgl": - new TickDelay(() -> mc.displayGuiScreen(new TestNanoVGGui()), 1); - break; - } - } - } - - @Override - public int getRequiredPermissionLevel() { - return -1; - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java b/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java deleted file mode 100644 index a772a23..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/OneConfigConfig.java +++ /dev/null @@ -1,81 +0,0 @@ -package io.polyfrost.oneconfig.config; - -import com.google.gson.JsonParser; -import io.polyfrost.oneconfig.config.data.Mod; -import io.polyfrost.oneconfig.config.interfaces.Config; - -import java.awt.*; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; - -public class OneConfigConfig extends Config { - - public static String currentProfile = "Default Profile"; - - // TODO i dont know how this works so this is just gonna be here for now - public static final int TRANSPARENT = new Color(0, 0, 0, 0).getRGB(); // Transparent // button sidebar normal - - public static final int GRAY_900 = new Color(13, 14, 15, 255).getRGB(); // Gray 900 - public static final int GRAY_900_80 = new Color(13, 14, 15, 204).getRGB(); // Gray 900 80% - public static final int GRAY_800 = new Color(21, 22, 23, 255).getRGB(); // Gray 800 - public static final int GRAY_700 = new Color(34, 35, 38, 255).getRGB(); // Gray 700 - public static final int GRAY_600 = new Color(42, 44, 48, 255).getRGB(); // Gray 600 - public static final int GRAY_500 = new Color(49, 51, 56, 255).getRGB(); // Gray 500 // button sidebar hover, button gray normal - public static final int GRAY_500_80 = new Color(49, 51, 56, 204).getRGB(); // Gray 500 80% // button sidebar pressed - - public static final int GRAY_400 = new Color(55, 59, 69, 255).getRGB(); // Gray 400 - public static final int GRAY_300 = new Color(73, 79, 92, 255).getRGB(); // Gray 300 // button gray hover - public static final int GRAY_200 = new Color(100, 107, 125, 255).getRGB(); // Gray 200 - public static final int GRAY_400_80 = new Color(55, 59, 69, 204).getRGB(); // Gray 400 80% // button gray pressed - public static final int BLUE_800 = new Color(13, 51, 128, 255).getRGB(); // Blue 800 - public static final int BLUE_700 = new Color(18, 71, 178, 255).getRGB(); // Blue 700 - public static final int BLUE_700_80 = new Color(18, 71, 178, 204).getRGB(); // Blue 700 80% - public static final int BLUE_600 = new Color(20, 82, 204, 255).getRGB(); // Blue 600 // button blue normal - public static final int BLUE_600_80 = new Color(20, 82, 204, 204).getRGB(); // Blue 600 80% // button blue click - public static final int BLUE_500 = new Color(25, 103, 255, 255).getRGB(); // Blue 500 // button blue hover - public static final int BLUE_400 = new Color(48, 129, 242, 255).getRGB(); - public static final int BLUE_400_80 = new Color(48, 129, 242, 204).getRGB(); - public static final int WHITE_50 = new Color(255, 255, 255, 127).getRGB(); // White 60% - public static final int WHITE_60 = new Color(255, 255, 255, 153).getRGB(); // White 60% - public static final int WHITE_80 = new Color(255, 255, 255, 204).getRGB(); // White 80% - public static final int WHITE_90 = new Color(255, 255, 255, 229).getRGB(); // White 90% - public static final int WHITE_95 = new Color(255, 255, 255, 242).getRGB(); // White 90% - public static final int WHITE = new Color(255, 255, 255, 255).getRGB(); // White 100% - - public static final int ERROR_700 = new Color(180, 24, 24, 255).getRGB(); // Red 700 - - public static boolean ROUNDED_CORNERS = true; - public static float CORNER_RADIUS_WIN = 20f; - public static float CORNER_RADIUS = 12f; - - - public OneConfigConfig() { - super(null, "OneConfig.json"); - } - - @Override - public void init(Mod mod) { - if (new File("OneConfig/" + configFile).exists()) load(); - else save(); - } - - @Override - public void save() { - try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(Paths.get("OneConfig/" + configFile)), StandardCharsets.UTF_8))) { - writer.write(gson.toJson(this.getClass())); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public void load() { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get("OneConfig/" + configFile)), StandardCharsets.UTF_8))) { - deserializePart(new JsonParser().parse(reader).getAsJsonObject(), this.getClass()); - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/ConfigPage.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/ConfigPage.java deleted file mode 100644 index c0a4169..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/ConfigPage.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -import io.polyfrost.oneconfig.config.data.PageLocation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigPage { - /** - * The name of the page that will be displayed to the user - */ - String name(); - - /** - * If the page button is at the top or bottem of the page - */ - PageLocation location(); - - /** - * The description of the page that will be displayed to the user - */ - String description() default ""; - - /** - * The category of the page - */ - String category() default "General"; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java deleted file mode 100644 index 9955c17..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/annotations/Option.java +++ /dev/null @@ -1,85 +0,0 @@ -package io.polyfrost.oneconfig.config.annotations; - -import io.polyfrost.oneconfig.config.data.InfoType; -import io.polyfrost.oneconfig.config.data.OptionType; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Option { - /** - * The name of the option that will be displayed to the user - */ - String name(); - - /** - * The type of the option - */ - OptionType type(); - - /** - * The category of the component - */ - String category() default "General"; - - /** - * The subcategory of the component (displayed as header) - */ - String subcategory(); - - /** - * The width of the option (1 = half width, 2 = full width) - */ - int size() default 1; - - /** - * A String array of all the possible values for the UniSelector, dropdownList, and ComboBox. - * Also used in the DualOption slider, index 0 is the left, index 1 is the right; for example: - * {"Option 1", "Option 2"} - */ - String[] options() default {}; - - /** - * The places you want dividers to be in a dropdown - */ - int[] dividers() default {}; - - /** - * The placeholder in the text field - */ - String placeholder() default ""; - - /** - * If the text field is secure or not - */ - boolean secure() default false; - - /** - * If the text field is multi line or not - */ - boolean multiLine() default false; - - /** - * Minimum value of slider - */ - float min() default 0; - - /** - * The maximum value of the slider - */ - float max() default 0; - - /** - * Steps of slider (0 for no steps) - */ - int step() default 0; - - /** - * Option for info option type - */ - InfoType infoType() default InfoType.INFO; -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java deleted file mode 100644 index 6cce197..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.polyfrost.oneconfig.config.core; - -import io.polyfrost.oneconfig.config.data.Mod; -import io.polyfrost.oneconfig.hud.HudCore; - -import java.util.ArrayList; - -public class ConfigCore { - public static ArrayList oneConfigMods = new ArrayList<>(); - - public static void saveAll() { - for (Mod modData : oneConfigMods) { - modData.config.save(); - } - } - - public static void reInitAll() { - ArrayList data = new ArrayList<>(oneConfigMods); - oneConfigMods.clear(); - HudCore.huds.clear(); - for (Mod modData : data) { - modData.config.init(modData); - } - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/InfoType.java b/src/main/java/io/polyfrost/oneconfig/config/data/InfoType.java deleted file mode 100644 index 1b96161..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/data/InfoType.java +++ /dev/null @@ -1,8 +0,0 @@ -package io.polyfrost.oneconfig.config.data; - -public enum InfoType { - INFO, - WARNING, - ERROR, - SUCCESS -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java b/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java deleted file mode 100644 index 095dded..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/data/Mod.java +++ /dev/null @@ -1,26 +0,0 @@ -package io.polyfrost.oneconfig.config.data; - -import io.polyfrost.oneconfig.config.interfaces.Config; - -public class Mod { - public final String name; - public final ModType modType; - public final String creator; - public final String version; - public Config config; - public final OptionPage defaultPage; - - /** - * @param name Friendly name of the mod - * @param modType Type of the mod (for example ModType.QOL) - * @param creator Creator of the mod - * @param version Version of the mod - */ - public Mod(String name, ModType modType, String creator, String version) { - this.name = name; - this.modType = modType; - this.creator = creator; - this.version = version; - this.defaultPage = new OptionPage(name, this); - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java b/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java deleted file mode 100644 index 9769584..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.polyfrost.oneconfig.config.data; - -public enum ModType { - PVP, - HUD, - UTIL_QOL, - HYPIXEL, - SKYBLOCK, - OTHER -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/OptionCategory.java b/src/main/java/io/polyfrost/oneconfig/config/data/OptionCategory.java deleted file mode 100644 index a3752bb..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/data/OptionCategory.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.polyfrost.oneconfig.config.data; - -import io.polyfrost.oneconfig.config.interfaces.BasicOption; -import io.polyfrost.oneconfig.gui.elements.config.ConfigPageButton; - -import java.util.ArrayList; -import java.util.LinkedHashMap; - -public class OptionCategory { - public final LinkedHashMap> subcategories = new LinkedHashMap<>(); - public final ArrayList topPages = new ArrayList<>(); - public final ArrayList bottomPages = new ArrayList<>(); -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java b/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java deleted file mode 100644 index 8103404..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/data/OptionPage.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.polyfrost.oneconfig.config.data; - -import java.util.LinkedHashMap; - -public class OptionPage { - public final String name; - public final Mod mod; - /** - * Depth 1 = categories - * Depth 2 = subcategories - * Depth 3 = list of options - */ - public final LinkedHashMap categories = new LinkedHashMap<>(); - - public OptionPage(String name, Mod mod) { - this.name = name; - this.mod = mod; - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java b/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java deleted file mode 100644 index 2a6fce4..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/data/OptionType.java +++ /dev/null @@ -1,36 +0,0 @@ -package io.polyfrost.oneconfig.config.data; - -public enum OptionType { - /** - * Type: boolean - */ - SWITCH, - /** - * Type: boolean - */ - CHECKBOX, - /** - * Type: boolean - */ - DUAL_OPTION, - /** - * Type: int - */ - UNI_SELECTOR, - /** - * Type: String - * Normal: 1x and 2x, Secure and Mutliline: 2x only - */ - TEXT, - /** - * Type: int or float - */ - SLIDER, - COLOR, - /** - * Type: int - */ - DROPDOWN, - MULTI_DROPDOWN, - INFO -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/data/PageLocation.java b/src/main/java/io/polyfrost/oneconfig/config/data/PageLocation.java deleted file mode 100644 index 9fe0c91..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/data/PageLocation.java +++ /dev/null @@ -1,6 +0,0 @@ -package io.polyfrost.oneconfig.config.data; - -public enum PageLocation { - TOP, - BOTTOM -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java deleted file mode 100644 index 7b9a807..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/BasicOption.java +++ /dev/null @@ -1,81 +0,0 @@ -package io.polyfrost.oneconfig.config.interfaces; - -import java.lang.reflect.Field; - -@SuppressWarnings({"unused"}) -public abstract class BasicOption { - protected final Field field; - protected final String name; - public final int size; - - /** - * Initialize option - * - * @param field variable attached to option (null for category) - * @param name name of option - * @param size size of option, 0 for single column, 1 for double. - */ - public BasicOption(Field field, String name, int size) { - this.field = field; - this.name = name; - this.size = size; - if (field != null) field.setAccessible(true); - } - - /** - * @param object Java object to set the variable to - */ - protected void set(Object object) throws IllegalAccessException { - if (field == null) return; - field.set(null, object); - } - - /** - * @return value of variable as Java object - */ - protected Object get() throws IllegalAccessException { - if (field == null) return null; - return field.get(null); - } - - /** - * @return height of option to align other options accordingly - */ - public abstract int getHeight(); - - /** - * Function that gets called when drawing option - * - * @param vg NanoVG context - * @param x x position - * @param y y position - */ - public abstract void draw(long vg, int x, int y); - - /** - * Function that gets called last drawing option, - * should be used for things that draw above other options - * - * @param vg NanoVG context - * @param x x position - * @param y y position - */ - public void drawLast(long vg, int x, int y) { - } - - /** - * Function that gets called when a key is typed - * - * @param key char that has been typed - * @param keyCode code of key - */ - public void keyTyped(char key, int keyCode) { - } - - /** - * @return If the component has an option to render at half size - */ - public boolean hasHalfSize() { - return true; - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java deleted file mode 100644 index cbba2e0..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java +++ /dev/null @@ -1,180 +0,0 @@ -package io.polyfrost.oneconfig.config.interfaces; - -import com.google.gson.*; -import io.polyfrost.oneconfig.config.annotations.ConfigPage; -import io.polyfrost.oneconfig.config.annotations.Option; -import io.polyfrost.oneconfig.config.core.ConfigCore; -import io.polyfrost.oneconfig.config.data.Mod; -import io.polyfrost.oneconfig.config.data.OptionCategory; -import io.polyfrost.oneconfig.config.data.OptionPage; -import io.polyfrost.oneconfig.config.profiles.Profiles; -import io.polyfrost.oneconfig.gui.OneConfigGui; -import io.polyfrost.oneconfig.gui.elements.config.*; -import io.polyfrost.oneconfig.gui.pages.ModConfigPage; -import net.minecraft.client.Minecraft; - -import java.io.*; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Map; -import java.util.Optional; - -public class Config { - protected final String configFile; - protected final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting().registerTypeAdapterFactory(OneConfigTypeAdapterFactory.getStaticTypeAdapterFactory()).create(); - private static Mod mod; - - /** - * @param modData information about the mod - * @param configFile file where config is stored - */ - public Config(Mod modData, String configFile) { - this.configFile = configFile; - init(modData); - } - - public void init(Mod mod) { - if (Profiles.getProfileFile(configFile).exists()) load(); - else save(); - mod.config = this; - generateOptionList(this.getClass(), mod.defaultPage, mod); - ConfigCore.oneConfigMods.add(mod); - Config.mod = mod; - } - - /** - * Save current config to file - */ - public void save() { - try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(Profiles.getProfileFile(configFile).toPath()), StandardCharsets.UTF_8))) { - writer.write(gson.toJson(this.getClass())); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Load file and overwrite current values - */ - public void load() { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(Profiles.getProfileFile(configFile).toPath()), StandardCharsets.UTF_8))) { - deserializePart(new JsonParser().parse(reader).getAsJsonObject(), this.getClass()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Generate the option list, for internal use only - * - * @param clazz target class - * @param page page to add options too - */ - protected void generateOptionList(Class clazz, OptionPage page, Mod mod) { - for (Field field : clazz.getDeclaredFields()) { - if (!field.isAnnotationPresent(Option.class) && !field.isAnnotationPresent(ConfigPage.class)) { - processCustomOption(field, page); - continue; - } else if (field.isAnnotationPresent(ConfigPage.class)) { - ConfigPage option = field.getAnnotation(ConfigPage.class); - if (!page.categories.containsKey(option.category())) - page.categories.put(option.category(), new OptionCategory()); - OptionPage newPage = new OptionPage(option.name(), mod); - try { - field.setAccessible(true); - Object object = field.get(clazz); - generateOptionList(object.getClass(), newPage, mod); - switch (option.location()) { - case TOP: - page.categories.get(option.category()).topPages.add(new ConfigPageButton(field, option.name(), option.description(), newPage)); - break; - case BOTTOM: - page.categories.get(option.category()).bottomPages.add(new ConfigPageButton(field, option.name(), option.description(), newPage)); - break; - } - } catch (IllegalAccessException e) { - continue; - } - continue; - } - Option option = field.getAnnotation(Option.class); - if (!page.categories.containsKey(option.category())) - page.categories.put(option.category(), new OptionCategory()); - if (!page.categories.get(option.category()).subcategories.containsKey(option.subcategory())) - page.categories.get(option.category()).subcategories.put(option.subcategory(), new ArrayList<>()); - ArrayList options = page.categories.get(option.category()).subcategories.get(option.subcategory()); - switch (option.type()) { - case SWITCH: - options.add(new ConfigSwitch(field, option.name(), option.size())); - break; - case CHECKBOX: - options.add(new ConfigCheckbox(field, option.name(), option.size())); - break; - case TEXT: - options.add(new ConfigTextBox(field, option.name(), option.size(), option.placeholder(), option.secure(), option.multiLine())); - break; - case DUAL_OPTION: - options.add(new ConfigDualOption(field, option.name(), option.size(), option.options())); - break; - case UNI_SELECTOR: - options.add(new ConfigUniSelector(field, option.name(), option.size(), option.options())); - break; - case DROPDOWN: - options.add(new ConfigDropdown(field, option.name(), option.size(), option.options(), option.dividers())); - break; - case SLIDER: - options.add(new ConfigSlider(field, option.name(), option.size(), option.min(), option.max(), option.step())); - break; - } - } - } - - /** - * Overwrite this method to add your own custom option types - * - * @param field target field - * @param page page to add options too - */ - protected void processCustomOption(Field field, OptionPage page) { - } - - /** - * Deserialize part of config and load values - * - * @param json json to deserialize - * @param clazz target class - */ - protected void deserializePart(JsonObject json, Class clazz) { - for (Map.Entry element : json.entrySet()) { - String name = element.getKey(); - JsonElement value = element.getValue(); - if (value.isJsonObject()) { - Optional> innerClass = Arrays.stream(clazz.getClasses()).filter(aClass -> aClass.getSimpleName().equals(name)).findFirst(); - if (innerClass.isPresent()) { - deserializePart(value.getAsJsonObject(), innerClass.get()); - continue; - } - } - try { - Field field = clazz.getField(name); - TypeAdapter adapter = gson.getAdapter(field.getType()); - Object object = adapter.fromJsonTree(value); - field.setAccessible(true); - field.set(null, object); - } catch (NoSuchFieldException | IllegalAccessException ignored) { - } - } - } - - /** - * Function to open the gui of this mod - */ - public void openGui() { - if (mod == null) return; - Minecraft.getMinecraft().displayGuiScreen(new OneConfigGui(new ModConfigPage(mod.defaultPage))); - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapter.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapter.java deleted file mode 100644 index 7754820..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapter.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.polyfrost.oneconfig.config.interfaces; - -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; -import java.lang.reflect.Field; - -final class OneConfigTypeAdapter extends TypeAdapter> { - - private final Gson gson; - private final JsonParser parser = new JsonParser(); - - private OneConfigTypeAdapter(final Gson gson) { - this.gson = gson; - } - - static TypeAdapter> getStaticTypeAdapter(final Gson gson) { - return new OneConfigTypeAdapter<>(gson); - } - - @Override - public void write(final JsonWriter out, final Class value) throws IOException { - try { - out.beginObject(); - for (Field field : value.getFields()) { - out.name(field.getName()); - field.setAccessible(true); - final TypeAdapter adapter = (TypeAdapter) gson.getAdapter(field.getType()); - adapter.write(out, field.get(field.getClass())); - } - for (Class clazz : value.getClasses()) { - out.name(clazz.getSimpleName()); - final TypeAdapter adapter = gson.getAdapter(JsonElement.class); - adapter.write(out, parser.parse(gson.toJson(clazz))); - } - out.endObject(); - } catch (final IllegalAccessException ex) { - throw new IOException(ex); - } - } - - @Override - public Class read(final JsonReader in) throws IOException { - return null; - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapterFactory.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapterFactory.java deleted file mode 100644 index af57163..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapterFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.polyfrost.oneconfig.config.interfaces; - -import com.google.gson.Gson; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; - -import static io.polyfrost.oneconfig.config.interfaces.OneConfigTypeAdapter.getStaticTypeAdapter; - -public class OneConfigTypeAdapterFactory implements TypeAdapterFactory { - - private static final TypeAdapterFactory staticTypeAdapterFactory = new OneConfigTypeAdapterFactory(); - - public static TypeAdapterFactory getStaticTypeAdapterFactory() { - return staticTypeAdapterFactory; - } - - @Override - public TypeAdapter create(final Gson gson, final TypeToken typeToken) { - final Type type = typeToken.getType(); - if (type.equals(Class.class)) { - @SuppressWarnings("unchecked") final TypeAdapter castStaticTypeAdapter = (TypeAdapter) getStaticTypeAdapter(gson); - return castStaticTypeAdapter; - } - return null; - } - -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Size.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Size.java deleted file mode 100644 index 4802ec5..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/interfaces/Size.java +++ /dev/null @@ -1,6 +0,0 @@ -package io.polyfrost.oneconfig.config.interfaces; - -public enum Size { - SINGLE_COLUMN, // A single column, 480x32 - DOUBLE_COLUMN // A double column, 992x32 -} diff --git a/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java b/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java deleted file mode 100644 index 45d448d..0000000 --- a/src/main/java/io/polyfrost/oneconfig/config/profiles/Profiles.java +++ /dev/null @@ -1,87 +0,0 @@ -package io.polyfrost.oneconfig.config.profiles; - -import io.polyfrost.oneconfig.OneConfig; -import io.polyfrost.oneconfig.config.OneConfigConfig; -import io.polyfrost.oneconfig.config.core.ConfigCore; -import org.apache.commons.io.FileUtils; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; - -public class Profiles { - private static final File profileDir = new File("OneConfig/profiles"); - public static ArrayList profiles; - - public static String getCurrentProfile() { - if (!profileDir.exists() && !profileDir.mkdir()) { - System.out.println("Could not create profiles folder"); - return null; - } - if (profiles == null) { - String[] profilesArray = new File("OneConfig/profiles").list((file, s) -> file.isDirectory()); - if (profilesArray != null) profiles = new ArrayList<>(Arrays.asList(profilesArray)); - } - if (!getProfileDir(OneConfigConfig.currentProfile).exists()) { - createProfile(OneConfigConfig.currentProfile); - } - return OneConfigConfig.currentProfile; - } - - public static void createProfile(String name) { - File folder = new File(profileDir, name); - if (!folder.exists() && !folder.mkdir()) { - System.out.println("Could not create profile folder"); - return; - } - profiles.add(name); - } - - public static File getProfileDir() { - return getProfileDir(getCurrentProfile()); - } - - public static File getProfileDir(String profile) { - return new File(new File("OneConfig/profiles"), profile); - } - - public static File getProfileFile(String file) { - return new File(getProfileDir(), file); - } - - public static void loadProfile(String profile) { - ConfigCore.saveAll(); - OneConfigConfig.currentProfile = profile; - OneConfig.config.save(); - ConfigCore.reInitAll(); - } - - public static void renameProfile(String name, String newName) { - try { - File newFile = new File(new File("OneConfig/profiles"), newName); - FileUtils.moveDirectory(getProfileDir(name), newFile); - if (OneConfigConfig.currentProfile.equals(name)) OneConfigConfig.currentProfile = newName; - profiles.remove(name); - profiles.add(newName); - } catch (IOException e) { - System.out.println("Failed to rename profile"); - } - } - - public static void deleteProfile(String name) { - if (name.equals(getCurrentProfile())) { - if (profiles.size() == 1) { - System.out.println("Cannot delete only profile!"); - return; - } - loadProfile(profiles.stream().filter(entry -> !entry.equals(name)).findFirst().get()); - } - try { - FileUtils.deleteDirectory(getProfileDir(name)); - profiles.remove(name); - } catch (IOException e) { - System.out.println("Failed to delete profile"); - } - } -} diff --git a/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java deleted file mode 100644 index 32e401b..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/HudGui.java +++ /dev/null @@ -1,326 +0,0 @@ -package io.polyfrost.oneconfig.gui; - -import io.polyfrost.oneconfig.hud.HudCore; -import io.polyfrost.oneconfig.hud.interfaces.BasicHud; -import io.polyfrost.oneconfig.lwjgl.RenderManager; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; -import org.lwjgl.input.Keyboard; - -import java.awt.*; -import java.io.IOException; -import java.util.ArrayList; - -public class HudGui extends GuiScreen { - private BasicHud editingHud; - private boolean isDragging; - private boolean isScaling; - private int xOffset; - private int yOffset; - - @Override - public void initGui() { - HudCore.editing = true; - Keyboard.enableRepeatEvents(true); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - Gui.drawRect(0, 0, this.width, this.height, new Color(80, 80, 80, 50).getRGB()); - - if (isDragging) { - setPosition(mouseX - xOffset, mouseY - yOffset, true); - } - - for (BasicHud hud : HudCore.huds) { - processHud(hud, mouseX); - } - } - - private void processHud(BasicHud hud, int mouseX) { - if (hud == editingHud && isScaling) { - float xFloat = hud.getXScaled(this.width); - float yFloat = hud.getYScaled(this.height); - float pos = getXSnapping(mouseX, true); - float newWidth = pos - xFloat; - float newScale = newWidth / ((hud.getWidth(hud.scale) + hud.paddingX * hud.scale) / hud.scale); - if (newScale > 20) - newScale = 20; - else if (newScale < 0.3) - newScale = 0.3f; - hud.scale = newScale; - - if (xFloat / this.width > 0.5) - editingHud.xUnscaled = (xFloat + (hud.getWidth(hud.scale) + hud.paddingX * hud.scale)) / (double) this.width; - if (yFloat / this.height > 0.5) - editingHud.yUnscaled = (yFloat + (hud.getHeight(hud.scale) + hud.paddingY * hud.scale)) / (double) this.height; - } - - int width = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int height = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - int x = (int) hud.getXScaled(this.width); - int y = (int) hud.getYScaled(this.height); - - if (hud.parent == null) - hud.drawExampleAll(x, y, hud.scale, true); - int color = new Color(215, 224, 235).getRGB(); - if (editingHud == hud) { - color = new Color(43, 159, 235).getRGB(); - if (isDragging) - Gui.drawRect(x, y, x + width, y + height, new Color(108, 176, 255, 60).getRGB()); - } - int finalColor = color; - RenderManager.setupAndDraw(true, (vg) -> { - RenderManager.drawLine(vg, x - 2 / 4f, y, x + width + 2 / 4f, y, 1, finalColor); - RenderManager.drawLine(vg, x, y, x, y + height, 1, finalColor); - RenderManager.drawLine(vg, x + width, y, x + width, y + height, 1, finalColor); - RenderManager.drawLine(vg, x - 2 / 4f, y + height, x + width + 2 / 4f, y + height, 1, finalColor); - }); - - if (hud == editingHud && !isDragging) { - RenderManager.setupAndDraw(true, (vg) -> { - RenderManager.drawCircle(vg, x + width, y + height, 3, new Color(43, 159, 235).getRGB()); - }); - } - - if (hud.childBottom != null) processHud(hud.childBottom, mouseX); - if (hud.childRight != null) processHud(hud.childRight, mouseX); - } - - private void setPosition(float newX, float newY, boolean snap) { - float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale; - float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale; - - if (editingHud.childRight != null) { - HudCore.huds.add(editingHud.childRight); - editingHud.childRight.parent = null; - editingHud.childRight = null; - } - if (editingHud.childBottom != null) { - HudCore.huds.add(editingHud.childBottom); - editingHud.childBottom.parent = null; - editingHud.childBottom = null; - } - if (editingHud.parent != null) { - HudCore.huds.add(editingHud); - if (editingHud.parent.childBottom == editingHud) - editingHud.parent.childBottom = null; - else if (editingHud.parent.childRight == editingHud) - editingHud.parent.childRight = null; - editingHud.parent = null; - } - - if (newX < 0) - newX = 0; - else if (newX + width > this.width) - newX = this.width - width; - if (newY < 0) - newY = 0; - else if (newY + height > this.height) - newY = this.height - height; - - if (snap) { - float snapX = getXSnapping(newX, false); - float snapY = getYSnapping(newY); - if (snapX != newX || snapY != newY) { - newX = snapX; - newY = snapY; - for (BasicHud hud : HudCore.huds) { - if (findParent(hud, snapX, snapY)) - break; - } - } - } - - if (newX / this.width <= 0.5) - editingHud.xUnscaled = newX / (double) this.width; - else - editingHud.xUnscaled = (newX + width) / (double) this.width; - if (newY / this.height <= 0.5) - editingHud.yUnscaled = newY / (double) this.height; - else - editingHud.yUnscaled = (newY + height) / (double) this.height; - } - - private boolean findParent(BasicHud hud, float snapX, float snapY) { - int hudWidth = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int hudX = (int) hud.getXScaled(this.width); - int hudHeight = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - int hudY = (int) hud.getYScaled(this.height); - if (hudX + hudWidth == snapX && hudY == snapY && hud.childRight == null) { - editingHud.parent = hud; - hud.childRight = editingHud; - HudCore.huds.remove(editingHud); - return true; - } else if (hudX == snapX && hudY + hudHeight == snapY && hud.childBottom == null) { - editingHud.parent = hud; - hud.childBottom = editingHud; - HudCore.huds.remove(editingHud); - return true; - } - return hud.childRight != null && findParent(hud.childRight, snapX, snapY) || hud.childBottom != null && findParent(hud.childBottom, snapX, snapY); - } - - private float getXSnapping(float pos, boolean rightOnly) { - float width = editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale; - ArrayList verticalLines = new ArrayList<>(); - for (BasicHud hud : HudCore.huds) { - verticalLines.addAll(getXSnappingHud(hud)); - } - getSpaceSnapping(verticalLines); - verticalLines.add(this.width / 2f); - float smallestDiff = -1; - float smallestLine = 0; - float smallestOffset = 0; - for (float lineX : verticalLines) { - for (float offset = 0; offset <= (rightOnly ? 0 : width); offset += width / 2f) { - if (Math.abs(lineX - pos - offset) < 5 && (Math.abs(lineX - pos - offset) < smallestDiff || smallestDiff == -1)) { - smallestDiff = Math.abs(lineX - pos); - smallestLine = lineX; - smallestOffset = offset; - } - } - } - if (smallestDiff != -1) { - RenderManager.drawDottedLine(smallestLine, 0, smallestLine, this.height, 2, 12, new Color(255, 255, 255).getRGB()); - return smallestLine - smallestOffset; - } - return pos; - } - - private ArrayList getXSnappingHud(BasicHud hud) { - ArrayList verticalLines = new ArrayList<>(); - if (hud == editingHud) return verticalLines; - if (hud.childRight != null) verticalLines.addAll(getXSnappingHud(hud.childRight)); - int hudWidth = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int hudX = (int) hud.getXScaled(this.width); - verticalLines.add((float) hudX); - verticalLines.add((float) (hudX + hudWidth)); - return verticalLines; - } - - private float getYSnapping(float pos) { - float height = editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale; - ArrayList horizontalLines = new ArrayList<>(); - for (BasicHud hud : HudCore.huds) { - horizontalLines.addAll(getYSnappingHud(hud)); - } - getSpaceSnapping(horizontalLines); - horizontalLines.add(this.height / 2f); - float smallestDiff = -1; - float smallestLine = 0; - float smallestOffset = 0; - for (float lineY : horizontalLines) { - for (float offset = 0; offset <= height; offset += height / 2f) { - if (Math.abs(lineY - pos - offset) < 5 && (Math.abs(lineY - pos - offset) < smallestDiff || smallestDiff == -1)) { - smallestDiff = Math.abs(lineY - pos); - smallestLine = lineY; - smallestOffset = offset; - } - } - } - if (smallestDiff != -1) { - RenderManager.drawDottedLine(0, smallestLine, this.width, smallestLine, 2, 12, new Color(255, 255, 255).getRGB()); - return smallestLine - smallestOffset; - } - return pos; - } - - private ArrayList getYSnappingHud(BasicHud hud) { - ArrayList horizontalLines = new ArrayList<>(); - if (hud == editingHud) return horizontalLines; - if (hud.childBottom != null) horizontalLines.addAll(getYSnappingHud(hud.childBottom)); - int hudHeight = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - int hudY = (int) hud.getYScaled(this.height); - horizontalLines.add((float) hudY); - horizontalLines.add((float) (hudY + hudHeight)); - return horizontalLines; - } - - private void getSpaceSnapping(ArrayList lines) { - ArrayList newLines = new ArrayList<>(); - for (int i = 0; i < lines.size(); i++) { - for (int l = i + 1; l < lines.size(); l++) { - newLines.add(Math.max(lines.get(i), lines.get(l)) + Math.abs(lines.get(i) - lines.get(l))); - newLines.add(Math.min(lines.get(i), lines.get(l)) - Math.abs(lines.get(i) - lines.get(l))); - } - } - lines.addAll(newLines); - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { - if (mouseButton == 0) { - if (editingHud != null) { - int width = (int) (editingHud.getWidth(editingHud.scale) + editingHud.paddingX * editingHud.scale); - int height = (int) (editingHud.getHeight(editingHud.scale) + editingHud.paddingY * editingHud.scale); - float x = editingHud.getXScaled(this.width); - float y = editingHud.getYScaled(this.height); - if (mouseX >= x + width - 3 && mouseX <= x + width + 3 && mouseY >= y + height - 3 && mouseY <= y + height + 3) { - isScaling = true; - return; - } - } - editingHud = null; - for (BasicHud hud : HudCore.huds) { - if (mouseClickedHud(hud, mouseX, mouseY)) - break; - } - } - } - - private boolean mouseClickedHud(BasicHud hud, int mouseX, int mouseY) { - int width = (int) (hud.getWidth(hud.scale) + hud.paddingX * hud.scale); - int height = (int) (hud.getHeight(hud.scale) + hud.paddingY * hud.scale); - float x = hud.getXScaled(this.width); - float y = hud.getYScaled(this.height); - if (mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height) { - editingHud = hud; - xOffset = (int) (mouseX - x); - yOffset = (int) (mouseY - y); - isDragging = true; - return true; - } - return hud.childBottom != null && mouseClickedHud(hud.childBottom, mouseX, mouseY) || hud.childRight != null && mouseClickedHud(hud.childRight, mouseX, mouseY); - } - - @Override - protected void mouseReleased(int mouseX, int mouseY, int state) { - isDragging = false; - isScaling = false; - } - - @Override - protected void keyTyped(char typedChar, int keyCode) throws IOException { - if (editingHud != null) { - float x = editingHud.getXScaled(this.width); - float y = editingHud.getYScaled(this.height); - switch (keyCode) { - case Keyboard.KEY_UP: - setPosition(x, y - 1, false); - break; - case Keyboard.KEY_DOWN: - setPosition(x, y + 1, false); - break; - case Keyboard.KEY_LEFT: - setPosition(x - 1, y, false); - break; - case Keyboard.KEY_RIGHT: - setPosition(x + 1, y, false); - break; - } - } - super.keyTyped(typedChar, keyCode); - } - - @Override - public void onGuiClosed() { - HudCore.editing = false; - Keyboard.enableRepeatEvents(false); - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } -} \ No newline at end of file diff --git a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java deleted file mode 100644 index 3377f19..0000000 --- a/src/main/java/io/polyfrost/oneconfig/gui/OneConfigGui.java +++ /dev/null @@ -1,234 +0,0 @@ -package io.polyfrost.oneconfig.gui; - -import io.polyfrost.oneconfig.config.OneConfigConfig; -import io.polyfrost.oneconfig.gui.elements.BasicElement; -import io.polyfrost.oneconfig.gui.elements.ColorSelector; -import io.polyfrost.oneconfig.gui.elements.TextInputField; -import io.polyfrost.oneconfig.gui.pages.HomePage; -import io.polyfrost.oneconfig.gui.pages.Page; -import io.polyfrost.oneconfig.lwjgl.RenderManager; -import io.polyfrost.oneconfig.lwjgl.Scissor; -import io.polyfrost.oneconfig.lwjgl.ScissorManager; -import io.polyfrost.oneconfig.lwjgl.font.Fonts; -import io.polyfrost.oneconfig.lwjgl.image.Images; -import io.polyfrost.oneconfig.utils.InputUtils; -import io.polyfrost.oneconfig.utils.MathUtils; -import net.minecraft.client.gui.GuiScreen; -import org.jetbrains.annotations.NotNull; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.nanovg.NanoVG; - -import java.awt.*; -import java.util.ArrayList; - -import static org.lwjgl.nanovg.NanoVG.nvgResetScissor; -import static org.lwjgl.nanovg.NanoVG.nvgScissor; - -public class OneConfigGui extends GuiScreen { - public static OneConfigGui INSTANCE; - public final int x = 320; - public final int y = 140; - private final SideBar sideBar = new SideBar(); - protected Page currentPage; - protected Page prevPage; - private float pageProgress = -224f; - private final TextInputField textInputField = new TextInputField(248, 40, "Search all of OneConfig...", false, false); - private final ArrayList previousPages = new ArrayList<>(); - private final ArrayList nextPages = new ArrayList<>(); - private final BasicElement backArrow = new BasicElement(40, 40, -1, false); - private final BasicElement forwardArrow = new BasicElement(40, 40, -1, false); - private final ArrayList parents = new ArrayList<>(); - private ColorSelector currentColorSelector; - public boolean mouseDown; - - public OneConfigGui() { - INSTANCE = this; - } - - public OneConfigGui(Page page) { - INSTANCE = this; - currentPage = page; - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawScreen(mouseX, mouseY, partialTicks); - long start = System.nanoTime(); - RenderManager.setupAndDraw((vg) -> { - if (currentPage == null) { - currentPage = new HomePage(); - parents.add(currentPage); - } - //nvgScale(vg, 0.5f, 0.5f); - if (OneConfigConfig.ROUNDE