aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/themes/textures
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-04-04 14:53:10 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-04-04 14:53:10 +0200
commitddca3a3232eff15a7130efda03e7e5c408554412 (patch)
treeef7678412590ca432bb2cd25aabfc3bf2ea4b7b0 /src/main/java/io/polyfrost/oneconfig/themes/textures
parent1210e38c2ff569a28b20d7d0182557fbf386d524 (diff)
parent2696141f9790fd6c8d3df1148f46d298512c4902 (diff)
downloadOneConfig-ddca3a3232eff15a7130efda03e7e5c408554412.tar.gz
OneConfig-ddca3a3232eff15a7130efda03e7e5c408554412.tar.bz2
OneConfig-ddca3a3232eff15a7130efda03e7e5c408554412.zip
merge
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/themes/textures')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/textures/TextureManager.java19
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java9
2 files changed, 19 insertions, 9 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/themes/textures/TextureManager.java b/src/main/java/io/polyfrost/oneconfig/themes/textures/TextureManager.java
index 9b583ef..a2e96d4 100644
--- a/src/main/java/io/polyfrost/oneconfig/themes/textures/TextureManager.java
+++ b/src/main/java/io/polyfrost/oneconfig/themes/textures/TextureManager.java
@@ -46,7 +46,7 @@ public class TextureManager {
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(element.ordinal() < 26) {
+ if (element.ordinal() < 26) {
if (img.getWidth() != img.getHeight()) {
themeLog.info("found tickable animated texture (" + element.name() + "). Loading texture");
try {
@@ -57,8 +57,8 @@ public class TextureManager {
}
}
} else {
- if(element.ordinal() < 29) {
- if(img.getHeight() != 144 || img.getWidth() != 758) {
+ if (element.ordinal() < 29) {
+ if (img.getHeight() != 144 || img.getWidth() != 758) {
themeLog.warn("found badly sized button texture " + element.location);
}
}
@@ -67,7 +67,7 @@ public class TextureManager {
}
/**
- * Draw the specified icon at the coordinates, scaled to the width and height.
+ * Draw the specified {@link ThemeElement} at the coordinates, scaled to the width and height.
*
* @param element element to draw
* @param x x coordinate (top left)
@@ -99,4 +99,15 @@ public class TextureManager {
}
}
}
+
+ /**
+ * Draw the specified {@link ThemeElement} at the coordinates, using its recommended width and height.
+ *
+ * @param element element to draw
+ * @param x x coordinate (top left)
+ * @param y y coordinate (top left)
+ */
+ public void draw(@NotNull ThemeElement element, int x, int y) {
+ this.draw(element, x, y, element.size, element.size);
+ }
}
diff --git a/src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java b/src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java
index b9882d0..5fe1242 100644
--- a/src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java
+++ b/src/main/java/io/polyfrost/oneconfig/themes/textures/TickableTexture.java
@@ -2,7 +2,6 @@ package io.polyfrost.oneconfig.themes.textures;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import io.polyfrost.oneconfig.themes.textures.ThemeElement;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
@@ -23,10 +22,10 @@ public class TickableTexture {
private final int framesToSkip;
private final BufferedImage image;
private final int sizeX, sizeY, frames;
- private int tick;
- private int tick2;
private final ThemeElement thisElement;
private final ResourceLocation location;
+ private int tick;
+ private int tick2;
public TickableTexture(ThemeElement element) throws IOException {
thisElement = element;
@@ -42,7 +41,7 @@ public class TickableTexture {
frametime = jsonObject.get("frametime").getAsInt();
if (frametime == 0) {
frametime = 1;
- themeLog.warn("You cannot have a frame tick time of 0. This will mean there is no animation as it will happen way too fast. Defaulting to 1, as we assume you wanted it fast.");
+ themeLog.warn("You cannot have a frame tick time of 0. This will mean there is no animation as it will happen impossibly fast. Defaulting to 1, as we assume you wanted it fast.");
}
} catch (Exception e) {
themeLog.error("failed to load metadata for tickable texture (" + element.location + "). Setting default (5)");
@@ -53,7 +52,7 @@ public class TickableTexture {
public void draw(int x, int y) {
GlStateManager.enableBlend();
- GlStateManager.color(1f,1f,1f,1f);
+ GlStateManager.color(1f, 1f, 1f, 1f);
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
if (tick < frames) {
Gui.drawModalRectWithCustomSizedTexture(x, y, 0, (tick * sizeX), sizeX, sizeX, sizeX, sizeX);