diff options
Diffstat (limited to 'src/main/java/io')
29 files changed, 177 insertions, 164 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/annotations/Button.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java index 98b735f..449d297 100644 --- a/src/main/java/io/polyfrost/oneconfig/annotations/Button.java +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Button.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.annotations; +package io.polyfrost.oneconfig.config.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/io/polyfrost/oneconfig/annotations/Category.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java index 21c5533..05b5277 100644 --- a/src/main/java/io/polyfrost/oneconfig/annotations/Category.java +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Category.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.annotations; +package io.polyfrost.oneconfig.config.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/io/polyfrost/oneconfig/annotations/ColorPicker.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java index bf997a6..feee4b4 100644 --- a/src/main/java/io/polyfrost/oneconfig/annotations/ColorPicker.java +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/ColorPicker.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.annotations; +package io.polyfrost.oneconfig.config.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/io/polyfrost/oneconfig/annotations/Selector.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java index 39d238c..8b476ab 100644 --- a/src/main/java/io/polyfrost/oneconfig/annotations/Selector.java +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Selector.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.annotations; +package io.polyfrost.oneconfig.config.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/io/polyfrost/oneconfig/annotations/Slider.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java index fa855bf..cf8bfcd 100644 --- a/src/main/java/io/polyfrost/oneconfig/annotations/Slider.java +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Slider.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.annotations; +package io.polyfrost.oneconfig.config.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/io/polyfrost/oneconfig/annotations/Switch.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java index fffb490..19ec1db 100644 --- a/src/main/java/io/polyfrost/oneconfig/annotations/Switch.java +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/Switch.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.annotations; +package io.polyfrost.oneconfig.config.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/io/polyfrost/oneconfig/annotations/TextField.java b/src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java index 5761dd6..7b5837c 100644 --- a/src/main/java/io/polyfrost/oneconfig/annotations/TextField.java +++ b/src/main/java/io/polyfrost/oneconfig/config/annotations/TextField.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.annotations; +package io.polyfrost.oneconfig.config.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/src/main/java/io/polyfrost/oneconfig/core/ConfigCore.java b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java index 8fe7c81..ff7ed28 100644 --- a/src/main/java/io/polyfrost/oneconfig/core/ConfigCore.java +++ b/src/main/java/io/polyfrost/oneconfig/config/core/ConfigCore.java @@ -1,7 +1,7 @@ -package io.polyfrost.oneconfig.core; +package io.polyfrost.oneconfig.config.core; -import io.polyfrost.oneconfig.data.ModData; -import io.polyfrost.oneconfig.interfaces.Option; +import io.polyfrost.oneconfig.config.data.ModData; +import io.polyfrost.oneconfig.config.interfaces.Option; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/io/polyfrost/oneconfig/data/ModData.java b/src/main/java/io/polyfrost/oneconfig/config/data/ModData.java index 24ed1e5..c5e6633 100644 --- a/src/main/java/io/polyfrost/oneconfig/data/ModData.java +++ b/src/main/java/io/polyfrost/oneconfig/config/data/ModData.java @@ -1,6 +1,6 @@ -package io.polyfrost.oneconfig.data; +package io.polyfrost.oneconfig.config.data; -import io.polyfrost.oneconfig.interfaces.Config; +import io.polyfrost.oneconfig.config.interfaces.Config; public class ModData { public final String name; diff --git a/src/main/java/io/polyfrost/oneconfig/data/ModType.java b/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java index 18cf638..8b6e7de 100644 --- a/src/main/java/io/polyfrost/oneconfig/data/ModType.java +++ b/src/main/java/io/polyfrost/oneconfig/config/data/ModType.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.data; +package io.polyfrost.oneconfig.config.data; public enum ModType { PVP, diff --git a/src/main/java/io/polyfrost/oneconfig/interfaces/Config.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java index 3549456..ce73f0c 100644 --- a/src/main/java/io/polyfrost/oneconfig/interfaces/Config.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Config.java @@ -1,9 +1,9 @@ -package io.polyfrost.oneconfig.interfaces; +package io.polyfrost.oneconfig.config.interfaces; import com.google.gson.*; -import io.polyfrost.oneconfig.annotations.*; -import io.polyfrost.oneconfig.core.ConfigCore; -import io.polyfrost.oneconfig.data.ModData; +import io.polyfrost.oneconfig.config.annotations.*; +import io.polyfrost.oneconfig.config.core.ConfigCore; +import io.polyfrost.oneconfig.config.data.ModData; import io.polyfrost.oneconfig.gui.elements.config.*; import java.io.*; diff --git a/src/main/java/io/polyfrost/oneconfig/interfaces/OneConfigTypeAdapter.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapter.java index df6ee87..a07e7c8 100644 --- a/src/main/java/io/polyfrost/oneconfig/interfaces/OneConfigTypeAdapter.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapter.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.interfaces; +package io.polyfrost.oneconfig.config.interfaces; import com.google.gson.Gson; import com.google.gson.JsonElement; diff --git a/src/main/java/io/polyfrost/oneconfig/interfaces/OneConfigTypeAdapterFactory.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapterFactory.java index 6491ba2..af57163 100644 --- a/src/main/java/io/polyfrost/oneconfig/interfaces/OneConfigTypeAdapterFactory.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/OneConfigTypeAdapterFactory.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.interfaces; +package io.polyfrost.oneconfig.config.interfaces; import com.google.gson.Gson; import com.google.gson.TypeAdapter; @@ -7,7 +7,7 @@ import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; -import static io.polyfrost.oneconfig.interfaces.OneConfigTypeAdapter.getStaticTypeAdapter; +import static io.polyfrost.oneconfig.config.interfaces.OneConfigTypeAdapter.getStaticTypeAdapter; public class OneConfigTypeAdapterFactory implements TypeAdapterFactory { diff --git a/src/main/java/io/polyfrost/oneconfig/interfaces/Option.java b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java index d996b60..5980a63 100644 --- a/src/main/java/io/polyfrost/oneconfig/interfaces/Option.java +++ b/src/main/java/io/polyfrost/oneconfig/config/interfaces/Option.java @@ -1,4 +1,4 @@ -package io.polyfrost.oneconfig.interfaces; +package io.polyfrost.oneconfig.config.interfaces; import java.lang.reflect.Field; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/Window.java b/src/main/java/io/polyfrost/oneconfig/gui/Window.java index 5ef880b..a0c15cb 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/Window.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/Window.java @@ -1,7 +1,7 @@ package io.polyfrost.oneconfig.gui; -import io.polyfrost.oneconfig.renderer.Renderer; import io.polyfrost.oneconfig.themes.Theme; +import io.polyfrost.oneconfig.themes.ThemeElement; import io.polyfrost.oneconfig.themes.Themes; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; @@ -49,8 +49,7 @@ public class Window extends GuiScreen { Gui.drawRect(left, top, right, top + 100, t.getTitleBarColor().getRGB()); Gui.drawRect(left, top + 100, right, top + 101, testingColor.getRGB()); - //ResourceLocation location = mc.getRenderManager().renderEngine.getDynamicTextureLocation("oneconfig",new DynamicTexture(ImageIO.read(t.getResource("assets/textures/icons/hudsettings128.png")))); - Renderer.drawScaledImage(t.getLargeIconAtlas(), left + 10, top + 10, 128, 1152); + t.getTextureManager().draw(ThemeElement.ALL_MODS, 10, 10, 32, 32); } public static Window getWindow() { diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java index a6951a6..1cf0ab8 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigButton.java @@ -1,6 +1,6 @@ package io.polyfrost.oneconfig.gui.elements.config; -import io.polyfrost.oneconfig.interfaces.Option; +import io.polyfrost.oneconfig.config.interfaces.Option; import java.lang.reflect.Field; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java index 0eae75a..e57f130 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigCategory.java @@ -1,6 +1,6 @@ package io.polyfrost.oneconfig.gui.elements.config; -import io.polyfrost.oneconfig.interfaces.Option; +import io.polyfrost.oneconfig.config.interfaces.Option; import java.util.List; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java index fb60af7..fcad08f 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigColor.java @@ -1,6 +1,6 @@ package io.polyfrost.oneconfig.gui.elements.config; -import io.polyfrost.oneconfig.interfaces.Option; +import io.polyfrost.oneconfig.config.interfaces.Option; import java.lang.reflect.Field; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java index c979131..3e0e208 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSelector.java @@ -1,6 +1,6 @@ package io.polyfrost.oneconfig.gui.elements.config; -import io.polyfrost.oneconfig.interfaces.Option; +import io.polyfrost.oneconfig.config.interfaces.Option; import java.lang.reflect.Field; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java index 55c1222..0427b35 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSlider.java @@ -1,6 +1,6 @@ package io.polyfrost.oneconfig.gui.elements.config; -import io.polyfrost.oneconfig.interfaces.Option; +import io.polyfrost.oneconfig.config.interfaces.Option; import java.lang.reflect.Field; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java index 1fa1590..08c315f 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigSwitch.java @@ -1,6 +1,6 @@ package io.polyfrost.oneconfig.gui.elements.config; -import io.polyfrost.oneconfig.interfaces.Option; +import io.polyfrost.oneconfig.config.interfaces.Option; import java.lang.reflect.Field; diff --git a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java index 195607a..407f733 100644 --- a/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java +++ b/src/main/java/io/polyfrost/oneconfig/gui/elements/config/OConfigText.java @@ -1,6 +1,6 @@ package io.polyfrost.oneconfig.gui.elements.config; -import io.polyfrost.oneconfig.interfaces.Option; +import io.polyfrost.oneconfig.config.interfaces.Option; import java.lang.reflect.Field; diff --git a/src/main/java/io/polyfrost/oneconfig/renderer/Renderer.java b/src/main/java/io/polyfrost/oneconfig/renderer/Renderer.java index f8612b7..313a1d0 100644 --- a/src/main/java/io/polyfrost/oneconfig/renderer/Renderer.java +++ b/src/main/java/io/polyfrost/oneconfig/renderer/Renderer.java @@ -5,10 +5,13 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.awt.*; public class Renderer extends Gui { + public static final Logger renderLog = LogManager.getLogger("OneConfig Renderer"); private static final Minecraft mc = Minecraft.getMinecraft(); private static final FontRenderer fr = mc.fontRendererObj; diff --git a/src/main/java/io/polyfrost/oneconfig/renderer/shaders/ShaderHelper.java b/src/main/java/io/polyfrost/oneconfig/renderer/shaders/ShaderHelper.java new file mode 100644 index 0000000..892719e --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/renderer/shaders/ShaderHelper.java @@ -0,0 +1,4 @@ +package io.polyfrost.oneconfig.renderer.shaders; + +public class ShaderHelper { +} diff --git a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java index 3cfceaa..04c912e 100644 --- a/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java +++ b/src/main/java/io/polyfrost/oneconfig/test/TestConfig.java @@ -1,11 +1,11 @@ package io.polyfrost.oneconfig.test; -import io.polyfrost.oneconfig.annotations.Category; -import io.polyfrost.oneconfig.annotations.Switch; -import io.polyfrost.oneconfig.annotations.TextField; -import io.polyfrost.oneconfig.data.ModData; -import io.polyfrost.oneconfig.data.ModType; -import io.polyfrost.oneconfig.interfaces.Config; +import io.polyfrost.oneconfig.config.annotations.Category; +import io.polyfrost.oneconfig.config.annotations.Switch; +import io.polyfrost.oneconfig.config.annotations.TextField; +import io.polyfrost.oneconfig.config.data.ModData; +import io.polyfrost.oneconfig.config.data.ModType; +import io.polyfrost.oneconfig.config.interfaces.Config; import java.io.File; diff --git a/src/main/java/io/polyfrost/oneconfig/themes/TextureManager.java b/src/main/java/io/polyfrost/oneconfig/themes/TextureManager.java new file mode 100644 index 0000000..749dea6 --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/themes/TextureManager.java @@ -0,0 +1,82 @@ +package io.polyfrost.oneconfig.themes; + +import javafx.util.Pair; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.util.ResourceLocation; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; + +import static io.polyfrost.oneconfig.themes.Themes.themeLog; + +public class TextureManager { + private static final Minecraft mc = Minecraft.getMinecraft(); + private final List<ResourceLocation> resources = new ArrayList<>(); + private final List<ThemeElement> tickableTextureLocations = new ArrayList<>(); + private final List<Pair<Integer, Integer>> tickableTextures = new ArrayList<>(); + private int tick = 0; + + /** + * Create a new texture manager for this theme, used for drawing of icons, etc. + */ + public TextureManager(Theme theme) { + for(ThemeElement element : ThemeElement.values()) { + BufferedImage img; + try { + img = ImageIO.read(theme.getResource(element.location)); + } catch (Exception e) { + themeLog.error("failed to get themed texture: " + element.location + ", having to fallback to default one. Is pack invalid?"); + img = new BufferedImage(128,128,BufferedImage.TYPE_INT_ARGB); + // TODO add fallback + } + ResourceLocation location = mc.getTextureManager().getDynamicTextureLocation(element.location, new DynamicTexture(img)); + resources.add(location); + if(img.getWidth() != element.size) { + themeLog.warn("Theme element " + element.name() + " with size " + img.getWidth() + "px is not recommended, expected " + element.size + "px. Continuing anyway."); + } + if(img.getWidth() != img.getHeight()) { + themeLog.info("found tickable animated texture (" + element.name() + "). Loading texture"); + tickableTextureLocations.add(element); + tickableTextures.add(new Pair<>(img.getWidth(), img.getHeight())); + } + } + } + + /** + * Draw the specified icon at the coordinates, scaled to the width and height. + * @param element element to draw + * @param x x coordinate (top left) + * @param y y coordinate (top left) + * @param width width of the image + * @param height height of the image + */ + public void draw(ThemeElement element, int x, int y, int width, int height) { + GlStateManager.enableBlend(); + GlStateManager.color(1f, 1f, 1f, 1f); + ResourceLocation location = resources.get(element.ordinal()); + mc.getTextureManager().bindTexture(location); + try { + if(tickableTextureLocations.contains(element)) { + int texWidth = tickableTextures.get(0).getKey(); // TODO unsure if this works safe + int texHeight = tickableTextures.get(0).getValue(); + int frames = texHeight / texWidth; + while(tick < frames) { + Gui.drawModalRectWithCustomSizedTexture(x, y, 0, (tick * texWidth), texWidth, texWidth, texWidth, texWidth); + tick++; + if(tick == frames) { + tick = 0; + } + } + } else { + Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, width, height, width, height, width, height); + } + } catch (Exception e) { + themeLog.error("Error occurred drawing texture " + element.name() + ", is theme invalid?", e); + } + } +} diff --git a/src/main/java/io/polyfrost/oneconfig/themes/Theme.java b/src/main/java/io/polyfrost/oneconfig/themes/Theme.java index cc88e4a..bd6ee80 100644 --- a/src/main/java/io/polyfrost/oneconfig/themes/Theme.java +++ b/src/main/java/io/polyfrost/oneconfig/themes/Theme.java @@ -7,14 +7,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.resources.FileResourcePack; import net.minecraft.util.ResourceLocation; -import org.jetbrains.annotations.NotNull; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; -import java.util.ArrayList; -import java.util.List; @SuppressWarnings("unused") public class Theme extends FileResourcePack { @@ -36,11 +33,7 @@ public class Theme extends FileResourcePack { private final String description; private final String title; private final int version; - private final ResourceLocation iconsLoc; - private final ResourceLocation modIconsLoc; - private final ResourceLocation smallIconsLoc; - private final ResourceLocation logoLoc; - private final ResourceLocation logoLocSmall; + private final TextureManager manager; @@ -89,12 +82,11 @@ public class Theme extends FileResourcePack { this.description = description; this.version = version; - iconsLoc = createLargeIconAtlas(); - smallIconsLoc = createSmallIconAtlas(); - modIconsLoc = createModIconsAtlas(); - logoLoc = getLocationFromName("textures/logos/logo.png"); - logoLocSmall = getLocationFromName("textures/logos/logo_small.png"); - Themes.themeLog.info("Successfully loaded theme and created atlases in " + ((float) (System.nanoTime() - start)) / 1000000f + "ms"); + manager = new TextureManager(this); + if(Themes.VERSION != version) { + Themes.themeLog.warn("Theme was made for a different version of OneConfig! This may cause issues in the GUI."); + } + Themes.themeLog.info("Successfully loaded theme in " + ((float) (System.nanoTime() - start)) / 1000000f + "ms"); } @@ -116,88 +108,6 @@ public class Theme extends FileResourcePack { } - /** - * Create the large icon atlas from this theme. - */ - private ResourceLocation createLargeIconAtlas() { - try { - List<BufferedImage> icons = new ArrayList<>(); - icons.add(ImageIO.read(getResource("textures/icons/discord.png"))); - icons.add(ImageIO.read(getResource("textures/icons/docs.png"))); - icons.add(ImageIO.read(getResource("textures/icons/feedback.png"))); - icons.add(ImageIO.read(getResource("textures/icons/guide.png"))); - icons.add(ImageIO.read(getResource("textures/icons/hudsettings.png"))); - icons.add(ImageIO.read(getResource("textures/icons/modsettings.png"))); - icons.add(ImageIO.read(getResource("textures/icons/store.png"))); - icons.add(ImageIO.read(getResource("textures/icons/themes.png"))); - icons.add(ImageIO.read(getResource("textures/icons/update.png"))); - return createAtlasFromList(icons, 128); - } catch (Exception e) { - Themes.themeLog.error("Failed to create large icon atlas, is pack invalid?", e); - return null; - } - } - - /** - * Create the small icon atlas for this theme. - */ - private ResourceLocation createSmallIconAtlas() { - try { - List<BufferedImage> icons = new ArrayList<>(); - icons.add(ImageIO.read(getResource("textures/smallicons/backarrow.png"))); - icons.add(ImageIO.read(getResource("textures/smallicons/close.png"))); - icons.add(ImageIO.read(getResource("textures/smallicons/forward.png"))); - icons.add(ImageIO.read(getResource("textures/smallicons/home.png"))); - icons.add(ImageIO.read(getResource("textures/smallicons/magnify.png"))); - icons.add(ImageIO.read(getResource("textures/smallicons/minimize.png"))); - icons.add(ImageIO.read(getResource("textures/smallicons/search.png"))); - return createAtlasFromList(icons, 32); - } catch (Exception e) { - Themes.themeLog.error("Failed to create small icon atlas, is pack invalid?", e); - return null; - } - } - - /** - * Create mod icon atlas for this theme. - */ - private ResourceLocation createModIconsAtlas() { - try { - List<BufferedImage> icons = new ArrayList<>(); - icons.add(ImageIO.read(getResource("textures/mod/allmods.png"))); - icons.add(ImageIO.read(getResource("textures/mod/hudmods.png"))); - icons.add(ImageIO.read(getResource("textures/mod/hypixel.png"))); - icons.add(ImageIO.read(getResource("textures/mod/performance.png"))); - icons.add(ImageIO.read(getResource("textures/mod/pvp.png"))); - icons.add(ImageIO.read(getResource("textures/mod/qolmods.png"))); - icons.add(ImageIO.read(getResource("textures/mod/skyblock.png"))); - icons.add(ImageIO.read(getResource("textures/mod/utilities.png"))); - return createAtlasFromList(icons, 32); - } catch (Exception e) { - Themes.themeLog.error("Failed to create mod icon atlas, is pack invalid?", e); - return null; - } - } - - - /** - * Create a texture atlas from the given list of images, vertically stacked. - * @param images List of BufferedImages to use - * @param imageSize image size in pixels (note: images must be square) - * @return ResourceLocation of the atlas - */ - public static ResourceLocation createAtlasFromList(@NotNull List<BufferedImage> images, int imageSize) { - BufferedImage out = new BufferedImage(imageSize, (images.size() * imageSize), BufferedImage.TYPE_INT_ARGB); - Graphics2D graphics2D = out.createGraphics(); - int i = 0; - for (BufferedImage img : images) { - graphics2D.drawImage(img, null, 0, i); - i += imageSize; - } - graphics2D.dispose(); - return mc.getTextureManager().getDynamicTextureLocation(String.valueOf(i), new DynamicTexture(out)); - } - /** * get a ResourceLocation of an image in the current theme. @@ -337,38 +247,10 @@ public class Theme extends FileResourcePack { } /** - * Get the large icon atlas. - */ - public ResourceLocation getLargeIconAtlas() { - return iconsLoc; - } - - /** - * Get the small icon atlas. - */ - public ResourceLocation getSmallIconAtlas() { - return smallIconsLoc; - } - - /** - * Get the mod icon atlas. - */ - public ResourceLocation getModIconsAtlas() { - return modIconsLoc; - } - - /** - * Get the logo for OneConfig as specified by this theme. - */ - public ResourceLocation getOneConfigLogo() { - return logoLoc; - } - - /** - * Get the small logo for OneConfig as specified by this theme. + * Get the texture manager for this theme, with all drawing utilities. */ - public ResourceLocation getSmallOneConfigLogo() { - return logoLocSmall; + public TextureManager getTextureManager() { + return manager; } } diff --git a/src/main/java/io/polyfrost/oneconfig/themes/ThemeElement.java b/src/main/java/io/polyfrost/oneconfig/themes/ThemeElement.java new file mode 100644 index 0000000..f0be82a --- /dev/null +++ b/src/main/java/io/polyfrost/oneconfig/themes/ThemeElement.java @@ -0,0 +1,42 @@ +package io.polyfrost.oneconfig.themes; + +public enum ThemeElement { + DISCORD("textures/icons/discord.png", 128), + DOCS("textures/icons/docs.png", 128), + FEEDBACK("textures/icons/feedback.png", 128), + GUIDE("textures/icons/guide.png", 128), + HUD_SETTINGS("textures/icons/hudsettings.png", 128), + MOD_SETTINGS("textures/icons/modsettings.png", 128), + STORE("textures/icons/store.png", 128), + THEMES("textures/icons/themes.png", 128), + UPDATE("textures/icons/update.png", 128), + + BACK_ARROW("textures/smallicons/backarrow.png", 32), + CLOSE("textures/smallicons/close.png", 32), + FORWARD_ARROW("textures/smallicons/forward.png", 32), + HOME("textures/smallicons/home.png", 32), + MAGNIFY("textures/smallicons/magnify.png", 32), + MINIMIZE("textures/smallicons/minimize.png", 32), + SEARCH("textures/smallicons/backarrow.png", 32), + + ALL_MODS("textures/mod/allmods.png", 32), + HUD_MODS("textures/mod/hudmods.png", 32), + QOL_MODS("textures/mod/qolmods.png", 32), + HYPIXEL("textures/mod/hypixel.png", 32), + PERFORMANCE("textures/mod/performance.png", 32), + PVP("textures/mod/pvp.png", 32), + SKYBLOCK("textures/mod/skyblock.png", 32), + UTILITIES("textures/mod/utilities.png", 32), + + LOGO("textures/logos/logo.png", 128), + SMALL_LOGO("textures/logos/logo_small.png", 32); + + + public final String location; + public final int size; + + ThemeElement(String location, int size) { + this.location = location; + this.size = size; + } +} diff --git a/src/main/java/io/polyfrost/oneconfig/themes/Themes.java b/src/main/java/io/polyfrost/oneconfig/themes/Themes.java index 7bff29c..38e5df7 100644 --- a/src/main/java/io/polyfrost/oneconfig/themes/Themes.java +++ b/src/main/java/io/polyfrost/oneconfig/themes/Themes.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Objects; public class Themes { + public static final int VERSION = 0; public static Theme activeTheme; public static final Logger themeLog = LogManager.getLogger("OneConfig Themes"); |