ColorObject is now color Utils. no longer object wrapping.
This commit is contained in:
parent
df67199fdd
commit
f550becac5
|
@ -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.
|
@ -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));
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||