diff options
author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-04-25 13:12:22 +0100 |
---|---|---|
committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-04-25 13:12:22 +0100 |
commit | 89d6576a7777a2949e04b2c6c8d2eb015a733529 (patch) | |
tree | 1a6906f9c71591aacbcbf5a32a1a1ed582b95fcb /src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java | |
parent | 29156d83c4213e319149fa5e0a926dd913404528 (diff) | |
download | OneConfig-89d6576a7777a2949e04b2c6c8d2eb015a733529.tar.gz OneConfig-89d6576a7777a2949e04b2c6c8d2eb015a733529.tar.bz2 OneConfig-89d6576a7777a2949e04b2c6c8d2eb015a733529.zip |
add size, do some config element stuff, fixes for cards, finish mods page and performance page, cleanup and some more
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java')
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java | 69 |
1 files changed, 50 insertions, 19 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java index 38304e4..071a311 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/ModCard.java @@ -1,12 +1,18 @@ package io.polyfrost.oneconfig.gui.elements; +import io.polyfrost.oneconfig.OneConfig; import io.polyfrost.oneconfig.config.OneConfigConfig; import io.polyfrost.oneconfig.config.data.ModData; +import io.polyfrost.oneconfig.config.data.ModType; +import io.polyfrost.oneconfig.gui.OneConfigGui; +import io.polyfrost.oneconfig.gui.pages.ModConfigPage; import io.polyfrost.oneconfig.lwjgl.RenderManager; import io.polyfrost.oneconfig.lwjgl.font.Fonts; import io.polyfrost.oneconfig.utils.ColorUtils; import io.polyfrost.oneconfig.utils.InputUtils; import net.minecraft.client.Minecraft; +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; @@ -32,23 +38,21 @@ public class ModCard extends BasicElement { @Override public void draw(long vg, int x, int y) { - if(disabled) NanoVG.nvgGlobalAlpha(vg, 0.5f); + if (disabled) NanoVG.nvgGlobalAlpha(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); - //RenderManager.drawRect(vg, x, y + 87, width, 12, colorPrimary); - if(iconPath != null) { + 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); } else { RenderManager.drawImage(vg, "/assets/oneconfig/textures/box.png", x + 98, y + 19, 48, 48); } - //favoriteHitbox.draw(vg, x + 212, y + 87); favoriteHitbox.update(x + 212, y + 87); favoriteHitbox.currentColor = ColorUtils.getColor(favoriteHitbox.currentColor, favoriteHitbox.colorPalette, favoriteHitbox.hovered, favoriteHitbox.clicked); RenderManager.drawRoundedRectVaried(vg, x + 212, y + 87, 32, 32, favoriteHitbox.currentColor, 0f, 0f, 12f, 0f); favorite = favoriteHitbox.isToggled(); - RenderManager.drawString(vg, modData.name, x + 12, y + 102, OneConfigConfig.WHITE, 14f, Fonts.INTER_MEDIUM); - if(favorite) { + RenderManager.drawString(vg, modData.name, x + 12, y + 103, OneConfigConfig.WHITE, 14f, Fonts.INTER_MEDIUM); + if (favorite) { RenderManager.drawImage(vg, "/assets/oneconfig/textures/love.png", x + 220, y + 95, 16, 16); } else { RenderManager.drawImage(vg, "/assets/oneconfig/textures/love_empty.png", x + 220, y + 95, 16, 16); @@ -57,19 +61,20 @@ public class ModCard extends BasicElement { isHoveredMain = InputUtils.isAreaHovered(x, y, width, 87); boolean isHoveredSecondary = InputUtils.isAreaHovered(x, y + 87, width - 32, 32) && !disabled; colorGray = ColorUtils.getColor(colorGray, 0, isHoveredMain, clicked && isHoveredMain); - if(active && !disabled) { + if (active && !disabled) { colorPrimary = ColorUtils.getColor(colorPrimary, 1, isHoveredSecondary, clicked && isHoveredSecondary); - } else colorPrimary = ColorUtils.smoothColor(colorPrimary, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, isHoveredSecondary, 20f); + } else + colorPrimary = ColorUtils.smoothColor(colorPrimary, OneConfigConfig.GRAY_500, OneConfigConfig.GRAY_400, isHoveredSecondary, 20f); - if(clicked && isHoveredMain) { - if(!active) toggled = false; + if (clicked && isHoveredMain) { + if (!active) toggled = false; } - if(clicked && favoriteHitbox.hovered) toggled = false; - if(clicked && !isHoveredSecondary && active) toggled = true; - if(!active & disabled) toggled = false; - //RenderManager.drawString(vg, "active=" + active, x + 300, y + 12, OneConfigConfig.WHITE, 12f, Fonts.INTER_MEDIUM); // TODO remove debug stuff - //RenderManager.drawString(vg, "disabled=" + disabled, x + 300, y + 24, OneConfigConfig.WHITE, 12f, Fonts.INTER_MEDIUM); - //RenderManager.drawString(vg, "favorite=" + favorite, x + 300, y + 36, OneConfigConfig.WHITE, 12f, Fonts.INTER_MEDIUM); + if (clicked && favoriteHitbox.hovered) toggled = false; + if (clicked && !isHoveredSecondary && active) toggled = true; + if (!active & disabled) toggled = false; + //RenderManager.drawString(vg, "active=" + active, x + 150, y + 92, OneConfigConfig.WHITE, 10f, Fonts.INTER_MEDIUM); // debug stuff + //RenderManager.drawString(vg, "disabled=" + disabled, x + 150, y + 103, OneConfigConfig.WHITE, 10f, Fonts.INTER_MEDIUM); + //RenderManager.drawString(vg, "favorite=" + favorite, x + 150, y + 114, OneConfigConfig.WHITE, 10f, Fonts.INTER_MEDIUM); active = toggled; @@ -77,8 +82,34 @@ public class ModCard extends BasicElement { } public void onClick() { - if(isHoveredMain) { - Minecraft.getMinecraft().thePlayer.sendChatMessage("you thought you opened the config for " + modData.name + " but actually it doesnt exist"); + if (isHoveredMain) { + for (ModData data : OneConfig.loadedMods) { + if (data.modType != ModType.OTHER) { + if (data.name.equalsIgnoreCase(modData.name)) { + OneConfigGui.INSTANCE.openPage(new ModConfigPage(data)); + } + } + } + for (ModMetadata mod : OneConfig.loadedOtherMods) { + if (mod.name.equalsIgnoreCase(modData.name)) { + System.out.println("Attempting to run command for a mod that isn't OneConfig: " + mod.name); + for (String commands : ClientCommandHandler.instance.getCommands().keySet()) { + if (commands.equalsIgnoreCase(mod.name)) { + System.out.println("Found command for mod: /" + commands); + Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + commands); + //Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + mod.name.toLowerCase()); + break; + } + if (commands.equalsIgnoreCase(mod.modId)) { + System.out.println("Found command for mod: /" + commands); + Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + commands); + break; + } + } + return; + } + + } } } |