aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
authornextdaydelivery <12willettsh@gmail.com>2022-02-19 15:10:17 +0000
committernextdaydelivery <12willettsh@gmail.com>2022-02-19 15:10:17 +0000
commit8dbf57afea03a33b5648e77823e4948abdf3ba4f (patch)
tree090513b61908d3b74caf99629c44fc5fb50f48f2 /src/main/java/io
parent3000dd17a482843ccf320d594d2dd39eb59145e8 (diff)
downloadOneConfig-8dbf57afea03a33b5648e77823e4948abdf3ba4f.tar.gz
OneConfig-8dbf57afea03a33b5648e77823e4948abdf3ba4f.tar.bz2
OneConfig-8dbf57afea03a33b5648e77823e4948abdf3ba4f.zip
finish theme stuff, do some window stuff and add colored text
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/polyfrost/oneconfig/gui/Window.java27
-rw-r--r--src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java16
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/TextureManager.java6
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/Theme.java2
-rw-r--r--src/main/java/io/polyfrost/oneconfig/themes/ThemeElement.java8
5 files changed, 35 insertions, 24 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/gui/Window.java b/src/main/java/io/polyfrost/oneconfig/gui/Window.java
index aea1851..245dbea 100644
--- a/src/main/java/io/polyfrost/oneconfig/gui/Window.java
+++ b/src/main/java/io/polyfrost/oneconfig/gui/Window.java
@@ -21,15 +21,8 @@ public class Window extends GuiScreen {
public static Window currentWindow;
private final Theme t = Themes.getActiveTheme();
private final int guiScaleToRestore;
- TrueTypeFont font;
public Window() {
- try {
- Font tempFont = Font.createFont(Font.TRUETYPE_FONT, Objects.requireNonNull(Window.class.getResourceAsStream("/assets/oneconfig/fonts/font.ttf")));
- font = new TrueTypeFont(tempFont.deriveFont(30f), true);
- } catch (FontFormatException | IOException e) {
- e.printStackTrace();
- }
super.initGui();
currentWindow = this;
guiScaleToRestore = Minecraft.getMinecraft().gameSettings.guiScale;
@@ -59,10 +52,21 @@ public class Window extends GuiScreen {
int bottom = (int) (1024 * currentProgress);
//Gui.drawRect(left - 1, top - 1, right + 1, bottom + 1, testingColor.getRGB());
//new Color(16, 17, 19, 255).getRGB()
- Renderer.drawRoundRect(left,top,right,bottom,30, testingColor.getRGB());
- Renderer.drawRoundRect(left + 1,top + 1,right - 2,bottom - 2,30, t.getBaseColor().getRGB());
- t.getTextureManager().draw(ThemeElement.LOGO, left + 24, top + 24, 64, 64); // 0.875
- font.drawString("OneConfig", left + 93f, top + 25, 1f,1f);
+ t.getTextureManager().draw(ThemeElement.BACKGROUND, left, top, right, bottom);
+ t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 480, top + 40, 640, 48);
+ t.getTextureManager().draw(ThemeElement.SEARCH, left + 504, top + 48, 32, 32);
+ t.getFont().drawString("Search all of OneConfig", left + 548, top + 48, 1.1f, 1f, new Color(242,242,242,255).getRGB());
+ t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 1504, top + 32, 64, 64);
+ t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 1424, top + 32, 64, 64);
+ t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 1344, top + 32, 64, 64);
+ //t.getTextureManager().draw(ThemeElement.CLOSE, left + 1504, top + 32, 64, 64);
+ //t.getTextureManager().draw(ThemeElement.BUTTON_OFF, left + 100, top + 100, 296, 64);
+ //t.getTextureManager().draw(ThemeElement.CLOSE);
+
+ //Renderer.drawRoundRect(left,top,right,bottom,30, testingColor.getRGB());
+ //Renderer.drawRoundRect(left + 1,top + 1,right - 2,bottom - 2,30, t.getBaseColor().getRGB());
+ //t.getTextureManager().draw(ThemeElement.LOGO, left + 24, top + 24, 64, 64); // 0.875
+ //t.getBoldFont().drawString("OneConfig", left + 93f, top + 25, 1f,1f);
//Gui.drawRect(left, top, right, bottom, t.getBaseColor().getRGB());
//Gui.drawRect(left, top, right, top + 100, t.getTitleBarColor().getRGB());
@@ -79,6 +83,5 @@ public class Window extends GuiScreen {
@Override
public void onGuiClosed() {
Minecraft.getMinecraft().gameSettings.guiScale = guiScaleToRestore;
- font.destroy();
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java b/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java
index 52025da..452bc48 100644
--- a/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java
+++ b/src/main/java/io/polyfrost/oneconfig/renderer/TrueTypeFont.java
@@ -5,13 +5,11 @@ import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
-import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.image.DataBufferInt;
-import java.io.File;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
@@ -270,12 +268,16 @@ public class TrueTypeFont {
return fontHeight;
}
- public void drawString(String text, float x, float y, float scaleX, float scaleY) {
- drawString(text, x, y, scaleX, scaleY, ALIGN_LEFT);
+ public void drawString(String text, float x, float y, float scaleX, float scaleY, int color) {
+ drawString(text, x, y, scaleX, scaleY, ALIGN_LEFT, color);
}
- public void drawString(String text, float x, float y, float scaleX, float scaleY, int format) {
+ public void drawString(String text, float x, float y, float scaleX, float scaleY, int format, int color) {
+ float f = (float) (color >> 16 & 255) / 255.0F;
+ float f1 = (float) (color >> 8 & 255) / 255.0F;
+ float f3 = (float) (color >> 24 & 255) / 255.0F;
+ float f2 = (float) (color & 255) / 255.0F;
int startIndex = 0;
int endIndex = text.length() - 1;
IntObject intObject;
@@ -322,6 +324,7 @@ public class TrueTypeFont {
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
+ GlStateManager.color(f, f1, f2, f3);
while (i >= startIndex && i <= endIndex) {
charCurrent = text.charAt(i);
if (charCurrent < 256) {
@@ -358,6 +361,7 @@ public class TrueTypeFont {
i += d;
}
GlStateManager.disableBlend();
+ GlStateManager.color(1f,1f,1f,1f);
}
public static int loadImage(BufferedImage bufferedImage) {
@@ -397,7 +401,7 @@ public class TrueTypeFont {
int internalFormat = GL11.GL_RGBA8,
format = GL11.GL_RGBA;
IntBuffer textureId = BufferUtils.createIntBuffer(1);
- ;
+
GL11.glGenTextures(textureId);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));
diff --git a/src/main/java/io/polyfrost/oneconfig/themes/TextureManager.java b/src/main/java/io/polyfrost/oneconfig/themes/TextureManager.java
index 6406e1b..f436a7b 100644
--- a/src/main/java/io/polyfrost/oneconfig/themes/TextureManager.java
+++ b/src/main/java/io/polyfrost/oneconfig/themes/TextureManager.java
@@ -54,7 +54,11 @@ public class TextureManager {
}
}
} else {
-
+ if(element.ordinal() < 29) {
+ if(img.getHeight() != 144 || img.getWidth() != 758) {
+ themeLog.warn("found badly sized button texture " + element.location);
+ }
+ }
}
}
}
diff --git a/src/main/java/io/polyfrost/oneconfig/themes/Theme.java b/src/main/java/io/polyfrost/oneconfig/themes/Theme.java
index 9e67799..4647397 100644
--- a/src/main/java/io/polyfrost/oneconfig/themes/Theme.java
+++ b/src/main/java/io/polyfrost/oneconfig/themes/Theme.java
@@ -90,7 +90,7 @@ public class Theme extends FileResourcePack {
TrueTypeFont boldFontTemp;
try {
boldFontTemp = new TrueTypeFont(Font.createFont(Font.TRUETYPE_FONT, getResource("textures/fonts/font_bold.ttf")).deriveFont(30f), true);
- normalFontTemp = new TrueTypeFont(Font.createFont(Font.TRUETYPE_FONT, getResource("textures/fonts/font.ttf")).deriveFont(12f), true);
+ normalFontTemp = new TrueTypeFont(Font.createFont(Font.TRUETYPE_FONT, getResource("textures/fonts/font.ttf")).deriveFont(18f), true);
} catch (FontFormatException e) {
Themes.themeLog.error("failed to derive fonts, is theme invalid?",e);
e.printStackTrace();
diff --git a/src/main/java/io/polyfrost/oneconfig/themes/ThemeElement.java b/src/main/java/io/polyfrost/oneconfig/themes/ThemeElement.java
index 818bfdf..30451d7 100644
--- a/src/main/java/io/polyfrost/oneconfig/themes/ThemeElement.java
+++ b/src/main/java/io/polyfrost/oneconfig/themes/ThemeElement.java
@@ -17,7 +17,7 @@ public enum ThemeElement {
HOME("textures/smallicons/home.png", 32),
MAGNIFY("textures/smallicons/magnify.png", 32),
MINIMIZE("textures/smallicons/minimize.png", 32),
- SEARCH("textures/smallicons/backarrow.png", 32),
+ SEARCH("textures/smallicons/search.png", 32),
ALL_MODS("textures/mod/allmods.png", 32),
HUD_MODS("textures/mod/hudmods.png", 32),
@@ -31,9 +31,9 @@ public enum ThemeElement {
LOGO("textures/logos/logo.png", 128),
SMALL_LOGO("textures/logos/logo_small.png", 64),
- BUTTON_OFF("textures/window/button_off.png", 512),
- BUTTON_HOVER("textures/window/button_hover.png", 512),
- BUTTON_CLICK("textures/window/button_click.png", 512),
+ BUTTON_OFF("textures/window/button_off.png", 758),
+ BUTTON_HOVER("textures/window/button_hover.png", 758),
+ BUTTON_CLICK("textures/window/button_click.png", 758),
BACKGROUND("textures/window/background.png", 1600);