ColorObject is now color Utils. no longer object wrapping.

This commit is contained in:
Speiger 2022-04-21 15:31:54 +02:00
parent df67199fdd
commit f550becac5
78 changed files with 2740 additions and 2679 deletions

View File

@ -66,5 +66,5 @@ dependencies {
compile 'com.google.code.gson:gson:2.8.6' compile 'com.google.code.gson:gson:2.8.6'
//Primitive Collections //Primitive Collections
compile 'de.speiger:Primitive-Collections:0.4.5' compile 'de.speiger:Primitive-Collections:0.6.0'
} }

Binary file not shown.

View File

@ -1,391 +0,0 @@
package speiger.src.coreengine.math.misc;
import java.awt.Color;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import speiger.src.collections.floats.lists.FloatList;
public class ColorObject
{
static final float DEVIDER = 1F / 255F;
public static final int R = 0xFF << 16;
public static final int G = 0xFF << 8;
public static final int B = 0xFF;
public static final int A = 0xFF << 24;
public static final long SIGN = 0x00000000FFFFFFFFL;
static final int ALL = 0xFFFFFFFF;
public static final ColorObject WHITE = new ColorObject(255, 255, 255);
public static final ColorObject LIGHT_GRAY = new ColorObject(192, 192, 192);
public static final ColorObject GRAY = new ColorObject(128, 128, 128);
public static final ColorObject DARK_GRAY = new ColorObject(64, 64, 64);
public static final ColorObject BLACK = new ColorObject(0, 0, 0);
public static final ColorObject RED = new ColorObject(255, 0, 0);
public static final ColorObject PINK = new ColorObject(255, 175, 175);
public static final ColorObject PURPLE = new ColorObject(106, 13, 173);
public static final ColorObject ORANGE = new ColorObject(255, 200, 0);
public static final ColorObject YELLOW = new ColorObject(255, 255, 0);
public static final ColorObject GREEN = new ColorObject(0, 255, 0);
public static final ColorObject DARK_GREEN = new ColorObject(7, 161, 0);
public static final ColorObject MAGENTA = new ColorObject(255, 0, 255);
public static final ColorObject CYAN = new ColorObject(0, 255, 255);
public static final ColorObject BLUE = new ColorObject(0, 0, 255);
public static final ColorObject LIGHT_BLUE = new ColorObject(0, 150, 255);
//Specialized Components that get reused
public static final ColorObject INVISIBLE = new ColorObject(0, 0, 0, 0);
public static final ColorObject TEXT_DEFAULT_BACKGROUND = new ColorObject(80, 80, 80, 144);
public static final ColorObject WINDOW_DEFAULT_BACKGROUND = new ColorObject(64, 64, 64, 128);
public static final ColorObject POPUP_DEFAULT_BACKGROUND = new ColorObject(85, 85, 85);
public static final ColorObject DESTRUCTION = new ColorObject(255, 0, 0, 128);
int rgba;
public ColorObject(int rgba)
{
this.rgba = rgba;
}
public ColorObject(int r, int g, int b)
{
rgba = A | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
}
public ColorObject(int r, int g, int b, int a)
{
rgba = ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
}
public static ColorObject rgb(int rgb)
{
return new ColorObject(rgb | (255 << 24));
}
public ColorObject copy()
{
return new ColorObject(rgba);
}
public ColorObject setRGB(int rgba)
{
this.rgba = rgba;
return this;
}
public ColorObject setRed(int r)
{
rgba = rgba & ~R | ((r & 0xFF) << 16);
return this;
}
public ColorObject setGreen(int g)
{
rgba = rgba & ~G | ((g & 0xFF) << 8);
return this;
}
public ColorObject setBlue(int b)
{
rgba = rgba & ~B | (b & 0xFF);
return this;
}
public ColorObject setAlpha(int a)
{
rgba = rgba & ~A | ((a & 0xFF) << 24);
return this;
}
public ColorObject setRed(float r)
{
return setRed((int)(r * 255F + 0.5F));
}
public ColorObject setGreen(float g)
{
return setGreen((int)(g * 255F + 0.5F));
}
public ColorObject setBlue(float b)
{
return setBlue((int)(b * 255F + 0.5F));
}
public ColorObject setAlpha(float a)
{
return setAlpha((int)(a * 255F + 0.5F));
}
public ColorObject setRGB(float hue, float brightness, float saturation, int alpha)
{
return setRGB(Color.HSBtoRGB(hue, saturation, brightness) | alpha << 24);
}
public int getRGB()
{
return rgba;
}
public int getRed()
{
return (rgba >> 16) & 0xFF;
}
public int getGreen()
{
return (rgba >> 8) & 0xFF;
}
public int getBlue()
{
return rgba & 0xFF;
}
public int getAlpha()
{
return (rgba >> 24) & 0xFF;
}
public float getRedFloat()
{
return ((rgba >> 16) & 0xFF) * DEVIDER;
}
public float getGreenFloat()
{
return ((rgba >> 8) & 0xFF) * DEVIDER;
}
public float getBlueFloat()
{
return (rgba & 0xFF) * DEVIDER;
}
public float getAlphaFloat()
{
return ((rgba >> 24) & 0xFF) * DEVIDER;
}
public String getHexCode(boolean alpha)
{
return "0x"+(alpha ? Long.toHexString(1 << 32 | rgba & SIGN) : Integer.toHexString((1 << 24) | (rgba & ~A))).substring(1);
}
public String getHTMLCode(boolean alpha)
{
return "#"+(alpha ? Long.toHexString(1 << 32 | rgba & SIGN) : Integer.toHexString((1 << 24) | (rgba & ~A))).substring(1);
}
public boolean needsDarkColor()
{
return getBrightness() >= 130;
}
public int getBrightness()
{
return getBrightness(rgba);
}
public Color toColor()
{
return new Color(rgba);
}
public float[] toHue()
{
return Color.RGBtoHSB(getRed(), getGreen(), getBlue(), new float[3]);
}
public ColorObject brighter()
{
return brighter(0.7F);
}
public ColorObject brighter(float factor)
{
rgba = brighter(rgba, factor);
return this;
}
public ColorObject darker()
{
return darker(0.7F);
}
public ColorObject darker(float factor)
{
rgba = darker(rgba, factor);
return this;
}
public ColorObject mix(ColorObject to, float factor)
{
rgba = mix(rgba, to.rgba, factor);
return this;
}
public ColorObject mix(ColorObject from, ColorObject to, float factor)
{
rgba = mix(from.rgba, to.rgba, factor);
return this;
}
public ColorObject write(FloatBuffer buffer, boolean alpha)
{
buffer.put(getRedFloat()).put(getGreenFloat()).put(getBlueFloat());
if(alpha)
{
buffer.put(getAlphaFloat());
}
return this;
}
public ColorObject read(FloatBuffer buffer, boolean alpha)
{
setRed(buffer.get()).setGreen(buffer.get()).setBlue(buffer.get());
if(alpha)
{
setAlpha(buffer.get());
}
return this;
}
public ColorObject write(ByteBuffer buffer, boolean alpha)
{
pack(rgba, alpha, buffer);
return this;
}
public ColorObject read(ByteBuffer buffer, boolean alpha)
{
setRed(buffer.get()).setGreen(buffer.get()).setBlue(buffer.get());
if(alpha)
{
setAlpha(buffer.get());
}
return this;
}
public ColorObject write(FloatList buffer, boolean alpha)
{
buffer.add(getRedFloat());
buffer.add(getGreenFloat());
buffer.add(getBlueFloat());
if(alpha)
{
buffer.add(getAlphaFloat());
}
return this;
}
public ColorObject writeFloat(ByteBuffer buffer, boolean alpha)
{
buffer.putFloat(getRedFloat()).putFloat(getGreenFloat()).putFloat(getBlueFloat());
if(alpha)
{
buffer.putFloat(getAlphaFloat());
}
return this;
}
@Override
public int hashCode()
{
return rgba;
}
@Override
public boolean equals(Object obj)
{
if(obj instanceof ColorObject)
{
return ((ColorObject)obj).rgba == rgba;
}
return false;
}
@Override
public String toString()
{
return "Color[r=" + getRed() + ", g=" + getGreen() + ", b=" + getBlue() + ", a=" + getAlpha() + "]";
}
public String getFloatColor()
{
return "Color[r=" + getRedFloat() + ", g=" + getGreenFloat() + ", b=" + getBlueFloat() + ", a=" + getAlphaFloat() + "]";
}
public static byte[] toByteArray(int color, boolean alpha)
{
byte[] data = new byte[alpha ? 4 : 3];
data[0] = (byte)((color >> 16) & 0xFF);
data[1] = (byte)((color >> 8) & 0xFF);
data[2] = (byte)(color & 0xFF);
if(alpha) data[3] = (byte)((color >> 24) & 0xFF);
return data;
}
public static void pack(int color, boolean alpha, ByteBuffer buffer)
{
buffer.put((byte)((color >> 16) & 0xFF)).put((byte)((color >> 8) & 0xFF)).put((byte)(color & 0xFF));
if(alpha)
{
buffer.put((byte)((color >> 24) & 0xFF));
}
}
public static void packFloat(int color, boolean alpha, FloatBuffer buffer)
{
buffer.put(((color >> 16) & 0xFF) * DEVIDER).put(((color >> 8) & 0xFF) * DEVIDER).put((color & 0xFF) * DEVIDER);
if(alpha)
{
buffer.put(((color >> 24) & 0xFF) * DEVIDER);
}
}
public static int getBrightness(int rgba)
{
return getBrightness((rgba >> 16) & 0xFF, (rgba >> 8) & 0xFF, rgba & 0xFF);
}
public static int getBrightness(int r, int g, int b)
{
return (int)Math.sqrt((r * r * 0.241F) + (g * g * 0.691F) + (b * b * 0.068F));
}
public static int mix(int from, int to, float factor)
{
float weight0 = (1F - factor);
float weight1 = factor;
int r = (int)((((from >> 16) & 0xFF) * weight0) + (((to >> 16) & 0xFF) * weight1));
int g = (int)((((from >> 8) & 0xFF) * weight0) + (((to >> 8) & 0xFF) * weight1));
int b = (int)(((from & 0xFF) * weight0) + ((to & 0xFF) * weight1));
int a = (int)((((from >> 24) & 0xFF) * weight0) + (((to >> 24) & 0xFF) * weight1));
return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | b & 0xFF;
}
public static int darker(int color, float factor)
{
int r = Math.max(0, (int)(((color >> 16) & 0xFF) * factor));
int g = Math.max(0, (int)(((color >> 8) & 0xFF) * factor));
int b = Math.max(0, (int)((color & 0xFF) * factor));
return (color & A) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
}
public static int brighter(int color, float factor)
{
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
int i = (int)(1.0 / (1.0 - factor));
if(r == 0 && g == 0 && b == 0)
{
return (color & A) | ((i & 0xFF) << 16) | ((i & 0xFF) << 8) | (i & 0xFF);
}
if(r > 0 && r < i) r = i;
if(g > 0 && g < i) g = i;
if(b > 0 && b < i) b = i;
return (color & A) | Math.min(255, (int)(r / factor)) << 16 | Math.min(255, (int)(g / factor)) << 8 | Math.min(255, (int)(b / factor));
}
}

View File

@ -0,0 +1,374 @@
package speiger.src.coreengine.math.misc;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import speiger.src.collections.floats.lists.FloatList;
import speiger.src.coreengine.math.MathUtils;
public class ColorUtils
{
static final float DEVIDER = 1F / 255F;
public static final int R = 0xFF << 16;
public static final int G = 0xFF << 8;
public static final int B = 0xFF;
public static final int A = 0xFF << 24;
public static final long SIGN = 0x00000000FFFFFFFFL;
static final int ALL = 0xFFFFFFFF;
public static final int WHITE = rgb(255, 255, 255);
public static final int LIGHT_GRAY = rgb(192, 192, 192);
public static final int GRAY = rgb(128, 128, 128);
public static final int DARK_GRAY = rgb(64, 64, 64);
public static final int BLACK = rgb(0, 0, 0);
public static final int RED = rgb(255, 0, 0);
public static final int PINK = rgb(255, 175, 175);
public static final int PURPLE = rgb(106, 13, 173);
public static final int ORANGE = rgb(255, 200, 0);
public static final int YELLOW = rgb(255, 255, 0);
public static final int GREEN = rgb(0, 255, 0);
public static final int DARK_GREEN = rgb(7, 161, 0);
public static final int MAGENTA = rgb(255, 0, 255);
public static final int CYAN = rgb(0, 255, 255);
public static final int BLUE = rgb(0, 0, 255);
public static final int LIGHT_BLUE = rgb(0, 150, 255);
//Specialized Components that get reused
public static final int INVISIBLE = rgb(0, 0, 0, 0);
public static final int TEXT_DEFAULT_BACKGROUND = rgb(80, 80, 80, 144);
public static final int WINDOW_DEFAULT_BACKGROUND = rgb(64, 64, 64, 128);
public static final int POPUP_DEFAULT_BACKGROUND = rgb(85, 85, 85);
public static final int DESTRUCTION = rgb(255, 0, 0, 128);
public static byte[] toByteArray(int color, boolean alpha)
{
byte[] data = new byte[alpha ? 4 : 3];
data[0] = (byte)((color >> 16) & 0xFF);
data[1] = (byte)((color >> 8) & 0xFF);
data[2] = (byte)(color & 0xFF);
if(alpha) data[3] = (byte)((color >> 24) & 0xFF);
return data;
}
public static void write(int color, boolean alpha, ByteBuffer buffer)
{
buffer.put((byte)((color >> 16) & 0xFF)).put((byte)((color >> 8) & 0xFF)).put((byte)(color & 0xFF));
if(alpha)
{
buffer.put((byte)((color >> 24) & 0xFF));
}
}
public static void write(int index, int color, boolean alpha, ByteBuffer buffer)
{
buffer.put(index, (byte)((color >> 16) & 0xFF)).put(index + 1, (byte)((color >> 8) & 0xFF)).put(index + 2, (byte)(color & 0xFF));
if(alpha)
{
buffer.put(index + 3, (byte)((color >> 24) & 0xFF));
}
}
public static void writeFloat(int color, boolean alpha, ByteBuffer buffer)
{
buffer.putFloat(((color >> 16) & 0xFF) * DEVIDER).putFloat(((color >> 8) & 0xFF) * DEVIDER).putFloat((color & 0xFF) * DEVIDER);
if(alpha)
{
buffer.putFloat(((color >> 24) & 0xFF) * DEVIDER);
}
}
public static void writeFloat(int index, int color, boolean alpha, ByteBuffer buffer)
{
buffer.putFloat(index, ((color >> 16) & 0xFF) * DEVIDER).putFloat(index + 1, ((color >> 8) & 0xFF) * DEVIDER).putFloat(index + 2, (color & 0xFF) * DEVIDER);
if(alpha)
{
buffer.putFloat(index + 3, ((color >> 24) & 0xFF) * DEVIDER);
}
}
public static void write(int color, boolean alpha, FloatBuffer buffer)
{
buffer.put(((color >> 16) & 0xFF) * DEVIDER).put(((color >> 8) & 0xFF) * DEVIDER).put((color & 0xFF) * DEVIDER);
if(alpha)
{
buffer.put(((color >> 24) & 0xFF) * DEVIDER);
}
}
public static void write(int index, int color, boolean alpha, FloatBuffer buffer)
{
buffer.put(index, ((color >> 16) & 0xFF) * DEVIDER).put(index + 1, ((color >> 8) & 0xFF) * DEVIDER).put(index + 2, (color & 0xFF) * DEVIDER);
if(alpha)
{
buffer.put(index + 3, ((color >> 24) & 0xFF) * DEVIDER);
}
}
public static void write(int color, boolean alpha, FloatList list)
{
list.add(((color >> 16) & 0xFF) * DEVIDER);
list.add(((color >> 8) & 0xFF) * DEVIDER);
list.add((color & 0xFF) * DEVIDER);
if(alpha)
{
list.add(((color >> 24) & 0xFF) * DEVIDER);
}
}
public static int read(ByteBuffer buffer, boolean alpha)
{
return alpha ? rgb(buffer.get(), buffer.get(), buffer.get()) : rgb(buffer.get(), buffer.get(), buffer.get(), buffer.get());
}
public static int read(ByteBuffer buffer, int index, boolean alpha)
{
return alpha ? rgb(buffer.get(index), buffer.get(index+1), buffer.get(index+2)) : rgb(buffer.get(index), buffer.get(index+1), buffer.get(index+2), buffer.get(index+3));
}
public static int readFloat(ByteBuffer buffer, boolean alpha)
{
return alpha ? rgb(buffer.getFloat(), buffer.getFloat(), buffer.getFloat()) : rgb(buffer.getFloat(), buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
}
public static int readFloat(ByteBuffer buffer, int index, boolean alpha)
{
return alpha ? rgb(buffer.getFloat(index), buffer.getFloat(index+1), buffer.getFloat(index+2)) : rgb(buffer.getFloat(index), buffer.getFloat(index+1), buffer.getFloat(index+2), buffer.getFloat(index+3));
}
public static int read(FloatBuffer buffer, boolean alpha)
{
return alpha ? rgb(buffer.get(), buffer.get(), buffer.get()) : rgb(buffer.get(), buffer.get(), buffer.get(), buffer.get());
}
public static int read(FloatBuffer buffer, int index, boolean alpha)
{
return alpha ? rgb(buffer.get(index), buffer.get(index+1), buffer.get(index+2)) : rgb(buffer.get(index), buffer.get(index+1), buffer.get(index+2), buffer.get(index+3));
}
public static boolean needsDarkColor(int rgba)
{
return getBrightness(rgba) >= 130;
}
public static int getBrightness(int rgba)
{
return getBrightness((rgba >> 16) & 0xFF, (rgba >> 8) & 0xFF, rgba & 0xFF);
}
public static int getBrightness(int r, int g, int b)
{
return (int)Math.sqrt((r * r * 0.241F) + (g * g * 0.691F) + (b * b * 0.068F));
}
public static int mix(int from, int to, float factor)
{
float weight0 = (1F - factor);
float weight1 = factor;
int r = (int)((((from >> 16) & 0xFF) * weight0) + (((to >> 16) & 0xFF) * weight1));
int g = (int)((((from >> 8) & 0xFF) * weight0) + (((to >> 8) & 0xFF) * weight1));
int b = (int)(((from & 0xFF) * weight0) + ((to & 0xFF) * weight1));
int a = (int)((((from >> 24) & 0xFF) * weight0) + (((to >> 24) & 0xFF) * weight1));
return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | b & 0xFF;
}
public static int darker(int color)
{
return darker(color, 0.7F);
}
public static int darker(int color, float factor)
{
int r = Math.max(0, (int)(((color >> 16) & 0xFF) * factor));
int g = Math.max(0, (int)(((color >> 8) & 0xFF) * factor));
int b = Math.max(0, (int)((color & 0xFF) * factor));
return (color & A) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
}
public static int brighter(int color)
{
return brighter(color, 0.7F);
}
public static int brighter(int color, float factor)
{
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
int i = (int)(1.0 / (1.0 - factor));
if(r == 0 && g == 0 && b == 0)
{
return (color & A) | ((i & 0xFF) << 16) | ((i & 0xFF) << 8) | (i & 0xFF);
}
if(r > 0 && r < i) r = i;
if(g > 0 && g < i) g = i;
if(b > 0 && b < i) b = i;
return (color & A) | Math.min(255, (int)(r / factor)) << 16 | Math.min(255, (int)(g / factor)) << 8 | Math.min(255, (int)(b / factor));
}
public static int toRGB(float hue, float saturation, float brightness)
{
if (saturation == 0)
{
int result = (int)(brightness * 255F + 0.5F);
return rgb(result, result, result);
}
float h = (hue - MathUtils.floor(hue)) * 6F;
float f = h - MathUtils.floor(h);
float p = brightness * (1F - saturation);
float q = brightness * (1F - saturation * f);
float t = brightness * (1F - (saturation * (1F - f)));
switch ((int)h) {
case 0: return rgb(brightness, t, p);
case 1: return rgb(q, brightness, p);
case 2: return rgb(p, brightness, t);
case 3: return rgb(p, q, brightness);
case 4: return rgb(t, p, brightness);
case 5: return rgb(brightness, p, q);
default: return BLACK;
}
}
public static float[] toHue(int rgba)
{
int r = getR(rgba);
int g = getG(rgba);
int b = getB(rgba);
int cmax = (r > g) ? r : g;
if (b > cmax) cmax = b;
int cmin = (r < g) ? r : g;
if (b < cmin) cmin = b;
float length = cmax - cmin;
float[] result = new float[3];
result[1] = cmax == 0 ? 0F : length / cmax;
result[2] = cmax * DEVIDER;
float hue = 0F;
if(result[1] != 0F) {
float redc = (cmax - r) / length;
float greenc = (cmax - g) / length;
float bluec = (cmax - b) / length;
if (r == cmax) hue = bluec - greenc;
else if (g == cmax) hue = 2F + redc - bluec;
else hue = 4F + greenc - redc;
hue /= 6F;
if (hue < 0) hue += 1F;
}
result[0] = hue;
return result;
}
public static int rgb(int rgb)
{
return rgb | (255 << 24);
}
public static int rgb(int r, int g, int b)
{
return A | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
}
public static int rgb(float r, float g, float b)
{
return rgb((int)(r * 255F + 0.5F), (int)(g * 255F + 0.5F), (int)(b * 255F + 0.5F));
}
public static int rgb(int r, int g, int b, int a)
{
return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
}
public static int rgb(float r, float g, float b, float a)
{
return rgb((int)(r * 255F + 0.5F), (int)(g * 255F + 0.5F), (int)(b * 255F + 0.5F), (int)(b * 255F + 0.5F));
}
public static int setR(int rgba, int r)
{
return rgba & ~R | ((r & 0xFF) << 16);
}
public static int setR(int rgba, float r)
{
return rgba & ~R | (((int)(r * 255F + 0.5F)) << 16);
}
public static int setG(int rgba, int g)
{
return rgba & ~G | ((g & 0xFF) << 8);
}
public static int setG(int rgba, float g)
{
return rgba & ~G | (((int)(g * 255F + 0.5F)) << 8);
}
public static int setB(int rgba, int b)
{
return rgba & ~B | (b & 0xFF);
}
public static int setB(int rgba, float b)
{
return rgba & ~B | ((int)(b * 255F + 0.5F));
}
public static int setA(int rgba, int a)
{
return rgba & ~A | ((a & 0xFF) << 24);
}
public static int setA(int rgba, float a)
{
return rgba & ~A | (((int)(a * 255F + 0.5F)) << 24);
}
public static int getR(int rgba)
{
return (rgba >> 16) & 0xFF;
}
public static float getRF(int rgba)
{
return ((rgba >> 16) & 0xFF) * DEVIDER;
}
public static int getG(int rgba)
{
return (rgba >> 8) & 0xFF;
}
public static float getGF(int rgba)
{
return ((rgba >> 8) & 0xFF) * DEVIDER;
}
public static int getB(int rgba)
{
return rgba & 0xFF;
}
public static float getBF(int rgba)
{
return (rgba & 0xFF) * DEVIDER;
}
public static int getA(int rgba)
{
return (rgba >> 24) & 0xFF;
}
public static float getAF(int rgba)
{
return ((rgba >> 24) & 0xFF) * DEVIDER;
}
public static String getHexCode(int rgba, boolean alpha)
{
return "0x"+(alpha ? Long.toHexString(1 << 32 | rgba & SIGN) : Integer.toHexString((1 << 24) | (rgba & ~A))).substring(1);
}
public static String getHTMLCode(int rgba, boolean alpha)
{
return "#"+(alpha ? Long.toHexString(1 << 32 | rgba & SIGN) : Integer.toHexString((1 << 24) | (rgba & ~A))).substring(1);
}
}

View File

@ -88,7 +88,7 @@ public abstract class GuiBase
public <T extends GuiComponent> T centerComponent(T comp) public <T extends GuiComponent> T centerComponent(T comp)
{ {
IGuiBox box = comp.getBox(); IGuiBox box = comp.getBox();
comp.setComponentPosition(Align.CENTER.align(width, box.getWidth()), Align.CENTER.align(height, box.getHeight())); comp.set(Align.CENTER.align(width, box.getWidth()), Align.CENTER.align(height, box.getHeight()));
return comp; return comp;
} }

View File

@ -23,6 +23,7 @@ import speiger.src.coreengine.rendering.gui.helper.box.GuiBox;
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox; import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains; import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains;
import speiger.src.coreengine.rendering.gui.helper.constrains.Constrain; import speiger.src.coreengine.rendering.gui.helper.constrains.Constrain;
import speiger.src.coreengine.rendering.gui.renderer.FontRenderer;
import speiger.src.coreengine.rendering.gui.renderer.IComponentRenderer; import speiger.src.coreengine.rendering.gui.renderer.IComponentRenderer;
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer; import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
import speiger.src.coreengine.rendering.input.Keyboard; import speiger.src.coreengine.rendering.input.Keyboard;
@ -96,6 +97,11 @@ public abstract class GuiComponent extends FlagHolder
return owner; return owner;
} }
public FontRenderer getFont()
{
return owner.getFont();
}
public void calculateActualBounds(float[] area, boolean start) public void calculateActualBounds(float[] area, boolean start)
{ {
if(start) if(start)
@ -199,7 +205,7 @@ public abstract class GuiComponent extends FlagHolder
} }
} }
init(); init();
onComponentChanged(true); onChanged(true);
if(binding != null) if(binding != null)
{ {
gui.addKeyListener(binding); gui.addKeyListener(binding);
@ -320,7 +326,7 @@ public abstract class GuiComponent extends FlagHolder
clearFlag(FLAG_MASS_CHANGE); clearFlag(FLAG_MASS_CHANGE);
if(changed && !quiet) if(changed && !quiet)
{ {
onComponentChanged(massRepaint); onChanged(massRepaint);
} }
} }
return this; return this;
@ -369,7 +375,7 @@ public abstract class GuiComponent extends FlagHolder
if(getBox().getBaseScale() != value) if(getBox().getBaseScale() != value)
{ {
getBox().setScale(value); getBox().setScale(value);
onComponentChanged(true); onChanged(true);
} }
return this; return this;
} }
@ -439,7 +445,7 @@ public abstract class GuiComponent extends FlagHolder
private void addBindingTooltip() private void addBindingTooltip()
{ {
tooltips.addComponent(binding.getTooltip(), new TextComponent(0F, 0F, 200F, 0F, "Key: "+ModType.getMods(binding.mod)+BindingType.KEYBOARD.getName(binding.key)).setLimitedHeight(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setScale(0.5F)); tooltips.addComponent(binding.getTooltip(), new TextComponent(0F, 0F, 200F, 0F, "Key: "+ModType.getMods(binding.mod)+BindingType.KEYBOARD.getName(binding.key)).limitHeight(false).align(Align.LEFT_TOP, Align.LEFT_TOP).setScale(0.5F));
} }
protected boolean onUserKey() protected boolean onUserKey()
@ -454,7 +460,7 @@ public abstract class GuiComponent extends FlagHolder
public <T extends GuiComponent> T setRelativeTo(T component, Align horizontal, Align vertical) public <T extends GuiComponent> T setRelativeTo(T component, Align horizontal, Align vertical)
{ {
return component.setComponentPosition(box.getMinX() + horizontal.align(box.getWidth(), component.getBox().getWidth()), box.getMinY() + vertical.align(box.getHeight(), component.getBox().getHeight())).cast(); return component.set(box.getMinX() + horizontal.align(box.getWidth(), component.getBox().getWidth()), box.getMinY() + vertical.align(box.getHeight(), component.getBox().getHeight())).cast();
} }
public <T extends GuiComponent> T centerComponent(T component) public <T extends GuiComponent> T centerComponent(T component)
@ -542,7 +548,7 @@ public abstract class GuiComponent extends FlagHolder
public GuiComponent addTooltip(String s, float width, float height, float scale) public GuiComponent addTooltip(String s, float width, float height, float scale)
{ {
tooltips.addComponent(new TextComponent(0F, 0F, width, height, s).setLimitedHeight(height != 0F).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setScale(scale)); tooltips.addComponent(new TextComponent(0F, 0F, width, height, s).limitHeight(height != 0F).align(Align.LEFT_TOP, Align.LEFT_TOP).setScale(scale));
return this; return this;
} }
@ -709,39 +715,39 @@ public abstract class GuiComponent extends FlagHolder
return this; return this;
} }
public GuiComponent moveComponent(float x, float y) public GuiComponent move(float x, float y)
{ {
if(x == 0F && y == 0F || constraints != null) return this; if(x == 0F && y == 0F || constraints != null) return this;
box.move(x, y); box.move(x, y);
onComponentChanged(false); onChanged(false);
return this; return this;
} }
public GuiComponent setComponentPosition(float x, float y) public GuiComponent set(float x, float y)
{ {
if(box.getBaseX() == x && box.getBaseY() == y || constraints != null) return this; if(box.getBaseX() == x && box.getBaseY() == y || constraints != null) return this;
box.setXY(x, y); box.setXY(x, y);
onComponentChanged(false); onChanged(false);
return this; return this;
} }
public GuiComponent resizeComponent(float moveX, float moveY) public GuiComponent resize(float moveX, float moveY)
{ {
if(moveX == 0F && moveY == 0F || constraints != null) return this; if(moveX == 0F && moveY == 0F || constraints != null) return this;
box.grow(moveX, moveY); box.grow(moveX, moveY);
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public GuiComponent setComponentBounds(float width, float height) public GuiComponent bounds(float width, float height)
{ {
if(box.getBaseWidth() == width && box.getBaseHeight() == height || constraints != null) return this; if(box.getBaseWidth() == width && box.getBaseHeight() == height || constraints != null) return this;
box.setBounds(width, height); box.setBounds(width, height);
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final void onComponentChanged(boolean repaint) public final void onChanged(boolean repaint)
{ {
if(owner == null) return; if(owner == null) return;
if(isFlagSet(FLAG_MASS_CHANGE)) if(isFlagSet(FLAG_MASS_CHANGE))
@ -771,7 +777,7 @@ public abstract class GuiComponent extends FlagHolder
if(children.isEmpty()) return; if(children.isEmpty()) return;
for(GuiComponent comp : children) for(GuiComponent comp : children)
{ {
comp.onComponentChanged(repaint); comp.onChanged(repaint);
} }
} }
@ -785,23 +791,23 @@ public abstract class GuiComponent extends FlagHolder
} }
public final void onFixedUpdate() public final void fixedUpdate()
{ {
if(fixedUpdateSelf()) fixedUpdateChildren(); if(fixedUpdateSelf()) fixedUpdateChildren();
} }
public final void onUpdate(int mouseX, int mouseY, float particalTicks) public final void update(int mouseX, int mouseY, float particalTicks)
{ {
if(animation != null) animation.update(particalTicks); if(animation != null) animation.update(particalTicks);
if(updateSelf(mouseX, mouseY, particalTicks)) updateChildren(mouseX, mouseY, particalTicks); if(updateSelf(mouseX, mouseY, particalTicks)) updateChildren(mouseX, mouseY, particalTicks);
} }
protected void onPreRender() protected void preRender()
{ {
} }
public final void onRender(int mouseX, int mouseY, float particalTicks) public final void render(int mouseX, int mouseY, float particalTicks)
{ {
if(customRenderer != null) if(customRenderer != null)
{ {
@ -813,10 +819,10 @@ public abstract class GuiComponent extends FlagHolder
} }
else else
{ {
onPreRender(); preRender();
getRenderer().setVisibility(totalVisibility).setBrightness(brightness); getRenderer().setVisibility(totalVisibility).setBrightness(brightness);
if(renderSelf(mouseX, mouseY, particalTicks)) renderChildren(mouseX, mouseY, particalTicks); if(renderSelf(mouseX, mouseY, particalTicks)) renderChildren(mouseX, mouseY, particalTicks);
onPostRender(); postRender();
getRenderer().resetEffects(); getRenderer().resetEffects();
} }
if(getGui() instanceof GuiScreenBase) if(getGui() instanceof GuiScreenBase)
@ -825,7 +831,7 @@ public abstract class GuiComponent extends FlagHolder
} }
} }
protected void onPostRender() protected void postRender()
{ {
} }
@ -869,7 +875,7 @@ public abstract class GuiComponent extends FlagHolder
{ {
if(entry.isVisible()) if(entry.isVisible())
{ {
entry.onFixedUpdate(); entry.fixedUpdate();
} }
} }
} }
@ -880,7 +886,7 @@ public abstract class GuiComponent extends FlagHolder
{ {
if(entry.isVisible()) if(entry.isVisible())
{ {
entry.onUpdate(mouseX, mouseY, particalTicks); entry.update(mouseX, mouseY, particalTicks);
} }
} }
} }
@ -894,9 +900,9 @@ public abstract class GuiComponent extends FlagHolder
float zOffset = entry.getZOffset() + 0.01F; float zOffset = entry.getZOffset() + 0.01F;
getRenderer().push(); getRenderer().push();
getRenderer().translate(0F, 0F, zOffset); getRenderer().translate(0F, 0F, zOffset);
entry.onPreRender(); entry.preRender();
entry.onRender(mouseX, mouseY, particalTicks); entry.render(mouseX, mouseY, particalTicks);
entry.onPostRender(); entry.postRender();
getRenderer().translate(0F, 0F, -zOffset); getRenderer().translate(0F, 0F, -zOffset);
getRenderer().pop(); getRenderer().pop();
} }

View File

@ -11,18 +11,18 @@ import java.util.function.IntToLongFunction;
import speiger.src.collections.ints.maps.impl.hash.Int2ObjectLinkedOpenHashMap; import speiger.src.collections.ints.maps.impl.hash.Int2ObjectLinkedOpenHashMap;
import speiger.src.collections.ints.maps.impl.hash.Int2ObjectOpenHashMap; import speiger.src.collections.ints.maps.impl.hash.Int2ObjectOpenHashMap;
import speiger.src.collections.ints.maps.interfaces.Int2ObjectMap; import speiger.src.collections.ints.maps.interfaces.Int2ObjectMap;
import speiger.src.collections.ints.maps.interfaces.Int2ObjectSortedMap; import speiger.src.collections.ints.maps.interfaces.Int2ObjectOrderedMap;
import speiger.src.collections.ints.sets.IntSet; import speiger.src.collections.ints.sets.IntSet;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.maps.impl.hash.Object2BooleanLinkedOpenHashMap; import speiger.src.collections.objects.maps.impl.hash.Object2BooleanLinkedOpenHashMap;
import speiger.src.collections.objects.maps.impl.hash.Object2ObjectLinkedOpenHashMap; import speiger.src.collections.objects.maps.impl.hash.Object2ObjectLinkedOpenHashMap;
import speiger.src.collections.objects.maps.interfaces.Object2BooleanSortedMap; import speiger.src.collections.objects.maps.interfaces.Object2BooleanOrderedMap;
import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap; import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap;
import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet; import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet;
import speiger.src.collections.objects.sets.ObjectSortedSet; import speiger.src.collections.objects.sets.ObjectOrderedSet;
import speiger.src.collections.objects.utils.maps.Object2ObjectMaps; import speiger.src.collections.objects.utils.maps.Object2ObjectMaps;
import speiger.src.coreengine.math.MathUtils; import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiBase; import speiger.src.coreengine.rendering.gui.GuiBase;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.components.TooltipPanel; import speiger.src.coreengine.rendering.gui.components.TooltipPanel;
@ -35,9 +35,9 @@ public class GuiScreenBase extends GuiBase
Int2ObjectMap<GuiComponent> getters = new Int2ObjectOpenHashMap<>(); Int2ObjectMap<GuiComponent> getters = new Int2ObjectOpenHashMap<>();
Set<GuiComponent> components = new ObjectLinkedOpenHashSet<>(); Set<GuiComponent> components = new ObjectLinkedOpenHashSet<>();
Set<IKeyComponent> keyOrder = new ObjectLinkedOpenHashSet<>(); Set<IKeyComponent> keyOrder = new ObjectLinkedOpenHashSet<>();
ObjectSortedSet<GuiComponent> renderOrder = new ObjectLinkedOpenHashSet<>(); ObjectOrderedSet<GuiComponent> renderOrder = new ObjectLinkedOpenHashSet<>();
Object2BooleanSortedMap<IButtonComponent> buttonOrder = new Object2BooleanLinkedOpenHashMap<>(); Object2BooleanOrderedMap<IButtonComponent> buttonOrder = new Object2BooleanLinkedOpenHashMap<>();
Int2ObjectSortedMap<IButtonComponent> selectedButtons = new Int2ObjectLinkedOpenHashMap<>(); Int2ObjectOrderedMap<IButtonComponent> selectedButtons = new Int2ObjectLinkedOpenHashMap<>();
Set<IButtonComponent> draggingButtons = new ObjectLinkedOpenHashSet<>(); Set<IButtonComponent> draggingButtons = new ObjectLinkedOpenHashSet<>();
TooltipPanel tooltips = new TooltipPanel(); TooltipPanel tooltips = new TooltipPanel();
int lastMouseX = -1; int lastMouseX = -1;
@ -153,7 +153,7 @@ public class GuiScreenBase extends GuiBase
super.onScreenChanged(); super.onScreenChanged();
for(GuiComponent entry : components) for(GuiComponent entry : components)
{ {
entry.onComponentChanged(true); entry.onChanged(true);
} }
} }
@ -164,7 +164,7 @@ public class GuiScreenBase extends GuiBase
{ {
if(entry.isVisible()) if(entry.isVisible())
{ {
entry.onFixedUpdate(); entry.fixedUpdate();
} }
} }
} }
@ -176,7 +176,7 @@ public class GuiScreenBase extends GuiBase
{ {
if(entry.isVisible()) if(entry.isVisible())
{ {
entry.onUpdate(mouseX, mouseY, particalTicks); entry.update(mouseX, mouseY, particalTicks);
} }
} }
} }
@ -196,7 +196,7 @@ public class GuiScreenBase extends GuiBase
float z = base.getZOffset(); float z = base.getZOffset();
boolean layer = base.usesRenderOrder(); boolean layer = base.usesRenderOrder();
render.translate(0.0F, 0.0F, layers + z + (layer ? extra : 0.0F)); render.translate(0.0F, 0.0F, layers + z + (layer ? extra : 0.0F));
base.onRender(mouseX, mouseY, particalTicks); base.render(mouseX, mouseY, particalTicks);
render.resetTransform(); render.resetTransform();
biggestZ = Math.max(biggestZ, z); biggestZ = Math.max(biggestZ, z);
if(layer) if(layer)
@ -227,9 +227,9 @@ public class GuiScreenBase extends GuiBase
{ {
drawsTooltip = true; drawsTooltip = true;
tooltips.updateTooltips(components); tooltips.updateTooltips(components);
tooltips.setComponentPosition(mouseX+tooltips.isOutsideScreen(mouseX, width), mouseY); tooltips.set(mouseX+tooltips.isOutsideScreen(mouseX, width), mouseY);
render.translate(0.0F, 0.0F, layers + 50F); render.translate(0.0F, 0.0F, layers + 50F);
tooltips.onRender(mouseX, mouseY, particalTicks); tooltips.render(mouseX, mouseY, particalTicks);
render.resetTransform(); render.resetTransform();
} }
} }
@ -241,7 +241,7 @@ public class GuiScreenBase extends GuiBase
if(!getUIManager().isRenderUIBoxes()) return; if(!getUIManager().isRenderUIBoxes()) return;
UIRenderer render = getRenderer(); UIRenderer render = getRenderer();
render.translate(0F, 0F, 100F); render.translate(0F, 0F, 100F);
render.drawFrame(comp.getBox(), ColorObject.RED); render.drawFrame(comp.getBox(), ColorUtils.RED);
render.translate(0F, 0F, -100F); render.translate(0F, 0F, -100F);
} }

View File

@ -1,6 +1,5 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
import speiger.src.coreengine.rendering.gui.helper.constrains.Constraints; import speiger.src.coreengine.rendering.gui.helper.constrains.Constraints;
@ -8,14 +7,14 @@ import speiger.src.coreengine.rendering.gui.helper.constrains.Constraints;
public class ButtonComponent extends GuiComponent implements IButtonComponent public class ButtonComponent extends GuiComponent implements IButtonComponent
{ {
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
ColorObject color; int color;
public ButtonComponent(String text, ColorObject color) public ButtonComponent(String text, int color)
{ {
this(0F, 0F, 0F, 0F, text, color); this(0F, 0F, 0F, 0F, text, color);
} }
public ButtonComponent(float x, float y, float width, float height, String text, ColorObject color) public ButtonComponent(float x, float y, float width, float height, String text, int color)
{ {
super(x, y, width, height); super(x, y, width, height);
this.text.setText(text); this.text.setText(text);
@ -34,7 +33,7 @@ public class ButtonComponent extends GuiComponent implements IButtonComponent
return text; return text;
} }
public ButtonComponent setColor(ColorObject color) public ButtonComponent setColor(int color)
{ {
this.color = color; this.color = color;
return this; return this;

View File

@ -1,6 +1,5 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
import speiger.src.coreengine.rendering.gui.components.misc.ICheckBox; import speiger.src.coreengine.rendering.gui.components.misc.ICheckBox;
@ -10,31 +9,31 @@ import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer;
public class CheckBoxComponent extends GuiComponent implements IButtonComponent, ICheckBox<CheckBoxComponent> public class CheckBoxComponent extends GuiComponent implements IButtonComponent, ICheckBox<CheckBoxComponent>
{ {
boolean isChecked = false; boolean isChecked = false;
ColorObject color; int color;
RenderBuffer buffer; RenderBuffer buffer;
public CheckBoxComponent(ColorObject color) public CheckBoxComponent(int color)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
setFlag(FLAG_SUPPORT_BINDING); setFlag(FLAG_SUPPORT_BINDING);
this.color = color; this.color = color;
} }
public CheckBoxComponent(ColorObject color, boolean checked) public CheckBoxComponent(int color, boolean checked)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
setFlag(FLAG_SUPPORT_BINDING); setFlag(FLAG_SUPPORT_BINDING);
this.color = color; this.color = color;
} }
public CheckBoxComponent(float x, float y, float width, float height, ColorObject color) public CheckBoxComponent(float x, float y, float width, float height, int color)
{ {
super(x, y, width, height); super(x, y, width, height);
setFlag(FLAG_SUPPORT_BINDING); setFlag(FLAG_SUPPORT_BINDING);
this.color = color; this.color = color;
} }
public CheckBoxComponent(float x, float y, float width, float height, ColorObject color, boolean checked) public CheckBoxComponent(float x, float y, float width, float height, int color, boolean checked)
{ {
super(x, y, width, height); super(x, y, width, height);
setFlag(FLAG_SUPPORT_BINDING); setFlag(FLAG_SUPPORT_BINDING);
@ -55,12 +54,12 @@ public class CheckBoxComponent extends GuiComponent implements IButtonComponent,
return this; return this;
} }
public final CheckBoxComponent setColor(ColorObject color) public final CheckBoxComponent setColor(int color)
{ {
if(this.color != color) if(this.color != color)
{ {
this.color = color; this.color = color;
onComponentChanged(true); onChanged(true);
} }
return this; return this;
} }

View File

@ -2,16 +2,15 @@ package speiger.src.coreengine.rendering.gui.components;
import java.util.function.IntFunction; import java.util.function.IntFunction;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.misc.Facing; import speiger.src.coreengine.math.misc.Facing;
public class GradientSliderComponent extends SliderComponent public class GradientSliderComponent extends SliderComponent
{ {
ColorObject fromColor; int fromColor;
ColorObject toColor; int toColor;
Facing direction; Facing direction;
public GradientSliderComponent(float x, float y, float width, float height, int min, int max, int value, ColorObject color, ColorObject fromColor, ColorObject toColor, Facing direction, IntFunction<String> textBuilder) public GradientSliderComponent(float x, float y, float width, float height, int min, int max, int value, int color, int fromColor, int toColor, Facing direction, IntFunction<String> textBuilder)
{ {
super(x, y, width, height, min, max, value, color, textBuilder); super(x, y, width, height, min, max, value, color, textBuilder);
this.direction = direction; this.direction = direction;
@ -19,7 +18,7 @@ public class GradientSliderComponent extends SliderComponent
this.toColor = toColor; this.toColor = toColor;
} }
public GradientSliderComponent(int min, int max, int value, ColorObject color, ColorObject fromColor, ColorObject toColor, Facing direction, IntFunction<String> textBuilder) public GradientSliderComponent(int min, int max, int value, int color, int fromColor, int toColor, Facing direction, IntFunction<String> textBuilder)
{ {
super(min, max, value, color, textBuilder); super(min, max, value, color, textBuilder);
this.direction = direction; this.direction = direction;

View File

@ -1,6 +1,6 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
import speiger.src.coreengine.rendering.gui.components.icon.IIcon; import speiger.src.coreengine.rendering.gui.components.icon.IIcon;
@ -8,9 +8,9 @@ import speiger.src.coreengine.rendering.gui.components.icon.IIcon;
public class IconButtonComponent extends GuiComponent implements IButtonComponent public class IconButtonComponent extends GuiComponent implements IButtonComponent
{ {
IIcon icon; IIcon icon;
ColorObject hoverColor; int hoverColor;
public IconButtonComponent(ColorObject hoverColor, IIcon icon) public IconButtonComponent(int hoverColor, IIcon icon)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.icon = icon; this.icon = icon;
@ -18,7 +18,7 @@ public class IconButtonComponent extends GuiComponent implements IButtonComponen
setFlag(FLAG_SUPPORT_BINDING); setFlag(FLAG_SUPPORT_BINDING);
} }
public IconButtonComponent(float x, float y, float width, float height, ColorObject hoverColor, IIcon icon) public IconButtonComponent(float x, float y, float width, float height, int hoverColor, IIcon icon)
{ {
super(x, y, width, height); super(x, y, width, height);
this.icon = icon; this.icon = icon;
@ -35,7 +35,7 @@ public class IconButtonComponent extends GuiComponent implements IButtonComponen
@Override @Override
protected boolean renderSelf(int mouseX, int mouseY, float particalTicks) protected boolean renderSelf(int mouseX, int mouseY, float particalTicks)
{ {
if(isTopHovered(mouseX, mouseY) && hoverColor.getAlpha() > 0) if(isTopHovered(mouseX, mouseY) && ColorUtils.getAF(hoverColor) > 0)
{ {
getRenderer().drawQuad(getBox(), hoverColor); getRenderer().drawQuad(getBox(), hoverColor);
} }

View File

@ -1,13 +1,12 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.textures.base.ITexture; import speiger.src.coreengine.rendering.textures.base.ITexture;
public class IconComponent extends GuiComponent public class IconComponent extends GuiComponent
{ {
ITexture texture; ITexture texture;
ColorObject override = ColorObject.WHITE; int override = -1;
public IconComponent(ITexture texture) public IconComponent(ITexture texture)
{ {
@ -15,7 +14,7 @@ public class IconComponent extends GuiComponent
this.texture = texture; this.texture = texture;
} }
public IconComponent(ITexture texture, ColorObject color) public IconComponent(ITexture texture, int color)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.texture = texture; this.texture = texture;
@ -28,7 +27,7 @@ public class IconComponent extends GuiComponent
this.texture = texture; this.texture = texture;
} }
public IconComponent(float x, float y, float width, float height, ITexture texture, ColorObject color) public IconComponent(float x, float y, float width, float height, ITexture texture, int color)
{ {
super(x, y, width, height); super(x, y, width, height);
this.texture = texture; this.texture = texture;
@ -41,7 +40,7 @@ public class IconComponent extends GuiComponent
return this; return this;
} }
public IconComponent setColor(ColorObject color) public IconComponent setColor(int color)
{ {
override = color; override = color;
return this; return this;

View File

@ -1,20 +1,19 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.helper.constrains.Constraints; import speiger.src.coreengine.rendering.gui.helper.constrains.Constraints;
public class LabelComponent extends GuiComponent public class LabelComponent extends GuiComponent
{ {
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
ColorObject color; int color;
public LabelComponent(String text, ColorObject color) public LabelComponent(String text, int color)
{ {
this(0F, 0F, 0F, 0F, text, color); this(0F, 0F, 0F, 0F, text, color);
} }
public LabelComponent(float x, float y, float width, float height, String text, ColorObject color) public LabelComponent(float x, float y, float width, float height, String text, int color)
{ {
super(x, y, width, height); super(x, y, width, height);
this.text.setText(text); this.text.setText(text);
@ -26,13 +25,13 @@ public class LabelComponent extends GuiComponent
return text; return text;
} }
public LabelComponent setColor(ColorObject color) public LabelComponent setColor(int color)
{ {
this.color = color; this.color = color;
return this; return this;
} }
public ColorObject getColor() public int getColor()
{ {
return color; return color;
} }

View File

@ -16,7 +16,7 @@ import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.lists.ObjectList; import speiger.src.collections.objects.lists.ObjectList;
import speiger.src.collections.objects.utils.ObjectIterators; import speiger.src.collections.objects.utils.ObjectIterators;
import speiger.src.coreengine.math.MathUtils; import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.vector.ints.Vec2i; import speiger.src.coreengine.math.vector.ints.Vec2i;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
@ -41,8 +41,8 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
public static final int FLAG_DISABLE_BACKGROUND = 1024; public static final int FLAG_DISABLE_BACKGROUND = 1024;
public static final int FLAG_START_AT_BOTTOM = 2048; public static final int FLAG_START_AT_BOTTOM = 2048;
protected ColorObject color; protected int color;
protected ColorObject hoverColor = ColorObject.LIGHT_GRAY.copy(); protected int hoverColor = ColorUtils.LIGHT_GRAY;
protected int hoverIndex = -1; protected int hoverIndex = -1;
protected int dragIndex = -1; protected int dragIndex = -1;
protected int movement = 0; protected int movement = 0;
@ -53,8 +53,8 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
protected int updateMode = 1; protected int updateMode = 1;
protected float entryHeight; protected float entryHeight;
protected float cachedWidth = 0F; protected float cachedWidth = 0F;
protected ScrollBarComponent verticalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY); protected ScrollBarComponent verticalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY);
protected ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY).setHorizontal(true); protected ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY).setHorizontal(true);
protected Vec2i lastMouse = Vec2i.newMutable(); protected Vec2i lastMouse = Vec2i.newMutable();
public ListComponent() public ListComponent()
@ -62,14 +62,14 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
} }
public ListComponent(ColorObject color, float entryHeight) public ListComponent(int color, float entryHeight)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.color = color; this.color = color;
this.entryHeight = entryHeight; this.entryHeight = entryHeight;
} }
public ListComponent(float x, float y, float width, float height, ColorObject color, float entryHeight) public ListComponent(float x, float y, float width, float height, int color, float entryHeight)
{ {
super(x, y, width, height); super(x, y, width, height);
this.color = color; this.color = color;
@ -125,13 +125,13 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
return isFlagSet(FLAG_START_AT_BOTTOM); return isFlagSet(FLAG_START_AT_BOTTOM);
} }
public ListComponent<T> setColor(ColorObject color) public ListComponent<T> setColor(int color)
{ {
this.color = color; this.color = color;
return this; return this;
} }
public ListComponent<T> setHoverColor(ColorObject color) public ListComponent<T> setHoverColor(int color)
{ {
hoverColor = color; hoverColor = color;
return this; return this;
@ -142,7 +142,7 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
if(this.entryHeight != entryHeight) if(this.entryHeight != entryHeight)
{ {
this.entryHeight = entryHeight; this.entryHeight = entryHeight;
onComponentChanged(true); onChanged(true);
} }
return this; return this;
} }
@ -242,7 +242,7 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
return entries; return entries;
} }
public ListComponent<T> addEntry(T entry) public ListComponent<T> add(T entry)
{ {
entries.add(entry); entries.add(entry);
if(getGui() != null) if(getGui() != null)
@ -253,7 +253,7 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
return this; return this;
} }
public ListComponent<T> addEntries(Collection<T> entries) public ListComponent<T> addAll(Collection<T> entries)
{ {
this.entries.addAll(entries); this.entries.addAll(entries);
if(getGui() != null) if(getGui() != null)
@ -393,8 +393,7 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
protected Iterator<T> rangeIterator(int start, int end) protected Iterator<T> rangeIterator(int start, int end)
{ {
return new Iterator<T>() return new Iterator<T>() {
{
int index = start; int index = start;
@Override @Override
@ -447,11 +446,11 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
horizontalBar.setScrollMax((int)(width / getBox().getScale())); horizontalBar.setScrollMax((int)(width / getBox().getScale()));
if(lastHorizontal != horizontalBar.isInUse()) if(lastHorizontal != horizontalBar.isInUse())
{ {
horizontalBar.onComponentChanged(true); horizontalBar.onChanged(true);
} }
if(lastVertical != verticalBar.isInUse()) if(lastVertical != verticalBar.isInUse())
{ {
verticalBar.onComponentChanged(true); verticalBar.onChanged(true);
} }
} }

View File

@ -6,7 +6,7 @@ import java.util.function.Supplier;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import speiger.src.coreengine.math.MathUtils; import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer; import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer;
import speiger.src.coreengine.rendering.tesselation.Tesselator; import speiger.src.coreengine.rendering.tesselation.Tesselator;
@ -104,8 +104,8 @@ public class PieComponent extends GuiComponent
{ {
IPieIndex pieIndex = indexes.get(j); IPieIndex pieIndex = indexes.get(j);
int steps = j == 0 ? maxSteps - stepsDone : pieIndex.getSteps(); int steps = j == 0 ? maxSteps - stepsDone : pieIndex.getSteps();
ColorObject color = pieIndex.getColor(); int color = pieIndex.getColor();
ColorObject darker = color.copy().darker(); int darker = ColorUtils.darker(color);
tes.offset(0F, 0F, 0.01F); tes.offset(0F, 0F, 0.01F);
for(int i = 0;i<steps;i++) for(int i = 0;i<steps;i++)
{ {
@ -140,15 +140,15 @@ public class PieComponent extends GuiComponent
{ {
public int getSteps(); public int getSteps();
public ColorObject getColor(); public int getColor();
} }
public static class PieIndex implements IPieIndex public static class PieIndex implements IPieIndex
{ {
int steps; int steps;
ColorObject color; int color;
public PieIndex(int steps, ColorObject color) public PieIndex(int steps, int color)
{ {
this.steps = steps; this.steps = steps;
this.color = color; this.color = color;
@ -161,7 +161,7 @@ public class PieComponent extends GuiComponent
} }
@Override @Override
public ColorObject getColor() public int getColor()
{ {
return color; return color;
} }

View File

@ -3,7 +3,6 @@ package speiger.src.coreengine.rendering.gui.components;
import java.util.function.IntFunction; import java.util.function.IntFunction;
import java.util.function.IntSupplier; import java.util.function.IntSupplier;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox; import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
import speiger.src.coreengine.rendering.gui.helper.box.ParentBox; import speiger.src.coreengine.rendering.gui.helper.box.ParentBox;
@ -14,28 +13,28 @@ public class ProgressBarComponent extends GuiComponent
{ {
IGuiBox inner = new ParentBox(1F); IGuiBox inner = new ParentBox(1F);
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
ColorObject color; int color;
int value; int value;
int max; int max;
IntFunction<String> name; IntFunction<String> name;
IntSupplier valueGenerator; IntSupplier valueGenerator;
public ProgressBarComponent(ColorObject color, int value, int max) public ProgressBarComponent(int color, int value, int max)
{ {
this(color, value, max, null); this(color, value, max, null);
} }
public ProgressBarComponent(ColorObject color, int value, int max, IntFunction<String> name) public ProgressBarComponent(int color, int value, int max, IntFunction<String> name)
{ {
this(0F, 0F, 0F, 0F, color, value, max, name); this(0F, 0F, 0F, 0F, color, value, max, name);
} }
public ProgressBarComponent(float x, float y, float width, float height, ColorObject color, int value, int max) public ProgressBarComponent(float x, float y, float width, float height, int color, int value, int max)
{ {
this(x, y, width, height, color, value, max, null); this(x, y, width, height, color, value, max, null);
} }
public ProgressBarComponent(float x, float y, float width, float height, ColorObject color, int value, int max, IntFunction<String> name) public ProgressBarComponent(float x, float y, float width, float height, int color, int value, int max, IntFunction<String> name)
{ {
super(x, y, width, height); super(x, y, width, height);
this.name = name; this.name = name;
@ -58,7 +57,7 @@ public class ProgressBarComponent extends GuiComponent
return text; return text;
} }
public ProgressBarComponent setColor(ColorObject color) public ProgressBarComponent setColor(int color)
{ {
this.color = color; this.color = color;
return this; return this;

View File

@ -1,7 +1,6 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.MathUtils; import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox; import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
@ -10,25 +9,25 @@ public class ScrollBarComponent extends GuiComponent implements IButtonComponent
{ {
public static final int FLAG_HORIZONTAL = 1024; public static final int FLAG_HORIZONTAL = 1024;
public static final int FLAG_INVERTED = 2048; public static final int FLAG_INVERTED = 2048;
ColorObject color; int color;
float lastMouse = -1; float lastMouse = -1;
int current; int current;
int max; int max;
public ScrollBarComponent(ColorObject color) public ScrollBarComponent(int color)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.color = color; this.color = color;
} }
public ScrollBarComponent(ColorObject color, int max) public ScrollBarComponent(int color, int max)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.color = color; this.color = color;
this.max = max; this.max = max;
} }
public ScrollBarComponent(ColorObject color, int max, int current) public ScrollBarComponent(int color, int max, int current)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.color = color; this.color = color;
@ -36,20 +35,20 @@ public class ScrollBarComponent extends GuiComponent implements IButtonComponent
this.current = current; this.current = current;
} }
public ScrollBarComponent(float x, float y, float width, float height, ColorObject color) public ScrollBarComponent(float x, float y, float width, float height, int color)
{ {
super(x, y, width, height); super(x, y, width, height);
this.color = color; this.color = color;
} }
public ScrollBarComponent(float x, float y, float width, float height, ColorObject color, int max) public ScrollBarComponent(float x, float y, float width, float height, int color, int max)
{ {
super(x, y, width, height); super(x, y, width, height);
this.color = color; this.color = color;
this.max = max; this.max = max;
} }
public ScrollBarComponent(float x, float y, float width, float height, ColorObject color, int max, int current) public ScrollBarComponent(float x, float y, float width, float height, int color, int max, int current)
{ {
super(x, y, width, height); super(x, y, width, height);
this.color = color; this.color = color;
@ -63,7 +62,7 @@ public class ScrollBarComponent extends GuiComponent implements IButtonComponent
} }
public ScrollBarComponent setColor(ColorObject color) public ScrollBarComponent setColor(int color)
{ {
this.color = color; this.color = color;
return this; return this;

View File

@ -1,6 +1,6 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox; import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains; import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains;
@ -10,8 +10,8 @@ public class ScrollPanelComponent extends GuiComponent
{ {
public static final int FLAG_CORNER = 1 << 20; public static final int FLAG_CORNER = 1 << 20;
ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY).setHorizontal(true); ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY).setHorizontal(true);
ScrollBarComponent verticalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY); ScrollBarComponent verticalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY);
protected PanelComponent container = new PanelComponent().setManualRenderer(true).setScissorsTest(true).cast(); protected PanelComponent container = new PanelComponent().setManualRenderer(true).setScissorsTest(true).cast();
PanelComponent viewPort = new PanelComponent().setManualRenderer(true).cast(); PanelComponent viewPort = new PanelComponent().setManualRenderer(true).cast();
@ -41,7 +41,7 @@ public class ScrollPanelComponent extends GuiComponent
{ {
addConstrains(horizontalBar, Constraints.getScrollbarConstraints(isFlagSet(FLAG_CORNER) ? () -> true : verticalBar::isInUse, true, 5F)); addConstrains(horizontalBar, Constraints.getScrollbarConstraints(isFlagSet(FLAG_CORNER) ? () -> true : verticalBar::isInUse, true, 5F));
addConstrains(verticalBar, Constraints.getScrollbarConstraints(isFlagSet(FLAG_CORNER) ? () -> true : horizontalBar::isInUse, false, 5F)); addConstrains(verticalBar, Constraints.getScrollbarConstraints(isFlagSet(FLAG_CORNER) ? () -> true : horizontalBar::isInUse, false, 5F));
onComponentChanged(false); onChanged(false);
} }
return this; return this;
} }
@ -68,14 +68,14 @@ public class ScrollPanelComponent extends GuiComponent
} }
horizontalBar.setScrollMax((int)maxX); horizontalBar.setScrollMax((int)maxX);
verticalBar.setScrollMax((int)maxY); verticalBar.setScrollMax((int)maxY);
owner.setComponentBounds(maxX, maxY).setComponentPosition(-horizontalBar.getScroll(), -verticalBar.getScroll()); owner.bounds(maxX, maxY).set(-horizontalBar.getScroll(), -verticalBar.getScroll());
} }
@Override @Override
protected boolean updateSelf(int mouseX, int mouseY, float particalTicks) protected boolean updateSelf(int mouseX, int mouseY, float particalTicks)
{ {
super.updateSelf(mouseX, mouseY, particalTicks); super.updateSelf(mouseX, mouseY, particalTicks);
container.setComponentPosition(-horizontalBar.getScroll(), -verticalBar.getScroll()); container.set(-horizontalBar.getScroll(), -verticalBar.getScroll());
return true; return true;
} }
@ -87,7 +87,7 @@ public class ScrollPanelComponent extends GuiComponent
{ {
enableScissors(viewPort.getBox()); enableScissors(viewPort.getBox());
getRenderer().translate(0F, 0F, 0.1F); getRenderer().translate(0F, 0F, 0.1F);
container.onRender(mouseX, mouseY, particalTicks); container.render(mouseX, mouseY, particalTicks);
getRenderer().translate(0F, 0F, -0.1F); getRenderer().translate(0F, 0F, -0.1F);
disableScissors(); disableScissors();
} }

View File

@ -1,6 +1,6 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox; import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains; import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains;
@ -9,8 +9,8 @@ import speiger.src.coreengine.rendering.gui.helper.constrains.Constraints;
public class ScrollWindowComponent extends WindowComponent public class ScrollWindowComponent extends WindowComponent
{ {
public static final int FLAG_CORNER = 1 << 26; public static final int FLAG_CORNER = 1 << 26;
ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY).setHorizontal(true); ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY).setHorizontal(true);
ScrollBarComponent verticalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY); ScrollBarComponent verticalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY);
protected PanelComponent container = new PanelComponent().setManualRenderer(true).cast(); protected PanelComponent container = new PanelComponent().setManualRenderer(true).cast();
PanelComponent viewPort = new PanelComponent().setManualRenderer(true).cast(); PanelComponent viewPort = new PanelComponent().setManualRenderer(true).cast();
@ -32,7 +32,7 @@ public class ScrollWindowComponent extends WindowComponent
addChild(verticalBar.addChangeListener(minimizedListener), Constraints.getVerticalScrollbar(isFlagSet(FLAG_CORNER) ? () -> true : horizontalBar::isInUse, 7.5F, 5F)); addChild(verticalBar.addChangeListener(minimizedListener), Constraints.getVerticalScrollbar(isFlagSet(FLAG_CORNER) ? () -> true : horizontalBar::isInUse, 7.5F, 5F));
viewPort.addChild(container); viewPort.addChild(container);
container.addChangeListener(this::recalculateSize).addChangeListener(minimizedListener); container.addChangeListener(this::recalculateSize).addChangeListener(minimizedListener);
addChild(viewPort.setComponentPosition(0F, 7.5F), new ComponentConstrains(null, null, Constraints.createConditionalParent(verticalBar::isInUse, 0F, 5F), Constraints.createConditionalParent(horizontalBar::isInUse, 7.5F, 12.5F))); addChild(viewPort.set(0F, 7.5F), new ComponentConstrains(null, null, Constraints.createConditionalParent(verticalBar::isInUse, 0F, 5F), Constraints.createConditionalParent(horizontalBar::isInUse, 7.5F, 12.5F)));
} }
public <T extends GuiComponent> T addComponent(T comp) public <T extends GuiComponent> T addComponent(T comp)
@ -61,7 +61,7 @@ public class ScrollWindowComponent extends WindowComponent
{ {
addConstrains(horizontalBar, Constraints.getScrollbarConstraints(isFlagSet(FLAG_CORNER) ? () -> true : verticalBar::isInUse, true, 5F)); addConstrains(horizontalBar, Constraints.getScrollbarConstraints(isFlagSet(FLAG_CORNER) ? () -> true : verticalBar::isInUse, true, 5F));
addConstrains(verticalBar, Constraints.getVerticalScrollbar(isFlagSet(FLAG_CORNER) ? () -> true : horizontalBar::isInUse, 7.5F, 5F)); addConstrains(verticalBar, Constraints.getVerticalScrollbar(isFlagSet(FLAG_CORNER) ? () -> true : horizontalBar::isInUse, 7.5F, 5F));
onComponentChanged(false); onChanged(false);
} }
return this; return this;
} }
@ -78,16 +78,16 @@ public class ScrollWindowComponent extends WindowComponent
} }
horizontalBar.setScrollMax((int)maxX); horizontalBar.setScrollMax((int)maxX);
verticalBar.setScrollMax((int)maxY); verticalBar.setScrollMax((int)maxY);
horizontalBar.onComponentChanged(true); horizontalBar.onChanged(true);
verticalBar.onComponentChanged(true); verticalBar.onChanged(true);
owner.setComponentBounds(maxX, maxY).setComponentPosition(-horizontalBar.getScroll(), -verticalBar.getScroll()); owner.bounds(maxX, maxY).set(-horizontalBar.getScroll(), -verticalBar.getScroll());
} }
@Override @Override
protected boolean updateSelf(int mouseX, int mouseY, float particalTicks) protected boolean updateSelf(int mouseX, int mouseY, float particalTicks)
{ {
super.updateSelf(mouseX, mouseY, particalTicks); super.updateSelf(mouseX, mouseY, particalTicks);
container.setComponentPosition(-horizontalBar.getScroll(), -verticalBar.getScroll()); container.set(-horizontalBar.getScroll(), -verticalBar.getScroll());
return true; return true;
} }
@ -100,7 +100,7 @@ public class ScrollWindowComponent extends WindowComponent
{ {
enableScissors(viewPort.getBox()); enableScissors(viewPort.getBox());
getRenderer().translate(0F, 0F, 0.1F); getRenderer().translate(0F, 0F, 0.1F);
container.onRender(mouseX, mouseY, particalTicks); container.render(mouseX, mouseY, particalTicks);
getRenderer().translate(0F, 0F, -0.1F); getRenderer().translate(0F, 0F, -0.1F);
disableScissors(); disableScissors();
} }

View File

@ -6,7 +6,6 @@ import java.util.function.Consumer;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import speiger.src.collections.ints.collections.IntCollection; import speiger.src.collections.ints.collections.IntCollection;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.value.IValue; import speiger.src.coreengine.math.value.IValue;
import speiger.src.coreengine.math.value.LiniarValue; import speiger.src.coreengine.math.value.LiniarValue;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
@ -25,16 +24,16 @@ import speiger.src.coreengine.rendering.tesselation.VertexType;
public class SelectionComponent extends GuiComponent implements IButtonComponent, Consumer<GuiComponent> public class SelectionComponent extends GuiComponent implements IButtonComponent, Consumer<GuiComponent>
{ {
public static final int FLAG_ANIMATE = 1 << 20; public static final int FLAG_ANIMATE = 1 << 20;
ListComponent<SelectionEntry> list = new ListComponent<SelectionEntry>().setComponentBounds(0F, 120F).setManualRenderer(true).setIgnoreBounds(true).cast(); ListComponent<SelectionEntry> list = new ListComponent<SelectionEntry>().bounds(0F, 120F).setManualRenderer(true).setIgnoreBounds(true).cast();
TextComponent text = new TextComponent().setAlignment(Align.LEFT_TOP, Align.CENTER).setTextScale(0.85F).setManualRenderer(true).cast(); TextComponent text = new TextComponent().align(Align.LEFT_TOP, Align.CENTER).setTextScale(0.85F).setManualRenderer(true).cast();
RenderBuffer buffer; RenderBuffer buffer;
ColorObject color; int color;
boolean isOpen = false; boolean isOpen = false;
int selectedIndex = -1; int selectedIndex = -1;
int defaultIndex = -1; int defaultIndex = -1;
IValue animation = null; IValue animation = null;
public SelectionComponent(ColorObject color) public SelectionComponent(int color)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.color = color; this.color = color;
@ -42,7 +41,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
list.setColor(color); list.setColor(color);
} }
public SelectionComponent(ColorObject color, Collection<String> collection) public SelectionComponent(int color, Collection<String> collection)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.color = color; this.color = color;
@ -51,7 +50,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
addEntries(collection); addEntries(collection);
} }
public SelectionComponent(float x, float y, float width, float height, ColorObject color) public SelectionComponent(float x, float y, float width, float height, int color)
{ {
super(x, y, width, height); super(x, y, width, height);
this.color = color; this.color = color;
@ -59,7 +58,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
list.setColor(color); list.setColor(color);
} }
public SelectionComponent(float x, float y, float width, float height, ColorObject color, Collection<String> collection) public SelectionComponent(float x, float y, float width, float height, int color, Collection<String> collection)
{ {
super(x, y, width, height); super(x, y, width, height);
this.color = color; this.color = color;
@ -71,7 +70,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
@Override @Override
public void init() public void init()
{ {
list.setEntryHeight(getGui().getFont().getFontHeight()).addUserActionListener(this); list.setEntryHeight(getGui().getFont().height()).addUserActionListener(this);
addChild(text, Constraints.getParentConstrains(21F, 0F, 10.5F, 0F)); addChild(text, Constraints.getParentConstrains(21F, 0F, 10.5F, 0F));
addChild(list, new ComponentConstrains(new ParentConstrain(), new ParentConstrain().invert(), new ParentConstrain(), null)); addChild(list, new ComponentConstrains(new ParentConstrain(), new ParentConstrain().invert(), new ParentConstrain(), null));
addCloseListener(buffer = getRenderer().createBuffer()); addCloseListener(buffer = getRenderer().createBuffer());
@ -107,7 +106,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
public SelectionComponent addEntry(String s) public SelectionComponent addEntry(String s)
{ {
list.addEntry(new SelectionEntry(s)); list.add(new SelectionEntry(s));
return this; return this;
} }
@ -115,7 +114,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
{ {
for(String s : collection) for(String s : collection)
{ {
list.addEntry(new SelectionEntry(s)); list.add(new SelectionEntry(s));
} }
return this; return this;
} }
@ -247,18 +246,18 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
render.setBrightness(brightness * 0.7F).drawQuad(box.getMinX(), box.getMinY(), box.getMinX(20F), box.getMaxY(), 0.001F, color); render.setBrightness(brightness * 0.7F).drawQuad(box.getMinX(), box.getMinY(), box.getMinX(20F), box.getMaxY(), 0.001F, color);
render.setFastTransform(false).setBrightness(brightness).translate(minX, minY, 0.02F + currentZ); render.setFastTransform(false).setBrightness(brightness).translate(minX, minY, 0.02F + currentZ);
render.scale(box.getScale()).rotateZ(rotation).drawBuffers(buffer, 0, 0).resetTransform().setFastTransform(true).translate(0F, 0F, 0.01F).setBrightness(1F); render.scale(box.getScale()).rotateZ(rotation).drawBuffers(buffer, 0, 0).resetTransform().setFastTransform(true).translate(0F, 0F, 0.01F).setBrightness(1F);
text.onRender(mouseX, mouseY, particalTicks); text.render(mouseX, mouseY, particalTicks);
if(animation != null) if(animation != null)
{ {
float progress = animation.get() / 90F; float progress = animation.get() / 90F;
box = list.getBox(); box = list.getBox();
enableScissors(box.getMinX(), box.getMinY(), box.getWidth(), box.getHeight() * progress); enableScissors(box.getMinX(), box.getMinY(), box.getWidth(), box.getHeight() * progress);
list.onRender(mouseX, mouseY, particalTicks); list.render(mouseX, mouseY, particalTicks);
disableScissors(); disableScissors();
} }
else if(isOpen) else if(isOpen)
{ {
list.onRender(mouseX, mouseY, particalTicks); list.render(mouseX, mouseY, particalTicks);
} }
return true; return true;
} }

View File

@ -3,7 +3,6 @@ package speiger.src.coreengine.rendering.gui.components;
import java.util.function.IntFunction; import java.util.function.IntFunction;
import speiger.src.coreengine.math.MathUtils; import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.misc.Facing; import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
@ -14,7 +13,7 @@ import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer;
public class SliderComponent extends GuiComponent implements IButtonComponent public class SliderComponent extends GuiComponent implements IButtonComponent
{ {
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
protected ColorObject color; protected int color;
protected boolean vertical = false; protected boolean vertical = false;
protected int min; protected int min;
@ -24,12 +23,12 @@ public class SliderComponent extends GuiComponent implements IButtonComponent
IntFunction<String> textBuilder; IntFunction<String> textBuilder;
protected RenderBuffer buffer; protected RenderBuffer buffer;
public SliderComponent(int min, int max, int value, ColorObject color, IntFunction<String> textBuilder) public SliderComponent(int min, int max, int value, int color, IntFunction<String> textBuilder)
{ {
this(0F, 0F, 0F, 0F, min, max, value, color, textBuilder); this(0F, 0F, 0F, 0F, min, max, value, color, textBuilder);
} }
public SliderComponent(float x, float y, float width, float height, int min, int max, int value, ColorObject color, IntFunction<String> textBuilder) public SliderComponent(float x, float y, float width, float height, int min, int max, int value, int color, IntFunction<String> textBuilder)
{ {
super(x, y, width, height); super(x, y, width, height);
this.min = min; this.min = min;
@ -80,7 +79,7 @@ public class SliderComponent extends GuiComponent implements IButtonComponent
return this; return this;
} }
public SliderComponent setColor(ColorObject color) public SliderComponent setColor(int color)
{ {
if(this.color != color) if(this.color != color)
{ {

View File

@ -0,0 +1,59 @@
package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.helper.Align;
import speiger.src.coreengine.rendering.gui.helper.constrains.Constraints;
import speiger.src.coreengine.rendering.gui.helper.constrains.ParentConstrain;
public class TabbedWindowComponent extends WindowComponent
{
public TabbedWindowComponent(float x, float y, float width, float height)
{
super(x, y, width, height, DEFAULT_FLAGS, "Test");
}
@Override
public void init()
{
super.init();
addChild(new Tab("Testing My theory with the full lenght text"), null, null, new ParentConstrain(), null);
}
public static class Tab extends GuiComponent
{
String name;
boolean closeable;
TextComponent comp;
public Tab(String name)
{
super(0F, 7F, 100F, 10F);
this.name = name;
comp = new TextComponent(name).setTextScale(0.4F).singleLine(true).horizontal(Align.LEFT_TOP);
}
@Override
public void init()
{
addChild(comp, Constraints.getParentConstrains());
}
@Override
protected void repaint()
{
String s = name;
float scale = comp.getTextScale();
float width = getFont().width(s)*scale;
float desiredWidth = getBox().getBaseWidth();
if(width > desiredWidth) {
while(getFont().width(s+"...") * scale > desiredWidth) {
s = s.substring(0, s.length()-1);
}
comp.setText(s+"...");
return;
}
comp.setText(s);
}
}
}

View File

@ -1,6 +1,5 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains; import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains;
import speiger.src.coreengine.rendering.gui.helper.constrains.ParentConstrain; import speiger.src.coreengine.rendering.gui.helper.constrains.ParentConstrain;
import speiger.src.coreengine.rendering.gui.helper.constrains.PixelConstrain; import speiger.src.coreengine.rendering.gui.helper.constrains.PixelConstrain;
@ -8,27 +7,27 @@ import speiger.src.coreengine.rendering.gui.helper.constrains.TextConstrain;
public class TextCheckBoxComponent extends CheckBoxComponent public class TextCheckBoxComponent extends CheckBoxComponent
{ {
TextComponent text = new TextComponent().setForcedSingleLine(true).setLimitedBounds(false).setTextScale(0.35F); TextComponent text = new TextComponent().singleLine(true).limit(false).setTextScale(0.35F);
public TextCheckBoxComponent(ColorObject color, String text) public TextCheckBoxComponent(int color, String text)
{ {
super(color); super(color);
this.text.setText(text); this.text.setText(text);
} }
public TextCheckBoxComponent(ColorObject color, String text, boolean checked) public TextCheckBoxComponent(int color, String text, boolean checked)
{ {
super(color, checked); super(color, checked);
this.text.setText(text); this.text.setText(text);
} }
public TextCheckBoxComponent(float x, float y, float width, float height, ColorObject color, String text) public TextCheckBoxComponent(float x, float y, float width, float height, int color, String text)
{ {
super(x, y, width, height, color); super(x, y, width, height, color);
this.text.setText(text); this.text.setText(text);
} }
public TextCheckBoxComponent(float x, float y, float width, float height, ColorObject color, String text, boolean checked) public TextCheckBoxComponent(float x, float y, float width, float height, int color, String text, boolean checked)
{ {
super(x, y, width, height, color, checked); super(x, y, width, height, color, checked);
this.text.setText(text); this.text.setText(text);

View File

@ -1,6 +1,6 @@
package speiger.src.coreengine.rendering.gui.components; package speiger.src.coreengine.rendering.gui.components;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.helper.Align; import speiger.src.coreengine.rendering.gui.helper.Align;
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox; import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
@ -24,8 +24,8 @@ public class TextComponent extends GuiComponent
String text = ""; String text = "";
Align vertical = Align.CENTER; Align vertical = Align.CENTER;
Align horizontal = Align.CENTER; Align horizontal = Align.CENTER;
ColorObject textColor = ColorObject.WHITE.copy(); int textColor = ColorUtils.WHITE;
ColorObject backGroundColor = null; Integer backGroundColor = null;
float italic = 0F; float italic = 0F;
float textScale = 1F; float textScale = 1F;
RenderBuffer buffer; RenderBuffer buffer;
@ -122,7 +122,7 @@ public class TextComponent extends GuiComponent
if(this.textScale != textScale) if(this.textScale != textScale)
{ {
this.textScale = textScale; this.textScale = textScale;
onComponentChanged(true); onChanged(true);
} }
return this; return this;
} }
@ -202,16 +202,17 @@ public class TextComponent extends GuiComponent
return isFlagSet(FLAG_SINGLE_LINE); return isFlagSet(FLAG_SINGLE_LINE);
} }
public final ColorObject getTextColor() public final int getTextColor()
{ {
return textColor; return textColor;
} }
public final ColorObject getBackgroundColor() public final Integer getBackgroundColor()
{ {
return backGroundColor; return backGroundColor;
} }
@Override
public FontRenderer getFont() public FontRenderer getFont()
{ {
return font; return font;
@ -247,123 +248,123 @@ public class TextComponent extends GuiComponent
return horizontal; return horizontal;
} }
public final TextComponent setBold(boolean value) public final TextComponent bold(boolean value)
{ {
if(setFlag(FLAG_BOLD, value)) if(setFlag(FLAG_BOLD, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setStrikeThrough(boolean value) public final TextComponent strikethrough(boolean value)
{ {
if(!setFlag(FLAG_STRIKE_THROUGH, value)) if(!setFlag(FLAG_STRIKE_THROUGH, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setUnderlined(boolean value) public final TextComponent underline(boolean value)
{ {
if(!setFlag(FLAG_UNDERLINE, value)) if(!setFlag(FLAG_UNDERLINE, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setFlipped(boolean value) public final TextComponent flipped(boolean value)
{ {
if(!setFlag(FLAG_FLIPPED, value)) if(!setFlag(FLAG_FLIPPED, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setSpecialRendering(boolean value) public final TextComponent special(boolean value)
{ {
if(!setFlag(FLAG_FORMATTING, value)) if(!setFlag(FLAG_FORMATTING, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setLimitedBounds(boolean value) public final TextComponent limit(boolean value)
{ {
if(!setFlag(FLAG_LIMITED_HEIGHT | FLAG_LIMITED_WIDTH, value)) if(!setFlag(FLAG_LIMITED_HEIGHT | FLAG_LIMITED_WIDTH, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setLimitedWidth(boolean value) public final TextComponent limitWidth(boolean value)
{ {
if(!setFlag(FLAG_LIMITED_WIDTH, value)) if(!setFlag(FLAG_LIMITED_WIDTH, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setLimitedHeight(boolean value) public final TextComponent limitHeight(boolean value)
{ {
if(!setFlag(FLAG_LIMITED_HEIGHT, value)) if(!setFlag(FLAG_LIMITED_HEIGHT, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setAutoScaling(boolean value) public final TextComponent autoScale(boolean value)
{ {
if(!setFlag(FLAG_AUTO_SCALE, value)) if(!setFlag(FLAG_AUTO_SCALE, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setForcedSingleLine(boolean value) public final TextComponent singleLine(boolean value)
{ {
if(!setFlag(FLAG_SINGLE_LINE, value)) if(!setFlag(FLAG_SINGLE_LINE, value))
{ {
return this; return this;
} }
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public final TextComponent setItalic(boolean value) public final TextComponent italic(boolean value)
{ {
return setItalic(value ? 3F : 0F); return italic(value ? 3F : 0F);
} }
public final TextComponent setItalic(float value) public final TextComponent italic(float value)
{ {
if(italic == value) if(italic == value)
{ {
return this; return this;
} }
italic = value; italic = value;
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public TextComponent setAlignment(Align horizontal, Align vertical) public TextComponent align(Align horizontal, Align vertical)
{ {
if(this.horizontal == horizontal && this.vertical == vertical) if(this.horizontal == horizontal && this.vertical == vertical)
{ {
@ -371,29 +372,29 @@ public class TextComponent extends GuiComponent
} }
this.horizontal = horizontal; this.horizontal = horizontal;
this.vertical = vertical; this.vertical = vertical;
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public TextComponent setHorizontalAlignment(Align horizontal) public TextComponent horizontal(Align horizontal)
{ {
if(this.horizontal == horizontal) if(this.horizontal == horizontal)
{ {
return this; return this;
} }
this.horizontal = horizontal; this.horizontal = horizontal;
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public TextComponent setVerticalAlignment(Align vertical) public TextComponent vertical(Align vertical)
{ {
if(this.vertical == vertical) if(this.vertical == vertical)
{ {
return this; return this;
} }
this.vertical = vertical; this.vertical = vertical;
onComponentChanged(true); onChanged(true);
return this; return this;
} }
@ -408,29 +409,29 @@ public class TextComponent extends GuiComponent
return this; return this;
} }
this.text = text; this.text = text;
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public TextComponent setTextColor(ColorObject color) public TextComponent textColor(int color)
{ {
if(textColor == color) if(textColor == color)
{ {
return this; return this;
} }
textColor = color; textColor = color;
onComponentChanged(true); onChanged(true);
return this; return this;
} }
public TextComponent setBackgroundColor(ColorObject color) public TextComponent backgroundColor(int color)
{ {
if(backGroundColor == color) if(backGroundColor == color)
{ {
return this; return this;
} }
backGroundColor = color; backGroundColor = color;
onComponentChanged(true); onChanged(true);
return this; return this;
} }
@ -441,7 +442,7 @@ public class TextComponent extends GuiComponent
return this; return this;
} }
this.font = font; this.font = font;
onComponentChanged(true); onChanged(true);
return this; return this;
} }
} }

View File

@ -5,7 +5,6 @@ import java.util.function.Predicate;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import speiger.src.coreengine.math.MathUtils; import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
import speiger.src.coreengine.rendering.gui.base.IKeyComponent; import speiger.src.coreengine.rendering.gui.base.IKeyComponent;
@ -33,8 +32,8 @@ public class TextFieldComponent extends GuiComponent
public static final int FLAG_INFINITE_WIDTH = 1 << 23; public static final int FLAG_INFINITE_WIDTH = 1 << 23;
public static final int FLAG_AUTO_VALIDATE = 1 << 24; public static final int FLAG_AUTO_VALIDATE = 1 << 24;
TextComponent text = new TextComponent().setHorizontalAlignment(Align.LEFT_TOP).setForcedSingleLine(true).setSpecialRendering(false).cast(); TextComponent text = new TextComponent().horizontal(Align.LEFT_TOP).singleLine(true).special(false).cast();
ColorObject color; int color;
int curserPosition = 0; int curserPosition = 0;
int selectionPosition = 0; int selectionPosition = 0;
long lastClickTime = 0; long lastClickTime = 0;
@ -45,14 +44,14 @@ public class TextFieldComponent extends GuiComponent
int largestPos = 0; int largestPos = 0;
IGuiBox viewPort = new ParentBox(1F); IGuiBox viewPort = new ParentBox(1F);
public TextFieldComponent(ColorObject color) public TextFieldComponent(int color)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
setFlag(FLAG_CAN_LOSE_FOCUS); setFlag(FLAG_CAN_LOSE_FOCUS);
this.color = color; this.color = color;
} }
public TextFieldComponent(float x, float y, float width, float height, ColorObject color) public TextFieldComponent(float x, float y, float width, float height, int color)
{ {
super(x, y, width, height); super(x, y, width, height);
setFlag(FLAG_CAN_LOSE_FOCUS); setFlag(FLAG_CAN_LOSE_FOCUS);
@ -69,7 +68,7 @@ public class TextFieldComponent extends GuiComponent
String s = text.getText(); String s = text.getText();
float scale = text.getTextScale(); float scale = text.getTextScale();
float width = text.getBox().getWidth(); float width = text.getBox().getWidth();
while(text.getFont().getTextLength(s) * scale > width && s.length() > 0) while(text.getFont().width(s) * scale > width && s.length() > 0)
{ {
s = s.substring(0, s.length() - 1); s = s.substring(0, s.length() - 1);
} }
@ -112,7 +111,7 @@ public class TextFieldComponent extends GuiComponent
return this; return this;
} }
public TextFieldComponent setColor(ColorObject color) public TextFieldComponent setColor(int color)
{ {
this.color = color; this.color = color;
return this; return this;
@ -122,7 +121,7 @@ public class TextFieldComponent extends GuiComponent
{ {
if(setFlag(FLAG_INFINITE_WIDTH, value)) if(setFlag(FLAG_INFINITE_WIDTH, value))
{ {
text.setLimitedBounds(!value); text.limit(!value);
if(getGui() != null) if(getGui() != null)
{ {
addConstrains(text, createConstraints()); addConstrains(text, createConstraints());
@ -162,7 +161,7 @@ public class TextFieldComponent extends GuiComponent
{ {
float scale = text.getTextScale(); float scale = text.getTextScale();
float width = text.getBox().getWidth(); float width = text.getBox().getWidth();
while(text.getFont().getTextLength(s) * scale > width) while(text.getFont().width(s) * scale > width)
{ {
s = s.substring(0, s.length() - 1); s = s.substring(0, s.length() - 1);
} }
@ -672,7 +671,7 @@ public class TextFieldComponent extends GuiComponent
lineOffset = text.length(); lineOffset = text.length();
} }
String s = text.getFont().trimStringToWidth(text.getText(lineOffset), text.getWidth()); String s = text.getFont().trimToWidth(text.getText(lineOffset), text.getWidth());
int k = s.length() + lineOffset; int k = s.length() + lineOffset;
if(curserPosition > k) if(curserPosition > k)
{ {
@ -690,7 +689,7 @@ public class TextFieldComponent extends GuiComponent
lineOffset = MathUtils.clamp(0, text.length(), lineOffset); lineOffset = MathUtils.clamp(0, text.length(), lineOffset);
if(lastLine != lineOffset) if(lastLine != lineOffset)
{ {
text.onComponentChanged(false); text.onChanged(false);
} }
} }
} }

View File

@ -4,7 +4,6 @@ import java.util.function.Predicate;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.vector.ints.Vec2i; import speiger.src.coreengine.math.vector.ints.Vec2i;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
@ -26,8 +25,8 @@ public class TextPanelComponent extends GuiComponent implements IButtonComponent
public static final int FLAG_FOCUS = 1024; public static final int FLAG_FOCUS = 1024;
public static final int FLAG_CAN_LOSE_FOCUS = 2048; public static final int FLAG_CAN_LOSE_FOCUS = 2048;
TextComponent text = new TextComponent().setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setForcedSingleLine(true).setSpecialRendering(false).cast(); TextComponent text = new TextComponent().align(Align.LEFT_TOP, Align.LEFT_TOP).singleLine(true).special(false).cast();
ColorObject color; int color;
int curserPosition = 0; int curserPosition = 0;
Vec2i curserPos = Vec2i.newMutable(); Vec2i curserPos = Vec2i.newMutable();
int selectionPosition = 0; int selectionPosition = 0;
@ -37,13 +36,13 @@ public class TextPanelComponent extends GuiComponent implements IButtonComponent
int clickCount = 0; int clickCount = 0;
Predicate<String> validator = Functions.getAlwaysTrue(); Predicate<String> validator = Functions.getAlwaysTrue();
public TextPanelComponent(ColorObject color) public TextPanelComponent(int color)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.color = color; this.color = color;
} }
public TextPanelComponent(float x, float y, float width, float height, ColorObject color) public TextPanelComponent(float x, float y, float width, float height, int color)
{ {
super(x, y, width, height); super(x, y, width, height);
this.color = color; this.color = color;
@ -67,7 +66,7 @@ public class TextPanelComponent extends GuiComponent implements IButtonComponent
return this; return this;
} }
public TextPanelComponent setColor(ColorObject color) public TextPanelComponent setColor(int color)
{ {
this.color = color; this.color = color;
return this; return this;
@ -102,7 +101,7 @@ public class TextPanelComponent extends GuiComponent implements IButtonComponent
} }
float height = text.getBox().getHeight(); float height = text.getBox().getHeight();
float scale = text.getTextScale(); float scale = text.getTextScale();
while(s.length() > 0 && text.getFont().getTextHeight(s) * scale > height) while(s.length() > 0 && text.getFont().height(s) * scale > height)
{ {
s = s.substring(0, s.length() - 1); s = s.substring(0, s.length() - 1);
} }
@ -132,7 +131,7 @@ public class TextPanelComponent extends GuiComponent implements IButtonComponent
if(isFlagSet(FLAG_FOCUS) && (getGlobalClock() / 15) % 2L == 0) if(isFlagSet(FLAG_FOCUS) && (getGlobalClock() / 15) % 2L == 0)
{ {
TextMetadata data = text.getMetadata(); TextMetadata data = text.getMetadata();
float height = text.getFont().getFontHeight() * text.getTextScale(); float height = text.getFont().height() * text.getTextScale();
if(hasSelectedText()) if(hasSelectedText())
{ {
if(selectionPos.getY() == curserPos.getY()) if(selectionPos.getY() == curserPos.getY())

View File

@ -4,10 +4,11 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.lists.ObjectList;
import speiger.src.collections.objects.maps.impl.hash.Object2ObjectLinkedOpenHashMap; import speiger.src.collections.objects.maps.impl.hash.Object2ObjectLinkedOpenHashMap;
import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap; import speiger.src.collections.objects.maps.interfaces.Object2ObjectMap;
import speiger.src.collections.objects.utils.maps.Object2ObjectMaps; import speiger.src.collections.objects.utils.maps.Object2ObjectMaps;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox; import speiger.src.coreengine.rendering.gui.helper.box.IGuiBox;
import speiger.src.coreengine.rendering.gui.helper.box.ParentBox; import speiger.src.coreengine.rendering.gui.helper.box.ParentBox;
@ -17,11 +18,11 @@ import speiger.src.coreengine.rendering.gui.helper.constrains.ParentConstrain;
public class TooltipPanel extends PanelComponent public class TooltipPanel extends PanelComponent
{ {
List<UUID> helperList = new ObjectArrayList<>(); ObjectList<UUID> helperList = new ObjectArrayList<>();
List<GuiComponent> indexedComponents = new ObjectArrayList<>(); List<GuiComponent> indexedComponents = new ObjectArrayList<>();
Object2ObjectMap<UUID, GuiComponent> renderedTooltips = new Object2ObjectLinkedOpenHashMap<>(); Object2ObjectMap<UUID, GuiComponent> renderedTooltips = new Object2ObjectLinkedOpenHashMap<>();
ColorObject color = ColorObject.BLACK; int color = ColorUtils.BLACK;
ColorObject borderColor = ColorObject.DARK_GRAY; int borderColor = ColorUtils.DARK_GRAY;
IGuiBox box = new ParentBox(1.2F); IGuiBox box = new ParentBox(1.2F);
@Override @Override
@ -62,7 +63,7 @@ public class TooltipPanel extends PanelComponent
{ {
if(child.isVisible()) child.calculateActualBounds(data, false); if(child.isVisible()) child.calculateActualBounds(data, false);
} }
setComponentBounds(data[2]-data[0] + 6.4F, data[3]-data[1] + 2.5F); bounds(data[2]-data[0] + 6.4F, data[3]-data[1] + 2.5F);
} }
@Override @Override

View File

@ -10,7 +10,7 @@ import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.sets.ObjectOpenHashSet; import speiger.src.collections.objects.sets.ObjectOpenHashSet;
import speiger.src.collections.objects.sets.ObjectSet; import speiger.src.collections.objects.sets.ObjectSet;
import speiger.src.coreengine.math.MathUtils; import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.misc.Facing; import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.math.vector.ints.Vec2i; import speiger.src.coreengine.math.vector.ints.Vec2i;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
@ -37,12 +37,12 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
public static final int FLAG_NO_BACKGROUND = 1 << 20; public static final int FLAG_NO_BACKGROUND = 1 << 20;
ScrollBarComponent verticalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY); ScrollBarComponent verticalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY);
ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY).setHorizontal(true); ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY).setHorizontal(true);
ColorObject color; int color;
ColorObject selectedColor; int selectedColor;
ColorObject hoverColor = ColorObject.LIGHT_GRAY; int hoverColor = ColorUtils.LIGHT_GRAY;
int hoverIndex = -1; int hoverIndex = -1;
int dragIndex = -1; int dragIndex = -1;
int movement; int movement;
@ -59,7 +59,7 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
List<T> visibleNodes = new ObjectArrayList<T>(); List<T> visibleNodes = new ObjectArrayList<T>();
RenderBuffer buffer; RenderBuffer buffer;
public TreeComponent(ColorObject color, float entryHeight) public TreeComponent(int color, float entryHeight)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.entryHeight = entryHeight; this.entryHeight = entryHeight;
@ -67,7 +67,7 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
this.selectedColor = color; this.selectedColor = color;
} }
public TreeComponent(ColorObject color, float entryHeight, T entry) public TreeComponent(int color, float entryHeight, T entry)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.entryHeight = entryHeight; this.entryHeight = entryHeight;
@ -81,7 +81,7 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
} }
} }
public TreeComponent(float x, float y, float width, float height, ColorObject color, float entryHeight, T entry) public TreeComponent(float x, float y, float width, float height, int color, float entryHeight, T entry)
{ {
super(x, y, width, height); super(x, y, width, height);
this.entryHeight = entryHeight; this.entryHeight = entryHeight;
@ -110,23 +110,23 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
createArrow(); createArrow();
} }
public TreeComponent<T> setColor(ColorObject color) public TreeComponent<T> setColor(int color)
{ {
if(this.color != color) if(this.color != color)
{ {
this.color = color; this.color = color;
onComponentChanged(true); onChanged(true);
} }
return this; return this;
} }
public TreeComponent<T> setHoverColor(ColorObject color) public TreeComponent<T> setHoverColor(int color)
{ {
hoverColor = color; hoverColor = color;
return this; return this;
} }
public TreeComponent<T> setSelectionColor(ColorObject color) public TreeComponent<T> setSelectionColor(int color)
{ {
selectedColor = color; selectedColor = color;
return this; return this;
@ -137,7 +137,7 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
if(this.entryHeight != entryHeight) if(this.entryHeight != entryHeight)
{ {
this.entryHeight = entryHeight; this.entryHeight = entryHeight;
onComponentChanged(true); onChanged(true);
} }
return this; return this;
} }
@ -206,7 +206,7 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
listChange = true; listChange = true;
openNodes.clear(); openNodes.clear();
selectedNodes.clear(); selectedNodes.clear();
onComponentChanged(true); onChanged(true);
return this; return this;
} }
@ -372,8 +372,8 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
} }
verticalBar.setScrollMax(MathUtils.ceil(visibleNodes.size() * entryHeight)); verticalBar.setScrollMax(MathUtils.ceil(visibleNodes.size() * entryHeight));
horizontalBar.setScrollMax((int)(width / getBox().getScale())); horizontalBar.setScrollMax((int)(width / getBox().getScale()));
horizontalBar.onComponentChanged(true); horizontalBar.onChanged(true);
verticalBar.onComponentChanged(true); verticalBar.onChanged(true);
} }
@Override @Override

View File

@ -3,7 +3,7 @@ package speiger.src.coreengine.rendering.gui.components;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.ObjIntConsumer; import java.util.function.ObjIntConsumer;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.misc.Facing; import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.math.misc.FacingList; import speiger.src.coreengine.math.misc.FacingList;
import speiger.src.coreengine.math.value.IValue; import speiger.src.coreengine.math.value.IValue;
@ -48,7 +48,7 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
final int flags; final int flags;
FacingList facing = null; FacingList facing = null;
String name; String name;
ColorObject color = ColorObject.WINDOW_DEFAULT_BACKGROUND; int color = ColorUtils.WINDOW_DEFAULT_BACKGROUND;
Vec2f lastSize = Vec2f.newMutable(); Vec2f lastSize = Vec2f.newMutable();
Vec2i lastClick = Vec2i.newMutable(); Vec2i lastClick = Vec2i.newMutable();
IValue animation = null; IValue animation = null;
@ -69,18 +69,18 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
public void init() public void init()
{ {
super.init(); super.init();
LabelComponent label = new LabelComponent(name, ColorObject.DARK_GRAY); LabelComponent label = new LabelComponent(name, ColorUtils.DARK_GRAY);
label.getText().setTextScale(0.4F).setHorizontalAlignment(Align.LEFT_TOP).setForcedSingleLine(true); label.getText().setTextScale(0.4F).horizontal(Align.LEFT_TOP).singleLine(true);
addChild(label, new ComponentConstrains(null, null, new ParentConstrain(), new PixelConstrain(7.5F))); addChild(label, new ComponentConstrains(null, null, new ParentConstrain(), new PixelConstrain(7.5F)));
float offset = 9F; float offset = 9F;
if((flags & WINDOW_FLAG_CLOSEABLE) != 0) if((flags & WINDOW_FLAG_CLOSEABLE) != 0)
{ {
addChild(new IconButtonComponent(0F, 0F, 7.5F, 7.5F, ColorObject.RED, new CrossIcon(ColorObject.WHITE).setPadding(2.5F, 2F)).addUserActionListener(new ConsumerConverter<GuiComponent>(0, this)).setZOffset(0.001F), new ComponentConstrains(new PixelConstrain(offset).setInverted(), null, null, null)); addChild(new IconButtonComponent(0F, 0F, 7.5F, 7.5F, ColorUtils.RED, new CrossIcon(ColorUtils.WHITE).setPadding(2.5F, 2F)).addUserActionListener(new ConsumerConverter<>(0, this)).setZOffset(0.001F), new ComponentConstrains(new PixelConstrain(offset).setInverted(), null, null, null));
offset += 7.5F; offset += 7.5F;
} }
if((flags & WINDOW_FLAG_MINIMIZEABLE) != 0) if((flags & WINDOW_FLAG_MINIMIZEABLE) != 0)
{ {
addChild(new IconButtonComponent(0F, 0F, 7.5F, 7.5F, ColorObject.GRAY, new LineIcon(ColorObject.WHITE, 0.7F, 0.25F)).addUserActionListener(new ConsumerConverter<GuiComponent>(1, this)).setZOffset(0.001F), new ComponentConstrains(new PixelConstrain(offset).setInverted(), null, null, null)); addChild(new IconButtonComponent(0F, 0F, 7.5F, 7.5F, ColorUtils.GRAY, new LineIcon(ColorUtils.WHITE, 0.7F, 0.25F)).addUserActionListener(new ConsumerConverter<>(1, this)).setZOffset(0.001F), new ComponentConstrains(new PixelConstrain(offset).setInverted(), null, null, null));
} }
if(canMoveIntoForground()) if(canMoveIntoForground())
{ {
@ -92,7 +92,7 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
{ {
if(setFlag(FLAG_MINIMIZED, value)) if(setFlag(FLAG_MINIMIZED, value))
{ {
onComponentChanged(false); onChanged(false);
} }
} }
@ -103,12 +103,12 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
if(value) if(value)
{ {
Vec2f last = InternalThreadPools.VEC2F.get().set(lastSize); Vec2f last = InternalThreadPools.VEC2F.get().set(lastSize);
setComponentBounds(last.getX(), isFlagSet(FLAG_MINIMIZED) ? getMinimizedY() : last.getY()); bounds(last.getX(), isFlagSet(FLAG_MINIMIZED) ? getMinimizedY() : last.getY());
lastSize.set(last); lastSize.set(last);
InternalThreadPools.VEC2F.accept(last.negate()); InternalThreadPools.VEC2F.accept(last.negate());
} }
else setComponentBounds(lastSize.getX(), lastSize.getY()); else bounds(lastSize.getX(), lastSize.getY());
onComponentChanged(false); onChanged(false);
} }
return this; return this;
} }
@ -128,7 +128,7 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
return 7.5F; return 7.5F;
} }
public WindowComponent setColor(ColorObject color) public WindowComponent setColor(int color)
{ {
this.color = color; this.color = color;
return this; return this;
@ -176,7 +176,7 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
updateMinizedState(true); updateMinizedState(true);
} }
Vec2f last = InternalThreadPools.VEC2F.get().set(lastSize); Vec2f last = InternalThreadPools.VEC2F.get().set(lastSize);
setComponentBounds(last.getX(), isFlagSet(FLAG_MINIMIZED) ? getMinimizedY() : last.getY()); bounds(last.getX(), isFlagSet(FLAG_MINIMIZED) ? getMinimizedY() : last.getY());
lastSize.set(last); lastSize.set(last);
InternalThreadPools.VEC2F.accept(last.negate()); InternalThreadPools.VEC2F.accept(last.negate());
animation = null; animation = null;
@ -201,7 +201,7 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
} }
@Override @Override
protected void onPreRender() protected void preRender()
{ {
if(animation != null) if(animation != null)
{ {
@ -218,7 +218,7 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
} }
@Override @Override
protected void onPostRender() protected void postRender()
{ {
if(animation != null) if(animation != null)
{ {
@ -242,7 +242,7 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
animation = (isMinimized() ? new LiniarValue(1F, 0F, 1F) : new LiniarValue(1F, 1F, 0F)).setSmooth(); animation = (isMinimized() ? new LiniarValue(1F, 0F, 1F) : new LiniarValue(1F, 1F, 0F)).setSmooth();
if(isMinimized()) if(isMinimized())
{ {
setComponentBounds(lastSize.getX(), lastSize.getY()); bounds(lastSize.getX(), lastSize.getY());
} }
updateMinizedState(false); updateMinizedState(false);
break; break;
@ -276,7 +276,7 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
{ {
if(facing.isEmpty() && isFlagSet(FLAG_MOVEABLE)) if(facing.isEmpty() && isFlagSet(FLAG_MOVEABLE))
{ {
moveComponent(mouseX - lastClick.getX(), mouseY - lastClick.getY()); move(mouseX - lastClick.getX(), mouseY - lastClick.getY());
} }
else if(!facing.isEmpty() && isFlagSet(FLAG_RESIZEABLE)) else if(!facing.isEmpty() && isFlagSet(FLAG_RESIZEABLE))
{ {
@ -291,27 +291,27 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
setMassChanging(); setMassChanging();
if(facing.contains(Facing.NORTH) && isFlagNotSet(FLAG_MINIMIZED)) if(facing.contains(Facing.NORTH) && isFlagNotSet(FLAG_MINIMIZED))
{ {
resizeComponent(0F, -(yChange / scale)); resize(0F, -(yChange / scale));
moveComponent(0F, yChange); move(0F, yChange);
} }
else if(facing.contains(Facing.SOUTH) && isFlagNotSet(FLAG_MINIMIZED)) else if(facing.contains(Facing.SOUTH) && isFlagNotSet(FLAG_MINIMIZED))
{ {
resizeComponent(0F, yChange / scale); resize(0F, yChange / scale);
} }
if(facing.contains(Facing.WEST)) if(facing.contains(Facing.WEST))
{ {
resizeComponent(-(xChange / scale) - 1F, 0F); resize(-(xChange / scale) - 1F, 0F);
moveComponent(xChange, 0F); move(xChange, 0F);
} }
else if(facing.contains(Facing.EAST)) else if(facing.contains(Facing.EAST))
{ {
resizeComponent(xChange / scale, 0F); resize(xChange / scale, 0F);
} }
ensureMinimumBounds(); ensureMinimumBounds();
finishMassChanging(); finishMassChanging();
if(xChange > 0F || yChange > 0F) if(xChange > 0F || yChange > 0F)
{ {
onComponentChanged(true); onChanged(true);
} }
} }
lastClick.set(mouseX, mouseY); lastClick.set(mouseX, mouseY);
@ -345,12 +345,12 @@ public class WindowComponent extends PanelComponent implements IButtonComponent,
if(box.getBaseWidth() < bounds.getX()) if(box.getBaseWidth() < bounds.getX())
{ {
box.setWidth(bounds.getX()); box.setWidth(bounds.getX());
onComponentChanged(true); onChanged(true);
} }
if(box.getBaseHeight() < bounds.getY()) if(box.getBaseHeight() < bounds.getY())
{ {
box.setHeight(bounds.getY()); box.setHeight(bounds.getY());
onComponentChanged(true); onChanged(true);
} }
} }
} }

View File

@ -1,17 +1,16 @@
package speiger.src.coreengine.rendering.gui.components.icon; package speiger.src.coreengine.rendering.gui.components.icon;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.misc.Facing; import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.rendering.gui.helper.UIShapes; import speiger.src.coreengine.rendering.gui.helper.UIShapes;
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer; import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
public class ArrowIcon implements IIcon public class ArrowIcon implements IIcon
{ {
ColorObject color; int color;
Facing direction; Facing direction;
float scale = 1F; float scale = 1F;
public ArrowIcon(ColorObject color, Facing direction) public ArrowIcon(int color, Facing direction)
{ {
this.color = color; this.color = color;
this.direction = direction; this.direction = direction;

View File

@ -1,16 +1,15 @@
package speiger.src.coreengine.rendering.gui.components.icon; package speiger.src.coreengine.rendering.gui.components.icon;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.helper.UIShapes; import speiger.src.coreengine.rendering.gui.helper.UIShapes;
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer; import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
public class CrossIcon implements IIcon public class CrossIcon implements IIcon
{ {
ColorObject color; int color;
float paddingX = 4F; float paddingX = 4F;
float paddingY = 2F; float paddingY = 2F;
public CrossIcon(ColorObject color) public CrossIcon(int color)
{ {
this.color = color; this.color = color;
} }

View File

@ -1,16 +1,15 @@
package speiger.src.coreengine.rendering.gui.components.icon; package speiger.src.coreengine.rendering.gui.components.icon;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer; import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
public class LineIcon implements IIcon public class LineIcon implements IIcon
{ {
ColorObject color; int color;
float height; float height;
float padding; float padding;
float thickness = 1F; float thickness = 1F;
public LineIcon(ColorObject color, float height, float padding) public LineIcon(int color, float height, float padding)
{ {
this.color = color; this.color = color;
this.height = height; this.height = height;

View File

@ -1,12 +1,12 @@
package speiger.src.coreengine.rendering.gui.components.icon; package speiger.src.coreengine.rendering.gui.components.icon;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer; import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
import speiger.src.coreengine.rendering.textures.base.ITexture; import speiger.src.coreengine.rendering.textures.base.ITexture;
public class TexturedIcon implements IIcon public class TexturedIcon implements IIcon
{ {
ColorObject color = ColorObject.WHITE; int color = ColorUtils.WHITE;
ITexture texture; ITexture texture;
boolean forceBounds = false; boolean forceBounds = false;
@ -15,7 +15,7 @@ public class TexturedIcon implements IIcon
this.texture = texture; this.texture = texture;
} }
public TexturedIcon(ColorObject color, ITexture texture) public TexturedIcon(int color, ITexture texture)
{ {
this.color = color; this.color = color;
this.texture = texture; this.texture = texture;

View File

@ -45,7 +45,7 @@ public class FlowLayout implements Consumer<GuiComponent>
widthUsed = 0F; widthUsed = 0F;
yInserted++; yInserted++;
} }
component.setComponentPosition(minX + widthUsed + padding.getX(), minY + maxHeight + (padding.getY() * yInserted)); component.set(minX + widthUsed + padding.getX(), minY + maxHeight + (padding.getY() * yInserted));
heightOffset = Math.max(heightOffset, bounds[3] - bounds[1]); heightOffset = Math.max(heightOffset, bounds[3] - bounds[1]);
widthUsed += width + padding.getX(); widthUsed += width + padding.getX();
xInserted++; xInserted++;

View File

@ -71,13 +71,13 @@ public class VerticalLayout implements Consumer<GuiComponent>
float[] bounds = new float[4]; float[] bounds = new float[4];
component.calculateActualBounds(bounds, true); component.calculateActualBounds(bounds, true);
float height = (bounds[3] - bounds[1]) + padding; float height = (bounds[3] - bounds[1]) + padding;
component.setComponentPosition(minX, minY + currentY); component.set(minX, minY + currentY);
currentY += height; currentY += height;
component.finishMassChanging(true); component.finishMassChanging(true);
} }
if(parent != null) if(parent != null)
{ {
parent.onComponentChanged(false); parent.onChanged(false);
} }
changing = false; changing = false;
} }

View File

@ -72,7 +72,7 @@ public abstract class BaseListEntry implements IListEntry
{ {
for(int i = 0;i<components.size();i++) for(int i = 0;i<components.size();i++)
{ {
components.get(i).onFixedUpdate(); components.get(i).fixedUpdate();
} }
} }
@ -84,7 +84,7 @@ public abstract class BaseListEntry implements IListEntry
GuiComponent entry = components.get(i); GuiComponent entry = components.get(i);
if(entry.isVisible()) if(entry.isVisible())
{ {
entry.setEnabled(enabled).onRender(mouseX, mouseY, particalTicks); entry.setEnabled(enabled).render(mouseX, mouseY, particalTicks);
} }
} }
} }

View File

@ -3,7 +3,7 @@ package speiger.src.coreengine.rendering.gui.components.list;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiBase; import speiger.src.coreengine.rendering.gui.GuiBase;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
@ -13,8 +13,8 @@ import speiger.src.coreengine.rendering.gui.helper.Align;
public class ExampleEntry implements IListEntry, IButtonComponent public class ExampleEntry implements IListEntry, IButtonComponent
{ {
TextComponent text = new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP); TextComponent text = new TextComponent().limit(false).align(Align.LEFT_TOP, Align.LEFT_TOP);
CheckBoxComponent checkBox = new CheckBoxComponent(ColorObject.ORANGE); CheckBoxComponent checkBox = new CheckBoxComponent(ColorUtils.ORANGE);
public ExampleEntry(String s) public ExampleEntry(String s)
{ {
@ -32,8 +32,8 @@ public class ExampleEntry implements IListEntry, IButtonComponent
{ {
text.setOwner(owner); text.setOwner(owner);
checkBox.setOwner(owner); checkBox.setOwner(owner);
checkBox.setComponentBounds(owner.getFont().getFontHeight(), owner.getFont().getFontHeight()); checkBox.bounds(owner.getFont().height(), owner.getFont().height());
text.setComponentPosition(owner.getFont().getFontHeight(), 0F); text.set(owner.getFont().height(), 0F);
} }
@Override @Override
@ -41,7 +41,7 @@ public class ExampleEntry implements IListEntry, IButtonComponent
{ {
text.setScale(scale); text.setScale(scale);
checkBox.setScale(scale); checkBox.setScale(scale);
text.setComponentPosition(checkBox.getBox().getWidth(), 0F); text.set(checkBox.getBox().getWidth(), 0F);
} }
@Override @Override
@ -58,8 +58,8 @@ public class ExampleEntry implements IListEntry, IButtonComponent
@Override @Override
public void onRender(GuiComponent comp, boolean enabled, int mouseX, int mouseY, float particalTicks) public void onRender(GuiComponent comp, boolean enabled, int mouseX, int mouseY, float particalTicks)
{ {
checkBox.onRender(mouseX, mouseY, particalTicks); checkBox.render(mouseX, mouseY, particalTicks);
text.onRender(mouseX, mouseY, particalTicks); text.render(mouseX, mouseY, particalTicks);
} }
@Override @Override

View File

@ -10,7 +10,7 @@ import speiger.src.coreengine.rendering.gui.helper.Align;
public class SelectionEntry implements IListEntry public class SelectionEntry implements IListEntry
{ {
TextComponent text = new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP); TextComponent text = new TextComponent().limit(false).align(Align.LEFT_TOP, Align.LEFT_TOP);
public SelectionEntry(){} public SelectionEntry(){}
@ -65,7 +65,7 @@ public class SelectionEntry implements IListEntry
@Override @Override
public void onRender(GuiComponent comp, boolean enabled, int mouseX, int mouseY, float particalTicks) public void onRender(GuiComponent comp, boolean enabled, int mouseX, int mouseY, float particalTicks)
{ {
text.onRender(mouseX, mouseY, particalTicks); text.render(mouseX, mouseY, particalTicks);
} }
@Override @Override

View File

@ -5,7 +5,7 @@ import speiger.src.coreengine.rendering.gui.helper.Align;
public class TextListEntry extends BaseListEntry public class TextListEntry extends BaseListEntry
{ {
TextComponent text = addComponent(new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setSpecialRendering(true).setComponentPosition(0F, 0F).cast()); TextComponent text = addComponent(new TextComponent().limit(false).align(Align.LEFT_TOP, Align.LEFT_TOP).special(true).set(0F, 0F).cast());
public TextListEntry(String s) public TextListEntry(String s)
{ {

View File

@ -3,7 +3,6 @@ package speiger.src.coreengine.rendering.gui.components.menu;
import java.util.List; import java.util.List;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains; import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains;
import speiger.src.coreengine.rendering.gui.helper.constrains.MenuConstrain; import speiger.src.coreengine.rendering.gui.helper.constrains.MenuConstrain;
@ -12,17 +11,17 @@ import speiger.src.coreengine.rendering.gui.helper.constrains.PixelConstrain;
public class MenuBarComponent extends GuiComponent public class MenuBarComponent extends GuiComponent
{ {
ColorObject color; int color;
List<MenuItemComponent> menuItems = new ObjectArrayList<MenuItemComponent>(); List<MenuItemComponent> menuItems = new ObjectArrayList<MenuItemComponent>();
float scale = 1F; float scale = 1F;
public MenuBarComponent(ColorObject color) public MenuBarComponent(int color)
{ {
super(0F, 0F, 0F, 0F); super(0F, 0F, 0F, 0F);
this.color = color; this.color = color;
} }
public MenuBarComponent(float x, float y, float width, float height, ColorObject color) public MenuBarComponent(float x, float y, float width, float height, int color)
{ {
super(x, y, width, height); super(x, y, width, height);
this.color = color; this.color = color;
@ -78,7 +77,7 @@ public class MenuBarComponent extends GuiComponent
addChild(item, new ComponentConstrains(new MenuConstrain<MenuItemComponent>(menuItems), new PixelConstrain(), item.createWidthConstriain(), new ParentConstrain())); addChild(item, new ComponentConstrains(new MenuConstrain<MenuItemComponent>(menuItems), new PixelConstrain(), item.createWidthConstriain(), new ParentConstrain()));
item.setZOffset(0.3F); item.setZOffset(0.3F);
item.setTextScale(scale); item.setTextScale(scale);
item.onComponentChanged(false); item.onChanged(false);
return item; return item;
} }

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains; import speiger.src.coreengine.rendering.gui.helper.constrains.ComponentConstrains;
import speiger.src.coreengine.rendering.gui.helper.constrains.Constrain; import speiger.src.coreengine.rendering.gui.helper.constrains.Constrain;
@ -55,7 +54,7 @@ public class MenuComponent extends MenuItemComponent implements Consumer<GuiComp
} }
@Override @Override
protected void setMenuColor(ColorObject color) protected void setMenuColor(int color)
{ {
super.setMenuColor(color); super.setMenuColor(color);
for(int i = 0,m=components.size();i<m;i++) for(int i = 0,m=components.size();i<m;i++)
@ -93,7 +92,7 @@ public class MenuComponent extends MenuItemComponent implements Consumer<GuiComp
{ {
for(int i = 0,m=components.size();i<m;i++) for(int i = 0,m=components.size();i<m;i++)
{ {
components.get(i).onComponentChanged(false); components.get(i).onChanged(false);
} }
} }
} }
@ -128,7 +127,7 @@ public class MenuComponent extends MenuItemComponent implements Consumer<GuiComp
components.add(comp); components.add(comp);
comp.setScale(defaultScale); comp.setScale(defaultScale);
comp.setMenuColor(color); comp.setMenuColor(color);
addChild(comp.setIgnoreBounds(true).addUserActionListener(this), createConstrains(comp)).onComponentChanged(false); addChild(comp.setIgnoreBounds(true).addUserActionListener(this), createConstrains(comp)).onChanged(false);
comp.setVisible(isFlagSet(FLAG_OPEN)); comp.setVisible(isFlagSet(FLAG_OPEN));
comp.setTextScale(textScale); comp.setTextScale(textScale);
return comp; return comp;
@ -146,7 +145,7 @@ public class MenuComponent extends MenuItemComponent implements Consumer<GuiComp
super.removeChild(comp); super.removeChild(comp);
if(components.remove(comp)) if(components.remove(comp))
{ {
onComponentChanged(false); onChanged(false);
} }
return this; return this;
} }
@ -257,7 +256,7 @@ public class MenuComponent extends MenuItemComponent implements Consumer<GuiComp
{ {
components.get(i).setBoxWidth(width); components.get(i).setBoxWidth(width);
} }
onComponentChanged(false); onChanged(false);
} }
return this; return this;
} }

View File

@ -1,6 +1,5 @@
package speiger.src.coreengine.rendering.gui.components.menu; package speiger.src.coreengine.rendering.gui.components.menu;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IButtonComponent; import speiger.src.coreengine.rendering.gui.base.IButtonComponent;
import speiger.src.coreengine.rendering.gui.components.TextComponent; import speiger.src.coreengine.rendering.gui.components.TextComponent;
@ -14,8 +13,8 @@ public class MenuItemComponent extends GuiComponent implements IButtonComponent
{ {
public static final int FLAG_KEEP_MENU_OPEN = 1 << 20; public static final int FLAG_KEEP_MENU_OPEN = 1 << 20;
TextComponent text = new TextComponent().setForcedSingleLine(true).setLimitedBounds(false).setTextScale(0.35F).cast(); TextComponent text = new TextComponent().singleLine(true).limit(false).setTextScale(0.35F).cast();
ColorObject color = null; Integer color = null;
protected float boxWidth; protected float boxWidth;
public MenuItemComponent(String name) public MenuItemComponent(String name)
@ -56,13 +55,13 @@ public class MenuItemComponent extends GuiComponent implements IButtonComponent
return isFlagSet(FLAG_KEEP_MENU_OPEN); return isFlagSet(FLAG_KEEP_MENU_OPEN);
} }
public MenuItemComponent setCustomColor(ColorObject color) public MenuItemComponent setCustomColor(int color)
{ {
this.color = color; this.color = color;
return this; return this;
} }
protected void setMenuColor(ColorObject color) protected void setMenuColor(int color)
{ {
if(this.color == null) if(this.color == null)
{ {

View File

@ -6,7 +6,7 @@ import java.util.function.Consumer;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.base.IKeyComponent; import speiger.src.coreengine.rendering.gui.base.IKeyComponent;
import speiger.src.coreengine.rendering.gui.components.ListComponent; import speiger.src.coreengine.rendering.gui.components.ListComponent;
@ -21,8 +21,8 @@ import speiger.src.coreengine.rendering.gui.renderer.IFontRenderer;
public class ConsoleComponent extends GuiComponent implements IKeyComponent public class ConsoleComponent extends GuiComponent implements IKeyComponent
{ {
TextFieldComponent chat = new TextFieldComponent(ColorObject.DARK_GRAY).setCanLoseFocus(false).setInfiniteText(true).setMaxTextLength(Integer.MAX_VALUE).setFocused(true); TextFieldComponent chat = new TextFieldComponent(ColorUtils.DARK_GRAY).setCanLoseFocus(false).setInfiniteText(true).setMaxTextLength(Integer.MAX_VALUE).setFocused(true);
ListComponent<MessageEntry> list = new ListComponent<>(ColorObject.DARK_GRAY.copy().setAlpha(120), 8F); ListComponent<MessageEntry> list = new ListComponent<>(ColorUtils.setA(ColorUtils.DARK_GRAY, 120), 8F);
float lastWidth = 0F; float lastWidth = 0F;
List<ConsoleMessage> messages = new ObjectArrayList<>(); List<ConsoleMessage> messages = new ObjectArrayList<>();
Consumer<String> listener; Consumer<String> listener;
@ -157,9 +157,9 @@ public class ConsoleComponent extends GuiComponent implements IKeyComponent
ScrollBarComponent scroll = list.getVerticalBar(); ScrollBarComponent scroll = list.getVerticalBar();
boolean atEnd = scroll.isAtEnd(); boolean atEnd = scroll.isAtEnd();
float width = (list.getBox().getWidth() -5F) / 0.45F; float width = (list.getBox().getWidth() -5F) / 0.45F;
for(String s : getGui().getFont().splitLines(text, width, IFontRenderer.SPECIAL)) for(String s : getGui().getFont().split(text, width, IFontRenderer.SPECIAL))
{ {
list.addEntry(new MessageEntry(s, messageId)); list.add(new MessageEntry(s, messageId));
} }
if(atEnd) scroll.setScrollEnd(); if(atEnd) scroll.setScrollEnd();
if(add) if(add)

View File

@ -3,7 +3,7 @@ package speiger.src.coreengine.rendering.gui.components.tree;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.GuiBase; import speiger.src.coreengine.rendering.gui.GuiBase;
import speiger.src.coreengine.rendering.gui.GuiComponent; import speiger.src.coreengine.rendering.gui.GuiComponent;
import speiger.src.coreengine.rendering.gui.components.TextComponent; import speiger.src.coreengine.rendering.gui.components.TextComponent;
@ -14,7 +14,7 @@ import speiger.src.coreengine.utils.profiler.IProfiler.IProfilerEntry;
public class ProfilerTreeEntry extends BaseTreeEntry public class ProfilerTreeEntry extends BaseTreeEntry
{ {
TextComponent text = new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setSpecialRendering(true).setTextScale(0.4F).setComponentPosition(0F, 1F).cast(); TextComponent text = new TextComponent().limit(false).align(Align.LEFT_TOP, Align.LEFT_TOP).special(true).setTextScale(0.4F).set(0F, 1F).cast();
IProfilerEntry entry; IProfilerEntry entry;
public ProfilerTreeEntry(IProfilerEntry entry) public ProfilerTreeEntry(IProfilerEntry entry)
@ -65,7 +65,7 @@ public class ProfilerTreeEntry extends BaseTreeEntry
@Override @Override
public void onRender(GuiComponent comp, boolean enabled, int mouseX, int mouseY, float particalTicks) public void onRender(GuiComponent comp, boolean enabled, int mouseX, int mouseY, float particalTicks)
{ {
text.setEnabled(enabled).onRender(mouseX, mouseY, particalTicks); text.setEnabled(enabled).render(mouseX, mouseY, particalTicks);
} }
@Override @Override
@ -108,17 +108,17 @@ public class ProfilerTreeEntry extends BaseTreeEntry
time /= 1000000L; time /= 1000000L;
if(time < 1) if(time < 1)
{ {
return "§<color="+ColorObject.LIGHT_BLUE.hashCode()+">"; return "§<color="+ColorUtils.LIGHT_BLUE+">";
} }
if(time >= 12) if(time >= 12)
{ {
return "§<color="+ColorObject.RED.hashCode()+">"; return "§<color="+ColorUtils.RED+">";
} }
if(time >= 5) if(time >= 5)
{ {
return "§<color="+ColorObject.YELLOW.hashCode()+">"; return "§<color="+ColorUtils.YELLOW+">";
} }
return "§<color="+ColorObject.GREEN.hashCode()+">"; return "§<color="+ColorUtils.GREEN+">";
} }
@Override @Override

View File

@ -6,7 +6,7 @@ import speiger.src.coreengine.rendering.gui.helper.Align;
public class TextTreeEntry extends BaseTreeEntry public class TextTreeEntry extends BaseTreeEntry
{ {
TextComponent text = addComponent(new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setSpecialRendering(true).setComponentPosition(0F, 0F).cast()); TextComponent text = addComponent(new TextComponent().limit(false).align(Align.LEFT_TOP, Align.LEFT_TOP).special(true).set(0F, 0F).cast());
public TextTreeEntry(String s) public TextTreeEntry(String s)
{ {

View File

@ -1,10 +1,10 @@
package speiger.src.coreengine.rendering.gui.components.window.color; package speiger.src.coreengine.rendering.gui.components.window.color;
import java.awt.Color; import java.awt.Color;
import java.util.function.Consumer; import java.util.function.IntConsumer;
import speiger.src.coreengine.math.MathUtils; import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.misc.Facing; import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.math.vector.floats.Vec2f; import speiger.src.coreengine.math.vector.floats.Vec2f;
import speiger.src.coreengine.rendering.gui.UITextures; import speiger.src.coreengine.rendering.gui.UITextures;
@ -25,24 +25,24 @@ import speiger.src.coreengine.utils.helpers.InternalThreadPools;
public class ColorPickerWindowComponent extends WindowComponent public class ColorPickerWindowComponent extends WindowComponent
{ {
Consumer<ColorObject> listener; IntConsumer listener;
IIcon wheelIcon = new TexturedIcon(UITextures.COLOR_WHEEL); IIcon wheelIcon = new TexturedIcon(UITextures.COLOR_WHEEL);
IGuiBox wheelBox = new GuiBox(15, 10, 70, 70); IGuiBox wheelBox = new GuiBox(15, 10, 70, 70);
IGuiBox selectedBox = new GuiBox(5F, 94F, 50F, 10F); IGuiBox selectedBox = new GuiBox(5F, 94F, 50F, 10F);
ColorObject[] colors = new ColorObject[]{ColorObject.rgb(0), ColorObject.rgb(0), ColorObject.rgb(0), ColorObject.rgb(0), ColorObject.rgb(0)}; int[] colors = new int[]{ColorUtils.rgb(0), ColorUtils.rgb(0), ColorUtils.rgb(0), ColorUtils.rgb(0), ColorUtils.rgb(0)};
SliderComponent brightness = new GradientSliderComponent(95, 13, 17, 76, 0, 100, 0, ColorObject.GRAY, colors[2], colors[3], Facing.NORTH, null).setScrollEffect(-1).setVertical(true); SliderComponent brightness = new GradientSliderComponent(95, 13, 17, 76, 0, 100, 0, ColorUtils.GRAY, colors[2], colors[3], Facing.NORTH, null).setScrollEffect(-1).setVertical(true);
SliderComponent saturation = new GradientSliderComponent(110, 13, 17, 76, 0, 100, 0, ColorObject.GRAY, colors[0], colors[1], Facing.NORTH, null).setScrollEffect(-1).setVertical(true); SliderComponent saturation = new GradientSliderComponent(110, 13, 17, 76, 0, 100, 0, ColorUtils.GRAY, colors[0], colors[1], Facing.NORTH, null).setScrollEffect(-1).setVertical(true);
TextFieldComponent code = new TextFieldComponent(60, 94, 104, 20, ColorObject.DARK_GRAY).setValidator(Functions.NUMBERS_ONLY).setMaxTextLength(8); TextFieldComponent code = new TextFieldComponent(60, 94, 104, 20, ColorUtils.DARK_GRAY).setValidator(Functions.NUMBERS_ONLY).setMaxTextLength(8);
float[] hsv = new float[3]; float[] hsv = new float[3];
IGuiBox[] colorBoxes; IGuiBox[] colorBoxes;
ColorPool pool; ColorPool pool;
public ColorPickerWindowComponent(float x, float y, ColorPool pool, ColorObject defaultColor, Consumer<ColorObject> listener, String name) public ColorPickerWindowComponent(float x, float y, ColorPool pool, int defaultColor, IntConsumer listener, String name)
{ {
super(x, y, 125, 140, FIXED_SIZE_POPUP, name); super(x, y, 125, 140, FIXED_SIZE_POPUP, name);
this.pool = pool; this.pool = pool;
this.listener = listener; this.listener = listener;
hsv = defaultColor.toHue(); hsv = ColorUtils.toHue(defaultColor);
colorBoxes = new IGuiBox[Math.min(18, pool.size())]; colorBoxes = new IGuiBox[Math.min(18, pool.size())];
for(int i = 0,m=colorBoxes.length;i<m;i++) for(int i = 0,m=colorBoxes.length;i<m;i++)
{ {
@ -59,8 +59,8 @@ public class ColorPickerWindowComponent extends WindowComponent
addChild(brightness.addChangeListener(minimizedListener).addUserActionListener(T -> setColor(hsv[0], hsv[1], T.cast(SliderComponent.class).getValue() * 0.01F))); addChild(brightness.addChangeListener(minimizedListener).addUserActionListener(T -> setColor(hsv[0], hsv[1], T.cast(SliderComponent.class).getValue() * 0.01F)));
addChild(saturation.addChangeListener(minimizedListener).addUserActionListener(T -> setColor(hsv[0], T.cast(SliderComponent.class).getValue() * 0.01F, hsv[2]))); addChild(saturation.addChangeListener(minimizedListener).addUserActionListener(T -> setColor(hsv[0], T.cast(SliderComponent.class).getValue() * 0.01F, hsv[2])));
addChild(code.setScale(0.5F).addChangeListener(minimizedListener).addUserActionListener(T -> onTyped())); addChild(code.setScale(0.5F).addChangeListener(minimizedListener).addUserActionListener(T -> onTyped()));
addChild(new ButtonComponent(0F, 0F, 0F, 20F, "Select", ColorObject.GREEN).setScale(0.4F).addUserActionListener(T -> apply()), new ComponentConstrains(null, new ParentConstrain(8F).invert(), new RelativeConstrain(0.5F / 0.4F), null)); addChild(new ButtonComponent(0F, 0F, 0F, 20F, "Select", ColorUtils.GREEN).setScale(0.4F).addUserActionListener(T -> apply()), new ComponentConstrains(null, new ParentConstrain(8F).invert(), new RelativeConstrain(0.5F / 0.4F), null));
addChild(new ButtonComponent(0F, 0F, 0F, 20F, "Cancel", ColorObject.RED).setScale(0.4F).addUserActionListener(T -> T.getGui().removeComponent(this)), new ComponentConstrains(new RelativeConstrain(0.5F), new ParentConstrain(8F).invert(), new RelativeConstrain(0.5F / 0.4F), null)); addChild(new ButtonComponent(0F, 0F, 0F, 20F, "Cancel", ColorUtils.RED).setScale(0.4F).addUserActionListener(T -> T.getGui().removeComponent(this)), new ComponentConstrains(new RelativeConstrain(0.5F), new ParentConstrain(8F).invert(), new RelativeConstrain(0.5F / 0.4F), null));
setColor(hsv[0], hsv[1], hsv[2]); setColor(hsv[0], hsv[1], hsv[2]);
} }
@ -76,17 +76,16 @@ public class ColorPickerWindowComponent extends WindowComponent
super.renderSelf(mouseX, mouseY, particalTicks); super.renderSelf(mouseX, mouseY, particalTicks);
wheelIcon.render(getRenderer().translate(0F, 0F, 0.01F).setBrightness(hsv[1]), wheelBox); wheelIcon.render(getRenderer().translate(0F, 0F, 0.01F).setBrightness(hsv[1]), wheelBox);
getRenderer().setBrightness(1F); getRenderer().setBrightness(1F);
ColorObject color = new ColorObject(0);
for(int i = 0,m=colorBoxes.length;i<m;i++) for(int i = 0,m=colorBoxes.length;i<m;i++)
{ {
IGuiBox box = colorBoxes[i]; IGuiBox box = colorBoxes[i];
getRenderer().drawQuad(box, color.setRGB(pool.getColor(i))).drawFrame(box, ColorObject.DARK_GRAY); getRenderer().drawQuad(box, pool.getColor(i)).drawFrame(box, ColorUtils.DARK_GRAY);
} }
getRenderer().drawQuad(selectedBox, colors[4]).drawFrame(selectedBox, ColorObject.DARK_GRAY); getRenderer().drawQuad(selectedBox, colors[4]).drawFrame(selectedBox, ColorUtils.DARK_GRAY);
float centerX = wheelBox.getCenterX(); float centerX = wheelBox.getCenterX();
float centerY = wheelBox.getCenterY(); float centerY = wheelBox.getCenterY();
Vec2f pos = InternalThreadPools.VEC2F.get().set(centerX, centerY).add(0F, -(hsv[2] * 33F)).rotate((float)Math.toRadians(-hsv[0] * 360F), centerX, centerY); Vec2f pos = InternalThreadPools.VEC2F.get().set(centerX, centerY).add(0F, -(hsv[2] * 33F)).rotate((float)Math.toRadians(-hsv[0] * 360F), centerX, centerY);
getRenderer().drawQuad(pos.getX() - 1F, pos.getY() - 1F, pos.getX() + 1F, pos.getY() + 1, 0.1F, ColorObject.BLACK); getRenderer().drawQuad(pos.getX() - 1F, pos.getY() - 1F, pos.getX() + 1F, pos.getY() + 1, 0.1F, ColorUtils.BLACK);
InternalThreadPools.VEC2F.accept(pos); InternalThreadPools.VEC2F.accept(pos);
getRenderer().translate(0F, 0F, -0.01F); getRenderer().translate(0F, 0F, -0.01F);
return true; return true;
@ -105,7 +104,7 @@ public class ColorPickerWindowComponent extends WindowComponent
public void apply() public void apply()
{ {
pool.addColor(colors[4].getRGB()); pool.addColor(colors[4]);
listener.accept(colors[4]); listener.accept(colors[4]);
getGui().removeComponent(this); getGui().removeComponent(this);
} }
@ -142,12 +141,12 @@ public class ColorPickerWindowComponent extends WindowComponent
hsv[0] = MathUtils.clamp(0F, 1F, hue); hsv[0] = MathUtils.clamp(0F, 1F, hue);
hsv[1] = MathUtils.clamp(0F, 1F, saturation); hsv[1] = MathUtils.clamp(0F, 1F, saturation);
hsv[2] = MathUtils.clamp(0F, 1F, brightness); hsv[2] = MathUtils.clamp(0F, 1F, brightness);
colors[0].setRGB(hsv[0], 0F, 1F, 255); colors[0] = ColorUtils.toRGB(hsv[0], 0F, 1F);
colors[1].setRGB(hsv[0], 1F, 1F, 255); colors[1] = ColorUtils.toRGB(hsv[0], 1F, 1F);
colors[2].setRGB(hsv[0], 1F, 0F, 255); colors[2] = ColorUtils.toRGB(hsv[0], 1F, 0F);
colors[3].setRGB(hsv[0], 1F, 1F, 255); colors[3] = ColorUtils.toRGB(hsv[0], 1F, 1F);
colors[4].setRGB(hsv[0], hsv[1], hsv[2], 255); colors[4] = ColorUtils.toRGB(hsv[0], hsv[1], hsv[2]);
code.setText(colors[4].getHTMLCode(false)); code.setText(ColorUtils.getHTMLCode(colors[4], false));
this.brightness.setValue((int)(hsv[2] * 100F)); this.brightness.setValue((int)(hsv[2] * 100F));
this.saturation.setValue((int)(hsv[1] * 100F)); this.saturation.setValue((int)(hsv[1] * 100F));
} }

View File

@ -3,7 +3,6 @@ package speiger.src.coreengine.rendering.gui.components.window.color;
import java.util.BitSet; import java.util.BitSet;
import speiger.src.coreengine.math.ArrayUtil; import speiger.src.coreengine.math.ArrayUtil;
import speiger.src.coreengine.math.misc.ColorObject;
public class ColorPool public class ColorPool
{ {
@ -12,7 +11,7 @@ public class ColorPool
public ColorPool(int size) public ColorPool(int size)
{ {
colors = ArrayUtil.fill(new int[size], ColorObject.WHITE.getRGB()); colors = ArrayUtil.fill(new int[size], -1);
locked = new BitSet(size); locked = new BitSet(size);
} }
@ -45,7 +44,7 @@ public class ColorPool
public void removeColor(int index) public void removeColor(int index)
{ {
colors[index] = ColorObject.WHITE.getRGB(); colors[index] = -1;
} }
public int getColor(int index) public int getColor(int index)
@ -91,7 +90,7 @@ public class ColorPool
public void clear() public void clear()
{ {
ArrayUtil.fill(colors, ColorObject.WHITE.getRGB()); ArrayUtil.fill(colors, -1);
locked.clear(); locked.clear();
} }

View File

@ -9,7 +9,7 @@ import org.lwjgl.glfw.GLFW;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.utils.ObjectLists; import speiger.src.collections.objects.utils.ObjectLists;
import speiger.src.coreengine.math.MathUtils; import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.vector.floats.Vec2f; import speiger.src.coreengine.math.vector.floats.Vec2f;
import speiger.src.coreengine.rendering.gui.GuiManager; import speiger.src.coreengine.rendering.gui.GuiManager;
import speiger.src.coreengine.rendering.gui.base.IKeyComponent; import speiger.src.coreengine.rendering.gui.base.IKeyComponent;
@ -61,11 +61,11 @@ public class PieProfilerWindowComponent extends WindowComponent
public void init() public void init()
{ {
super.init(); super.init();
addChild(pie.setAutoUpdate(true).setComponentPosition(0F, 5F).addChangeListener(minimizedListener), new ComponentConstrains(null, null, new ParentConstrain(), new DynamicConstrain(this::calculatePieHeight))); addChild(pie.setAutoUpdate(true).set(0F, 5F).addChangeListener(minimizedListener), new ComponentConstrains(null, null, new ParentConstrain(), new DynamicConstrain(this::calculatePieHeight)));
buttons[0] = createButton(0, "Client"); buttons[0] = createButton(0, "Client");
buttons[1] = createButton(1, "GPU"); buttons[1] = createButton(1, "GPU");
buttons[2] = createButton(2, "Server"); buttons[2] = createButton(2, "Server");
extraFeatures[0] = new TextComponent(0F, 0F, 18F, 5.5F).setTextScale(0.3F).setText("[0] Back").setAlignment(Align.LEFT_TOP, Align.CENTER); extraFeatures[0] = new TextComponent(0F, 0F, 18F, 5.5F).setTextScale(0.3F).setText("[0] Back").align(Align.LEFT_TOP, Align.CENTER);
extraFeatures[0].addChangeListener(T -> T.setVisible(!isMinimized() && currentEntry != null && currentEntry.getParent() != null)); extraFeatures[0].addChangeListener(T -> T.setVisible(!isMinimized() && currentEntry != null && currentEntry.getParent() != null));
addChild(extraFeatures[0], new ComponentConstrains(null, new DynamicConstrain(() -> pie.getBox().getBaseHeight() + (-5.5F)), new PixelConstrain(38).setInverted(), null)); addChild(extraFeatures[0], new ComponentConstrains(null, new DynamicConstrain(() -> pie.getBox().getBaseHeight() + (-5.5F)), new PixelConstrain(38).setInverted(), null));
@ -157,18 +157,18 @@ public class PieProfilerWindowComponent extends WindowComponent
{ {
ProfilerData data = lastValues.get(i); ProfilerData data = lastValues.get(i);
TextComponent[] info = entries.get(i); TextComponent[] info = entries.get(i);
ColorObject color = data.getColor(); int color = data.getColor();
info[0].setMassChanging(TextComponent.class).setTextColor(color).setText("[" + (i + 1) + "] " + data.getName()).finishMassChanging(); info[0].setMassChanging(TextComponent.class).textColor(color).setText("[" + (i + 1) + "] " + data.getName()).finishMassChanging();
info[1].setMassChanging(TextComponent.class).setTextColor(color).setText(PERCENT_FORMAT.format(data.getEffect()) + "%").finishMassChanging(); info[1].setMassChanging(TextComponent.class).textColor(color).setText(PERCENT_FORMAT.format(data.getEffect()) + "%").finishMassChanging();
info[2].setMassChanging(TextComponent.class).setTextColor(color).setText(PERCENT_FORMAT.format(data.getTotalEffect()) + "%").finishMassChanging(); info[2].setMassChanging(TextComponent.class).textColor(color).setText(PERCENT_FORMAT.format(data.getTotalEffect()) + "%").finishMassChanging();
} }
if(last != textInUse) if(last != textInUse)
{ {
resizeComponent(0F, (textInUse - last) * 5.5F); resize(0F, (textInUse - last) * 5.5F);
} }
else if(lastEmpty) else if(lastEmpty)
{ {
onComponentChanged(true); onChanged(true);
} }
return true; return true;
} }
@ -251,7 +251,7 @@ public class PieProfilerWindowComponent extends WindowComponent
} }
return entries; return entries;
} }
return ObjectLists.singleton(new PieIndex(pie.getMaxSteps(), ColorObject.LIGHT_BLUE)); return ObjectLists.singleton(new PieIndex(pie.getMaxSteps(), ColorUtils.LIGHT_BLUE));
} }
protected float calculatePieHeight() protected float calculatePieHeight()
@ -288,7 +288,7 @@ public class PieProfilerWindowComponent extends WindowComponent
{ {
final int index = entries.size(); final int index = entries.size();
String text = column == 0 ? "[" + (entries.size() + 1) + "] Unknown" : PERCENT_FORMAT.format(0D) + "%"; String text = column == 0 ? "[" + (entries.size() + 1) + "] Unknown" : PERCENT_FORMAT.format(0D) + "%";
TextComponent comp = new TextComponent(0F, 0F, 18F, 5.5F).setTextScale(0.3F).setText(text).setAlignment(column == 0 ? Align.LEFT_TOP : Align.RIGHT_BOTTOM, Align.CENTER); TextComponent comp = new TextComponent(0F, 0F, 18F, 5.5F).setTextScale(0.3F).setText(text).align(column == 0 ? Align.LEFT_TOP : Align.RIGHT_BOTTOM, Align.CENTER);
comp.addChangeListener(T -> T.setVisible(!isMinimized() && index < textInUse)); comp.addChangeListener(T -> T.setVisible(!isMinimized() && index < textInUse));
Constrain xPos = column == 0 ? null : (column == 1 ? new PixelConstrain(38F).setInverted() : new PixelConstrain(19F).setInverted()); Constrain xPos = column == 0 ? null : (column == 1 ? new PixelConstrain(38F).setInverted() : new PixelConstrain(19F).setInverted());
addChild(comp, new ComponentConstrains(xPos, new DynamicConstrain(() -> pie.getBox().getBaseHeight() + (index * 5.5F)), column == 0 ? new PixelConstrain(38).setInverted() : null, null)); addChild(comp, new ComponentConstrains(xPos, new DynamicConstrain(() -> pie.getBox().getBaseHeight() + (index * 5.5F)), column == 0 ? new PixelConstrain(38).setInverted() : null, null));
@ -297,7 +297,7 @@ public class PieProfilerWindowComponent extends WindowComponent
protected ButtonComponent createButton(int index, String name) protected ButtonComponent createButton(int index, String name)
{ {
ButtonComponent button = new ButtonComponent(name, ColorObject.GRAY); ButtonComponent button = new ButtonComponent(name, ColorUtils.GRAY);
button.getText().setTextScale(0.3F); button.getText().setTextScale(0.3F);
button.addChangeListener(minimizedListener).addUserActionListener(T -> setProfiler(getProfiler(index), getRoot(index))); button.addChangeListener(minimizedListener).addUserActionListener(T -> setProfiler(getProfiler(index), getRoot(index)));
addChild(button, new ComponentConstrains(new RelativeConstrain(index * 0.3333F), new PixelConstrain(8F).setInverted(), new RelativeConstrain(0.3333F), new PixelConstrain(7F))); addChild(button, new ComponentConstrains(new RelativeConstrain(index * 0.3333F), new PixelConstrain(8F).setInverted(), new RelativeConstrain(0.3333F), new PixelConstrain(7F)));

View File

@ -5,7 +5,7 @@ import java.util.function.ObjIntConsumer;
import speiger.src.collections.ints.queues.IntArrayFIFOQueue; import speiger.src.collections.ints.queues.IntArrayFIFOQueue;
import speiger.src.collections.ints.queues.IntPriorityQueue; import speiger.src.collections.ints.queues.IntPriorityQueue;
import speiger.src.collections.ints.utils.IntPriorityQueues; import speiger.src.collections.ints.utils.IntPriorityQueues;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.vector.floats.Vec2f; import speiger.src.coreengine.math.vector.floats.Vec2f;
import speiger.src.coreengine.rendering.gui.GuiManager; import speiger.src.coreengine.rendering.gui.GuiManager;
import speiger.src.coreengine.rendering.gui.components.ButtonComponent; import speiger.src.coreengine.rendering.gui.components.ButtonComponent;
@ -22,7 +22,7 @@ import speiger.src.coreengine.utils.profiler.IProfiler.IProfilerEntry;
public class TreeProfilerWindowComponent extends WindowComponent public class TreeProfilerWindowComponent extends WindowComponent
{ {
IntPriorityQueue todoList = IntPriorityQueues.synchronize(new IntArrayFIFOQueue()); IntPriorityQueue todoList = IntPriorityQueues.synchronize(new IntArrayFIFOQueue());
TreeComponent<ProfilerTreeEntry> tree = new TreeComponent<ProfilerTreeEntry>(ColorObject.GRAY, 9F).disableBackground(true).setSelectionMode(TreeComponent.SELECTION_MODE_INTERACT); TreeComponent<ProfilerTreeEntry> tree = new TreeComponent<ProfilerTreeEntry>(ColorUtils.GRAY, 9F).disableBackground(true).setSelectionMode(TreeComponent.SELECTION_MODE_INTERACT);
ButtonComponent[] buttons = new ButtonComponent[3]; ButtonComponent[] buttons = new ButtonComponent[3];
ObjIntConsumer<IProfiler> listener = (T, V) -> todoList.enqueue(V); ObjIntConsumer<IProfiler> listener = (T, V) -> todoList.enqueue(V);
IProfiler profiler; IProfiler profiler;
@ -169,7 +169,7 @@ public class TreeProfilerWindowComponent extends WindowComponent
protected ButtonComponent createButton(int index, String name) protected ButtonComponent createButton(int index, String name)
{ {
ButtonComponent button = new ButtonComponent(name, ColorObject.GRAY); ButtonComponent button = new ButtonComponent(name, ColorUtils.GRAY);
button.getText().setTextScale(0.3F); button.getText().setTextScale(0.3F);
button.addChangeListener(minimizedListener).addUserActionListener(T -> setProfiler(getProfiler(index), PieProfilerWindowComponent.getRoot(index))); button.addChangeListener(minimizedListener).addUserActionListener(T -> setProfiler(getProfiler(index), PieProfilerWindowComponent.getRoot(index)));
addChild(button, new ComponentConstrains(new RelativeConstrain(index * 0.3333F), new PixelConstrain(8F).setInverted(), new RelativeConstrain(0.3333F), new PixelConstrain(7F))); addChild(button, new ComponentConstrains(new RelativeConstrain(index * 0.3333F), new PixelConstrain(8F).setInverted(), new RelativeConstrain(0.3333F), new PixelConstrain(7F)));

View File

@ -1,7 +1,7 @@
package speiger.src.coreengine.rendering.gui.components.window.misc; package speiger.src.coreengine.rendering.gui.components.window.misc;
import speiger.src.collections.booleans.functions.BooleanConsumer; import speiger.src.collections.booleans.functions.BooleanConsumer;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.components.ButtonComponent; import speiger.src.coreengine.rendering.gui.components.ButtonComponent;
import speiger.src.coreengine.rendering.gui.components.TextComponent; import speiger.src.coreengine.rendering.gui.components.TextComponent;
import speiger.src.coreengine.rendering.gui.components.WindowComponent; import speiger.src.coreengine.rendering.gui.components.WindowComponent;
@ -13,9 +13,9 @@ import speiger.src.coreengine.rendering.gui.helper.constrains.TextConstrain;
public class ChoiceComponent extends WindowComponent public class ChoiceComponent extends WindowComponent
{ {
TextComponent message = new TextComponent().setLimitedHeight(false).setTextScale(0.5F); TextComponent message = new TextComponent().limitHeight(false).setTextScale(0.5F);
ButtonComponent yesButton = new ButtonComponent("Yes", ColorObject.GRAY); ButtonComponent yesButton = new ButtonComponent("Yes", ColorUtils.GRAY);
ButtonComponent noButton = new ButtonComponent("No", ColorObject.GRAY); ButtonComponent noButton = new ButtonComponent("No", ColorUtils.GRAY);
BooleanConsumer listener; BooleanConsumer listener;
public ChoiceComponent(float width, String windowTitle, String message, BooleanConsumer listener) public ChoiceComponent(float width, String windowTitle, String message, BooleanConsumer listener)

View File

@ -1,6 +1,6 @@
package speiger.src.coreengine.rendering.gui.components.window.misc; package speiger.src.coreengine.rendering.gui.components.window.misc;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.components.ButtonComponent; import speiger.src.coreengine.rendering.gui.components.ButtonComponent;
import speiger.src.coreengine.rendering.gui.components.TextComponent; import speiger.src.coreengine.rendering.gui.components.TextComponent;
import speiger.src.coreengine.rendering.gui.components.WindowComponent; import speiger.src.coreengine.rendering.gui.components.WindowComponent;
@ -11,8 +11,8 @@ import speiger.src.coreengine.rendering.gui.helper.constrains.TextConstrain;
public class MessageComponent extends WindowComponent public class MessageComponent extends WindowComponent
{ {
TextComponent message = new TextComponent().setLimitedHeight(false).setTextScale(0.5F); TextComponent message = new TextComponent().limitHeight(false).setTextScale(0.5F);
ButtonComponent resultButton = new ButtonComponent("", ColorObject.GRAY); ButtonComponent resultButton = new ButtonComponent("", ColorUtils.GRAY);
public MessageComponent(float width, String windowTitle, String confirmButton, String message) public MessageComponent(float width, String windowTitle, String confirmButton, String message)
{ {

View File

@ -1,6 +1,6 @@
package speiger.src.coreengine.rendering.gui.components.window.misc; package speiger.src.coreengine.rendering.gui.components.window.misc;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.components.ButtonComponent; import speiger.src.coreengine.rendering.gui.components.ButtonComponent;
import speiger.src.coreengine.rendering.gui.components.TextComponent; import speiger.src.coreengine.rendering.gui.components.TextComponent;
import speiger.src.coreengine.rendering.gui.components.TextFieldComponent; import speiger.src.coreengine.rendering.gui.components.TextFieldComponent;
@ -12,10 +12,10 @@ import speiger.src.coreengine.rendering.gui.helper.constrains.TextConstrain;
public class TextInputComponent extends WindowComponent public class TextInputComponent extends WindowComponent
{ {
TextComponent message = new TextComponent().setLimitedHeight(false).setTextScale(0.5F); TextComponent message = new TextComponent().limitHeight(false).setTextScale(0.5F);
TextFieldComponent input = new TextFieldComponent(ColorObject.GRAY).setCanLoseFocus(false).setInfiniteText(true).setMaxTextLength(Integer.MAX_VALUE).setFocused(true); TextFieldComponent input = new TextFieldComponent(ColorUtils.GRAY).setCanLoseFocus(false).setInfiniteText(true).setMaxTextLength(Integer.MAX_VALUE).setFocused(true);
ButtonComponent confirm = new ButtonComponent("Confirm", ColorObject.DARK_GREEN); ButtonComponent confirm = new ButtonComponent("Confirm", ColorUtils.DARK_GREEN);
ButtonComponent cancel = new ButtonComponent("Cancel", ColorObject.RED); ButtonComponent cancel = new ButtonComponent("Cancel", ColorUtils.RED);
public TextInputComponent(float width, String name, String message) public TextInputComponent(float width, String name, String message)
{ {

View File

@ -37,7 +37,7 @@ public class FontBuilder
public static ObjectObjectPair<BufferedImage, JsonObject> createBitmapFont(InputStream stream, float size) public static ObjectObjectPair<BufferedImage, JsonObject> createBitmapFont(InputStream stream, float size)
{ {
return createBitmapFont(stream, size, "ISO-8859-1"); return createBitmapFont(stream, size, "UTF-8");
} }
public static ObjectObjectPair<BufferedImage, JsonObject> createBitmapFont(InputStream stream, float size, String charset) public static ObjectObjectPair<BufferedImage, JsonObject> createBitmapFont(InputStream stream, float size, String charset)
@ -72,7 +72,7 @@ public class FontBuilder
Consumer<CharData> data = T -> { Consumer<CharData> data = T -> {
AssetLocation location = T.asLocation(); AssetLocation location = T.asLocation();
toDraw.put(location, T); toDraw.put(location, T);
if(T.width > 0 && !builder.add(location, T.width, T.getExtraY(T.height))) throw new IllegalStateException("Character: " + location + " isnt Accepted, W=" + T.width + ", H=" + T.height); if(T.width > 0 && !builder.add(location, T.width, T.getExtraY(T.height), 2)) throw new IllegalStateException("Character: " + location + " isnt Accepted, W=" + T.width + ", H=" + T.height);
}; };
Font font = Font.createFont(Font.TRUETYPE_FONT, ttf).deriveFont(size); Font font = Font.createFont(Font.TRUETYPE_FONT, ttf).deriveFont(size);

View File

@ -2,7 +2,6 @@ package speiger.src.coreengine.rendering.gui.helper;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.misc.Facing; import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer; import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer; import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer;
@ -11,13 +10,13 @@ import speiger.src.coreengine.rendering.tesselation.VertexType;
public class UIShapes public class UIShapes
{ {
public static void createCross(RenderBuffer buffer, float width, float height, float paddingA, float paddingB, ColorObject color) public static void createCross(RenderBuffer buffer, float width, float height, float paddingA, float paddingB, int color)
{ {
createCross(buffer.start(GL11.GL_TRIANGLES, VertexType.UI), width, height, paddingA, paddingB, color); createCross(buffer.start(GL11.GL_TRIANGLES, VertexType.UI), width, height, paddingA, paddingB, color);
buffer.finishShape(0); buffer.finishShape(0);
} }
public static void createCross(Tesselator tes, float width, float height, float paddingA, float paddingB, ColorObject color) public static void createCross(Tesselator tes, float width, float height, float paddingA, float paddingB, int color)
{ {
tes.setOffset(-(width * 0.5F), -(height * 0.5F), 0F); tes.setOffset(-(width * 0.5F), -(height * 0.5F), 0F);
tes.pos(paddingB, paddingA, 0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(paddingB, paddingA, 0F).tex(0F, 0F).color4f(color).endVertex();
@ -36,7 +35,7 @@ public class UIShapes
tes.setOffset(0F, 0F, 0F); tes.setOffset(0F, 0F, 0F);
} }
public static void createCross(UIRenderer renderer, float width, float height, float paddingA, float paddingB, ColorObject color) public static void createCross(UIRenderer renderer, float width, float height, float paddingA, float paddingB, int color)
{ {
renderer.translate(-(width * 0.5F), -(height * 0.5F)); renderer.translate(-(width * 0.5F), -(height * 0.5F));
renderer.startCustomShape(GL11.GL_TRIANGLES, false); renderer.startCustomShape(GL11.GL_TRIANGLES, false);
@ -56,13 +55,13 @@ public class UIShapes
renderer.translate((width * 0.5F), (height * 0.5F)); renderer.translate((width * 0.5F), (height * 0.5F));
} }
public static void createArrow(RenderBuffer buffer, float width, float height, ColorObject color, Facing dir) public static void createArrow(RenderBuffer buffer, float width, float height, int color, Facing dir)
{ {
createArrow(buffer.start(GL11.GL_TRIANGLES, VertexType.UI), width, height, color, dir); createArrow(buffer.start(GL11.GL_TRIANGLES, VertexType.UI), width, height, color, dir);
buffer.finishShape(0); buffer.finishShape(0);
} }
public static void createArrow(Tesselator tes, float width, float height, ColorObject color, Facing dir) public static void createArrow(Tesselator tes, float width, float height, int color, Facing dir)
{ {
float halfWidth = width * 0.5F; float halfWidth = width * 0.5F;
float halfHeight = height * 0.5F; float halfHeight = height * 0.5F;
@ -117,7 +116,7 @@ public class UIShapes
tes.setOffset(0F, 0F, 0F); tes.setOffset(0F, 0F, 0F);
} }
public static void createArrow(UIRenderer renderer, float width, float height, ColorObject color, Facing dir) public static void createArrow(UIRenderer renderer, float width, float height, int color, Facing dir)
{ {
float halfWidth = width * 0.5F; float halfWidth = width * 0.5F;
float halfHeight = height * 0.5F; float halfHeight = height * 0.5F;

View File

@ -77,7 +77,7 @@ public class Animator
applyValues(true); applyValues(true);
if(changed) if(changed)
{ {
owner.onComponentChanged(redraw); owner.onChanged(redraw);
} }
owner.finishMassChanging(); owner.finishMassChanging();
} }

View File

@ -9,7 +9,6 @@ import speiger.src.collections.floats.lists.FloatArrayList;
import speiger.src.collections.floats.lists.FloatList; import speiger.src.collections.floats.lists.FloatList;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.utils.ObjectLists; import speiger.src.collections.objects.utils.ObjectLists;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.rendering.gui.components.TextComponent; import speiger.src.coreengine.rendering.gui.components.TextComponent;
import speiger.src.coreengine.rendering.gui.helper.Align; import speiger.src.coreengine.rendering.gui.helper.Align;
import speiger.src.coreengine.rendering.gui.renderer.buffer.DelayedRenderBuffer; import speiger.src.coreengine.rendering.gui.renderer.buffer.DelayedRenderBuffer;
@ -52,15 +51,15 @@ public class FontRenderer implements IFontRenderer
} }
@Override @Override
public float getFontHeight() public float height()
{ {
return provider.getFontHeight(); return provider.height();
} }
@Override @Override
public float getBaseLine() public float baseLine()
{ {
return provider.getBaseLine(); return provider.baseLine();
} }
@Override @Override
@ -91,7 +90,7 @@ public class FontRenderer implements IFontRenderer
List<Line> lines = lexer.evaluateLines(text, context, Float.MAX_VALUE); List<Line> lines = lexer.evaluateLines(text, context, Float.MAX_VALUE);
if(lines.isEmpty()) return ObjectLists.empty(); if(lines.isEmpty()) return ObjectLists.empty();
WordContext effects = context.getEffect(); WordContext effects = context.getEffect();
ColorObject textColor = new ColorObject(effects.color); int textColor = effects.color;
float yOffset = 0F; float yOffset = 0F;
IVertexBuilder builder = new TranslatedVertexBuilder(bufferBuilder, x, y, z, 1F); IVertexBuilder builder = new TranslatedVertexBuilder(bufferBuilder, x, y, z, 1F);
bufferBuilder.begin(GL11.GL_TRIANGLES, VertexType.IN_WORLD_UI); bufferBuilder.begin(GL11.GL_TRIANGLES, VertexType.IN_WORLD_UI);
@ -102,7 +101,7 @@ public class FontRenderer implements IFontRenderer
{ {
xOffset += renderChar(letter, xOffset, yOffset, context.getScale(), effects.italic, effects.flipped, textColor, builder, true); xOffset += renderChar(letter, xOffset, yOffset, context.getScale(), effects.italic, effects.flipped, textColor, builder, true);
} }
yOffset += getFontHeight() * context.getScale(); yOffset += height() * context.getScale();
} }
bufferBuilder.finishData(); bufferBuilder.finishData();
if(bufferBuilder.getVertexCount() > 0) if(bufferBuilder.getVertexCount() > 0)
@ -131,8 +130,8 @@ public class FontRenderer implements IFontRenderer
return; return;
} }
bufferBuilder.begin(GL11.GL_TRIANGLES, VertexType.UI); bufferBuilder.begin(GL11.GL_TRIANGLES, VertexType.UI);
int maxLanes = component.isHeightLimited() ? Math.min((int)(boxHeight / (getFontHeight() * context.getScale())), lines.size()) : lines.size(); int maxLanes = component.isHeightLimited() ? Math.min((int)(boxHeight / (height() * context.getScale())), lines.size()) : lines.size();
float maxHeight = maxLanes * getFontHeight() * context.getScale(); float maxHeight = maxLanes * height() * context.getScale();
float maxWidth = 0F; float maxWidth = 0F;
float yOffset = component.getVertical().align(boxHeight, maxHeight); float yOffset = component.getVertical().align(boxHeight, maxHeight);
float startX = component.getHorizontal().align(boxWidth, lines.get(0).getWidth()); float startX = component.getHorizontal().align(boxWidth, lines.get(0).getWidth());
@ -142,7 +141,7 @@ public class FontRenderer implements IFontRenderer
{ {
effects = effects.next(); effects = effects.next();
} }
ColorObject textColor = new ColorObject(effects.color); int textColor = effects.color;
Float strikeThrough = effects.strike_through ? startX : null; Float strikeThrough = effects.strike_through ? startX : null;
Float underline = effects.underline ? startX : -1F; Float underline = effects.underline ? startX : -1F;
if(component.getBackgroundColor() != null) if(component.getBackgroundColor() != null)
@ -175,7 +174,7 @@ public class FontRenderer implements IFontRenderer
{ {
addUnderline(underline, xOffset - underline, yOffset, textColor, lineBuffer, false); addUnderline(underline, xOffset - underline, yOffset, textColor, lineBuffer, false);
} }
textColor.setRGB(next.color); textColor = next.color;
underline = newLine; underline = newLine;
effects = next; effects = next;
} }
@ -188,7 +187,7 @@ public class FontRenderer implements IFontRenderer
{ {
addUnderline(underline, xOffset - underline, yOffset, textColor, lineBuffer, false); addUnderline(underline, xOffset - underline, yOffset, textColor, lineBuffer, false);
} }
yOffset += getFontHeight() * context.getScale(); yOffset += height() * context.getScale();
component.getMetadata().addLine(lines.get(i)); component.getMetadata().addLine(lines.get(i));
} }
maxWidth /= 2; maxWidth /= 2;
@ -202,7 +201,7 @@ public class FontRenderer implements IFontRenderer
} }
} }
protected float renderChar(CharInstance instance, float x, float y, float scale, float italic, boolean flipped, ColorObject color, IVertexBuilder buffer, boolean flipPos) protected float renderChar(CharInstance instance, float x, float y, float scale, float italic, boolean flipped, int color, IVertexBuilder buffer, boolean flipPos)
{ {
switch(instance.getCharacter()) switch(instance.getCharacter())
{ {
@ -231,13 +230,13 @@ public class FontRenderer implements IFontRenderer
return instance.getXAdvance() * scale; return instance.getXAdvance() * scale;
} }
protected void addBackground(IVertexBuilder tes, List<Line> lines, int maxLines, float yPos, Align align, float width, ColorObject color, boolean flipPos) protected void addBackground(IVertexBuilder tes, List<Line> lines, int maxLines, float yPos, Align align, float width, int color, boolean flipPos)
{ {
for(int i = 0;i < maxLines;i++) for(int i = 0;i < maxLines;i++)
{ {
float lineWidth = lines.get(i).getWidth(); float lineWidth = lines.get(i).getWidth();
float xOffset = align.align(width, lineWidth); float xOffset = align.align(width, lineWidth);
float maxY = flipPos ? yPos - getFontHeight() : yPos + getFontHeight(); float maxY = flipPos ? yPos - height() : yPos + height();
tes.pos(xOffset, maxY, 0.0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(xOffset, maxY, 0.0F).tex(0F, 0F).color4f(color).endVertex();
tes.pos(xOffset, yPos, 0.0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(xOffset, yPos, 0.0F).tex(0F, 0F).color4f(color).endVertex();
tes.pos(xOffset + lineWidth, maxY, 0.0F).tex(0F, 0F).color4f(color).endVertex(); tes.pos(xOffset + lineWidth, maxY, 0.0F).tex(0F, 0F).color4f(color).endVertex();
@ -248,14 +247,14 @@ public class FontRenderer implements IFontRenderer
} }
} }
protected void addUnderline(float xStart, float width, float yStart, ColorObject color, IVertexBuilder buffer, boolean flipPos) protected void addUnderline(float xStart, float width, float yStart, int color, IVertexBuilder buffer, boolean flipPos)
{ {
float minY = yStart + getBaseLine() + 0.5F; float minY = yStart + baseLine() + 0.5F;
float maxY = yStart + getBaseLine() + 1.5F; float maxY = yStart + baseLine() + 1.5F;
if(flipPos) if(flipPos)
{ {
minY = yStart - getBaseLine() - 0.5F; minY = yStart - baseLine() - 0.5F;
maxY = yStart - getBaseLine() - 1.5F; maxY = yStart - baseLine() - 1.5F;
} }
buffer.pos(xStart, maxY, 0F).tex(0F, 0F).color4f(color).endVertex(); buffer.pos(xStart, maxY, 0F).tex(0F, 0F).color4f(color).endVertex();
buffer.pos(xStart, minY, 0F).tex(0F, 0F).color4f(color).endVertex(); buffer.pos(xStart, minY, 0F).tex(0F, 0F).color4f(color).endVertex();
@ -265,10 +264,10 @@ public class FontRenderer implements IFontRenderer
buffer.pos(xStart + width, minY, 0F).tex(0F, 0F).color4f(color).endVertex(); buffer.pos(xStart + width, minY, 0F).tex(0F, 0F).color4f(color).endVertex();
} }
protected void addStrikeThrough(float xStart, float width, float yStart, ColorObject color, IVertexBuilder buffer) protected void addStrikeThrough(float xStart, float width, float yStart, int color, IVertexBuilder buffer)
{ {
float minY = yStart + getFontHeight() / 2.0F; float minY = yStart + height() / 2.0F;
float maxY = yStart + getFontHeight() / 2.0F + 1.4F; float maxY = yStart + height() / 2.0F + 1.4F;
buffer.pos(xStart, maxY, 0.0F).tex(0F, 0F).color4f(color).endVertex(); buffer.pos(xStart, maxY, 0.0F).tex(0F, 0F).color4f(color).endVertex();
buffer.pos(xStart, minY, 0.0F).tex(0F, 0F).color4f(color).endVertex(); buffer.pos(xStart, minY, 0.0F).tex(0F, 0F).color4f(color).endVertex();
buffer.pos(xStart + width, maxY, 0.0F).tex(0F, 0F).color4f(color).endVertex(); buffer.pos(xStart + width, maxY, 0.0F).tex(0F, 0F).color4f(color).endVertex();
@ -284,7 +283,7 @@ public class FontRenderer implements IFontRenderer
} }
@Override @Override
public String trimStringToWidth(String text, float limit, boolean reverse) public String trimToWidth(String text, float limit, boolean reverse)
{ {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
float width = 0F; float width = 0F;
@ -293,7 +292,7 @@ public class FontRenderer implements IFontRenderer
for(int i = start;i >= 0 && i < text.length() && width < limit;i += direction) for(int i = start;i >= 0 && i < text.length() && width < limit;i += direction)
{ {
char letter = text.charAt(i); char letter = text.charAt(i);
width += getCharLength(letter); width += width(letter);
if(width > limit) break; if(width > limit) break;
if(reverse) builder.insert(0, letter); if(reverse) builder.insert(0, letter);
else builder.append(letter); else builder.append(letter);
@ -302,7 +301,7 @@ public class FontRenderer implements IFontRenderer
} }
@Override @Override
public float getCharLength(int codepoint, boolean bold) public float width(int codepoint, boolean bold)
{ {
switch(codepoint) switch(codepoint)
{ {
@ -317,7 +316,7 @@ public class FontRenderer implements IFontRenderer
} }
@Override @Override
public float getTextLength(String text, int flags) public float width(String text, int flags)
{ {
float result = 0.0F; float result = 0.0F;
float current = 0.0F; float current = 0.0F;
@ -344,13 +343,13 @@ public class FontRenderer implements IFontRenderer
continue; continue;
} }
} }
current += getCharLength(character, bold); current += width(character, bold);
} }
return Math.max(result, current); return Math.max(result, current);
} }
@Override @Override
public float[] getTextLengths(String text, int flags) public float[] widths(String text, int flags)
{ {
FloatList results = new FloatArrayList(); FloatList results = new FloatArrayList();
results.add(0F); results.add(0F);
@ -383,7 +382,7 @@ public class FontRenderer implements IFontRenderer
continue; continue;
} }
} }
current += getCharLength(character, bold); current += width(character, bold);
} }
if(chars++ > 0) if(chars++ > 0)
{ {
@ -395,9 +394,9 @@ public class FontRenderer implements IFontRenderer
} }
@Override @Override
public float getTextHeight(String text, int flags) public float height(String text, int flags)
{ {
return getTextLengths(text, flags).length - 1 * getFontHeight(); return widths(text, flags).length - 1 * height();
} }
@Override @Override
@ -407,7 +406,7 @@ public class FontRenderer implements IFontRenderer
} }
@Override @Override
public String[] splitLines(String text, float maxWidth, int flags) public String[] split(String text, float maxWidth, int flags)
{ {
TextContext context = new TextContext(1F, ((flags & IFontRenderer.SPECIAL) != 0 ? 16 : 0) | ((flags & IFontRenderer.BOLD) != 0 ? 1 : 0)); TextContext context = new TextContext(1F, ((flags & IFontRenderer.SPECIAL) != 0 ? 16 : 0) | ((flags & IFontRenderer.BOLD) != 0 ? 1 : 0));
List<Line> lines = lexer.evaluateLines(text, context, maxWidth); List<Line> lines = lexer.evaluateLines(text, context, maxWidth);

View File

@ -8,27 +8,27 @@ public interface IFontRenderer
public static final int BOLD = 1; public static final int BOLD = 1;
public static final int SPECIAL = 2; public static final int SPECIAL = 2;
public float getFontHeight(); public float height();
public float getBaseLine(); public float baseLine();
public ITexture getTexture(); public ITexture getTexture();
public CharInstance getInstance(int codepoint, boolean bold); public CharInstance getInstance(int codepoint, boolean bold);
public void updateText(TextComponent component); public void updateText(TextComponent component);
public default String trimStringToWidth(String text, float limit){return trimStringToWidth(text, limit, false);} public default String trimToWidth(String text, float limit){return trimToWidth(text, limit, false);}
public String trimStringToWidth(String text, float limit, boolean reverse); public String trimToWidth(String text, float limit, boolean reverse);
public default float getCharLength(int codepoint){return getCharLength(codepoint, false);}; public default float width(int codepoint){return width(codepoint, false);};
public float getCharLength(int codepoint, boolean bold); public float width(int codepoint, boolean bold);
public default float getTextLength(String text){return getTextLength(text, 0);}; public default float width(String text){return width(text, 0);};
public float getTextLength(String text, int flags); public float width(String text, int flags);
public float[] getTextLengths(String text, int flags); public float[] widths(String text, int flags);
public default float getTextHeight(String text){return getTextHeight(text, 0);}; public default float height(String text){return height(text, 0);};
public float getTextHeight(String text, int flags); public float height(String text, int flags);
public String[] splitLines(String text, float maxWidth, int flags); public String[] split(String text, float maxWidth, int flags);
public boolean isCharValid(int codepoint); public boolean isCharValid(int codepoint);
public default String clearInvalidLetters(String text) public default String clearInvalidLetters(String text)

View File

@ -12,7 +12,6 @@ import speiger.src.collections.objects.queues.ObjectArrayFIFOQueue;
import speiger.src.collections.objects.queues.ObjectPriorityDequeue; import speiger.src.collections.objects.queues.ObjectPriorityDequeue;
import speiger.src.collections.utils.Stack; import speiger.src.collections.utils.Stack;
import speiger.src.coreengine.assets.reloader.IReloadableResource; import speiger.src.coreengine.assets.reloader.IReloadableResource;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.misc.Facing; import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.math.vector.floats.Vec2f; import speiger.src.coreengine.math.vector.floats.Vec2f;
import speiger.src.coreengine.math.vector.floats.Vec3f; import speiger.src.coreengine.math.vector.floats.Vec3f;
@ -347,6 +346,7 @@ public class UIRenderer implements IReloadableResource
last = call.getCount(); last = call.getCount();
callPool.accept(call); callPool.accept(call);
} }
activeCalls.clear();
texturedModel.unbindArray(); texturedModel.unbindArray();
shader.stopShader(); shader.stopShader();
renderer.resetVertexes(); renderer.resetVertexes();
@ -414,22 +414,22 @@ public class UIRenderer implements IReloadableResource
return this; return this;
} }
public UIRenderer drawQuad(IGuiBox box, ColorObject color) public UIRenderer drawQuad(IGuiBox box, int color)
{ {
return drawQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), color); return drawQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), color);
} }
public UIRenderer drawQuad(IGuiBox box, float zLevel, ColorObject color) public UIRenderer drawQuad(IGuiBox box, float zLevel, int color)
{ {
return drawQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), zLevel, color); return drawQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), zLevel, color);
} }
public UIRenderer drawQuad(float minX, float minY, float maxX, float maxY, ColorObject color) public UIRenderer drawQuad(float minX, float minY, float maxX, float maxY, int color)
{ {
return drawQuad(minX, minY, maxX, maxY, 0.0F, color); return drawQuad(minX, minY, maxX, maxY, 0.0F, color);
} }
public UIRenderer drawQuad(float minX, float minY, float maxX, float maxY, float zLevel, ColorObject color) public UIRenderer drawQuad(float minX, float minY, float maxX, float maxY, float zLevel, int color)
{ {
ensureDrawing(GL11.GL_TRIANGLES, false); ensureDrawing(GL11.GL_TRIANGLES, false);
applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper); applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper);
@ -443,22 +443,22 @@ public class UIRenderer implements IReloadableResource
return this; return this;
} }
public UIRenderer drawTexturedQuad(IGuiBox box, ColorObject color, float minU, float minV, float maxU, float maxV) public UIRenderer drawTexturedQuad(IGuiBox box, int color, float minU, float minV, float maxU, float maxV)
{ {
return drawTexturedQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), color, minU, minV, maxU, maxV); return drawTexturedQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), color, minU, minV, maxU, maxV);
} }
public UIRenderer drawTexturedQuad(IGuiBox box, float zLevel, ColorObject color, float minU, float minV, float maxU, float maxV) public UIRenderer drawTexturedQuad(IGuiBox box, float zLevel, int color, float minU, float minV, float maxU, float maxV)
{ {
return drawTexturedQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), zLevel, color, minU, minV, maxU, maxV); return drawTexturedQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), zLevel, color, minU, minV, maxU, maxV);
} }
public UIRenderer drawTexturedQuad(float minX, float minY, float maxX, float maxY, ColorObject color, float minU, float minV, float maxU, float maxV) public UIRenderer drawTexturedQuad(float minX, float minY, float maxX, float maxY, int color, float minU, float minV, float maxU, float maxV)
{ {
return drawTexturedQuad(minX, minY, maxX, maxY, 0F, color, minU, minV, maxU, maxV); return drawTexturedQuad(minX, minY, maxX, maxY, 0F, color, minU, minV, maxU, maxV);
} }
public UIRenderer drawTexturedQuad(float minX, float minY, float maxX, float maxY, float zLevel, ColorObject color, float minU, float minV, float maxU, float maxV) public UIRenderer drawTexturedQuad(float minX, float minY, float maxX, float maxY, float zLevel, int color, float minU, float minV, float maxU, float maxV)
{ {
ensureDrawing(GL11.GL_TRIANGLES, true); ensureDrawing(GL11.GL_TRIANGLES, true);
applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper); applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper);
@ -472,21 +472,21 @@ public class UIRenderer implements IReloadableResource
return this; return this;
} }
public UIRenderer drawGradientQuad(IGuiBox box, ColorObject from, ColorObject to, Facing direction) public UIRenderer drawGradientQuad(IGuiBox box, int from, int to, Facing direction)
{ {
return drawGradientQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), from, to, direction); return drawGradientQuad(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), from, to, direction);
} }
public UIRenderer drawGradientQuad(float minX, float minY, float maxX, float maxY, ColorObject from, ColorObject to, Facing direction) public UIRenderer drawGradientQuad(float minX, float minY, float maxX, float maxY, int from, int to, Facing direction)
{ {
return drawGradientQuad(minX, minY, maxX, maxY, 0F, from, to, direction); return drawGradientQuad(minX, minY, maxX, maxY, 0F, from, to, direction);
} }
public UIRenderer drawGradientQuad(float minX, float minY, float maxX, float maxY, float zLevel, ColorObject start, ColorObject end, Facing direction) public UIRenderer drawGradientQuad(float minX, float minY, float maxX, float maxY, float zLevel, int start, int end, Facing direction)
{ {
if(!direction.isPositive()) if(!direction.isPositive())
{ {
ColorObject wrapper = start; int wrapper = start;
start = end; start = end;
end = wrapper; end = wrapper;
} }
@ -502,22 +502,22 @@ public class UIRenderer implements IReloadableResource
return this; return this;
} }
public UIRenderer drawFrame(IGuiBox box, ColorObject color) public UIRenderer drawFrame(IGuiBox box, int color)
{ {
return drawFrame(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), color); return drawFrame(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), color);
} }
public UIRenderer drawFrame(IGuiBox box, float zLevel, ColorObject color) public UIRenderer drawFrame(IGuiBox box, float zLevel, int color)
{ {
return drawFrame(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), zLevel, color); return drawFrame(box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), zLevel, color);
} }
public UIRenderer drawFrame(float minX, float minY, float maxX, float maxY, ColorObject color) public UIRenderer drawFrame(float minX, float minY, float maxX, float maxY, int color)
{ {
return drawFrame(minX, minY, maxX, maxY, 0F, color); return drawFrame(minX, minY, maxX, maxY, 0F, color);
} }
public UIRenderer drawFrame(float minX, float minY, float maxX, float maxY, float zLevel, ColorObject color) public UIRenderer drawFrame(float minX, float minY, float maxX, float maxY, float zLevel, int color)
{ {
ensureDrawing(GL11.GL_LINES, false); ensureDrawing(GL11.GL_LINES, false);
applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper); applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper);
@ -533,12 +533,12 @@ public class UIRenderer implements IReloadableResource
return this; return this;
} }
public UIRenderer drawLine(float minX, float minY, float maxX, float maxY, ColorObject color) public UIRenderer drawLine(float minX, float minY, float maxX, float maxY, int color)
{ {
return drawLine(minX, minY, maxX, maxY, 0F, color); return drawLine(minX, minY, maxX, maxY, 0F, color);
} }
public UIRenderer drawLine(float minX, float minY, float maxX, float maxY, float zLevel, ColorObject color) public UIRenderer drawLine(float minX, float minY, float maxX, float maxY, float zLevel, int color)
{ {
ensureDrawing(GL11.GL_LINES, false); ensureDrawing(GL11.GL_LINES, false);
applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper); applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper);
@ -578,7 +578,7 @@ public class UIRenderer implements IReloadableResource
return this; return this;
} }
public UIRenderer color(ColorObject color) public UIRenderer color(int color)
{ {
renderer.color4f(color); renderer.color4f(color);
return this; return this;

View File

@ -1,12 +1,11 @@
package speiger.src.coreengine.rendering.gui.renderer.lexer; package speiger.src.coreengine.rendering.gui.renderer.lexer;
import java.awt.Color;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.StringJoiner; import java.util.StringJoiner;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.lists.ObjectList; import speiger.src.collections.objects.lists.ObjectList;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.rendering.gui.components.TextComponent; import speiger.src.coreengine.rendering.gui.components.TextComponent;
import speiger.src.coreengine.utils.helpers.TextUtil; import speiger.src.coreengine.utils.helpers.TextUtil;
@ -20,13 +19,13 @@ public class TextContext
static final int SINGLE = 32; static final int SINGLE = 32;
final int originalFlags; final int originalFlags;
final Color originalColor; final int originalColor;
final float originalItalic; final float originalItalic;
final float scale; final float scale;
int flags = 0; int flags = 0;
float italic = 0F; float italic = 0F;
ColorObject color = ColorObject.WHITE.copy(); int color = ColorUtils.WHITE;
ObjectList<WordContext> changes = new ObjectArrayList<WordContext>(); ObjectList<WordContext> changes = new ObjectArrayList<WordContext>();
public TextContext(float scale) public TextContext(float scale)
@ -38,27 +37,27 @@ public class TextContext
{ {
this.scale = scale; this.scale = scale;
originalFlags = this.flags = flags; originalFlags = this.flags = flags;
originalColor = Color.WHITE; originalColor = ColorUtils.WHITE;
originalItalic = 0F; originalItalic = 0F;
changes.add(new WordContext(0, flags, italic, color.hashCode())); changes.add(new WordContext(0, flags, italic, color));
} }
public TextContext(TextComponent component) public TextContext(TextComponent component)
{ {
scale = component.getTextScale(); scale = component.getTextScale();
originalFlags = createFlags(component); originalFlags = createFlags(component);
originalColor = component.getTextColor().toColor(); originalColor = component.getTextColor();
originalItalic = component.getItalic(); originalItalic = component.getItalic();
flags = originalFlags; flags = originalFlags;
color.setRGB(originalColor.getRGB()); color = originalColor;
italic = originalItalic; italic = originalItalic;
changes.add(new WordContext(0, flags, italic, color.hashCode())); changes.add(new WordContext(0, flags, italic, color));
} }
public void reset() public void reset()
{ {
flags = originalFlags; flags = originalFlags;
color.setRGB(originalColor.getRGB()); color = originalColor;
italic = originalItalic; italic = originalItalic;
} }
@ -95,10 +94,10 @@ public class TextContext
setFlag(FLIPPED, TextUtil.findFlag(entry, "flip", (flags & FLIPPED) != 0)); setFlag(FLIPPED, TextUtil.findFlag(entry, "flip", (flags & FLIPPED) != 0));
setFlag(UNDERLINE, TextUtil.findFlag(entry, "underline", (flags & UNDERLINE) != 0)); setFlag(UNDERLINE, TextUtil.findFlag(entry, "underline", (flags & UNDERLINE) != 0));
setFlag(STRIKE_THROUGH, TextUtil.findFlag(entry, "strike", (flags & STRIKE_THROUGH) != 0)); setFlag(STRIKE_THROUGH, TextUtil.findFlag(entry, "strike", (flags & STRIKE_THROUGH) != 0));
color = TextUtil.findColor(entry, "color", color, new ColorObject(originalColor.getRGB())); color = TextUtil.findColor(entry, "color", color, originalColor);
italic = TextUtil.findFloat(entry, "italic", italic, italic > 0.0F ? 0.0F : 3.0F); italic = TextUtil.findFloat(entry, "italic", italic, italic > 0.0F ? 0.0F : 3.0F);
} }
WordContext context = new WordContext(index, flags, italic, color.hashCode()); WordContext context = new WordContext(index, flags, italic, color);
changes.get(changes.size() - 1).setNext(context); changes.get(changes.size() - 1).setNext(context);
changes.add(context); changes.add(context);
} }
@ -171,7 +170,7 @@ public class TextContext
if(flipped) joiner.add("flipped=true"); if(flipped) joiner.add("flipped=true");
if(underline) joiner.add("underline=true"); if(underline) joiner.add("underline=true");
if(strike_through) joiner.add("strike=true"); if(strike_through) joiner.add("strike=true");
if(color != -1) joiner.add("color="+ColorObject.rgb(color).getHexCode(true)); if(color != -1) joiner.add("color="+ColorUtils.getHexCode(color, true));
if(italic > 0F) joiner.add("italic="+ITALIC_FORMAT.format(italic)); if(italic > 0F) joiner.add("italic="+ITALIC_FORMAT.format(italic));
return joiner.toString(); return joiner.toString();
} }
@ -184,7 +183,7 @@ public class TextContext
if(flipped != prev.flipped) joiner.add("flipped="+flipped); if(flipped != prev.flipped) joiner.add("flipped="+flipped);
if(underline != prev.underline) joiner.add("underline="+underline); if(underline != prev.underline) joiner.add("underline="+underline);
if(strike_through != prev.strike_through) joiner.add("strike="+strike_through); if(strike_through != prev.strike_through) joiner.add("strike="+strike_through);
if(color != prev.color) joiner.add("color="+ColorObject.rgb(color).getHexCode(true)); if(color != prev.color) joiner.add("color="+ColorUtils.getHexCode(color, true));
if(Float.compare(italic, prev.italic) != 0) joiner.add("italic="+ITALIC_FORMAT.format(italic)); if(Float.compare(italic, prev.italic) != 0) joiner.add("italic="+ITALIC_FORMAT.format(italic));
return joiner.toString(); return joiner.toString();
} }

View File

@ -36,7 +36,7 @@ public class TextMetadata
{ {
lines.add(line); lines.add(line);
maxWidth = Math.max(maxWidth, line.getWidth()); maxWidth = Math.max(maxWidth, line.getWidth());
maxHeight = lines.size() * owner.getFont().getFontHeight() * scale; maxHeight = lines.size() * owner.getFont().height() * scale;
} }
public void setStart(float x, float y) public void setStart(float x, float y)
@ -117,7 +117,7 @@ public class TextMetadata
public int getIndex(float width, float height) public int getIndex(float width, float height)
{ {
return lines.isEmpty() ? 0 : lines.get(MathUtils.clamp(0, lines.size() - 1, (int)(height / (owner.getFont().getFontHeight() * scale)))).getIndex(width, true); return lines.isEmpty() ? 0 : lines.get(MathUtils.clamp(0, lines.size() - 1, (int)(height / (owner.getFont().height() * scale)))).getIndex(width, true);
} }
public void getIndex(float width, float height, Vec2i result) public void getIndex(float width, float height, Vec2i result)
@ -127,7 +127,7 @@ public class TextMetadata
result.negate(); result.negate();
return; return;
} }
int index = MathUtils.clamp(0, lines.size() - 1, (int)(height / (owner.getFont().getFontHeight() * scale))); int index = MathUtils.clamp(0, lines.size() - 1, (int)(height / (owner.getFont().height() * scale)));
result.set(lines.get(index).getIndex(width, false), index); result.set(lines.get(index).getIndex(width, false), index);
} }

View File

@ -66,13 +66,13 @@ public class BitmapFontProvider implements IFontProvider
} }
@Override @Override
public float getFontHeight() public float height()
{ {
return info.fontHeight; return info.fontHeight;
} }
@Override @Override
public float getBaseLine() public float baseLine()
{ {
return info.fontBase; return info.fontBase;
} }

View File

@ -11,8 +11,8 @@ public interface IFontProvider
public ITexture getTexture(); public ITexture getTexture();
public boolean isCharacterValid(int codePoint); public boolean isCharacterValid(int codePoint);
public CharInstance getCharacter(int codePoint, boolean bold); public CharInstance getCharacter(int codePoint, boolean bold);
public float getFontHeight(); public float height();
public float getBaseLine(); public float baseLine();
public float getSpaceWidth(); public float getSpaceWidth();
public float getTabWidth(); public float getTabWidth();

View File

@ -12,7 +12,7 @@ import speiger.src.collections.objects.utils.ObjectLists;
import speiger.src.coreengine.assets.AssetLocation; import speiger.src.coreengine.assets.AssetLocation;
import speiger.src.coreengine.assets.AssetManager; import speiger.src.coreengine.assets.AssetManager;
import speiger.src.coreengine.assets.IAsset; import speiger.src.coreengine.assets.IAsset;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.utils.collections.iterators.IterableWrapper; import speiger.src.coreengine.utils.collections.iterators.IterableWrapper;
import speiger.src.coreengine.utils.helpers.JsonUtil; import speiger.src.coreengine.utils.helpers.JsonUtil;
@ -76,7 +76,7 @@ public class ModelLoader
String[] position = data[0].split(";"); String[] position = data[0].split(";");
String[] normal = data[2].split(";"); String[] normal = data[2].split(";");
buffer.putFloat(Float.parseFloat(position[0])).putFloat(Float.parseFloat(position[1])).putFloat(Float.parseFloat(position[2])); buffer.putFloat(Float.parseFloat(position[0])).putFloat(Float.parseFloat(position[1])).putFloat(Float.parseFloat(position[2]));
ColorObject.pack(Integer.parseInt(data[1]), true, buffer); ColorUtils.write(Integer.parseInt(data[1]), true, buffer);
buffer.putFloat(Float.parseFloat(normal[0])).putFloat(Float.parseFloat(normal[1])).putFloat(Float.parseFloat(normal[2])); buffer.putFloat(Float.parseFloat(normal[0])).putFloat(Float.parseFloat(normal[1])).putFloat(Float.parseFloat(normal[2]));
} }
else if(line.startsWith("[")) else if(line.startsWith("["))

View File

@ -54,7 +54,7 @@ public class VertexLoader
public static Object2ObjectMap<String, List<Number>> parseMappedVertexData(JsonObject obj, List<VertexEntry> entries, boolean excludeOptional) public static Object2ObjectMap<String, List<Number>> parseMappedVertexData(JsonObject obj, List<VertexEntry> entries, boolean excludeOptional)
{ {
Object2ObjectMap<String, List<Number>> mappedData = Object2ObjectMap.createLinkedMap(); Object2ObjectMap<String, List<Number>> mappedData = Object2ObjectMap.builder().linkedMap();
int stride = VertexEntry.caclulateStride(entries); int stride = VertexEntry.caclulateStride(entries);
int[] vertexes = JsonUtil.parseIntArray(obj.getAsJsonArray("vertexes")); int[] vertexes = JsonUtil.parseIntArray(obj.getAsJsonArray("vertexes"));
for(int i = 0,offset=0,m=entries.size();i<m;i++) for(int i = 0,offset=0,m=entries.size();i<m;i++)

View File

@ -2,7 +2,7 @@ package speiger.src.coreengine.rendering.shader.uniforms;
import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL20;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.vector.floats.Vec3f; import speiger.src.coreengine.math.vector.floats.Vec3f;
import speiger.src.coreengine.rendering.utils.AllocationTracker; import speiger.src.coreengine.rendering.utils.AllocationTracker;
@ -24,9 +24,9 @@ public class UniformVec3f extends UniformBase<Vec3f>
} }
} }
public void storeData(ColorObject color) public void storeData(int color)
{ {
storeData(STORAGE.set(color.getRedFloat(), color.getGreenFloat(), color.getBlueFloat())); storeData(STORAGE.set(ColorUtils.getRF(color), ColorUtils.getGF(color), ColorUtils.getBF(color)));
} }
public void storeData(float x, float y, float z) public void storeData(float x, float y, float z)

View File

@ -2,7 +2,7 @@ package speiger.src.coreengine.rendering.shader.uniforms;
import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL20;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.vector.floats.Vec4f; import speiger.src.coreengine.math.vector.floats.Vec4f;
import speiger.src.coreengine.rendering.utils.AllocationTracker; import speiger.src.coreengine.rendering.utils.AllocationTracker;
@ -24,10 +24,9 @@ public class UniformVec4f extends UniformBase<Vec4f>
} }
} }
public void storeData(ColorObject color) public void storeData(int color)
{ {
STORAGE.set(color.getRedFloat(), color.getGreenFloat(), color.getBlueFloat(), color.getAlphaFloat()); storeData(STORAGE.set(ColorUtils.getRF(color), ColorUtils.getGF(color), ColorUtils.getBF(color), ColorUtils.getAF(color)));
storeData(STORAGE);
} }
public void storeData(float x, float y, float z, float w) public void storeData(float x, float y, float z, float w)

View File

@ -1,6 +1,6 @@
package speiger.src.coreengine.rendering.tesselation; package speiger.src.coreengine.rendering.tesselation;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.vector.floats.Vec2f; import speiger.src.coreengine.math.vector.floats.Vec2f;
import speiger.src.coreengine.math.vector.floats.Vec3f; import speiger.src.coreengine.math.vector.floats.Vec3f;
import speiger.src.coreengine.math.vector.floats.Vec4f; import speiger.src.coreengine.math.vector.floats.Vec4f;
@ -13,10 +13,10 @@ public interface IVertexBuilder
public default IVertexBuilder pos(Vec3f vec) { return pos(vec.getX(), vec.getY(), vec.getZ()); } public default IVertexBuilder pos(Vec3f vec) { return pos(vec.getX(), vec.getY(), vec.getZ()); }
public IVertexBuilder pos(float x, float y, float z); public IVertexBuilder pos(float x, float y, float z);
public default IVertexBuilder color3f(ColorObject color) { return color3f(color.getRedFloat(), color.getGreenFloat(), color.getBlueFloat()); } public default IVertexBuilder color3f(int color) { return color3f(ColorUtils.getRF(color), ColorUtils.getGF(color), ColorUtils.getBF(color)); }
public IVertexBuilder color3f(float r, float g, float b); public IVertexBuilder color3f(float r, float g, float b);
public default IVertexBuilder color4f(ColorObject color){ return color4f(color.getRedFloat(), color.getGreenFloat(), color.getBlueFloat(), color.getAlphaFloat()); } public default IVertexBuilder color4f(int color){ return color4f(ColorUtils.getRF(color), ColorUtils.getGF(color), ColorUtils.getBF(color), ColorUtils.getAF(color)); }
public default IVertexBuilder color4f(float r, float g, float b) { return color4f(r, g, b, 1F); } public default IVertexBuilder color4f(float r, float g, float b) { return color4f(r, g, b, 1F); }
public IVertexBuilder color4f(float r, float g, float b, float a); public IVertexBuilder color4f(float r, float g, float b, float a);

View File

@ -20,7 +20,7 @@ public class DynamicDataManager<T>
{ {
static final ThreadPool<DataSlot> SLOTS = new ThreadPool<>(1000, DataSlot::new, DataSlot::clear); static final ThreadPool<DataSlot> SLOTS = new ThreadPool<>(1000, DataSlot::new, DataSlot::clear);
final IDynamicDataHandler<T> manager; final IDynamicDataHandler<T> manager;
Int2ObjectMap<DataSlot> slots = Int2ObjectMap.createLinkedMap(); Int2ObjectMap<DataSlot> slots = Int2ObjectMap.builder().linkedMap();
Set<DataSlot> emptySlots = new ObjectAVLTreeSet<>(); Set<DataSlot> emptySlots = new ObjectAVLTreeSet<>();
IntSet changedSlots = new IntAVLTreeSet(); IntSet changedSlots = new IntAVLTreeSet();
DataSlot lastSlot = null; DataSlot lastSlot = null;

View File

@ -3,7 +3,7 @@ package speiger.src.coreengine.utils.helpers;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Locale; import java.util.Locale;
import speiger.src.coreengine.math.misc.ColorObject; import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.utils.io.GameLog; import speiger.src.coreengine.utils.io.GameLog;
import speiger.src.coreengine.utils.io.GameLog.LogLevel; import speiger.src.coreengine.utils.io.GameLog.LogLevel;
@ -19,10 +19,10 @@ public class TextUtil
return "§<color"+(color == null ? "" : "="+color.intValue())+">"; return "§<color"+(color == null ? "" : "="+color.intValue())+">";
} }
public static ColorObject getColorFromText(String s) public static int getColorFromText(String s)
{ {
s = s == null ? "" : s; s = s == null ? "" : s;
return ColorObject.rgb((s.hashCode() & 11184810) + 4473924); return ColorUtils.rgb((s.hashCode() & 11184810) + 4473924);
} }
public static String searchUntil(String s, int startIndex, char endChar, String invalidChars) public static String searchUntil(String s, int startIndex, char endChar, String invalidChars)
@ -62,14 +62,14 @@ public class TextUtil
return original; return original;
} }
public static ColorObject findColor(String value, String search, ColorObject current, ColorObject original) public static int findColor(String value, String search, int current, int original)
{ {
if(value.startsWith(search)) if(value.startsWith(search))
{ {
try try
{ {
int equals = value.indexOf("="); int equals = value.indexOf("=");
return equals == -1 ? original : ColorObject.rgb(Integer.decode(value.substring(equals + 1)).intValue()); return equals == -1 ? original : ColorUtils.rgb(Integer.decode(value.substring(equals + 1)).intValue());
} }
catch(Exception e) catch(Exception e)
{ {

View File

@ -6,7 +6,7 @@ import java.util.List;
import speiger.src.collections.objects.lists.ObjectList; import speiger.src.collections.objects.lists.ObjectList;
import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet; import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet;
import speiger.src.collections.objects.sets.ObjectSortedSet; import speiger.src.collections.objects.sets.ObjectOrderedSet;
import speiger.src.collections.objects.utils.ObjectIterators; import speiger.src.collections.objects.utils.ObjectIterators;
import speiger.src.coreengine.utils.io.finders.IFileFinder; import speiger.src.coreengine.utils.io.finders.IFileFinder;
import speiger.src.coreengine.utils.io.finders.JavaFileFinder; import speiger.src.coreengine.utils.io.finders.JavaFileFinder;
@ -18,7 +18,7 @@ public class FileFinder
protected int flags; protected int flags;
protected String customPath; protected String customPath;
protected ObjectSortedSet<String> fileFormats; protected ObjectOrderedSet<String> fileFormats;
protected IFileFinder finder; protected IFileFinder finder;
public FileFinder(int flags, String...fileFormats) public FileFinder(int flags, String...fileFormats)

View File

@ -29,6 +29,13 @@ public class MapTag implements IMapTag
{ {
} }
public MapTag(String id, DataTag tag)
{
if(tag instanceof ListTag) putList(id, tag.cast());
else if(tag instanceof MapTag) putMap(id, tag.cast());
else putTag(id, tag);
}
@Override @Override
public int getId() public int getId()
{ {

View File

@ -4,7 +4,7 @@ import java.io.File;
import java.util.StringJoiner; import java.util.StringJoiner;
import speiger.src.collections.objects.lists.ObjectList; import speiger.src.collections.objects.lists.ObjectList;
import speiger.src.collections.objects.sets.ObjectSortedSet; import speiger.src.collections.objects.sets.ObjectOrderedSet;
public interface IFileFinder public interface IFileFinder
{ {
@ -14,9 +14,9 @@ public interface IFileFinder
public static final int ANY = 4; public static final int ANY = 4;
public static final int SAVE = 8; public static final int SAVE = 8;
public ObjectList<File> build(int flags, String startPath, ObjectSortedSet<String> validFormats, String description); public ObjectList<File> build(int flags, String startPath, ObjectOrderedSet<String> validFormats, String description);
public default String toFileFormat(ObjectSortedSet<String> validFormats) public default String toFileFormat(ObjectOrderedSet<String> validFormats)
{ {
StringJoiner joiner = new StringJoiner(","); StringJoiner joiner = new StringJoiner(",");
for(String s : validFormats) joiner.add(s); for(String s : validFormats) joiner.add(s);

View File

@ -8,14 +8,14 @@ import javax.swing.filechooser.FileFilter;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.lists.ObjectList; import speiger.src.collections.objects.lists.ObjectList;
import speiger.src.collections.objects.sets.ObjectSortedSet; import speiger.src.collections.objects.sets.ObjectOrderedSet;
public class JavaFileFinder implements IFileFinder public class JavaFileFinder implements IFileFinder
{ {
public static final IFileFinder INSTANCE = new JavaFileFinder(); public static final IFileFinder INSTANCE = new JavaFileFinder();
@Override @Override
public ObjectList<File> build(int flags, String startPath, ObjectSortedSet<String> validFormats, String description) public ObjectList<File> build(int flags, String startPath, ObjectOrderedSet<String> validFormats, String description)
{ {
JFileChooser file = new JFileChooser(startPath); JFileChooser file = new JFileChooser(startPath);
if((flags & FOLDER) != 0) file.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if((flags & FOLDER) != 0) file.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@ -41,9 +41,9 @@ public class JavaFileFinder implements IFileFinder
private static class Filter extends FileFilter private static class Filter extends FileFilter
{ {
String description; String description;
ObjectSortedSet<String> validFormats; ObjectOrderedSet<String> validFormats;
public Filter(String description, ObjectSortedSet<String> validFormats) public Filter(String description, ObjectOrderedSet<String> validFormats)
{ {
StringJoiner joiner = new StringJoiner(", ", " (", ")"); StringJoiner joiner = new StringJoiner(", ", " (", ")");
for(String s : validFormats) joiner.add("."+s); for(String s : validFormats) joiner.add("."+s);

View File

@ -9,14 +9,14 @@ import org.lwjgl.util.nfd.NativeFileDialog;
import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.lists.ObjectList; import speiger.src.collections.objects.lists.ObjectList;
import speiger.src.collections.objects.sets.ObjectSortedSet; import speiger.src.collections.objects.sets.ObjectOrderedSet;
public class NativeFileFinder implements IFileFinder public class NativeFileFinder implements IFileFinder
{ {
public static final IFileFinder INSTANCE = new NativeFileFinder(); public static final IFileFinder INSTANCE = new NativeFileFinder();
@Override @Override
public ObjectList<File> build(int flags, String startPath, ObjectSortedSet<String> validFormats, String description) public ObjectList<File> build(int flags, String startPath, ObjectOrderedSet<String> validFormats, String description)
{ {
ObjectList<File> files = new ObjectArrayList<>(); ObjectList<File> files = new ObjectArrayList<>();
if((flags & SAVE) != 0) if((flags & SAVE) != 0)

View File

@ -5,7 +5,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.ObjIntConsumer; import java.util.function.ObjIntConsumer;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.utils.helpers.TextUtil; import speiger.src.coreengine.utils.helpers.TextUtil;
public interface IProfiler public interface IProfiler
@ -112,7 +111,7 @@ public interface IProfiler
public static class ProfilerData implements Comparable<ProfilerData> public static class ProfilerData implements Comparable<ProfilerData>
{ {
String name; String name;
ColorObject color; int color;
long nanoTime; long nanoTime;
double effect; double effect;
double totalEffect; double totalEffect;
@ -141,7 +140,7 @@ public interface IProfiler
return name; return name;
} }
public ColorObject getColor() public int getColor()
{ {
return color; return color;
} }

View File

@ -0,0 +1,30 @@
package speiger.src.coreengine.utils.tasks;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
public class ThreadUtils
{
public static void join(List<Future<?>> futures)
{
for(int i = futures.size() -1;i>=0;i--)
{
Future<?> future = futures.get(i);
if(future.isDone()) continue;
try { future.get(); }
catch(InterruptedException | ExecutionException e) { }
}
}
public static void join(Future<?>...futures)
{
for(int i = futures.length -1;i>=0;i--)
{
Future<?> future = futures[i];
if(future.isDone()) continue;
try { future.get(); }
catch(InterruptedException | ExecutionException e) { }
}
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB