aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/polyfrost/oneconfig/themes
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/themes')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/Theme.java17
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/Themes.java5
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/textures/TextureManager.java38
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/textures/ThemeElement.java2
4 files changed, 44 insertions, 18 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/themes/Theme.java b/src/main/java/io/polyfrost/oneconfig/themes/Theme.java
index 63450da..5f2bfac 100644
--- a/src/main/java/io/polyfrost/oneconfig/themes/Theme.java
+++ b/src/main/java/io/polyfrost/oneconfig/themes/Theme.java
@@ -22,6 +22,7 @@ public class Theme extends FileResourcePack {
private final File themeFile;
private final File themeConfigFile;
private static final Minecraft mc = Minecraft.getMinecraft();
+ private final long loadedTime = System.currentTimeMillis();
private final JsonObject packMetadata;
private final JsonObject packConfig;
private final Color accentColor;
@@ -40,6 +41,7 @@ public class Theme extends FileResourcePack {
private final TextureManager manager;
private final TrueTypeFont boldFont;
private final TrueTypeFont normalFont;
+ private boolean ready;
@@ -50,6 +52,7 @@ public class Theme extends FileResourcePack {
*/
protected Theme(File themePack) throws IOException {
super(themePack);
+ ready = false;
long start = System.nanoTime();
themeFile = themePack;
themeConfigFile = new File(themeFile.getPath() + ".json");
@@ -110,6 +113,7 @@ public class Theme extends FileResourcePack {
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");
+ ready = true;
}
@@ -290,4 +294,17 @@ public class Theme extends FileResourcePack {
return boldFont;
}
+ /**
+ * Get the time this theme was loaded. (used for debugging)
+ */
+ public long getLoadedTime() {
+ return loadedTime;
+ }
+
+ /**
+ * Check if the theme is fully loaded or not.
+ */
+ public boolean isReady() {
+ return ready;
+ }
}
diff --git a/src/main/java/io/polyfrost/oneconfig/themes/Themes.java b/src/main/java/io/polyfrost/oneconfig/themes/Themes.java
index 38e5df7..240c97d 100644
--- a/src/main/java/io/polyfrost/oneconfig/themes/Themes.java
+++ b/src/main/java/io/polyfrost/oneconfig/themes/Themes.java
@@ -45,4 +45,9 @@ public class Themes {
// TODO restart gui
}
+
+ public String toString() {
+ return "OneConfig Theme {loaded=" + activeTheme.getLoadedTime() + ", name=" + activeTheme.getName() + ", desc=" + activeTheme.getDescription() + ", ready=" + activeTheme.isReady() + "}";
+ }
+
}
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 5825fb1..9b583ef 100644
--- a/src/main/java/io/polyfrost/oneconfig/themes/textures/TextureManager.java
+++ b/src/main/java/io/polyfrost/oneconfig/themes/textures/TextureManager.java
@@ -8,6 +8,7 @@ import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.crash.CrashReport;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;
+import org.jetbrains.annotations.NotNull;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@@ -15,6 +16,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import static io.polyfrost.oneconfig.themes.Themes.activeTheme;
import static io.polyfrost.oneconfig.themes.Themes.themeLog;
public class TextureManager {
@@ -73,26 +75,28 @@ public class TextureManager {
* @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(!tickableTextures.isEmpty()) {
- for (TickableTexture texture : tickableTextures) {
- if (texture.getElement().equals(element)) {
- texture.draw(x, y);
- } else {
- Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, width, height, width, height, width, height);
+ public void draw(@NotNull ThemeElement element, int x, int y, int width, int height) {
+ if (activeTheme.isReady()) {
+ ResourceLocation location = resources.get(element.ordinal());
+ mc.getTextureManager().bindTexture(location);
+ GlStateManager.enableBlend();
+ try {
+ if (!tickableTextures.isEmpty()) {
+ for (TickableTexture texture : tickableTextures) {
+ if (texture.getElement().equals(element)) {
+ texture.draw(x, y);
+ } else {
+ Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, width, height, width, height, width, height);
+ }
}
+ } else {
+ Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, width, height, width, height, width, height);
}
- } else {
- Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, width, height, width, height, width, height);
+ GlStateManager.disableBlend();
+ GlStateManager.color(1f, 1f, 1f, 1f);
+ } catch (Exception e) {
+ themeLog.error("Error occurred drawing texture " + element.name() + ", is theme invalid?", e);
}
- GlStateManager.disableBlend();
- } 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/textures/ThemeElement.java b/src/main/java/io/polyfrost/oneconfig/themes/textures/ThemeElement.java
index 096b2aa..2ab3bc9 100644
--- a/src/main/java/io/polyfrost/oneconfig/themes/textures/ThemeElement.java
+++ b/src/main/java/io/polyfrost/oneconfig/themes/textures/ThemeElement.java
@@ -31,7 +31,7 @@ public enum ThemeElement {
LOGO("textures/logos/logo.png", 128),
SMALL_LOGO("textures/logos/logo_small.png", 64),
- BUTTON_OFF("textures/window/button_off.png", 758),
+ BUTTON("textures/window/button.png", 758),
BUTTON_HOVER("textures/window/button_hover.png", 758),
BUTTON_CLICK("textures/window/button_click.png", 758),