From c79dc3cf7b3750aa03fb33a07b4af044b37f9407 Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sat, 6 Aug 2022 19:56:02 +0900 Subject: new: add forge config button compat (#80) --- .../polyfrost/oneconfig/gui/elements/ModCard.java | 11 +++++++- .../config/compatibility/forge/ForgeCompat.java | 31 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/forge/ForgeCompat.java (limited to 'src/main') 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 ffac8e3..841a157 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java @@ -8,6 +8,7 @@ import cc.polyfrost.oneconfig.gui.pages.ModsPage; import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.internal.config.OneConfigConfig; +import cc.polyfrost.oneconfig.internal.config.compatibility.forge.ForgeCompat; import cc.polyfrost.oneconfig.internal.config.core.ConfigCore; import cc.polyfrost.oneconfig.platform.Platform; import cc.polyfrost.oneconfig.renderer.RenderManager; @@ -92,8 +93,16 @@ public class ModCard extends BasicElement { } public void onClick() { - if (isHoveredMain) + if (isHoveredMain) { + if (modData instanceof ForgeCompat.ForgeCompatMod) { + Runnable runnable = ForgeCompat.compatMods.get(modData); + if (runnable != null) { + runnable.run(); + return; + } + } OneConfigGui.INSTANCE.openPage(new ModConfigPage(modData.defaultPage)); + } } public Mod getModData() { diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/forge/ForgeCompat.java b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/forge/ForgeCompat.java new file mode 100644 index 0000000..fc5ca5e --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/internal/config/compatibility/forge/ForgeCompat.java @@ -0,0 +1,31 @@ +package cc.polyfrost.oneconfig.internal.config.compatibility.forge; + +import cc.polyfrost.oneconfig.config.data.Mod; +import cc.polyfrost.oneconfig.config.data.ModType; +import cc.polyfrost.oneconfig.config.migration.Migrator; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; + +public class ForgeCompat { + public static final HashMap compatMods = new HashMap<>(); + + public static class ForgeCompatMod extends Mod { + + public ForgeCompatMod(String name, ModType modType, @Nullable String modIcon, @Nullable Migrator migrator) { + super(name, modType, modIcon, migrator); + } + + public ForgeCompatMod(String name, ModType modType, @Nullable String modIcon) { + super(name, modType, modIcon); + } + + public ForgeCompatMod(String name, ModType modType, @Nullable Migrator migrator) { + super(name, modType, migrator); + } + + public ForgeCompatMod(String name, ModType modType) { + super(name, modType); + } + } +} -- cgit