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'
//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)
{
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;
}

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.constrains.ComponentConstrains;
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.UIRenderer;
import speiger.src.coreengine.rendering.input.Keyboard;
@ -96,6 +97,11 @@ public abstract class GuiComponent extends FlagHolder
return owner;
}
public FontRenderer getFont()
{
return owner.getFont();
}
public void calculateActualBounds(float[] area, boolean start)
{
if(start)
@ -199,7 +205,7 @@ public abstract class GuiComponent extends FlagHolder
}
}
init();
onComponentChanged(true);
onChanged(true);
if(binding != null)
{
gui.addKeyListener(binding);
@ -320,7 +326,7 @@ public abstract class GuiComponent extends FlagHolder
clearFlag(FLAG_MASS_CHANGE);
if(changed && !quiet)
{
onComponentChanged(massRepaint);
onChanged(massRepaint);
}
}
return this;
@ -369,7 +375,7 @@ public abstract class GuiComponent extends FlagHolder
if(getBox().getBaseScale() != value)
{
getBox().setScale(value);
onComponentChanged(true);
onChanged(true);
}
return this;
}
@ -439,7 +445,7 @@ public abstract class GuiComponent extends FlagHolder
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()
@ -454,7 +460,7 @@ public abstract class GuiComponent extends FlagHolder
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)
@ -542,7 +548,7 @@ public abstract class GuiComponent extends FlagHolder
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;
}
@ -709,39 +715,39 @@ public abstract class GuiComponent extends FlagHolder
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;
box.move(x, y);
onComponentChanged(false);
onChanged(false);
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;
box.setXY(x, y);
onComponentChanged(false);
onChanged(false);
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;
box.grow(moveX, moveY);
onComponentChanged(true);
onChanged(true);
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;
box.setBounds(width, height);
onComponentChanged(true);
onChanged(true);
return this;
}
public final void onComponentChanged(boolean repaint)
public final void onChanged(boolean repaint)
{
if(owner == null) return;
if(isFlagSet(FLAG_MASS_CHANGE))
@ -771,7 +777,7 @@ public abstract class GuiComponent extends FlagHolder
if(children.isEmpty()) return;
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();
}
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(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)
{
@ -813,10 +819,10 @@ public abstract class GuiComponent extends FlagHolder
}
else
{
onPreRender();
preRender();
getRenderer().setVisibility(totalVisibility).setBrightness(brightness);
if(renderSelf(mouseX, mouseY, particalTicks)) renderChildren(mouseX, mouseY, particalTicks);
onPostRender();
postRender();
getRenderer().resetEffects();
}
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())
{
entry.onFixedUpdate();
entry.fixedUpdate();
}
}
}
@ -880,7 +886,7 @@ public abstract class GuiComponent extends FlagHolder
{
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;
getRenderer().push();
getRenderer().translate(0F, 0F, zOffset);
entry.onPreRender();
entry.onRender(mouseX, mouseY, particalTicks);
entry.onPostRender();
entry.preRender();
entry.render(mouseX, mouseY, particalTicks);
entry.postRender();
getRenderer().translate(0F, 0F, -zOffset);
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.Int2ObjectOpenHashMap;
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.objects.lists.ObjectArrayList;
import speiger.src.collections.objects.maps.impl.hash.Object2BooleanLinkedOpenHashMap;
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.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.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.GuiComponent;
import speiger.src.coreengine.rendering.gui.components.TooltipPanel;
@ -35,9 +35,9 @@ public class GuiScreenBase extends GuiBase
Int2ObjectMap<GuiComponent> getters = new Int2ObjectOpenHashMap<>();
Set<GuiComponent> components = new ObjectLinkedOpenHashSet<>();
Set<IKeyComponent> keyOrder = new ObjectLinkedOpenHashSet<>();
ObjectSortedSet<GuiComponent> renderOrder = new ObjectLinkedOpenHashSet<>();
Object2BooleanSortedMap<IButtonComponent> buttonOrder = new Object2BooleanLinkedOpenHashMap<>();
Int2ObjectSortedMap<IButtonComponent> selectedButtons = new Int2ObjectLinkedOpenHashMap<>();
ObjectOrderedSet<GuiComponent> renderOrder = new ObjectLinkedOpenHashSet<>();
Object2BooleanOrderedMap<IButtonComponent> buttonOrder = new Object2BooleanLinkedOpenHashMap<>();
Int2ObjectOrderedMap<IButtonComponent> selectedButtons = new Int2ObjectLinkedOpenHashMap<>();
Set<IButtonComponent> draggingButtons = new ObjectLinkedOpenHashSet<>();
TooltipPanel tooltips = new TooltipPanel();
int lastMouseX = -1;
@ -153,7 +153,7 @@ public class GuiScreenBase extends GuiBase
super.onScreenChanged();
for(GuiComponent entry : components)
{
entry.onComponentChanged(true);
entry.onChanged(true);
}
}
@ -164,7 +164,7 @@ public class GuiScreenBase extends GuiBase
{
if(entry.isVisible())
{
entry.onFixedUpdate();
entry.fixedUpdate();
}
}
}
@ -176,7 +176,7 @@ public class GuiScreenBase extends GuiBase
{
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();
boolean layer = base.usesRenderOrder();
render.translate(0.0F, 0.0F, layers + z + (layer ? extra : 0.0F));
base.onRender(mouseX, mouseY, particalTicks);
base.render(mouseX, mouseY, particalTicks);
render.resetTransform();
biggestZ = Math.max(biggestZ, z);
if(layer)
@ -227,9 +227,9 @@ public class GuiScreenBase extends GuiBase
{
drawsTooltip = true;
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);
tooltips.onRender(mouseX, mouseY, particalTicks);
tooltips.render(mouseX, mouseY, particalTicks);
render.resetTransform();
}
}
@ -241,7 +241,7 @@ public class GuiScreenBase extends GuiBase
if(!getUIManager().isRenderUIBoxes()) return;
UIRenderer render = getRenderer();
render.translate(0F, 0F, 100F);
render.drawFrame(comp.getBox(), ColorObject.RED);
render.drawFrame(comp.getBox(), ColorUtils.RED);
render.translate(0F, 0F, -100F);
}

View File

@ -1,6 +1,5 @@
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.base.IButtonComponent;
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
{
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);
}
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);
this.text.setText(text);
@ -34,7 +33,7 @@ public class ButtonComponent extends GuiComponent implements IButtonComponent
return text;
}
public ButtonComponent setColor(ColorObject color)
public ButtonComponent setColor(int color)
{
this.color = color;
return this;

View File

@ -1,6 +1,5 @@
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.base.IButtonComponent;
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>
{
boolean isChecked = false;
ColorObject color;
int color;
RenderBuffer buffer;
public CheckBoxComponent(ColorObject color)
public CheckBoxComponent(int color)
{
super(0F, 0F, 0F, 0F);
setFlag(FLAG_SUPPORT_BINDING);
this.color = color;
}
public CheckBoxComponent(ColorObject color, boolean checked)
public CheckBoxComponent(int color, boolean checked)
{
super(0F, 0F, 0F, 0F);
setFlag(FLAG_SUPPORT_BINDING);
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);
setFlag(FLAG_SUPPORT_BINDING);
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);
setFlag(FLAG_SUPPORT_BINDING);
@ -55,12 +54,12 @@ public class CheckBoxComponent extends GuiComponent implements IButtonComponent,
return this;
}
public final CheckBoxComponent setColor(ColorObject color)
public final CheckBoxComponent setColor(int color)
{
if(this.color != color)
{
this.color = color;
onComponentChanged(true);
onChanged(true);
}
return this;
}

View File

@ -2,16 +2,15 @@ package speiger.src.coreengine.rendering.gui.components;
import java.util.function.IntFunction;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.misc.Facing;
public class GradientSliderComponent extends SliderComponent
{
ColorObject fromColor;
ColorObject toColor;
int fromColor;
int toColor;
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);
this.direction = direction;
@ -19,7 +18,7 @@ public class GradientSliderComponent extends SliderComponent
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);
this.direction = direction;

View File

@ -1,6 +1,6 @@
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.base.IButtonComponent;
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
{
IIcon icon;
ColorObject hoverColor;
int hoverColor;
public IconButtonComponent(ColorObject hoverColor, IIcon icon)
public IconButtonComponent(int hoverColor, IIcon icon)
{
super(0F, 0F, 0F, 0F);
this.icon = icon;
@ -18,7 +18,7 @@ public class IconButtonComponent extends GuiComponent implements IButtonComponen
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);
this.icon = icon;
@ -35,7 +35,7 @@ public class IconButtonComponent extends GuiComponent implements IButtonComponen
@Override
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);
}

View File

@ -1,13 +1,12 @@
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.textures.base.ITexture;
public class IconComponent extends GuiComponent
{
ITexture texture;
ColorObject override = ColorObject.WHITE;
int override = -1;
public IconComponent(ITexture texture)
{
@ -15,7 +14,7 @@ public class IconComponent extends GuiComponent
this.texture = texture;
}
public IconComponent(ITexture texture, ColorObject color)
public IconComponent(ITexture texture, int color)
{
super(0F, 0F, 0F, 0F);
this.texture = texture;
@ -28,7 +27,7 @@ public class IconComponent extends GuiComponent
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);
this.texture = texture;
@ -41,7 +40,7 @@ public class IconComponent extends GuiComponent
return this;
}
public IconComponent setColor(ColorObject color)
public IconComponent setColor(int color)
{
override = color;
return this;

View File

@ -1,20 +1,19 @@
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.helper.constrains.Constraints;
public class LabelComponent extends GuiComponent
{
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);
}
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);
this.text.setText(text);
@ -26,13 +25,13 @@ public class LabelComponent extends GuiComponent
return text;
}
public LabelComponent setColor(ColorObject color)
public LabelComponent setColor(int color)
{
this.color = color;
return this;
}
public ColorObject getColor()
public int getColor()
{
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.utils.ObjectIterators;
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.rendering.gui.GuiComponent;
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_START_AT_BOTTOM = 2048;
protected ColorObject color;
protected ColorObject hoverColor = ColorObject.LIGHT_GRAY.copy();
protected int color;
protected int hoverColor = ColorUtils.LIGHT_GRAY;
protected int hoverIndex = -1;
protected int dragIndex = -1;
protected int movement = 0;
@ -53,8 +53,8 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
protected int updateMode = 1;
protected float entryHeight;
protected float cachedWidth = 0F;
protected ScrollBarComponent verticalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY);
protected ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY).setHorizontal(true);
protected ScrollBarComponent verticalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY);
protected ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY).setHorizontal(true);
protected Vec2i lastMouse = Vec2i.newMutable();
public ListComponent()
@ -62,14 +62,14 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
super(0F, 0F, 0F, 0F);
}
public ListComponent(ColorObject color, float entryHeight)
public ListComponent(int color, float entryHeight)
{
super(0F, 0F, 0F, 0F);
this.color = color;
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);
this.color = color;
@ -125,13 +125,13 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
return isFlagSet(FLAG_START_AT_BOTTOM);
}
public ListComponent<T> setColor(ColorObject color)
public ListComponent<T> setColor(int color)
{
this.color = color;
return this;
}
public ListComponent<T> setHoverColor(ColorObject color)
public ListComponent<T> setHoverColor(int color)
{
hoverColor = color;
return this;
@ -142,7 +142,7 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
if(this.entryHeight != entryHeight)
{
this.entryHeight = entryHeight;
onComponentChanged(true);
onChanged(true);
}
return this;
}
@ -242,7 +242,7 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
return entries;
}
public ListComponent<T> addEntry(T entry)
public ListComponent<T> add(T entry)
{
entries.add(entry);
if(getGui() != null)
@ -253,7 +253,7 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
return this;
}
public ListComponent<T> addEntries(Collection<T> entries)
public ListComponent<T> addAll(Collection<T> entries)
{
this.entries.addAll(entries);
if(getGui() != null)
@ -393,8 +393,7 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
protected Iterator<T> rangeIterator(int start, int end)
{
return new Iterator<T>()
{
return new Iterator<T>() {
int index = start;
@Override
@ -447,11 +446,11 @@ public class ListComponent<T extends IListEntry> extends GuiComponent
horizontalBar.setScrollMax((int)(width / getBox().getScale()));
if(lastHorizontal != horizontalBar.isInUse())
{
horizontalBar.onComponentChanged(true);
horizontalBar.onChanged(true);
}
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 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.renderer.buffer.RenderBuffer;
import speiger.src.coreengine.rendering.tesselation.Tesselator;
@ -104,8 +104,8 @@ public class PieComponent extends GuiComponent
{
IPieIndex pieIndex = indexes.get(j);
int steps = j == 0 ? maxSteps - stepsDone : pieIndex.getSteps();
ColorObject color = pieIndex.getColor();
ColorObject darker = color.copy().darker();
int color = pieIndex.getColor();
int darker = ColorUtils.darker(color);
tes.offset(0F, 0F, 0.01F);
for(int i = 0;i<steps;i++)
{
@ -140,15 +140,15 @@ public class PieComponent extends GuiComponent
{
public int getSteps();
public ColorObject getColor();
public int getColor();
}
public static class PieIndex implements IPieIndex
{
int steps;
ColorObject color;
int color;
public PieIndex(int steps, ColorObject color)
public PieIndex(int steps, int color)
{
this.steps = steps;
this.color = color;
@ -161,7 +161,7 @@ public class PieComponent extends GuiComponent
}
@Override
public ColorObject getColor()
public int getColor()
{
return color;
}

View File

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

View File

@ -1,7 +1,6 @@
package speiger.src.coreengine.rendering.gui.components;
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.base.IButtonComponent;
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_INVERTED = 2048;
ColorObject color;
int color;
float lastMouse = -1;
int current;
int max;
public ScrollBarComponent(ColorObject color)
public ScrollBarComponent(int color)
{
super(0F, 0F, 0F, 0F);
this.color = color;
}
public ScrollBarComponent(ColorObject color, int max)
public ScrollBarComponent(int color, int max)
{
super(0F, 0F, 0F, 0F);
this.color = color;
this.max = max;
}
public ScrollBarComponent(ColorObject color, int max, int current)
public ScrollBarComponent(int color, int max, int current)
{
super(0F, 0F, 0F, 0F);
this.color = color;
@ -36,20 +35,20 @@ public class ScrollBarComponent extends GuiComponent implements IButtonComponent
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);
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);
this.color = color;
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);
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;
return this;

View File

@ -1,6 +1,6 @@
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.helper.box.IGuiBox;
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;
ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY).setHorizontal(true);
ScrollBarComponent verticalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY);
ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY).setHorizontal(true);
ScrollBarComponent verticalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY);
protected PanelComponent container = new PanelComponent().setManualRenderer(true).setScissorsTest(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(verticalBar, Constraints.getScrollbarConstraints(isFlagSet(FLAG_CORNER) ? () -> true : horizontalBar::isInUse, false, 5F));
onComponentChanged(false);
onChanged(false);
}
return this;
}
@ -68,14 +68,14 @@ public class ScrollPanelComponent extends GuiComponent
}
horizontalBar.setScrollMax((int)maxX);
verticalBar.setScrollMax((int)maxY);
owner.setComponentBounds(maxX, maxY).setComponentPosition(-horizontalBar.getScroll(), -verticalBar.getScroll());
owner.bounds(maxX, maxY).set(-horizontalBar.getScroll(), -verticalBar.getScroll());
}
@Override
protected boolean updateSelf(int mouseX, int mouseY, float particalTicks)
{
super.updateSelf(mouseX, mouseY, particalTicks);
container.setComponentPosition(-horizontalBar.getScroll(), -verticalBar.getScroll());
container.set(-horizontalBar.getScroll(), -verticalBar.getScroll());
return true;
}
@ -87,7 +87,7 @@ public class ScrollPanelComponent extends GuiComponent
{
enableScissors(viewPort.getBox());
getRenderer().translate(0F, 0F, 0.1F);
container.onRender(mouseX, mouseY, particalTicks);
container.render(mouseX, mouseY, particalTicks);
getRenderer().translate(0F, 0F, -0.1F);
disableScissors();
}

View File

@ -1,6 +1,6 @@
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.helper.box.IGuiBox;
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 static final int FLAG_CORNER = 1 << 26;
ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY).setHorizontal(true);
ScrollBarComponent verticalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY);
ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY).setHorizontal(true);
ScrollBarComponent verticalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY);
protected PanelComponent container = 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));
viewPort.addChild(container);
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)
@ -61,7 +61,7 @@ public class ScrollWindowComponent extends WindowComponent
{
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));
onComponentChanged(false);
onChanged(false);
}
return this;
}
@ -78,16 +78,16 @@ public class ScrollWindowComponent extends WindowComponent
}
horizontalBar.setScrollMax((int)maxX);
verticalBar.setScrollMax((int)maxY);
horizontalBar.onComponentChanged(true);
verticalBar.onComponentChanged(true);
owner.setComponentBounds(maxX, maxY).setComponentPosition(-horizontalBar.getScroll(), -verticalBar.getScroll());
horizontalBar.onChanged(true);
verticalBar.onChanged(true);
owner.bounds(maxX, maxY).set(-horizontalBar.getScroll(), -verticalBar.getScroll());
}
@Override
protected boolean updateSelf(int mouseX, int mouseY, float particalTicks)
{
super.updateSelf(mouseX, mouseY, particalTicks);
container.setComponentPosition(-horizontalBar.getScroll(), -verticalBar.getScroll());
container.set(-horizontalBar.getScroll(), -verticalBar.getScroll());
return true;
}
@ -100,7 +100,7 @@ public class ScrollWindowComponent extends WindowComponent
{
enableScissors(viewPort.getBox());
getRenderer().translate(0F, 0F, 0.1F);
container.onRender(mouseX, mouseY, particalTicks);
container.render(mouseX, mouseY, particalTicks);
getRenderer().translate(0F, 0F, -0.1F);
disableScissors();
}

View File

@ -6,7 +6,6 @@ import java.util.function.Consumer;
import org.lwjgl.opengl.GL11;
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.LiniarValue;
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 static final int FLAG_ANIMATE = 1 << 20;
ListComponent<SelectionEntry> list = new ListComponent<SelectionEntry>().setComponentBounds(0F, 120F).setManualRenderer(true).setIgnoreBounds(true).cast();
TextComponent text = new TextComponent().setAlignment(Align.LEFT_TOP, Align.CENTER).setTextScale(0.85F).setManualRenderer(true).cast();
ListComponent<SelectionEntry> list = new ListComponent<SelectionEntry>().bounds(0F, 120F).setManualRenderer(true).setIgnoreBounds(true).cast();
TextComponent text = new TextComponent().align(Align.LEFT_TOP, Align.CENTER).setTextScale(0.85F).setManualRenderer(true).cast();
RenderBuffer buffer;
ColorObject color;
int color;
boolean isOpen = false;
int selectedIndex = -1;
int defaultIndex = -1;
IValue animation = null;
public SelectionComponent(ColorObject color)
public SelectionComponent(int color)
{
super(0F, 0F, 0F, 0F);
this.color = color;
@ -42,7 +41,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
list.setColor(color);
}
public SelectionComponent(ColorObject color, Collection<String> collection)
public SelectionComponent(int color, Collection<String> collection)
{
super(0F, 0F, 0F, 0F);
this.color = color;
@ -51,7 +50,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
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);
this.color = color;
@ -59,7 +58,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
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);
this.color = color;
@ -71,7 +70,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
@Override
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(list, new ComponentConstrains(new ParentConstrain(), new ParentConstrain().invert(), new ParentConstrain(), null));
addCloseListener(buffer = getRenderer().createBuffer());
@ -107,7 +106,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
public SelectionComponent addEntry(String s)
{
list.addEntry(new SelectionEntry(s));
list.add(new SelectionEntry(s));
return this;
}
@ -115,7 +114,7 @@ public class SelectionComponent extends GuiComponent implements IButtonComponent
{
for(String s : collection)
{
list.addEntry(new SelectionEntry(s));
list.add(new SelectionEntry(s));
}
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.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);
text.onRender(mouseX, mouseY, particalTicks);
text.render(mouseX, mouseY, particalTicks);
if(animation != null)
{
float progress = animation.get() / 90F;
box = list.getBox();
enableScissors(box.getMinX(), box.getMinY(), box.getWidth(), box.getHeight() * progress);
list.onRender(mouseX, mouseY, particalTicks);
list.render(mouseX, mouseY, particalTicks);
disableScissors();
}
else if(isOpen)
{
list.onRender(mouseX, mouseY, particalTicks);
list.render(mouseX, mouseY, particalTicks);
}
return true;
}

View File

@ -3,7 +3,6 @@ package speiger.src.coreengine.rendering.gui.components;
import java.util.function.IntFunction;
import speiger.src.coreengine.math.MathUtils;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.rendering.gui.GuiComponent;
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
{
TextComponent text = new TextComponent();
protected ColorObject color;
protected int color;
protected boolean vertical = false;
protected int min;
@ -24,12 +23,12 @@ public class SliderComponent extends GuiComponent implements IButtonComponent
IntFunction<String> textBuilder;
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);
}
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);
this.min = min;
@ -80,7 +79,7 @@ public class SliderComponent extends GuiComponent implements IButtonComponent
return this;
}
public SliderComponent setColor(ColorObject color)
public SliderComponent setColor(int 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;
import speiger.src.coreengine.math.misc.ColorObject;
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.PixelConstrain;
@ -8,27 +7,27 @@ import speiger.src.coreengine.rendering.gui.helper.constrains.TextConstrain;
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);
this.text.setText(text);
}
public TextCheckBoxComponent(ColorObject color, String text, boolean checked)
public TextCheckBoxComponent(int color, String text, boolean checked)
{
super(color, checked);
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);
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);
this.text.setText(text);

View File

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

View File

@ -5,7 +5,6 @@ import java.util.function.Predicate;
import org.lwjgl.glfw.GLFW;
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.base.IButtonComponent;
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_AUTO_VALIDATE = 1 << 24;
TextComponent text = new TextComponent().setHorizontalAlignment(Align.LEFT_TOP).setForcedSingleLine(true).setSpecialRendering(false).cast();
ColorObject color;
TextComponent text = new TextComponent().horizontal(Align.LEFT_TOP).singleLine(true).special(false).cast();
int color;
int curserPosition = 0;
int selectionPosition = 0;
long lastClickTime = 0;
@ -45,14 +44,14 @@ public class TextFieldComponent extends GuiComponent
int largestPos = 0;
IGuiBox viewPort = new ParentBox(1F);
public TextFieldComponent(ColorObject color)
public TextFieldComponent(int color)
{
super(0F, 0F, 0F, 0F);
setFlag(FLAG_CAN_LOSE_FOCUS);
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);
setFlag(FLAG_CAN_LOSE_FOCUS);
@ -69,7 +68,7 @@ public class TextFieldComponent extends GuiComponent
String s = text.getText();
float scale = text.getTextScale();
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);
}
@ -112,7 +111,7 @@ public class TextFieldComponent extends GuiComponent
return this;
}
public TextFieldComponent setColor(ColorObject color)
public TextFieldComponent setColor(int color)
{
this.color = color;
return this;
@ -122,7 +121,7 @@ public class TextFieldComponent extends GuiComponent
{
if(setFlag(FLAG_INFINITE_WIDTH, value))
{
text.setLimitedBounds(!value);
text.limit(!value);
if(getGui() != null)
{
addConstrains(text, createConstraints());
@ -162,7 +161,7 @@ public class TextFieldComponent extends GuiComponent
{
float scale = text.getTextScale();
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);
}
@ -672,7 +671,7 @@ public class TextFieldComponent extends GuiComponent
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;
if(curserPosition > k)
{
@ -690,7 +689,7 @@ public class TextFieldComponent extends GuiComponent
lineOffset = MathUtils.clamp(0, text.length(), 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 speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.vector.ints.Vec2i;
import speiger.src.coreengine.rendering.gui.GuiComponent;
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_CAN_LOSE_FOCUS = 2048;
TextComponent text = new TextComponent().setAlignment(Align.LEFT_TOP, Align.LEFT_TOP).setForcedSingleLine(true).setSpecialRendering(false).cast();
ColorObject color;
TextComponent text = new TextComponent().align(Align.LEFT_TOP, Align.LEFT_TOP).singleLine(true).special(false).cast();
int color;
int curserPosition = 0;
Vec2i curserPos = Vec2i.newMutable();
int selectionPosition = 0;
@ -37,13 +36,13 @@ public class TextPanelComponent extends GuiComponent implements IButtonComponent
int clickCount = 0;
Predicate<String> validator = Functions.getAlwaysTrue();
public TextPanelComponent(ColorObject color)
public TextPanelComponent(int color)
{
super(0F, 0F, 0F, 0F);
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);
this.color = color;
@ -67,7 +66,7 @@ public class TextPanelComponent extends GuiComponent implements IButtonComponent
return this;
}
public TextPanelComponent setColor(ColorObject color)
public TextPanelComponent setColor(int color)
{
this.color = color;
return this;
@ -102,7 +101,7 @@ public class TextPanelComponent extends GuiComponent implements IButtonComponent
}
float height = text.getBox().getHeight();
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);
}
@ -132,7 +131,7 @@ public class TextPanelComponent extends GuiComponent implements IButtonComponent
if(isFlagSet(FLAG_FOCUS) && (getGlobalClock() / 15) % 2L == 0)
{
TextMetadata data = text.getMetadata();
float height = text.getFont().getFontHeight() * text.getTextScale();
float height = text.getFont().height() * text.getTextScale();
if(hasSelectedText())
{
if(selectionPos.getY() == curserPos.getY())

View File

@ -4,10 +4,11 @@ import java.util.List;
import java.util.UUID;
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.interfaces.Object2ObjectMap;
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.helper.box.IGuiBox;
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
{
List<UUID> helperList = new ObjectArrayList<>();
ObjectList<UUID> helperList = new ObjectArrayList<>();
List<GuiComponent> indexedComponents = new ObjectArrayList<>();
Object2ObjectMap<UUID, GuiComponent> renderedTooltips = new Object2ObjectLinkedOpenHashMap<>();
ColorObject color = ColorObject.BLACK;
ColorObject borderColor = ColorObject.DARK_GRAY;
int color = ColorUtils.BLACK;
int borderColor = ColorUtils.DARK_GRAY;
IGuiBox box = new ParentBox(1.2F);
@Override
@ -62,7 +63,7 @@ public class TooltipPanel extends PanelComponent
{
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

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.ObjectSet;
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.vector.ints.Vec2i;
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;
ScrollBarComponent verticalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY);
ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorObject.LIGHT_GRAY).setHorizontal(true);
ScrollBarComponent verticalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY);
ScrollBarComponent horizontalBar = new ScrollBarComponent(ColorUtils.LIGHT_GRAY).setHorizontal(true);
ColorObject color;
ColorObject selectedColor;
ColorObject hoverColor = ColorObject.LIGHT_GRAY;
int color;
int selectedColor;
int hoverColor = ColorUtils.LIGHT_GRAY;
int hoverIndex = -1;
int dragIndex = -1;
int movement;
@ -59,7 +59,7 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
List<T> visibleNodes = new ObjectArrayList<T>();
RenderBuffer buffer;
public TreeComponent(ColorObject color, float entryHeight)
public TreeComponent(int color, float entryHeight)
{
super(0F, 0F, 0F, 0F);
this.entryHeight = entryHeight;
@ -67,7 +67,7 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
this.selectedColor = color;
}
public TreeComponent(ColorObject color, float entryHeight, T entry)
public TreeComponent(int color, float entryHeight, T entry)
{
super(0F, 0F, 0F, 0F);
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);
this.entryHeight = entryHeight;
@ -110,23 +110,23 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
createArrow();
}
public TreeComponent<T> setColor(ColorObject color)
public TreeComponent<T> setColor(int color)
{
if(this.color != color)
{
this.color = color;
onComponentChanged(true);
onChanged(true);
}
return this;
}
public TreeComponent<T> setHoverColor(ColorObject color)
public TreeComponent<T> setHoverColor(int color)
{
hoverColor = color;
return this;
}
public TreeComponent<T> setSelectionColor(ColorObject color)
public TreeComponent<T> setSelectionColor(int color)
{
selectedColor = color;
return this;
@ -137,7 +137,7 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
if(this.entryHeight != entryHeight)
{
this.entryHeight = entryHeight;
onComponentChanged(true);
onChanged(true);
}
return this;
}
@ -206,7 +206,7 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
listChange = true;
openNodes.clear();
selectedNodes.clear();
onComponentChanged(true);
onChanged(true);
return this;
}
@ -372,8 +372,8 @@ public class TreeComponent<T extends ITreeEntry> extends GuiComponent implements
}
verticalBar.setScrollMax(MathUtils.ceil(visibleNodes.size() * entryHeight));
horizontalBar.setScrollMax((int)(width / getBox().getScale()));
horizontalBar.onComponentChanged(true);
verticalBar.onComponentChanged(true);
horizontalBar.onChanged(true);
verticalBar.onChanged(true);
}
@Override

View File

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

View File

@ -1,17 +1,16 @@
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.rendering.gui.helper.UIShapes;
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
public class ArrowIcon implements IIcon
{
ColorObject color;
int color;
Facing direction;
float scale = 1F;
public ArrowIcon(ColorObject color, Facing direction)
public ArrowIcon(int color, Facing direction)
{
this.color = color;
this.direction = direction;

View File

@ -1,16 +1,15 @@
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.renderer.UIRenderer;
public class CrossIcon implements IIcon
{
ColorObject color;
int color;
float paddingX = 4F;
float paddingY = 2F;
public CrossIcon(ColorObject color)
public CrossIcon(int color)
{
this.color = color;
}

View File

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

View File

@ -1,12 +1,12 @@
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.textures.base.ITexture;
public class TexturedIcon implements IIcon
{
ColorObject color = ColorObject.WHITE;
int color = ColorUtils.WHITE;
ITexture texture;
boolean forceBounds = false;
@ -15,7 +15,7 @@ public class TexturedIcon implements IIcon
this.texture = texture;
}
public TexturedIcon(ColorObject color, ITexture texture)
public TexturedIcon(int color, ITexture texture)
{
this.color = color;
this.texture = texture;

View File

@ -45,7 +45,7 @@ public class FlowLayout implements Consumer<GuiComponent>
widthUsed = 0F;
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]);
widthUsed += width + padding.getX();
xInserted++;

View File

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

View File

@ -72,7 +72,7 @@ public abstract class BaseListEntry implements IListEntry
{
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);
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.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.GuiComponent;
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
{
TextComponent text = new TextComponent().setLimitedBounds(false).setAlignment(Align.LEFT_TOP, Align.LEFT_TOP);
CheckBoxComponent checkBox = new CheckBoxComponent(ColorObject.ORANGE);
TextComponent text = new TextComponent().limit(false).align(Align.LEFT_TOP, Align.LEFT_TOP);
CheckBoxComponent checkBox = new CheckBoxComponent(ColorUtils.ORANGE);
public ExampleEntry(String s)
{
@ -32,8 +32,8 @@ public class ExampleEntry implements IListEntry, IButtonComponent
{
text.setOwner(owner);
checkBox.setOwner(owner);
checkBox.setComponentBounds(owner.getFont().getFontHeight(), owner.getFont().getFontHeight());
text.setComponentPosition(owner.getFont().getFontHeight(), 0F);
checkBox.bounds(owner.getFont().height(), owner.getFont().height());
text.set(owner.getFont().height(), 0F);
}
@Override
@ -41,7 +41,7 @@ public class ExampleEntry implements IListEntry, IButtonComponent
{
text.setScale(scale);
checkBox.setScale(scale);
text.setComponentPosition(checkBox.getBox().getWidth(), 0F);
text.set(checkBox.getBox().getWidth(), 0F);
}
@Override
@ -58,8 +58,8 @@ public class ExampleEntry implements IListEntry, IButtonComponent
@Override
public void onRender(GuiComponent comp, boolean enabled, int mouseX, int mouseY, float particalTicks)
{
checkBox.onRender(mouseX, mouseY, particalTicks);
text.onRender(mouseX, mouseY, particalTicks);
checkBox.render(mouseX, mouseY, particalTicks);
text.render(mouseX, mouseY, particalTicks);
}
@Override

View File

@ -10,7 +10,7 @@ import speiger.src.coreengine.rendering.gui.helper.Align;
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(){}
@ -65,7 +65,7 @@ public class SelectionEntry implements IListEntry
@Override
public void onRender(GuiComponent comp, boolean enabled, int mouseX, int mouseY, float particalTicks)
{
text.onRender(mouseX, mouseY, particalTicks);
text.render(mouseX, mouseY, particalTicks);
}
@Override

View File

@ -5,7 +5,7 @@ import speiger.src.coreengine.rendering.gui.helper.Align;
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)
{

View File

@ -3,7 +3,6 @@ package speiger.src.coreengine.rendering.gui.components.menu;
import java.util.List;
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.helper.constrains.ComponentConstrains;
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
{
ColorObject color;
int color;
List<MenuItemComponent> menuItems = new ObjectArrayList<MenuItemComponent>();
float scale = 1F;
public MenuBarComponent(ColorObject color)
public MenuBarComponent(int color)
{
super(0F, 0F, 0F, 0F);
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);
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()));
item.setZOffset(0.3F);
item.setTextScale(scale);
item.onComponentChanged(false);
item.onChanged(false);
return item;
}

View File

@ -4,7 +4,6 @@ import java.util.List;
import java.util.function.Consumer;
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.helper.constrains.ComponentConstrains;
import speiger.src.coreengine.rendering.gui.helper.constrains.Constrain;
@ -55,7 +54,7 @@ public class MenuComponent extends MenuItemComponent implements Consumer<GuiComp
}
@Override
protected void setMenuColor(ColorObject color)
protected void setMenuColor(int color)
{
super.setMenuColor(color);
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++)
{
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);
comp.setScale(defaultScale);
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.setTextScale(textScale);
return comp;
@ -146,7 +145,7 @@ public class MenuComponent extends MenuItemComponent implements Consumer<GuiComp
super.removeChild(comp);
if(components.remove(comp))
{
onComponentChanged(false);
onChanged(false);
}
return this;
}
@ -257,7 +256,7 @@ public class MenuComponent extends MenuItemComponent implements Consumer<GuiComp
{
components.get(i).setBoxWidth(width);
}
onComponentChanged(false);
onChanged(false);
}
return this;
}

View File

@ -1,6 +1,5 @@
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.base.IButtonComponent;
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;
TextComponent text = new TextComponent().setForcedSingleLine(true).setLimitedBounds(false).setTextScale(0.35F).cast();
ColorObject color = null;
TextComponent text = new TextComponent().singleLine(true).limit(false).setTextScale(0.35F).cast();
Integer color = null;
protected float boxWidth;
public MenuItemComponent(String name)
@ -56,13 +55,13 @@ public class MenuItemComponent extends GuiComponent implements IButtonComponent
return isFlagSet(FLAG_KEEP_MENU_OPEN);
}
public MenuItemComponent setCustomColor(ColorObject color)
public MenuItemComponent setCustomColor(int color)
{
this.color = color;
return this;
}
protected void setMenuColor(ColorObject color)
protected void setMenuColor(int color)
{
if(this.color == null)
{

View File

@ -6,7 +6,7 @@ import java.util.function.Consumer;
import org.lwjgl.glfw.GLFW;
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.base.IKeyComponent;
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
{
TextFieldComponent chat = new TextFieldComponent(ColorObject.DARK_GRAY).setCanLoseFocus(false).setInfiniteText(true).setMaxTextLength(Integer.MAX_VALUE).setFocused(true);
ListComponent<MessageEntry> list = new ListComponent<>(ColorObject.DARK_GRAY.copy().setAlpha(120), 8F);
TextFieldComponent chat = new TextFieldComponent(ColorUtils.DARK_GRAY).setCanLoseFocus(false).setInfiniteText(true).setMaxTextLength(Integer.MAX_VALUE).setFocused(true);
ListComponent<MessageEntry> list = new ListComponent<>(ColorUtils.setA(ColorUtils.DARK_GRAY, 120), 8F);
float lastWidth = 0F;
List<ConsoleMessage> messages = new ObjectArrayList<>();
Consumer<String> listener;
@ -157,9 +157,9 @@ public class ConsoleComponent extends GuiComponent implements IKeyComponent
ScrollBarComponent scroll = list.getVerticalBar();
boolean atEnd = scroll.isAtEnd();
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(add)

View File

@ -3,7 +3,7 @@ package speiger.src.coreengine.rendering.gui.components.tree;
import java.util.Map;
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.GuiComponent;
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
{
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;
public ProfilerTreeEntry(IProfilerEntry entry)
@ -65,7 +65,7 @@ public class ProfilerTreeEntry extends BaseTreeEntry
@Override
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
@ -108,17 +108,17 @@ public class ProfilerTreeEntry extends BaseTreeEntry
time /= 1000000L;
if(time < 1)
{
return "§<color="+ColorObject.LIGHT_BLUE.hashCode()+">";
return "§<color="+ColorUtils.LIGHT_BLUE+">";
}
if(time >= 12)
{
return "§<color="+ColorObject.RED.hashCode()+">";
return "§<color="+ColorUtils.RED+">";
}
if(time >= 5)
{
return "§<color="+ColorObject.YELLOW.hashCode()+">";
return "§<color="+ColorUtils.YELLOW+">";
}
return "§<color="+ColorObject.GREEN.hashCode()+">";
return "§<color="+ColorUtils.GREEN+">";
}
@Override

View File

@ -6,7 +6,7 @@ import speiger.src.coreengine.rendering.gui.helper.Align;
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)
{

View File

@ -1,10 +1,10 @@
package speiger.src.coreengine.rendering.gui.components.window.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.misc.ColorObject;
import speiger.src.coreengine.math.misc.ColorUtils;
import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.math.vector.floats.Vec2f;
import speiger.src.coreengine.rendering.gui.UITextures;
@ -25,24 +25,24 @@ import speiger.src.coreengine.utils.helpers.InternalThreadPools;
public class ColorPickerWindowComponent extends WindowComponent
{
Consumer<ColorObject> listener;
IntConsumer listener;
IIcon wheelIcon = new TexturedIcon(UITextures.COLOR_WHEEL);
IGuiBox wheelBox = new GuiBox(15, 10, 70, 70);
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)};
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 saturation = new GradientSliderComponent(110, 13, 17, 76, 0, 100, 0, ColorObject.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);
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, ColorUtils.GRAY, colors[2], colors[3], 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, ColorUtils.DARK_GRAY).setValidator(Functions.NUMBERS_ONLY).setMaxTextLength(8);
float[] hsv = new float[3];
IGuiBox[] colorBoxes;
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);
this.pool = pool;
this.listener = listener;
hsv = defaultColor.toHue();
hsv = ColorUtils.toHue(defaultColor);
colorBoxes = new IGuiBox[Math.min(18, pool.size())];
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(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(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, "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, "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", 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]);
}
@ -76,17 +76,16 @@ public class ColorPickerWindowComponent extends WindowComponent
super.renderSelf(mouseX, mouseY, particalTicks);
wheelIcon.render(getRenderer().translate(0F, 0F, 0.01F).setBrightness(hsv[1]), wheelBox);
getRenderer().setBrightness(1F);
ColorObject color = new ColorObject(0);
for(int i = 0,m=colorBoxes.length;i<m;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 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);
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);
getRenderer().translate(0F, 0F, -0.01F);
return true;
@ -105,7 +104,7 @@ public class ColorPickerWindowComponent extends WindowComponent
public void apply()
{
pool.addColor(colors[4].getRGB());
pool.addColor(colors[4]);
listener.accept(colors[4]);
getGui().removeComponent(this);
}
@ -142,12 +141,12 @@ public class ColorPickerWindowComponent extends WindowComponent
hsv[0] = MathUtils.clamp(0F, 1F, hue);
hsv[1] = MathUtils.clamp(0F, 1F, saturation);
hsv[2] = MathUtils.clamp(0F, 1F, brightness);
colors[0].setRGB(hsv[0], 0F, 1F, 255);
colors[1].setRGB(hsv[0], 1F, 1F, 255);
colors[2].setRGB(hsv[0], 1F, 0F, 255);
colors[3].setRGB(hsv[0], 1F, 1F, 255);
colors[4].setRGB(hsv[0], hsv[1], hsv[2], 255);
code.setText(colors[4].getHTMLCode(false));
colors[0] = ColorUtils.toRGB(hsv[0], 0F, 1F);
colors[1] = ColorUtils.toRGB(hsv[0], 1F, 1F);
colors[2] = ColorUtils.toRGB(hsv[0], 1F, 0F);
colors[3] = ColorUtils.toRGB(hsv[0], 1F, 1F);
colors[4] = ColorUtils.toRGB(hsv[0], hsv[1], hsv[2]);
code.setText(ColorUtils.getHTMLCode(colors[4], false));
this.brightness.setValue((int)(hsv[2] * 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 speiger.src.coreengine.math.ArrayUtil;
import speiger.src.coreengine.math.misc.ColorObject;
public class ColorPool
{
@ -12,7 +11,7 @@ public class ColorPool
public ColorPool(int size)
{
colors = ArrayUtil.fill(new int[size], ColorObject.WHITE.getRGB());
colors = ArrayUtil.fill(new int[size], -1);
locked = new BitSet(size);
}
@ -45,7 +44,7 @@ public class ColorPool
public void removeColor(int index)
{
colors[index] = ColorObject.WHITE.getRGB();
colors[index] = -1;
}
public int getColor(int index)
@ -91,7 +90,7 @@ public class ColorPool
public void clear()
{
ArrayUtil.fill(colors, ColorObject.WHITE.getRGB());
ArrayUtil.fill(colors, -1);
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.utils.ObjectLists;
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.rendering.gui.GuiManager;
import speiger.src.coreengine.rendering.gui.base.IKeyComponent;
@ -61,11 +61,11 @@ public class PieProfilerWindowComponent extends WindowComponent
public void 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[1] = createButton(1, "GPU");
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));
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);
TextComponent[] info = entries.get(i);
ColorObject color = data.getColor();
info[0].setMassChanging(TextComponent.class).setTextColor(color).setText("[" + (i + 1) + "] " + data.getName()).finishMassChanging();
info[1].setMassChanging(TextComponent.class).setTextColor(color).setText(PERCENT_FORMAT.format(data.getEffect()) + "%").finishMassChanging();
info[2].setMassChanging(TextComponent.class).setTextColor(color).setText(PERCENT_FORMAT.format(data.getTotalEffect()) + "%").finishMassChanging();
int color = data.getColor();
info[0].setMassChanging(TextComponent.class).textColor(color).setText("[" + (i + 1) + "] " + data.getName()).finishMassChanging();
info[1].setMassChanging(TextComponent.class).textColor(color).setText(PERCENT_FORMAT.format(data.getEffect()) + "%").finishMassChanging();
info[2].setMassChanging(TextComponent.class).textColor(color).setText(PERCENT_FORMAT.format(data.getTotalEffect()) + "%").finishMassChanging();
}
if(last != textInUse)
{
resizeComponent(0F, (textInUse - last) * 5.5F);
resize(0F, (textInUse - last) * 5.5F);
}
else if(lastEmpty)
{
onComponentChanged(true);
onChanged(true);
}
return true;
}
@ -251,7 +251,7 @@ public class PieProfilerWindowComponent extends WindowComponent
}
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()
@ -288,7 +288,7 @@ public class PieProfilerWindowComponent extends WindowComponent
{
final int index = entries.size();
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));
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));
@ -297,7 +297,7 @@ public class PieProfilerWindowComponent extends WindowComponent
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.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)));

View File

@ -5,7 +5,7 @@ import java.util.function.ObjIntConsumer;
import speiger.src.collections.ints.queues.IntArrayFIFOQueue;
import speiger.src.collections.ints.queues.IntPriorityQueue;
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.rendering.gui.GuiManager;
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
{
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];
ObjIntConsumer<IProfiler> listener = (T, V) -> todoList.enqueue(V);
IProfiler profiler;
@ -169,7 +169,7 @@ public class TreeProfilerWindowComponent extends WindowComponent
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.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)));

View File

@ -1,7 +1,7 @@
package speiger.src.coreengine.rendering.gui.components.window.misc;
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.TextComponent;
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
{
TextComponent message = new TextComponent().setLimitedHeight(false).setTextScale(0.5F);
ButtonComponent yesButton = new ButtonComponent("Yes", ColorObject.GRAY);
ButtonComponent noButton = new ButtonComponent("No", ColorObject.GRAY);
TextComponent message = new TextComponent().limitHeight(false).setTextScale(0.5F);
ButtonComponent yesButton = new ButtonComponent("Yes", ColorUtils.GRAY);
ButtonComponent noButton = new ButtonComponent("No", ColorUtils.GRAY);
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;
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.TextComponent;
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
{
TextComponent message = new TextComponent().setLimitedHeight(false).setTextScale(0.5F);
ButtonComponent resultButton = new ButtonComponent("", ColorObject.GRAY);
TextComponent message = new TextComponent().limitHeight(false).setTextScale(0.5F);
ButtonComponent resultButton = new ButtonComponent("", ColorUtils.GRAY);
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;
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.TextComponent;
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
{
TextComponent message = new TextComponent().setLimitedHeight(false).setTextScale(0.5F);
TextFieldComponent input = new TextFieldComponent(ColorObject.GRAY).setCanLoseFocus(false).setInfiniteText(true).setMaxTextLength(Integer.MAX_VALUE).setFocused(true);
ButtonComponent confirm = new ButtonComponent("Confirm", ColorObject.DARK_GREEN);
ButtonComponent cancel = new ButtonComponent("Cancel", ColorObject.RED);
TextComponent message = new TextComponent().limitHeight(false).setTextScale(0.5F);
TextFieldComponent input = new TextFieldComponent(ColorUtils.GRAY).setCanLoseFocus(false).setInfiniteText(true).setMaxTextLength(Integer.MAX_VALUE).setFocused(true);
ButtonComponent confirm = new ButtonComponent("Confirm", ColorUtils.DARK_GREEN);
ButtonComponent cancel = new ButtonComponent("Cancel", ColorUtils.RED);
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)
{
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)
@ -72,7 +72,7 @@ public class FontBuilder
Consumer<CharData> data = T -> {
AssetLocation location = T.asLocation();
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);

View File

@ -2,7 +2,6 @@ package speiger.src.coreengine.rendering.gui.helper;
import org.lwjgl.opengl.GL11;
import speiger.src.coreengine.math.misc.ColorObject;
import speiger.src.coreengine.math.misc.Facing;
import speiger.src.coreengine.rendering.gui.renderer.UIRenderer;
import speiger.src.coreengine.rendering.gui.renderer.buffer.RenderBuffer;
@ -11,13 +10,13 @@ import speiger.src.coreengine.rendering.tesselation.VertexType;
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);
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.pos(paddingB, paddingA, 0F).tex(0F, 0F).color4f(color).endVertex();
@ -36,7 +35,7 @@ public class UIShapes
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.startCustomShape(GL11.GL_TRIANGLES, false);
@ -56,13 +55,13 @@ public class UIShapes
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);
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 halfHeight = height * 0.5F;
@ -117,7 +116,7 @@ public class UIShapes
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 halfHeight = height * 0.5F;

View File

@ -77,7 +77,7 @@ public class Animator
applyValues(true);
if(changed)
{
owner.onComponentChanged(redraw);
owner.onChanged(redraw);
}
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.objects.lists.ObjectArrayList;
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.helper.Align;
import speiger.src.coreengine.rendering.gui.renderer.buffer.DelayedRenderBuffer;
@ -52,15 +51,15 @@ public class FontRenderer implements IFontRenderer
}
@Override
public float getFontHeight()
public float height()
{
return provider.getFontHeight();
return provider.height();
}
@Override
public float getBaseLine()
public float baseLine()
{
return provider.getBaseLine();
return provider.baseLine();
}
@Override
@ -91,7 +90,7 @@ public class FontRenderer implements IFontRenderer
List<Line> lines = lexer.evaluateLines(text, context, Float.MAX_VALUE);
if(lines.isEmpty()) return ObjectLists.empty();
WordContext effects = context.getEffect();
ColorObject textColor = new ColorObject(effects.color);
int textColor = effects.color;
float yOffset = 0F;
IVertexBuilder builder = new TranslatedVertexBuilder(bufferBuilder, x, y, z, 1F);
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);
}
yOffset += getFontHeight() * context.getScale();
yOffset += height() * context.getScale();
}
bufferBuilder.finishData();
if(bufferBuilder.getVertexCount() > 0)
@ -131,8 +130,8 @@ public class FontRenderer implements IFontRenderer
return;
}
bufferBuilder.begin(GL11.GL_TRIANGLES, VertexType.UI);
int maxLanes = component.isHeightLimited() ? Math.min((int)(boxHeight / (getFontHeight() * context.getScale())), lines.size()) : lines.size();
float maxHeight = maxLanes * getFontHeight() * context.getScale();
int maxLanes = component.isHeightLimited() ? Math.min((int)(boxHeight / (height() * context.getScale())), lines.size()) : lines.size();
float maxHeight = maxLanes * height() * context.getScale();
float maxWidth = 0F;
float yOffset = component.getVertical().align(boxHeight, maxHeight);
float startX = component.getHorizontal().align(boxWidth, lines.get(0).getWidth());
@ -142,7 +141,7 @@ public class FontRenderer implements IFontRenderer
{
effects = effects.next();
}
ColorObject textColor = new ColorObject(effects.color);
int textColor = effects.color;
Float strikeThrough = effects.strike_through ? startX : null;
Float underline = effects.underline ? startX : -1F;
if(component.getBackgroundColor() != null)
@ -175,7 +174,7 @@ public class FontRenderer implements IFontRenderer
{
addUnderline(underline, xOffset - underline, yOffset, textColor, lineBuffer, false);
}
textColor.setRGB(next.color);
textColor = next.color;
underline = newLine;
effects = next;
}
@ -188,7 +187,7 @@ public class FontRenderer implements IFontRenderer
{
addUnderline(underline, xOffset - underline, yOffset, textColor, lineBuffer, false);
}
yOffset += getFontHeight() * context.getScale();
yOffset += height() * context.getScale();
component.getMetadata().addLine(lines.get(i));
}
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())
{
@ -231,13 +230,13 @@ public class FontRenderer implements IFontRenderer
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++)
{
float lineWidth = lines.get(i).getWidth();
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, yPos, 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 maxY = yStart + getBaseLine() + 1.5F;
float minY = yStart + baseLine() + 0.5F;
float maxY = yStart + baseLine() + 1.5F;
if(flipPos)
{
minY = yStart - getBaseLine() - 0.5F;
maxY = yStart - getBaseLine() - 1.5F;
minY = yStart - baseLine() - 0.5F;
maxY = yStart - baseLine() - 1.5F;
}
buffer.pos(xStart, maxY, 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();
}
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 maxY = yStart + getFontHeight() / 2.0F + 1.4F;
float minY = yStart + height() / 2.0F;
float maxY = yStart + height() / 2.0F + 1.4F;
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 + width, maxY, 0.0F).tex(0F, 0F).color4f(color).endVertex();
@ -284,7 +283,7 @@ public class FontRenderer implements IFontRenderer
}
@Override
public String trimStringToWidth(String text, float limit, boolean reverse)
public String trimToWidth(String text, float limit, boolean reverse)
{
StringBuilder builder = new StringBuilder();
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)
{
char letter = text.charAt(i);
width += getCharLength(letter);
width += width(letter);
if(width > limit) break;
if(reverse) builder.insert(0, letter);
else builder.append(letter);
@ -302,7 +301,7 @@ public class FontRenderer implements IFontRenderer
}
@Override
public float getCharLength(int codepoint, boolean bold)
public float width(int codepoint, boolean bold)
{
switch(codepoint)
{
@ -317,7 +316,7 @@ public class FontRenderer implements IFontRenderer
}
@Override
public float getTextLength(String text, int flags)
public float width(String text, int flags)
{
float result = 0.0F;
float current = 0.0F;
@ -344,13 +343,13 @@ public class FontRenderer implements IFontRenderer
continue;
}
}
current += getCharLength(character, bold);
current += width(character, bold);
}
return Math.max(result, current);
}
@Override
public float[] getTextLengths(String text, int flags)
public float[] widths(String text, int flags)
{
FloatList results = new FloatArrayList();
results.add(0F);
@ -383,7 +382,7 @@ public class FontRenderer implements IFontRenderer
continue;
}
}
current += getCharLength(character, bold);
current += width(character, bold);
}
if(chars++ > 0)
{
@ -395,9 +394,9 @@ public class FontRenderer implements IFontRenderer
}
@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
@ -407,7 +406,7 @@ public class FontRenderer implements IFontRenderer
}
@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));
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 SPECIAL = 2;
public float getFontHeight();
public float getBaseLine();
public float height();
public float baseLine();
public ITexture getTexture();
public CharInstance getInstance(int codepoint, boolean bold);
public void updateText(TextComponent component);
public default String trimStringToWidth(String text, float limit){return trimStringToWidth(text, limit, false);}
public String trimStringToWidth(String text, float limit, boolean reverse);
public default String trimToWidth(String text, float limit){return trimToWidth(text, limit, false);}
public String trimToWidth(String text, float limit, boolean reverse);
public default float getCharLength(int codepoint){return getCharLength(codepoint, false);};
public float getCharLength(int codepoint, boolean bold);
public default float width(int codepoint){return width(codepoint, false);};
public float width(int codepoint, boolean bold);
public default float getTextLength(String text){return getTextLength(text, 0);};
public float getTextLength(String text, int flags);
public float[] getTextLengths(String text, int flags);
public default float width(String text){return width(text, 0);};
public float width(String text, int flags);
public float[] widths(String text, int flags);
public default float getTextHeight(String text){return getTextHeight(text, 0);};
public float getTextHeight(String text, int flags);
public default float height(String text){return height(text, 0);};
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 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.utils.Stack;
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.vector.floats.Vec2f;
import speiger.src.coreengine.math.vector.floats.Vec3f;
@ -347,6 +346,7 @@ public class UIRenderer implements IReloadableResource
last = call.getCount();
callPool.accept(call);
}
activeCalls.clear();
texturedModel.unbindArray();
shader.stopShader();
renderer.resetVertexes();
@ -414,22 +414,22 @@ public class UIRenderer implements IReloadableResource
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);
}
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);
}
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);
}
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);
applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper);
@ -443,22 +443,22 @@ public class UIRenderer implements IReloadableResource
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);
}
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);
}
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);
}
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);
applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper);
@ -472,21 +472,21 @@ public class UIRenderer implements IReloadableResource
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);
}
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);
}
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())
{
ColorObject wrapper = start;
int wrapper = start;
start = end;
end = wrapper;
}
@ -502,22 +502,22 @@ public class UIRenderer implements IReloadableResource
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);
}
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);
}
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);
}
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);
applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper);
@ -533,12 +533,12 @@ public class UIRenderer implements IReloadableResource
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);
}
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);
applyAlignment(minX, minY, maxX, maxY, zLevel, alignHelper);
@ -578,7 +578,7 @@ public class UIRenderer implements IReloadableResource
return this;
}
public UIRenderer color(ColorObject color)
public UIRenderer color(int color)
{
renderer.color4f(color);
return this;
@ -702,7 +702,7 @@ public class UIRenderer implements IReloadableResource
private int getDrawCall()
{
return activeCalls.isEmpty() ? 0 : activeCalls.last().getCount();
return activeCalls.isEmpty() ? 0 : activeCalls.last().getCount();
}
private int getTextureId(ITexture texture)

View File

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

View File

@ -36,7 +36,7 @@ public class TextMetadata
{
lines.add(line);
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)
@ -117,7 +117,7 @@ public class TextMetadata
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)
@ -127,7 +127,7 @@ public class TextMetadata
result.negate();
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);
}

View File

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

View File

@ -11,8 +11,8 @@ public interface IFontProvider
public ITexture getTexture();
public boolean isCharacterValid(int codePoint);
public CharInstance getCharacter(int codePoint, boolean bold);
public float getFontHeight();
public float getBaseLine();
public float height();
public float baseLine();
public float getSpaceWidth();
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.AssetManager;
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.helpers.JsonUtil;
@ -76,7 +76,7 @@ public class ModelLoader
String[] position = data[0].split(";");
String[] normal = data[2].split(";");
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]));
}
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)
{
Object2ObjectMap<String, List<Number>> mappedData = Object2ObjectMap.createLinkedMap();
Object2ObjectMap<String, List<Number>> mappedData = Object2ObjectMap.builder().linkedMap();
int stride = VertexEntry.caclulateStride(entries);
int[] vertexes = JsonUtil.parseIntArray(obj.getAsJsonArray("vertexes"));
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 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.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)

View File

@ -2,7 +2,7 @@ package speiger.src.coreengine.rendering.shader.uniforms;
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.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);
storeData(STORAGE.set(ColorUtils.getRF(color), ColorUtils.getGF(color), ColorUtils.getBF(color), ColorUtils.getAF(color)));
}
public void storeData(float x, float y, float z, float w)

View File

@ -1,6 +1,6 @@
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.Vec3f;
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 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 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 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);
final IDynamicDataHandler<T> manager;
Int2ObjectMap<DataSlot> slots = Int2ObjectMap.createLinkedMap();
Int2ObjectMap<DataSlot> slots = Int2ObjectMap.builder().linkedMap();
Set<DataSlot> emptySlots = new ObjectAVLTreeSet<>();
IntSet changedSlots = new IntAVLTreeSet();
DataSlot lastSlot = null;

View File

@ -3,7 +3,7 @@ package speiger.src.coreengine.utils.helpers;
import java.text.DecimalFormat;
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.LogLevel;
@ -19,10 +19,10 @@ public class TextUtil
return "§<color"+(color == null ? "" : "="+color.intValue())+">";
}
public static ColorObject getColorFromText(String s)
public static int getColorFromText(String 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)
@ -62,14 +62,14 @@ public class TextUtil
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))
{
try
{
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)
{

View File

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

View File

@ -28,6 +28,13 @@ public class MapTag implements IMapTag
public MapTag()
{
}
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
public int getId()

View File

@ -4,7 +4,7 @@ import java.io.File;
import java.util.StringJoiner;
import speiger.src.collections.objects.lists.ObjectList;
import speiger.src.collections.objects.sets.ObjectSortedSet;
import speiger.src.collections.objects.sets.ObjectOrderedSet;
public interface IFileFinder
{
@ -14,9 +14,9 @@ public interface IFileFinder
public static final int ANY = 4;
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(",");
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.ObjectList;
import speiger.src.collections.objects.sets.ObjectSortedSet;
import speiger.src.collections.objects.sets.ObjectOrderedSet;
public class JavaFileFinder implements IFileFinder
{
public static final IFileFinder INSTANCE = new JavaFileFinder();
@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);
if((flags & FOLDER) != 0) file.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@ -41,9 +41,9 @@ public class JavaFileFinder implements IFileFinder
private static class Filter extends FileFilter
{
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(", ", " (", ")");
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.ObjectList;
import speiger.src.collections.objects.sets.ObjectSortedSet;
import speiger.src.collections.objects.sets.ObjectOrderedSet;
public class NativeFileFinder implements IFileFinder
{
public static final IFileFinder INSTANCE = new NativeFileFinder();
@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<>();
if((flags & SAVE) != 0)

View File

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