diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-05-23 18:05:14 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-05-23 18:05:14 +0200 |
commit | a086a98cff6d5b327477fe7846495f1d392feebd (patch) | |
tree | 18f52aab6777c27a0e623921f863efb1c50fdb80 /src/main/java | |
parent | cc30afc4eb515c93b0d763e4347bee628c007372 (diff) | |
download | OneConfig-a086a98cff6d5b327477fe7846495f1d392feebd.tar.gz OneConfig-a086a98cff6d5b327477fe7846495f1d392feebd.tar.bz2 OneConfig-a086a98cff6d5b327477fe7846495f1d392feebd.zip |
OC-23 some things
Diffstat (limited to 'src/main/java')
9 files changed, 35 insertions, 34 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java index 8812894..e612be7 100644 --- a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java @@ -72,11 +72,10 @@ public class OneConfig { 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.THIRD_PARTY, author, metadata.version); + String imageName = Loader.instance().activeModContainer() == null || Loader.instance().activeModContainer().getMetadata().logoFile.trim().equals("") ? null : "/" + Loader.instance().activeModContainer().getMetadata().logoFile; + Mod newMod = new Mod(metadata.name, ModType.THIRD_PARTY, imageName); newMod.isShortCut = true; - if (mod instanceof DummyModContainer || newMod.name.equals("OneConfig")) - continue; + if (mod instanceof DummyModContainer || newMod.name.equals("OneConfig")) continue; if (modData.add(newMod)) loadedMods.add(newMod); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java index a5ac1f6..f31b609 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java @@ -130,25 +130,28 @@ public class VigilanceConfig extends Config { private String getName(PropertyAttributesExt ext) { try { + PropertyAttributesExt.class.getDeclaredField("i18nName").setAccessible(true); return I18n.format((String) PropertyAttributesExt.class.getDeclaredField("i18nName").get(ext)); } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); + return ext.getName(); } } private String getCategory(PropertyAttributesExt ext) { try { + PropertyAttributesExt.class.getDeclaredField("i18nCategory").setAccessible(true); return I18n.format((String) PropertyAttributesExt.class.getDeclaredField("i18nCategory").get(ext)); } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); + return ext.getCategory(); } } private String getSubcategory(PropertyAttributesExt ext) { try { + PropertyAttributesExt.class.getDeclaredField("i18nSubcategory").setAccessible(true); return I18n.format((String) PropertyAttributesExt.class.getDeclaredField("i18nSubcategory").get(ext)); } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); + return ext.getSubcategory(); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java b/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java index c7e86cd..da069c5 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java @@ -1,38 +1,36 @@ package cc.polyfrost.oneconfig.config.data; import cc.polyfrost.oneconfig.config.interfaces.Config; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Objects; public class Mod { public final String name; public final ModType modType; - public final String creator; - public final String version; + public final String modIcon; public Config config; public final OptionPage defaultPage; public boolean isShortCut = false; - private static final ArrayList<Mod> mods = new ArrayList<>(); /** * @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 + * @param modIcon path to icon of the mod (png or svg format) */ - public Mod(String name, ModType modType, String creator, String version) { - int i = 1; - for (Mod mod : mods) { - if (mod.name.startsWith(name)) { - ++i; - name = name + " " + i; - } - } + public Mod(String name, ModType modType, @Nullable String modIcon) { this.name = name; this.modType = modType; - this.creator = creator; - this.version = version; + this.modIcon = modIcon; this.defaultPage = new OptionPage(name, this); - mods.add(this); + } + + /** + * @param name Friendly name of the mod + * @param modType Type of the mod (for example ModType.QOL) + */ + public Mod(String name, ModType modType) { + this(name, modType, null); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 3bfcc74..73453ed 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -84,7 +84,6 @@ public class OneConfigGui extends UScreen { int y = (int) ((UResolution.getWindowHeight() - 800 * scale) / 2f / scale); RenderManager.scale(vg, scale, scale); if (OneConfigConfig.ROUNDED_CORNERS) { - // TODO: Fix issue with white surroundings, related to font rendering RenderManager.drawDropShadow(vg, x, y, 1280, 800, 32, 16, 20); RenderManager.drawRoundedRect(vg, x + 224, y, 1056, 800, OneConfigConfig.GRAY_800, OneConfigConfig.CORNER_RADIUS_WIN); RenderManager.drawRoundedRect(vg, x, y, 244, 800, OneConfigConfig.GRAY_900_80, OneConfigConfig.CORNER_RADIUS_WIN); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java index d11956d..5853585 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java @@ -19,7 +19,6 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; public class ModCard extends BasicElement { - private final String iconPath; private final Mod modData; private final BasicElement favoriteHitbox = new BasicElement(32, 32, -2, true); private boolean active, disabled, favorite; @@ -27,10 +26,9 @@ public class ModCard extends BasicElement { private int colorPrimary = OneConfigConfig.PRIMARY_600; private boolean isHoveredMain = false; - public ModCard(@NotNull Mod mod, @Nullable String iconPath, boolean active, boolean disabled, boolean favorite) { + public ModCard(@NotNull Mod mod, boolean active, boolean disabled, boolean favorite) { super(244, 119, false); this.modData = mod; - this.iconPath = iconPath; this.active = active; toggled = active; this.disabled = disabled; @@ -45,8 +43,10 @@ public class ModCard extends BasicElement { RenderManager.drawRoundedRectVaried(vg, x, y, width, 87, colorGray, 12f, 12f, 0f, 0f); RenderManager.drawRoundedRectVaried(vg, x, y + 87, width, 32, colorPrimary, 0f, 0f, 12f, 12f); RenderManager.drawLine(vg, x, y + 86, x + width, y + 86, 2, OneConfigConfig.GRAY_300); - if (iconPath != null) { - RenderManager.drawImage(vg, iconPath, x, y, width, 87); + if (modData.modIcon != null) { + if (modData.modIcon.toLowerCase().endsWith(".svg")) + RenderManager.drawSvg(vg, modData.modIcon, x + 98, y + 19, 48, 48); + else RenderManager.drawImage(vg, modData.modIcon, x + 98, y + 19, 48, 48); } else { RenderManager.drawSvg(vg, SVGs.BOX, x + 98, y + 19, 48, 48); } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java index 4be79c4..5ecaa9e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigColorElement.java @@ -74,7 +74,7 @@ public class ConfigColorElement extends BasicOption { if (element.isClicked() && !element.isToggled()) { OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY())); } - if(OneConfigGui.INSTANCE.currentColorSelector != null) { + if (OneConfigGui.INSTANCE != null && OneConfigGui.INSTANCE.currentColorSelector != null) { color = (OneConfigGui.INSTANCE.getColor()); } setColor(color); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java index cd46797..4cd1a32 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java @@ -22,7 +22,7 @@ public class ModsPage extends Page { public ModsPage() { super("Mods"); for (Mod modData : OneConfig.loadedMods) { - modCards.add(OneConfigConfig.favoriteMods.contains(modData.name) ? 0 : modCards.size(), new ModCard(modData, null, modData.config == null || modData.config.enabled, false, OneConfigConfig.favoriteMods.contains(modData.name))); + modCards.add(OneConfigConfig.favoriteMods.contains(modData.name) ? 0 : modCards.size(), new ModCard(modData, modData.config == null || modData.config.enabled, false, OneConfigConfig.favoriteMods.contains(modData.name))); } modCategories.add(new BasicButton(64, 32, "All", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(0))); modCategories.add(new BasicButton(80, 32, "Combat", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(1))); @@ -30,7 +30,7 @@ public class ModsPage extends Page { modCategories.add(new BasicButton(104, 32, "Utility & QoL", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(3))); modCategories.add(new BasicButton(80, 32, "Hypixel", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(4))); modCategories.add(new BasicButton(80, 32, "Skyblock", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(5))); - modCategories.add(new BasicButton(88, 32, "3rd Party", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(7))); + modCategories.add(new BasicButton(88, 32, "3rd Party", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(6))); modCategories.get(0).setToggled(true); } diff --git a/src/main/java/cc/polyfrost/oneconfig/plugin/asm/tweakers/VigilantTransformer.java b/src/main/java/cc/polyfrost/oneconfig/plugin/asm/tweakers/VigilantTransformer.java index 732db97..45dc1e2 100644 --- a/src/main/java/cc/polyfrost/oneconfig/plugin/asm/tweakers/VigilantTransformer.java +++ b/src/main/java/cc/polyfrost/oneconfig/plugin/asm/tweakers/VigilantTransformer.java @@ -93,11 +93,12 @@ public class VigilantTransformer implements ITransformer { public static VigilanceConfig returnNewConfig(Vigilant vigilant, File file) { if (vigilant != null && Minecraft.getMinecraft().isCallingFromMinecraftThread()) { String name = !vigilant.getGuiTitle().equals("Settings") ? vigilant.getGuiTitle() : Loader.instance().activeModContainer() == null ? "Unknown" : Loader.instance().activeModContainer().getName(); + String imageName = Loader.instance().activeModContainer() == null || Loader.instance().activeModContainer().getMetadata().logoFile.trim().equals("") ? null : "/" + Loader.instance().activeModContainer().getMetadata().logoFile; if (name.equals("OneConfig")) name = "Essential"; String finalName = name; // duplicate fix if (ConfigCore.oneConfigMods.stream().anyMatch(mod -> mod.name.equals(finalName))) return null; - return new VigilanceConfig(new Mod(name, ModType.THIRD_PARTY, Loader.instance().activeModContainer() == null ? "Unknown" : Loader.instance().activeModContainer().getName(), Loader.instance().activeModContainer() == null ? "1.0.0" : Loader.instance().activeModContainer().getVersion()), file.getAbsolutePath(), vigilant); + return new VigilanceConfig(new Mod(name, ModType.THIRD_PARTY, imageName), file.getAbsolutePath(), vigilant); } else { return null; } diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java index d65fea3..e8aad07 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestConfig.java @@ -6,6 +6,7 @@ import cc.polyfrost.oneconfig.config.core.OneKeyBind; import cc.polyfrost.oneconfig.config.data.*; import cc.polyfrost.oneconfig.config.interfaces.Config; import cc.polyfrost.oneconfig.config.core.OneColor; +import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import net.minecraftforge.fml.common.FMLCommonHandler; public class TestConfig extends Config { @@ -325,7 +326,7 @@ public class TestConfig extends Config { public TestConfig() { - super(new Mod("hacks", ModType.UTIL_QOL, "ShadyDev", "1.0"), "hacksConfig.json"); + super(new Mod("hacks", ModType.UTIL_QOL, SVGs.CASH_DOLLAR.filePath), "hacksConfig.json"); addDependency("switchTest5", () -> switchTest4); addDependency("Test page.testDescription", () -> false); } |