diff options
Diffstat (limited to 'src/main/java')
49 files changed, 579 insertions, 208 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java index 3661c42..8812894 100644 --- a/src/main/java/cc/polyfrost/oneconfig/OneConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/OneConfig.java @@ -28,8 +28,8 @@ import java.util.List; @net.minecraftforge.fml.common.Mod(modid = "@ID@", name = "@NAME@", version = "@VER@") public class OneConfig { public static File jarFile; - public static File oneConfigDir = new File("./OneConfig/"); - public static File themesDir = new File(oneConfigDir, "themes/"); + public static File oneConfigDir = new File("./OneConfig"); + public static File themesDir = new File(oneConfigDir, "themes"); public static OneConfigConfig config; public static TestConfig testConfig; public static List<Mod> loadedMods = new ArrayList<>(); diff --git a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java index f21e569..fac2112 100644 --- a/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java +++ b/src/main/java/cc/polyfrost/oneconfig/command/OneConfigCommand.java @@ -4,7 +4,7 @@ import cc.polyfrost.oneconfig.gui.HudGui; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.test.TestNanoVGGui; import cc.polyfrost.oneconfig.utils.TickDelay; -import gg.essential.universal.UScreen; +import cc.polyfrost.oneconfig.libs.universal.UScreen; import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandSender; diff --git a/src/main/java/cc/polyfrost/oneconfig/config/OneConfigConfig.java b/src/main/java/cc/polyfrost/oneconfig/config/OneConfigConfig.java index a590536..407afdf 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/OneConfigConfig.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/OneConfigConfig.java @@ -89,7 +89,7 @@ public class OneConfigConfig extends Config { @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()); + deserializePart(new JsonParser().parse(reader).getAsJsonObject(), this); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java new file mode 100644 index 0000000..14d1e72 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilanceConfig.java @@ -0,0 +1,135 @@ +package cc.polyfrost.oneconfig.config.compatibility; + +import cc.polyfrost.oneconfig.config.core.ConfigCore; +import cc.polyfrost.oneconfig.config.data.Mod; +import cc.polyfrost.oneconfig.config.data.OptionCategory; +import cc.polyfrost.oneconfig.config.data.OptionPage; +import cc.polyfrost.oneconfig.config.data.OptionSubcategory; +import cc.polyfrost.oneconfig.config.interfaces.BasicOption; +import cc.polyfrost.oneconfig.config.interfaces.Config; +import cc.polyfrost.oneconfig.gui.elements.config.*; +import gg.essential.vigilance.Vigilant; +import gg.essential.vigilance.data.*; +import kotlin.reflect.KMutableProperty0; +import kotlin.reflect.jvm.ReflectJvmMapping; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Objects; + +public class VigilanceConfig extends Config { + public final Vigilant vigilant; + + public VigilanceConfig(Mod modData, String configFile, Vigilant vigilant) { + super(modData, configFile); + this.vigilant = vigilant; + init(modData); + } + + @Override + public void init(Mod mod) { + if (vigilant != null) { + mod.config = this; + generateOptionsList(mod.defaultPage); + ConfigCore.oneConfigMods.add(mod); + this.mod = mod; + } + } + + @Override + public void save() { + vigilant.markDirty(); + vigilant.writeData(); + } + + @Override + public void load() { + //no-op + } + + private void generateOptionsList(OptionPage page) { + for (PropertyData option : ((VigilantAccessor) vigilant).getPropertyCollector().getProperties()) { + PropertyAttributesExt attributes = option.getAttributesExt(); + if (attributes.getHidden()) continue; + if (!page.categories.containsKey(attributes.getCategory())) + page.categories.put(attributes.getCategory(), new OptionCategory()); + OptionCategory category = page.categories.get(attributes.getCategory()); + if (category.subcategories.size() == 0 || !category.subcategories.get(category.subcategories.size() - 1).getName().equals(attributes.getSubcategory())) + category.subcategories.add(new OptionSubcategory(attributes.getSubcategory())); + ArrayList<BasicOption> options = category.subcategories.get(category.subcategories.size() - 1).options; + switch (attributes.getType()) { + case SWITCH: + options.add(new ConfigSwitch(getFieldOfProperty(option), option.getInstance(), attributes.getName(), 2)); + break; + case CHECKBOX: + options.add(new ConfigCheckbox(getFieldOfProperty(option), option.getInstance(), attributes.getName(), 2)); + break; + case PARAGRAPH: + case TEXT: + options.add(new ConfigTextBox(getFieldOfProperty(option), option.getInstance(), attributes.getName(), 2, attributes.getPlaceholder(), attributes.getProtected(), attributes.getType() == PropertyType.PARAGRAPH)); + break; + case SELECTOR: + options.add(new ConfigDropdown(getFieldOfProperty(option), option.getInstance(), attributes.getName(), 2, attributes.getOptions().toArray(new String[0]))); + break; + case PERCENT_SLIDER: + options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), attributes.getName(), 2, 0, 1, 0)); + break; + case DECIMAL_SLIDER: + options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), attributes.getName(), 2, attributes.getMinF(), attributes.getMaxF(), 0)); + break; + case SLIDER: + options.add(new ConfigSlider(getFieldOfProperty(option), option.getInstance(), attributes.getName(), 2, attributes.getMin(), attributes.getMax(), 0)); + break; + /*case COLOR: TODO: find a way to go from Color to OneColor + options.add(new ConfigColorElement(getFieldOfProperty(option), option.getInstance(), attributes.getName(), 2)); + break;*/ + case BUTTON: + options.add(new ConfigButton(() -> ((CallablePropertyValue) option.getValue()).invoke(option.getInstance()), option.getInstance(), attributes.getName(), 2, attributes.getPlaceholder())); + break; + } + if (attributes.getType() == PropertyType.SWITCH || attributes.getType() == PropertyType.CHECKBOX) { + optionNames.put(PropertyKt.fullPropertyPath(option.getAttributesExt()), options.get(options.size() - 1)); + } + } + } + + private Field getFieldOfProperty(PropertyData data) { + if (data.getValue() instanceof FieldBackedPropertyValue) { + FieldBackedPropertyValue fieldBackedPropertyValue = (FieldBackedPropertyValue) data.getValue(); + try { + Field field = fieldBackedPropertyValue.getClass().getDeclaredField("field"); + field.setAccessible(true); + return (Field) field.get(fieldBackedPropertyValue); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } else if (data.getValue() instanceof ValueBackedPropertyValue) { + ValueBackedPropertyValue valueBackedPropertyValue = (ValueBackedPropertyValue) data.getValue(); + try { + Field field = valueBackedPropertyValue.getClass().getDeclaredField("obj"); + field.setAccessible(true); + return (Field) field.get(valueBackedPropertyValue); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } else if (data.getValue() instanceof KPropertyBackedPropertyValue) { + KPropertyBackedPropertyValue kPropertyBackedPropertyValue = (KPropertyBackedPropertyValue) data.getValue(); + try { + Field field = kPropertyBackedPropertyValue.getClass().getDeclaredField("property"); + field.setAccessible(true); + KMutableProperty0 property = (KMutableProperty0) field.get(kPropertyBackedPropertyValue); + return ReflectJvmMapping.getJavaField(property); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } else throw new RuntimeException("Unknown property value type: " + data.getValue().getClass()); + } + + @SuppressWarnings("unused") + public void addDependency(PropertyData property, PropertyData dependency) { + BasicOption option = optionNames.get(PropertyKt.fullPropertyPath(property.getAttributesExt())); + if (option != null) { + option.setDependency(() -> Objects.equals(dependency.getValue().getValue(vigilant), true)); + } + } +} diff --git a/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilantAccessor.java b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilantAccessor.java new file mode 100644 index 0000000..4c79a21 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/config/compatibility/VigilantAccessor.java @@ -0,0 +1,7 @@ +package cc.polyfrost.oneconfig.config.compatibility; + +import gg.essential.vigilance.data.PropertyCollector; + +public interface VigilantAccessor { + PropertyCollector getPropertyCollector(); +} diff --git a/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java index d455411..d62247c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/core/OneKeyBind.java @@ -1,6 +1,6 @@ package cc.polyfrost.oneconfig.config.core; -import gg.essential.universal.UKeyboard; +import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import java.util.ArrayList; 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 e38c062..c7e86cd 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/data/Mod.java @@ -2,6 +2,8 @@ package cc.polyfrost.oneconfig.config.data; import cc.polyfrost.oneconfig.config.interfaces.Config; +import java.util.ArrayList; + public class Mod { public final String name; public final ModType modType; @@ -10,6 +12,7 @@ public class Mod { 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 @@ -18,10 +21,18 @@ public class Mod { * @param version Version of the mod */ 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; + } + } this.name = name; this.modType = modType; this.creator = creator; this.version = version; this.defaultPage = new OptionPage(name, this); + mods.add(this); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java index 694404a..49d2049 100644 --- a/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java +++ b/src/main/java/cc/polyfrost/oneconfig/config/interfaces/Config.java @@ -10,9 +10,8 @@ import cc.polyfrost.oneconfig.gui.elements.config.*; import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; import cc.polyfrost.oneconfig.hud.BasicHud; import cc.polyfrost.oneconfig.hud.HudCore; -import cc.polyfrost.oneconfig.lwjgl.RenderManager; import com.google.gson.*; -import gg.essential.universal.UScreen; +import cc.polyfrost.oneconfig.libs.universal.UScreen; import java.io.*; import java.lang.reflect.Field; @@ -20,14 +19,13 @@ import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.*; -import java.util.function.Consumer; import java.util.function.Supplier; public class Config { transient protected final String configFile; transient protected final Gson gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).setPrettyPrinting().create(); - transient private Mod mod; - final transient private HashMap<String, BasicOption> optionNames = new HashMap<>(); + transient public Mod mod; + public final transient HashMap<String, BasicOption> optionNames = new HashMap<>(); public boolean enabled = true; /** @@ -35,8 +33,17 @@ public class Config { * @param configFile file where config is stored */ public Config(Mod modData, String configFile) { + this(modData, configFile, true); + } + + /** + * @param modData information about the mod + * @param configFile file where config is stored + * @param initialize whether to load the config immediately or not + */ + public Config(Mod modData, String configFile, boolean initialize) { this.configFile = configFile; - init(modData); + if (initialize) init(modData); } public void init(Mod mod) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java index e81fb86..4595725 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/HudGui.java @@ -4,9 +4,9 @@ import cc.polyfrost.oneconfig.config.core.ConfigCore; import cc.polyfrost.oneconfig.hud.BasicHud; import cc.polyfrost.oneconfig.hud.HudCore; import cc.polyfrost.oneconfig.lwjgl.RenderManager; -import gg.essential.universal.UKeyboard; -import gg.essential.universal.UMatrixStack; -import gg.essential.universal.UScreen; +import cc.polyfrost.oneconfig.libs.universal.UKeyboard; +import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; +import cc.polyfrost.oneconfig.libs.universal.UScreen; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java index 66bc2cd..d0e0625 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/OneConfigGui.java @@ -14,11 +14,10 @@ import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; -import gg.essential.universal.*; +import cc.polyfrost.oneconfig.libs.universal.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.lwjgl.input.Mouse; -import org.lwjgl.nanovg.NanoVG; import java.util.ArrayList; @@ -82,7 +81,7 @@ public class OneConfigGui extends UScreen { scale = Math.min(Math.min(1f, UResolution.getWindowWidth() / 1280f), Math.min(1f, UResolution.getWindowHeight() / 800f)); int x = (int) ((UResolution.getWindowWidth() - 1280 * scale) / 2f / scale); int y = (int) ((UResolution.getWindowHeight() - 800 * scale) / 2f / scale); - NanoVG.nvgScale(vg, scale, scale); + RenderManager.scale(vg, scale, scale); if (OneConfigConfig.ROUNDED_CORNERS) { 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); @@ -103,22 +102,22 @@ public class OneConfigGui extends UScreen { if (previousPages.size() == 0) { backArrow.disable(true); - NanoVG.nvgGlobalAlpha(vg, 0.5f); + RenderManager.withAlpha(vg, 0.5f); } else { backArrow.disable(false); - if (!backArrow.isHovered() || Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); + if (!backArrow.isHovered() || Mouse.isButtonDown(0)) RenderManager.withAlpha(vg, 0.8f); } RenderManager.drawSvg(vg, SVGs.ARROW_CIRCLE_LEFT, x + 249, y + 25, 22, 22); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); if (nextPages.size() == 0) { forwardArrow.disable(true); - NanoVG.nvgGlobalAlpha(vg, 0.5f); + RenderManager.withAlpha(vg, 0.5f); } else { forwardArrow.disable(false); - if (!forwardArrow.isHovered() || Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); + if (!forwardArrow.isHovered() || Mouse.isButtonDown(0)) RenderManager.withAlpha(vg, 0.8f); } RenderManager.drawSvg(vg, SVGs.ARROW_CIRCLE_RIGHT, x + 289, y + 25, 22, 22); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); if (backArrow.isClicked() && previousPages.size() > 0) { try { @@ -138,7 +137,7 @@ public class OneConfigGui extends UScreen { Scissor scissor = ScissorManager.scissor(vg, x + 224, y + 88, 1056, 698); if (prevPage != null) { - pageProgress = MathUtils.easeInOutCirc(50, pageProgress, 832 - pageProgress, 600); + pageProgress = MathUtils.easeInOutCirc(50, pageProgress, 832 - pageProgress, 600, deltaTime); prevPage.scrollWithDraw(vg, (int) (x - pageProgress), y + 72); RenderManager.drawLine(vg, (int) (x - pageProgress + 1055), y + 72, (int) (x - pageProgress + 1057), y + 800, 2, OneConfigConfig.GRAY_700); // TODO might remove this currentPage.scrollWithDraw(vg, (int) (x - pageProgress + 1056), y + 72); @@ -225,7 +224,7 @@ public class OneConfigGui extends UScreen { /** * initialize a new ColorSelector and add it to the draw script. This method is used to make sure it is always rendered on top. * - * @implNote Correct usage: <code>OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY()));</code> + * Correct usage: <code>OneConfigGui.INSTANCE.initColorSelector(new ColorSelector(color, InputUtils.mouseX(), InputUtils.mouseY()));</code> */ public void initColorSelector(ColorSelector colorSelector) { currentColorSelector = colorSelector; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java index 059e69d..11e9c6e 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/SideBar.java @@ -6,10 +6,9 @@ import cc.polyfrost.oneconfig.gui.pages.HomePage; import cc.polyfrost.oneconfig.gui.pages.ModsPage; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.MathUtils; -import gg.essential.universal.UScreen; +import cc.polyfrost.oneconfig.libs.universal.UScreen; import java.util.ArrayList; import java.util.List; @@ -38,7 +37,7 @@ public class SideBar { } public void draw(long vg, int x, int y) { - currentY = MathUtils.easeInOutCirc(50, currentY, targetY - currentY, 400); + currentY = MathUtils.easeInOutCirc(50, currentY, targetY - currentY, 400, OneConfigGui.INSTANCE.getDeltaTime()); RenderManager.drawRoundedRect(vg, x + 16, y + currentY, 192, 36, OneConfigConfig.BLUE_600, OneConfigConfig.CORNER_RADIUS); int i = 0; if (targetY == 0) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java index 07c4a04..bcfebd3 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/BasicElement.java @@ -1,5 +1,6 @@ package cc.polyfrost.oneconfig.gui.elements; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java index dc257a8..3b37b53 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -129,7 +129,7 @@ public class ColorSelector { } i += 128; } - percentMove = MathUtils.easeOut(percentMove, mode, 100f); + percentMove = MathUtils.easeOut(percentMove, mode, 100f, OneConfigGui.INSTANCE.getDeltaTime()); RenderManager.drawString(vg, "HSB Box", x + 55, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); RenderManager.drawString(vg, "Color Wheel", x + 172.5f, y + 81, OneConfigConfig.WHITE, 12f, Fonts.MEDIUM); 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 4942f9f..9518579 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ModCard.java @@ -8,16 +8,14 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; -import gg.essential.universal.wrappers.UPlayer; +import cc.polyfrost.oneconfig.libs.universal.wrappers.UPlayer; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.fml.common.ModMetadata; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.lwjgl.nanovg.NanoVG; import java.util.ArrayList; @@ -44,7 +42,7 @@ public class ModCard extends BasicElement { @Override public void draw(long vg, int x, int y) { - if (disabled) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (disabled) RenderManager.withAlpha(vg, 0.5f); 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); @@ -80,15 +78,16 @@ public class ModCard extends BasicElement { if (!active & disabled) toggled = false; active = toggled; - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } public void onClick() { if (isHoveredMain) { for (Mod data : OneConfig.loadedMods) { - if (data.modType != ModType.THIRD_PARTY) { + if (!data.isShortCut) { if (data.name.equalsIgnoreCase(modData.name)) { OneConfigGui.INSTANCE.openPage(new ModConfigPage(data.defaultPage)); + return; } } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java index 2e8cb4f..d2a996d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigButton.java @@ -5,36 +5,43 @@ import cc.polyfrost.oneconfig.config.interfaces.BasicOption; import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import org.lwjgl.nanovg.NanoVG; import java.lang.reflect.Field; public class ConfigButton extends BasicOption { private final BasicButton button; + public ConfigButton(Runnable runnable, Object parent, String name, int size, String text) { + super(null, parent, name, size); + this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, null, null, 1, BasicButton.ALIGNMENT_CENTER, runnable); + } + public ConfigButton(Field field, Object parent, String name, int size, String text) { super(field, parent, name, size); - Runnable runnable = () -> { - }; - try { - runnable = (Runnable) get(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, null, null, 1, BasicButton.ALIGNMENT_CENTER, runnable); + this.button = new BasicButton(size == 1 ? 128 : 256, 32, text, null, null, 1, BasicButton.ALIGNMENT_CENTER, getRunnableFromField(field, parent)); } @Override public void draw(long vg, int x, int y) { button.disable(!isEnabled()); - if(!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if(!isEnabled()) RenderManager.withAlpha(vg, 0.5f); RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); button.draw(vg, x + (size == 1 ? 352 : 736), y); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } @Override public int getHeight() { return 32; } + + private static Runnable getRunnableFromField(Field field, Object parent) { + Runnable runnable = () -> {}; + try { + runnable = (Runnable) field.get(parent); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return runnable; + } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java index 36cd13f..4c864ec 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigCheckbox.java @@ -2,14 +2,13 @@ package cc.polyfrost.oneconfig.gui.elements.config; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; -import org.lwjgl.nanovg.NanoVG; import java.awt.*; import java.lang.reflect.Field; @@ -24,7 +23,7 @@ public class ConfigCheckbox extends BasicOption { @Override public void draw(long vg, int x, int y) { - if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (!isEnabled()) RenderManager.withAlpha(vg, 0.5f); boolean toggled = false; try { toggled = (boolean) get(); @@ -48,7 +47,7 @@ public class ConfigCheckbox extends BasicOption { RenderManager.drawHollowRoundRect(vg, x, y + 4, 23.5f, 23.5f, OneConfigConfig.GRAY_300, 6f, 1f); // the 0.5f is to make it look better ok } RenderManager.drawString(vg, name, x + 32, y + 17, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); - percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 50f)); + percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 50f, OneConfigGui.INSTANCE.getDeltaTime())); if (percentOn != 0 && percentOn != 1f) { RenderManager.drawRoundedRect(vg, x, y + 4, 24, 24, ColorUtils.setAlpha(OneConfigConfig.BLUE_500, (int) (percentOn * 255)), 6f); RenderManager.drawSvg(vg, SVGs.CHECKBOX_TICK, x, y + 4, 24, 24, new Color(1f, 1f, 1f, percentOn).getRGB()); @@ -57,7 +56,7 @@ public class ConfigCheckbox extends BasicOption { RenderManager.drawSvg(vg, SVGs.CHECKBOX_TICK, x, y + 4, 24, 24); } if(percentOn != 0 && hover) RenderManager.drawHollowRoundRect(vg, x - 1, y + 3, 24, 24, OneConfigConfig.BLUE_600, 6f, 2f); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java index f6041c9..d39566d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDropdown.java @@ -2,14 +2,13 @@ package cc.polyfrost.oneconfig.gui.elements.config; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import org.lwjgl.input.Mouse; -import org.lwjgl.nanovg.NanoVG; import java.awt.*; import java.lang.reflect.Field; @@ -27,7 +26,7 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f @Override public void draw(long vg, int x, int y) { - if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (!isEnabled()) RenderManager.withAlpha(vg, 0.5f); RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); boolean hovered; @@ -49,7 +48,7 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f } catch (IllegalAccessException ignored) { } - if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); + if (hovered && Mouse.isButtonDown(0)) RenderManager.withAlpha(vg, 0.8f); if (size == 1) { RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, backgroundColor, 12); RenderManager.drawString(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); @@ -61,7 +60,7 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 964, y + 4, 24, 24); } - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } @Override @@ -79,15 +78,15 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f } catch (IllegalAccessException ignored) { } - if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); + if (hovered && Mouse.isButtonDown(0)) RenderManager.withAlpha(vg, 0.8f); if (size == 1) { RenderManager.drawRoundedRect(vg, x + 224, y, 256, 32, backgroundColor, 12); RenderManager.drawString(vg, options[selected], x + 236, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); - if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); + if (hovered && Mouse.isButtonDown(0)) RenderManager.withAlpha(vg, 0.8f); RenderManager.drawRoundedRect(vg, x + 452, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 452, y + 4, 24, 24); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); RenderManager.drawRoundedRect(vg, x + 224, y + 48, 256, options.length * 32 + 8, OneConfigConfig.GRAY_700, 12); RenderManager.drawHollowRoundRect(vg, x + 223, y + 47, 258, options.length * 32 + 10, new Color(204, 204, 204, 77).getRGB(), 12, 1); int optionY = y + 52; @@ -115,11 +114,11 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f } else { RenderManager.drawRoundedRect(vg, x + 352, y, 640, 32, backgroundColor, 12); RenderManager.drawString(vg, options[selected], x + 364, y + 16, OneConfigConfig.WHITE_80, 14f, Fonts.MEDIUM); - if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); + if (hovered && Mouse.isButtonDown(0)) RenderManager.withAlpha(vg, 0.8f); RenderManager.drawRoundedRect(vg, x + 964, y + 4, 24, 24, OneConfigConfig.BLUE_600, 8); RenderManager.drawSvg(vg, SVGs.DROPDOWN_LIST, x + 964, y + 4, 24, 24); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); RenderManager.drawRoundedRect(vg, x + 352, y + 48, 640, options.length * 32 + 8, OneConfigConfig.GRAY_700, 12); RenderManager.drawHollowRoundRect(vg, x + 351, y + 47, 642, options.length * 32 + 10, new Color(204, 204, 204, 77).getRGB(), 12, 1); int optionY = y + 52; @@ -146,7 +145,7 @@ public class ConfigDropdown extends BasicOption { // TODO: remove dividers and f optionY += 32; } } - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java index 599c094..cc1af3c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigDualOption.java @@ -2,12 +2,12 @@ package cc.polyfrost.oneconfig.gui.elements.config; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; -import org.lwjgl.nanovg.NanoVG; import java.lang.reflect.Field; @@ -36,7 +36,7 @@ public class ConfigDualOption extends BasicOption { toggled = (boolean) get(); } catch (IllegalAccessException ignored) { } - if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (!isEnabled()) RenderManager.withAlpha(vg, 0.5f); boolean hovered = InputUtils.isAreaHovered(x + 226, y, 256, 32) && isEnabled(); colorSelected = ColorUtils.smoothColor(colorSelected, OneConfigConfig.BLUE_600, OneConfigConfig.BLUE_500, hovered, 40f); colorUnselected = ColorUtils.smoothColor(colorUnselected, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, hovered, 40f); @@ -47,7 +47,7 @@ public class ConfigDualOption extends BasicOption { RenderManager.drawString(vg, left, x + 290 - RenderManager.getTextWidth(vg, left, 12f, Fonts.MEDIUM) / 2, y + 17, OneConfigConfig.WHITE_90, 12f, Fonts.MEDIUM); RenderManager.drawString(vg, right, x + 418 - RenderManager.getTextWidth(vg, right, 12f, Fonts.MEDIUM) / 2, y + 17, OneConfigConfig.WHITE_90, 12f, Fonts.MEDIUM); - NanoVG.nvgGlobalAlpha(vg, 1); + RenderManager.withAlpha(vg, 1); if (hovered && InputUtils.isClicked()) { toggled = !toggled; try { @@ -57,6 +57,6 @@ public class ConfigDualOption extends BasicOption { e.printStackTrace(); } } - percentMove = MathUtils.clamp(MathUtils.easeOut(percentMove, toggled ? 1f : 0f, 75)); + percentMove = MathUtils.clamp(MathUtils.easeOut(percentMove, toggled ? 1f : 0f, 75, OneConfigGui.INSTANCE.getDeltaTime())); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java index 5b3efae..0ddcab3 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigKeyBind.java @@ -7,10 +7,8 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.elements.BasicButton; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import gg.essential.universal.UKeyboard; -import org.lwjgl.nanovg.NanoVG; +import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import java.lang.reflect.Field; @@ -26,7 +24,7 @@ public class ConfigKeyBind extends BasicOption { @Override public void draw(long vg, int x, int y) { - if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (!isEnabled()) RenderManager.withAlpha(vg, 0.5f); RenderManager.drawString(vg, name, x, y + 17, OneConfigConfig.WHITE, 14f, Fonts.MEDIUM); OneKeyBind keyBind = getKeyBind(); String text = keyBind.getDisplay(); @@ -47,7 +45,7 @@ public class ConfigKeyBind extends BasicOption { } else if (text.equals("")) text = "None"; button.setText(text); button.draw(vg, x + (size == 1 ? 224 : 736), y); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java index 81cd946..5878cc0 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigPageButton.java @@ -7,12 +7,10 @@ import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.pages.ModConfigPage; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import org.lwjgl.input.Mouse; -import org.lwjgl.nanovg.NanoVG; import java.lang.reflect.Field; @@ -34,8 +32,8 @@ public class ConfigPageButton extends BasicOption { boolean clicked = hovered && InputUtils.isClicked(); backgroundColor = ColorUtils.smoothColor(backgroundColor, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, hovered, 100); - if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.8f); - if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (hovered && Mouse.isButtonDown(0)) RenderManager.withAlpha(vg, 0.8f); + if (!isEnabled()) RenderManager.withAlpha(vg, 0.5f); RenderManager.drawRoundedRect(vg, x - 16, y, 1024, height, backgroundColor, 20); RenderManager.drawString(vg, name, x + 10, y + 32, OneConfigConfig.WHITE_90, 24, Fonts.MEDIUM); @@ -44,7 +42,7 @@ public class ConfigPageButton extends BasicOption { RenderManager.drawSvg(vg, SVGs.CHEVRON_RIGHT, x + 981f, y + (description.equals("") ? 20f : 36f), 13, 22); if (clicked) OneConfigGui.INSTANCE.openPage(new ModConfigPage(page)); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java index c9f2691..3f8a2d9 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSlider.java @@ -8,7 +8,6 @@ import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; import org.lwjgl.input.Mouse; -import org.lwjgl.nanovg.NanoVG; import java.lang.reflect.Field; @@ -34,7 +33,7 @@ public class ConfigSlider extends BasicOption { float value = 0; boolean hovered = InputUtils.isAreaHovered(x + 352, y, 512, 32) && isEnabled(); inputField.disable(!isEnabled()); - if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (!isEnabled()) RenderManager.withAlpha(vg, 0.5f); boolean isMouseDown = Mouse.isButtonDown(0); if (hovered && isMouseDown && !mouseWasDown) dragging = true; mouseWasDown = isMouseDown; @@ -80,7 +79,7 @@ public class ConfigSlider extends BasicOption { if (step == 0) RenderManager.drawRoundedRect(vg, xCoordinate - 12, y + 4, 24, 24, OneConfigConfig.WHITE, 12f); else RenderManager.drawRoundedRect(vg, xCoordinate - 4, y + 4, 8, 24, OneConfigConfig.WHITE, 4f); inputField.draw(vg, x + 892, y); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } private int getStepCoordinate(int xCoordinate, int x) { diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java index 92961a6..5eadad2 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigSwitch.java @@ -2,12 +2,12 @@ package cc.polyfrost.oneconfig.gui.elements.config; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; -import org.lwjgl.nanovg.NanoVG; import java.lang.reflect.Field; @@ -32,7 +32,7 @@ public class ConfigSwitch extends BasicOption { boolean hovered = InputUtils.isAreaHovered(x, y, 42, 32); colorDisabled = ColorUtils.smoothColor(colorDisabled, OneConfigConfig.GRAY_400, OneConfigConfig.GRAY_300, hovered, 40f); colorEnabled = ColorUtils.smoothColor(colorEnabled, OneConfigConfig.BLUE_600, OneConfigConfig.BLUE_500, hovered, 40f); - if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (!isEnabled()) RenderManager.withAlpha(vg, 0.5f); RenderManager.drawRoundedRect(vg, x, y + 4, 42, 24, colorDisabled, 12f); if (percentOn != 0) RenderManager.drawRoundedRect(vg, x, y + 4, 42, 24, ColorUtils.setAlpha(colorEnabled, (int) (255 * percentOn)), 12f); @@ -48,8 +48,8 @@ public class ConfigSwitch extends BasicOption { e.printStackTrace(); } } - percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 75)); - NanoVG.nvgGlobalAlpha(vg, 1f); + percentOn = MathUtils.clamp(MathUtils.easeOut(percentOn, toggled ? 1f : 0f, 75, OneConfigGui.INSTANCE.getDeltaTime())); + RenderManager.withAlpha(vg, 1f); } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java index dbe0482..7398ddb 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigTextBox.java @@ -8,7 +8,6 @@ import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.InputUtils; import org.lwjgl.input.Mouse; -import org.lwjgl.nanovg.NanoVG; import java.awt.*; import java.lang.reflect.Field; @@ -27,7 +26,7 @@ public class ConfigTextBox extends BasicOption { @Override public void draw(long vg, int x, int y) { - if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (!isEnabled()) RenderManager.withAlpha(vg, 0.5f); textField.disable(!isEnabled()); RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14, Fonts.MEDIUM); @@ -46,10 +45,10 @@ public class ConfigTextBox extends BasicOption { boolean hovered = InputUtils.isAreaHovered(x + 967, y + 7, 18, 18) && isEnabled(); int color = hovered ? OneConfigConfig.WHITE : OneConfigConfig.WHITE_80; if (hovered && InputUtils.isClicked()) textField.setPassword(!textField.getPassword()); - if (hovered && Mouse.isButtonDown(0)) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (hovered && Mouse.isButtonDown(0)) RenderManager.withAlpha(vg, 0.5f); RenderManager.drawSvg(vg, icon, x + 967, y + 7, 18, 18, color); } - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java index 938e830..ccda382 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/config/ConfigUniSelector.java @@ -2,16 +2,15 @@ package cc.polyfrost.oneconfig.gui.elements.config; import cc.polyfrost.oneconfig.config.OneConfigConfig; import cc.polyfrost.oneconfig.config.interfaces.BasicOption; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.lwjgl.RenderManager; +import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; -import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.utils.ColorUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; -import org.lwjgl.nanovg.NanoVG; import java.lang.reflect.Field; @@ -39,7 +38,7 @@ public class ConfigUniSelector extends BasicOption { selected = (int) get(); } catch (IllegalAccessException ignored) { } - if (!isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (!isEnabled()) RenderManager.withAlpha(vg, 0.5f); String option = options[selected] + " " + (selected + 1) + "/" + options.length; RenderManager.drawString(vg, name, x, y + 16, OneConfigConfig.WHITE_90, 14f, Fonts.MEDIUM); @@ -58,11 +57,11 @@ public class ConfigUniSelector extends BasicOption { colorLeft = ColorUtils.smoothColor(colorLeft, OneConfigConfig.BLUE_500, OneConfigConfig.BLUE_400, hoveredLeft, 40f); colorRight = ColorUtils.smoothColor(colorRight, OneConfigConfig.BLUE_500, OneConfigConfig.BLUE_400, hoveredRight, 40f); - if (selected <= 0 && isEnabled()) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (selected <= 0 && isEnabled()) RenderManager.withAlpha(vg, 0.5f); RenderManager.drawSvg(vg, SVGs.CHEVRON_LEFT, x + 231, y + 7, 18, 18, colorLeft); - if (isEnabled()) NanoVG.nvgGlobalAlpha(vg, selected >= options.length - 1 ? 0.5f : 1f); + if (isEnabled()) RenderManager.withAlpha(vg, selected >= options.length - 1 ? 0.5f : 1f); RenderManager.drawSvg(vg, SVGs.CHEVRON_RIGHT, x + 455, y + 7, 18, 18, colorRight); - if (isEnabled()) NanoVG.nvgGlobalAlpha(vg, 1f); + if (isEnabled()) RenderManager.withAlpha(vg, 1f); if (hoveredLeft && InputUtils.isClicked()) { previous = selected; @@ -81,8 +80,8 @@ public class ConfigUniSelector extends BasicOption { } percentMove = selected < previous ? 0f : 1f; } - if (previous != -1) percentMove = MathUtils.easeOut(percentMove, selected < previous ? 1f : 0f, 75); + if (previous != -1) percentMove = MathUtils.easeOut(percentMove, selected < previous ? 1f : 0f, 75, OneConfigGui.INSTANCE.getDeltaTime()); if ((selected < previous ? 1f : 0f) == percentMove) previous = -1; - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java index 0660efe..08e8597 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/NumberInputField.java @@ -1,12 +1,11 @@ package cc.polyfrost.oneconfig.gui.elements.text; import cc.polyfrost.oneconfig.config.OneConfigConfig; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.elements.BasicElement; import cc.polyfrost.oneconfig.lwjgl.RenderManager; -import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; import cc.polyfrost.oneconfig.utils.ColorUtils; -import org.lwjgl.nanovg.NanoVG; public class NumberInputField extends TextInputField { private final BasicElement upArrow = new BasicElement(12, 14, false); @@ -62,20 +61,20 @@ public class NumberInputField extends TextInputField { setCurrentValue(current); } if (current >= max && !disabled) { - NanoVG.nvgGlobalAlpha(vg, 0.3f); + RenderManager.withAlpha(vg, 0.3f); upArrow.disable(true); } RenderManager.drawRoundedRectVaried(vg, x + width + 4, y, 12, 14, colorTop, 6f, 6f, 0f, 0f); RenderManager.drawSvg(vg, SVGs.CHEVRON_UP, x + width + 5, y + 2, 10, 10); - if (current >= max && !disabled) NanoVG.nvgGlobalAlpha(vg, 1f); + if (current >= max && !disabled) RenderManager.withAlpha(vg, 1f); if (current <= min && !disabled) { - NanoVG.nvgGlobalAlpha(vg, 0.3f); + RenderManager.withAlpha(vg, 0.3f); downArrow.disable(true); } RenderManager.drawRoundedRectVaried(vg, x + width + 4, y + 14, 12, 14, colorBottom, 0f, 0f, 6f, 6f); RenderManager.drawSvg(vg, SVGs.CHEVRON_DOWN, x + width + 5, y + 15, 10, 10); - NanoVG.nvgGlobalAlpha(vg, 1f); + RenderManager.withAlpha(vg, 1f); try { super.draw(vg, x, y - 2); diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java index a91d19d..c08d9f6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java @@ -9,7 +9,7 @@ import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.TextUtils; -import gg.essential.universal.UKeyboard; +import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import kotlin.Pair; import org.jetbrains.annotations.NotNull; import org.lwjgl.input.Keyboard; 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 1d2dfac..cd46797 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/ModsPage.java @@ -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(6))); + modCategories.add(new BasicButton(88, 32, "3rd Party", null, null, 0, BasicButton.ALIGNMENT_CENTER, true, () -> unselect(7))); modCategories.get(0).setToggled(true); } @@ -85,7 +85,7 @@ public class ModsPage extends Page { } private boolean inSelection(ModCard modCard) { - return modCategories.get(0).isToggled() && (OneConfigConfig.allShowShortCut || !modCard.getModData().isShortCut) || (modCategories.get(1).isToggled() && modCard.getModData().modType == ModType.PVP) || (modCategories.get(2).isToggled() && modCard.getModData().modType == ModType.HUD) || (modCategories.get(3).isToggled() && modCard.getModData().modType == ModType.UTIL_QOL) || (modCategories.get(4).isToggled() && modCard.getModData().modType == ModType.HYPIXEL) || (modCategories.get(5).isToggled() && modCard.getModData().modType == ModType.SKYBLOCK) || (modCategories.get(6).isToggled() && modCard.getModData().modType == ModType.THIRD_PARTY); + return modCategories.get(0).isToggled() && (OneConfigConfig.allShowShortCut || !modCard.getModData().isShortCut) || (modCategories.get(1).isToggled() && modCard.getModData().modType == ModType.PVP) || (modCategories.get(2).isToggled() && modCard.getModData().modType == ModType.HUD) || (modCategories.get(3).isToggled() && modCard.getModData().modType == ModType.UTIL_QOL) || (modCategories.get(4).isToggled() && modCard.getModData().modType == ModType.HYPIXEL) || (modCategories.get(5).isToggled() && modCard.getModData().modType == ModType.SKYBLOCK) || (modCategories.get(6).isToggled() && modCard.getModData().modType == ModType.THIRD_PARTY); } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java index fdb5292..b4ab9e7 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/Page.java @@ -1,5 +1,6 @@ package cc.polyfrost.oneconfig.gui.pages; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; import cc.polyfrost.oneconfig.lwjgl.scissor.ScissorManager; import cc.polyfrost.oneconfig.utils.MathUtils; @@ -48,7 +49,7 @@ public abstract class Page { if (scrollTarget > 0f) scrollTarget = 0f; else if (scrollTarget < -maxScroll + 728) scrollTarget = -maxScroll + 728; - currentScroll = MathUtils.easeOut(currentScroll, scrollTarget, 50f); + currentScroll = MathUtils.easeOut(currentScroll, scrollTarget, 50f, OneConfigGui.INSTANCE.getDeltaTime()); ScissorManager.resetScissor(vg, scissor); } diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/HudCore.java b/src/main/java/cc/polyfrost/oneconfig/hud/HudCore.java index f307349..8bf650f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/hud/HudCore.java +++ b/src/main/java/cc/polyfrost/oneconfig/hud/HudCore.java @@ -1,6 +1,6 @@ package cc.polyfrost.oneconfig.hud; -import gg.essential.universal.UResolution; +import cc.polyfrost.oneconfig.libs.universal.UResolution; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; diff --git a/src/main/java/cc/polyfrost/oneconfig/init/OneConfigInit.java b/src/main/java/cc/polyfrost/oneconfig/init/OneConfigInit.java index 9c9595d..33b13d5 100644 --- a/src/main/java/cc/polyfrost/oneconfig/init/OneConfigInit.java +++ b/src/main/java/cc/polyfrost/oneconfig/init/OneConfigInit.java @@ -6,15 +6,13 @@ import org.spongepowered.asm.mixin.Mixins; /** * Initializes the OneConfig mod. - * <p>MUST BE CALLED VIA AN ITWEAKER / FMLLOADINGPLUGIN FOR 1.12 AND BELOW, OR A PRELAUNCH TWEAKER FOR 1.14+ FABRIC.</p> + * <p><b>MUST BE CALLED VIA AN ITWEAKER / FMLLOADINGPLUGIN FOR 1.12 AND BELOW, OR A PRELAUNCH TWEAKER FOR 1.14+ FABRIC.</b></p> */ @SuppressWarnings("unused") public class OneConfigInit { public static void initialize(String[] args) { - if (!Launch.blackboard.containsKey("oneconfig.initialized")) { - Launch.blackboard.put("oneconfig.initialized", true); - MixinBootstrap.init(); - Mixins.addConfiguration("mixins.oneconfig.json"); - } + Launch.blackboard.put("oneconfig.initialized", true); + MixinBootstrap.init(); + Mixins.addConfiguration("mixins.oneconfig.json"); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java index 973677e..090121b 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java @@ -1,9 +1,9 @@ package cc.polyfrost.oneconfig.lwjgl; import cc.polyfrost.oneconfig.gui.OneConfigGui; +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import cc.polyfrost.oneconfig.libs.universal.UScreen; import cc.polyfrost.oneconfig.mixin.ShaderGroupAccessor; -import gg.essential.universal.UMinecraft; -import gg.essential.universal.UScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.shader.Shader; diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/OneColor.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/OneColor.java index d598e07..9c62d1a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/OneColor.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/OneColor.java @@ -15,7 +15,7 @@ import java.awt.*; * </code> */ @SuppressWarnings("unused") -public class OneColor { +public final class OneColor { transient private Integer rgba = null; private short[] hsba; private int chroma = -1; diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java index 9d6763f..c1df2fe 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java @@ -8,9 +8,9 @@ import cc.polyfrost.oneconfig.lwjgl.font.Fonts; import cc.polyfrost.oneconfig.lwjgl.image.ImageLoader; import cc.polyfrost.oneconfig.lwjgl.image.Images; import cc.polyfrost.oneconfig.lwjgl.image.SVGs; -import gg.essential.universal.UGraphics; -import gg.essential.universal.UMinecraft; -import gg.essential.universal.UResolution; +import cc.polyfrost.oneconfig.libs.universal.UGraphics; +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import cc.polyfrost.oneconfig.libs.universal.UResolution; import net.minecraft.client.gui.Gui; import net.minecraft.client.shader.Framebuffer; import org.lwjgl.nanovg.*; @@ -298,6 +298,14 @@ public final class RenderManager { return nvgColor; } + public static void scale(long vg, float x, float y) { + nvgScale(vg, x, y); + } + + public static void withAlpha(long vg, float alpha) { + nvgGlobalAlpha(vg, alpha); + } + public static void drawSvg(long vg, String filePath, float x, float y, float width, float height) { float w = width; float h = height; diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java index a369f26..8267ba7 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/Font.java @@ -1,7 +1,5 @@ package cc.polyfrost.oneconfig.lwjgl.font; -import org.lwjgl.nanovg.NanoVG; - import java.nio.ByteBuffer; public class Font { diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java index 128ae48..fb436dd 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java @@ -15,7 +15,7 @@ import java.util.HashMap; public class ImageLoader { private final HashMap<String, Integer> imageHashMap = new HashMap<>(); - private final HashMap<String, Integer> SVGHashMap = new HashMap<>(); + private final HashMap<String, Integer> svgHashMap = new HashMap<>(); public static ImageLoader INSTANCE = new ImageLoader(); public boolean loadImage(long vg, String fileName) { @@ -42,7 +42,7 @@ public class ImageLoader { public boolean loadSVG(long vg, String fileName, float SVGWidth, float SVGHeight) { String name = fileName + "-" + SVGWidth + "-" + SVGHeight; - if (!SVGHashMap.containsKey(name)) { + if (!svgHashMap.containsKey(name)) { try { InputStream inputStream = this.getClass().getResourceAsStream(fileName); if (inputStream == null) return false; @@ -70,7 +70,7 @@ public class ImageLoader { NanoSVG.nsvgDeleteRasterizer(rasterizer); NanoSVG.nsvgDelete(svg); - SVGHashMap.put(name, NanoVG.nvgCreateImageRGBA(vg, w, h, NanoVG.NVG_IMAGE_REPEATX | NanoVG.NVG_IMAGE_REPEATY | NanoVG.NVG_IMAGE_GENERATE_MIPMAPS, image)); + svgHashMap.put(name, NanoVG.nvgCreateImageRGBA(vg, w, h, NanoVG.NVG_IMAGE_REPEATX | NanoVG.NVG_IMAGE_REPEATY | NanoVG.NVG_IMAGE_GENERATE_MIPMAPS, image)); return true; } catch (Exception e) { System.err.println("Failed to parse SVG file"); @@ -100,20 +100,20 @@ public class ImageLoader { public int getSVG( String fileName, float width, float height) { String name = fileName + "-" + width + "-" + height; - return SVGHashMap.get(name); + return svgHashMap.get(name); } public void removeSVG(long vg, String fileName, float width, float height) { String name = fileName + "-" + width + "-" + height; NanoVG.nvgDeleteImage(vg, imageHashMap.get(name)); - SVGHashMap.remove(name); + svgHashMap.remove(name); } public void clearSVGs(long vg) { - HashMap<String, Integer> temp = new HashMap<>(SVGHashMap); + HashMap<String, Integer> temp = new HashMap<>(svgHashMap); for (String image : temp.keySet()) { - NanoVG.nvgDeleteImage(vg, SVGHashMap.get(image)); - SVGHashMap.remove(image); + NanoVG.nvgDeleteImage(vg, svgHashMap.get(image)); + svgHashMap.remove(image); } } } diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java deleted file mode 100644 index 8e388dc..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java +++ /dev/null @@ -1,56 +0,0 @@ -package cc.polyfrost.oneconfig.lwjgl.plugin; - -import net.minecraft.launchwrapper.IClassTransformer; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.*; - -/** - * Taken from LWJGLTwoPointFive under The Unlicense - * <a href="https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/">https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/</a> - */ -@SuppressWarnings("unused") -public class ClassTransformer implements IClassTransformer { - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) { - if (name.equals("org.lwjgl.nanovg.NanoVGGLConfig")) { - ClassReader reader = new ClassReader(basicClass); - ClassNode node = new ClassNode(); - reader.accept(node, ClassReader.EXPAND_FRAMES); - - for (MethodNode method : node.methods) { - if (method.name.equals("configGL")) { - InsnList list = new InsnList(); - - list.add(new VarInsnNode(Opcodes.LLOAD, 0)); - list.add(new TypeInsnNode(Opcodes.NEW, "cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider")); - list.add(new InsnNode(Opcodes.DUP)); - list.add(new MethodInsnNode( - Opcodes.INVOKESPECIAL, - "cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider", - "<init>", - "()V", - false - )); - list.add(new MethodInsnNode( - Opcodes.INVOKESTATIC, - "org/lwjgl/nanovg/NanoVGGLConfig", - "config", - "(JLorg/lwjgl/system/FunctionProvider;)V", - false - )); - list.add(new InsnNode(Opcodes.RETURN)); - - method.instructions.clear(); - method.instructions.insert(list); - } - } - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - node.accept(cw); - return cw.toByteArray(); - } - return basicClass; - } -}
\ No newline at end of file diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java index a3f3780..0f821c9 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java +++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java @@ -1,6 +1,5 @@ package cc.polyfrost.oneconfig.lwjgl.scissor; -import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor; import org.lwjgl.nanovg.NanoVG; import java.util.ArrayList; diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/LoadingPlugin.java b/src/main/java/cc/polyfrost/oneconfig/plugin/LoadingPlugin.java index 6cd8911..be2b399 100644 --- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/LoadingPlugin.java +++ b/src/main/java/cc/polyfrost/oneconfig/plugin/LoadingPlugin.java @@ -1,4 +1,4 @@ -package cc.polyfrost.oneconfig.lwjgl.plugin; +package cc.polyfrost.oneconfig.plugin; import cc.polyfrost.oneconfig.init.OneConfigInit; import net.minecraft.launchwrapper.Launch; @@ -9,12 +9,12 @@ import java.lang.reflect.Field; import java.util.Map; import java.util.Set; -/** - * Taken from LWJGLTwoPointFive under The Unlicense - * <a href="https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/">https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/</a> - */ public class LoadingPlugin implements IFMLLoadingPlugin { + /** + * Taken from LWJGLTwoPointFive under The Unlicense + * <a href="https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/">https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/</a> + */ public LoadingPlugin() { try { Field f_exceptions = LaunchClassLoader.class.getDeclaredField("classLoaderExceptions"); @@ -29,7 +29,7 @@ public class LoadingPlugin implements IFMLLoadingPlugin { @Override public String[] getASMTransformerClass() { - return new String[]{"cc.polyfrost.oneconfig.lwjgl.plugin.ClassTransformer"}; + return new String[]{"cc.polyfrost.oneconfig.plugin.asm.ClassTransformer"}; } @Override diff --git a/src/main/java/cc/polyfrost/oneconfig/plugin/OneConfigMixinPlugin.java b/src/main/java/cc/polyfrost/oneconfig/plugin/OneConfigMixinPlugin.java new file mode 100644 index 0000000..9ceacde --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/plugin/OneConfigMixinPlugin.java @@ -0,0 +1,51 @@ +package cc.polyfrost.oneconfig.plugin; + +import org.spongepowered.asm.lib.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class OneConfigMixinPlugin implements IMixinConfigPlugin { + public static boolean isVigilance = false; + @Override + public void onLoad(String mixinPackage) { + try { + Class.forName("gg.essential.vigilance.Vigilant"); + isVigilance = true; + } catch (Exception e) { + isVigilance = false; + } + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + return !targetClassName.contains("vigilance") || isVigilance; + } + + @Override + public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { + + } + + @Override + public List<String> getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/src/main/java/cc/polyfrost/oneconfig/plugin/asm/ClassTransformer.java b/src/main/java/cc/polyfrost/oneconfig/plugin/asm/ClassTransformer.java new file mode 100644 index 0000000..989b5da --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/plugin/asm/ClassTransformer.java @@ -0,0 +1,64 @@ +package cc.polyfrost.oneconfig.plugin.asm; + +import cc.polyfrost.oneconfig.plugin.asm.tweakers.NanoVGGLConfigTransformer; +import cc.polyfrost.oneconfig.plugin.asm.tweakers.VigilantTransformer; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import net.minecraft.launchwrapper.IClassTransformer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.tree.ClassNode; + +import java.util.Collection; + +/** + * Taken from LWJGLTwoPointFive under The Unlicense + * <a href="https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/">https://github.com/DJtheRedstoner/LWJGLTwoPointFive/blob/master/LICENSE/</a> + * <p>also half taken from asmworkspace by asbyth ty</p> + */ +@SuppressWarnings("unused") +public class ClassTransformer implements IClassTransformer { + private static final Logger logger = LogManager.getLogger("OneConfig ASM"); + private final Multimap<String, ITransformer> transformerMap = ArrayListMultimap.create(); + + public ClassTransformer() { + registerTransformer(new NanoVGGLConfigTransformer()); + registerTransformer(new VigilantTransformer()); + } + + private void registerTransformer(ITransformer transformer) { + // loop through names of classes + for (String cls : transformer.getClassName()) { + // put the classes into the transformer map + transformerMap.put(cls, transformer); + } + } + + @Override + public byte[] transform(String name, String transformedName, byte[] basicClass) { + if (basicClass == null) return null; + + Collection<ITransformer> transformers = transformerMap.get(transformedName); + if (transformers.isEmpty()) return basicClass; + + + ClassReader reader = new ClassReader(basicClass); + ClassNode node = new ClassNode(); + reader.accept(node, ClassReader.EXPAND_FRAMES); + + for (ITransformer transformer : transformers) { + transformer.transform(transformedName, node); + } + + ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); + try { + node.accept(cw); + } catch (Throwable t) { + logger.error("Exception when transforming " + transformedName + " : " + t.getClass().getSimpleName()); + t.printStackTrace(); + } + return cw.toByteArray(); + } +}
\ No newline at end of file diff --git a/src/main/java/cc/polyfrost/oneconfig/plugin/asm/ITransformer.java b/src/main/java/cc/polyfrost/oneconfig/plugin/asm/ITransformer.java new file mode 100644 index 0000000..f1e12bf --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/plugin/asm/ITransformer.java @@ -0,0 +1,8 @@ +package cc.polyfrost.oneconfig.plugin.asm; + +import org.objectweb.asm.tree.ClassNode; + +public interface ITransformer { + String[] getClassName(); + void transform(String transformedName, ClassNode node); +} diff --git a/src/main/java/cc/polyfrost/oneconfig/plugin/asm/tweakers/NanoVGGLConfigTransformer.java b/src/main/java/cc/polyfrost/oneconfig/plugin/asm/tweakers/NanoVGGLConfigTransformer.java new file mode 100644 index 0000000..38da8dd --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/plugin/asm/tweakers/NanoVGGLConfigTransformer.java @@ -0,0 +1,43 @@ +package cc.polyfrost.oneconfig.plugin.asm.tweakers; + +import cc.polyfrost.oneconfig.plugin.asm.ITransformer; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.tree.*; + +public class NanoVGGLConfigTransformer implements ITransformer { + @Override + public String[] getClassName() { + return new String[]{"org.lwjgl.nanovg.NanoVGGLConfig"}; + } + + @Override + public void transform(String transformedName, ClassNode node) { + for (MethodNode method : node.methods) { + if (method.name.equals("configGL")) { + InsnList list = new InsnList(); + + list.add(new VarInsnNode(Opcodes.LLOAD, 0)); + list.add(new TypeInsnNode(Opcodes.NEW, "cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider")); + list.add(new InsnNode(Opcodes.DUP)); + list.add(new MethodInsnNode( + Opcodes.INVOKESPECIAL, + "cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider", + "<init>", + "()V", + false + )); + list.add(new MethodInsnNode( + Opcodes.INVOKESTATIC, + "org/lwjgl/nanovg/NanoVGGLConfig", + "config", + "(JLorg/lwjgl/system/FunctionProvider;)V", + false + )); + list.add(new InsnNode(Opcodes.RETURN)); + + method.instructions.clear(); + method.instructions.insert(list); + } + } + } +} 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 new file mode 100644 index 0000000..732db97 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/plugin/asm/tweakers/VigilantTransformer.java @@ -0,0 +1,105 @@ +package cc.polyfrost.oneconfig.plugin.asm.tweakers; + +import cc.polyfrost.oneconfig.config.compatibility.VigilanceConfig; +import cc.polyfrost.oneconfig.config.core.ConfigCore; +import cc.polyfrost.oneconfig.config.data.Mod; +import cc.polyfrost.oneconfig.config.data.ModType; +import cc.polyfrost.oneconfig.plugin.asm.ITransformer; +import gg.essential.vigilance.Vigilant; +import gg.essential.vigilance.data.PropertyCollector; +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.common.Loader; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.tree.*; + +import java.io.File; + +public class VigilantTransformer implements ITransformer { + @Override + public String[] getClassName() { + return new String[]{"gg.essential.vigilance.Vigilant"}; + } + + @Override + public void transform(String transformedName, ClassNode node) { + node.fields.add(new FieldNode(Opcodes.ACC_PUBLIC, "oneconfig$config", Type.getDescriptor(VigilanceConfig.class), null, null)); + node.fields.add(new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, "oneconfig$file", Type.getDescriptor(File.class), null, null)); + + node.interfaces.add("cc/polyfrost/oneconfig/config/compatibility/VigilantAccessor"); + MethodNode methodNode = new MethodNode(Opcodes.ACC_PUBLIC, "getPropertyCollector", "()Lgg/essential/vigilance/data/PropertyCollector;", null, null); + LabelNode labelNode = new LabelNode(); + methodNode.instructions.add(labelNode); + methodNode.instructions.add(new LineNumberNode(421421, labelNode)); + methodNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); + methodNode.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "propertyCollector", Type.getDescriptor(PropertyCollector.class))); + methodNode.instructions.add(new InsnNode(Opcodes.ARETURN)); + node.methods.add(methodNode); + + MethodNode methodNode2 = new MethodNode(Opcodes.ACC_PUBLIC, "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", null, null); + LabelNode labelNode2 = new LabelNode(); + LabelNode labelNode3 = new LabelNode(); + LabelNode labelNode4 = new LabelNode(); + methodNode2.instructions.add(labelNode2); + methodNode2.instructions.add(new LineNumberNode(15636436, labelNode2)); + methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); + methodNode2.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class))); + + methodNode2.instructions.add(new JumpInsnNode(Opcodes.IFNULL, labelNode4)); + + methodNode2.instructions.add(labelNode3); + methodNode2.instructions.add(new LineNumberNode(15636437, labelNode3)); + methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); + methodNode2.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class))); + methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1)); + methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 2)); + methodNode2.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, Type.getInternalName(VigilanceConfig.class), "addDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false)); + + methodNode2.instructions.add(labelNode4); + methodNode2.instructions.add(new LineNumberNode(15636438, labelNode4)); + methodNode2.instructions.add(new InsnNode(Opcodes.RETURN)); + node.methods.add(methodNode2); + + for (MethodNode method : node.methods) { + if (method.name.equals("initialize")) { + InsnList list = new InsnList(); + list.add(new VarInsnNode(Opcodes.ALOAD, 0)); + list.add(new VarInsnNode(Opcodes.ALOAD, 0)); + list.add(new VarInsnNode(Opcodes.ALOAD, 0)); + list.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class))); + list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(getClass()), "returnNewConfig", "(Lgg/essential/vigilance/Vigilant;Ljava/io/File;)Lcc/polyfrost/oneconfig/config/compatibility/VigilanceConfig;", false)); + list.add(new FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", Type.getDescriptor(VigilanceConfig.class))); + method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list); + } else if (method.name.equals("addDependency") && method.desc.equals("(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V")) { + InsnList list = new InsnList(); + + list.add(new VarInsnNode(Opcodes.ALOAD, 0)); + list.add(new VarInsnNode(Opcodes.ALOAD, 1)); + list.add(new VarInsnNode(Opcodes.ALOAD, 2)); + list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "gg/essential/vigilance/Vigilant", "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false)); + + method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list); + } else if (method.name.equals("<init>") && method.desc.equals("(Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;)V")) { + InsnList list = new InsnList(); + list.add(new VarInsnNode(Opcodes.ALOAD, 0)); + list.add(new VarInsnNode(Opcodes.ALOAD, 1)); + list.add(new FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class))); + method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list); + } + } + } + + @SuppressWarnings("unused") + 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(); + 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); + } else { + return null; + } + } +} diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java b/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java index c4349e8..7f1fb7f 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java @@ -2,7 +2,7 @@ package cc.polyfrost.oneconfig.test; import cc.polyfrost.oneconfig.hud.BasicHud; import cc.polyfrost.oneconfig.lwjgl.RenderManager; -import gg.essential.universal.UMinecraft; +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import net.minecraft.client.Minecraft; public class TestHud extends BasicHud { diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui.java b/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui.java index dac7e12..f29fea4 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestNanoVGGui.java @@ -2,8 +2,8 @@ package cc.polyfrost.oneconfig.test; import cc.polyfrost.oneconfig.lwjgl.RenderManager; import cc.polyfrost.oneconfig.lwjgl.font.Fonts; -import gg.essential.universal.UMatrixStack; -import gg.essential.universal.UScreen; +import cc.polyfrost.oneconfig.libs.universal.UMatrixStack; +import cc.polyfrost.oneconfig.libs.universal.UScreen; import org.jetbrains.annotations.NotNull; import java.awt.*; diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java index aa37005..2e48bdc 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java @@ -1,8 +1,7 @@ package cc.polyfrost.oneconfig.utils; import cc.polyfrost.oneconfig.config.OneConfigConfig; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; +import cc.polyfrost.oneconfig.gui.OneConfigGui; import java.awt.*; @@ -49,7 +48,6 @@ public class ColorUtils { * @param currentColor the current color (also the one you want to change) * @param direction false to move towards initColor, true to move towards finalColor * @param speed speed of the transition - * @return currentColor but with the new color */ public static int smoothColor(int currentColor, int initColor, int finalColor, boolean direction, float speed) { float[] init = splitColor(initColor); @@ -58,8 +56,7 @@ public class ColorUtils { return getColorComponents(current, init, finalC, direction, speed); } - @Contract(value = "_ -> new", pure = true) - private static float @NotNull [] splitColor(int color) { + private static float[] splitColor(int color) { return new float[]{(color >> 16 & 255) / 255f, (color >> 8 & 255) / 255f, (color & 255) / 255f, (color >> 24 & 255) / 255f}; } @@ -74,7 +71,8 @@ public class ColorUtils { } private static float smooth(float current, float min, float max, boolean moveToFinal, float speed) { - current = MathUtils.easeOut(current, moveToFinal ? 1f : 0f, speed); + float deltaTime = OneConfigGui.INSTANCE == null ? 16 : OneConfigGui.INSTANCE.getDeltaTime(); + current = MathUtils.easeOut(current, moveToFinal ? 1f : 0f, speed, deltaTime); if (current <= min) { current = min; } diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java index 6264451..7263a19 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java @@ -19,6 +19,7 @@ public final class IOUtils { * Taken from legui under MIT License * <a href="https://github.com/SpinyOwl/legui/blob/develop/LICENSE">https://github.com/SpinyOwl/legui/blob/develop/LICENSE</a> */ + @SuppressWarnings("RedundantCast") public static ByteBuffer resourceToByteBuffer(String path) throws IOException { byte[] bytes; path = path.trim(); diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java index 6053a99..922010d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/InputUtils.java @@ -1,7 +1,7 @@ package cc.polyfrost.oneconfig.utils; import cc.polyfrost.oneconfig.gui.OneConfigGui; -import gg.essential.universal.UResolution; +import cc.polyfrost.oneconfig.libs.universal.UResolution; import org.lwjgl.input.Mouse; public class InputUtils { diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java index e10679a..e86061a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/MathUtils.java @@ -1,7 +1,5 @@ package cc.polyfrost.oneconfig.utils; -import cc.polyfrost.oneconfig.gui.OneConfigGui; - public class MathUtils { public static float clamp(float number) { return number < 0f ? 0f : Math.min(number, 1f); @@ -11,9 +9,9 @@ public class MathUtils { return number < min ? min : Math.min(number, max); } - public static float easeOut(float current, float goal, float speed) { + public static float easeOut(float current, float goal, float speed, float deltaTime) { if (Math.round(Math.abs(goal - current) * 100) > 0) { - return current + (goal - current) / speed * (OneConfigGui.INSTANCE == null ? 17 : OneConfigGui.INSTANCE.getDeltaTime()); + return current + (goal - current) / speed * deltaTime; } else { return goal; } @@ -26,8 +24,8 @@ public class MathUtils { /** * taken from <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a> */ - public static float easeInOutCirc(float t, float b, float c, float d) { - c *= OneConfigGui.INSTANCE == null ? 17 : OneConfigGui.INSTANCE.getDeltaTime(); + public static float easeInOutCirc(float t, float b, float c, float d, float deltaTime) { + c *= deltaTime; if ((t /= d / 2) < 1) return -c / 2 * ((float) Math.sqrt(1 - t * t) - 1) + b; return c / 2 * ((float) Math.sqrt(1 - (t -= 2) * t) + 1) + b; } |