gui and text drawing, gui misc
This commit is contained in:
parent
c906760bd4
commit
4ec8affe85
37 changed files with 799 additions and 646 deletions
|
@ -5,6 +5,7 @@ import game.color.TextColor;
|
|||
import game.gui.Font;
|
||||
import game.gui.FontChar;
|
||||
import game.log.Log;
|
||||
import game.util.Util;
|
||||
|
||||
public abstract class Drawing {
|
||||
public static class Vec2i {
|
||||
|
@ -25,11 +26,6 @@ public abstract class Drawing {
|
|||
this.offset = off;
|
||||
}
|
||||
}
|
||||
|
||||
// private static final int FLAG_ULINE = 0x01;
|
||||
// private static final int FLAG_CLINE = 0x02;
|
||||
// private static final int FLAG_BLINK = 0x04;
|
||||
// private static final int FLAG_FADE = 0x08;
|
||||
|
||||
// public static void drawTexturedModalRect(int tw, int th, int x, int y, int textureX, int textureY, int width, int height)
|
||||
// {
|
||||
|
@ -42,35 +38,6 @@ public abstract class Drawing {
|
|||
// rb.pos((double)(x + width), (double)(y + 0), 0.0).tex((double)((float)(textureX + width) * xs), (double)((float)(textureY + 0) * ys)).endVertex();
|
||||
// rb.pos((double)(x + 0), (double)(y + 0), 0.0).tex((double)((float)(textureX + 0) * xs), (double)((float)(textureY + 0) * ys)).endVertex();
|
||||
// Tessellator.draw();
|
||||
// }
|
||||
|
||||
public static void drawTexturedModalRect(RenderBuffer rb, int tw, int th, int x, int y, int textureX, int textureY, int width, int height, int color)
|
||||
{
|
||||
float xs = 1.0f / (float)tw; // 0.00390625F;
|
||||
float ys = 1.0f / (float)th; // 0.00390625F;
|
||||
rb.pos((double)(x + 0), (double)(y + height), 0.0).tex((double)((float)(textureX + 0) * xs), (double)((float)(textureY + height) * ys)).color(color).endVertex();
|
||||
rb.pos((double)(x + width), (double)(y + height), 0.0).tex((double)((float)(textureX + width) * xs), (double)((float)(textureY + height) * ys)).color(color).endVertex();
|
||||
rb.pos((double)(x + width), (double)(y + 0), 0.0).tex((double)((float)(textureX + width) * xs), (double)((float)(textureY + 0) * ys)).color(color).endVertex();
|
||||
rb.pos((double)(x + 0), (double)(y + 0), 0.0).tex((double)((float)(textureX + 0) * xs), (double)((float)(textureY + 0) * ys)).color(color).endVertex();
|
||||
}
|
||||
|
||||
private static void color(int c) {
|
||||
float a = (float)(c >> 24 & 255) / 255.0F;
|
||||
float r = (float)(c >> 16 & 255) / 255.0F;
|
||||
float g = (float)(c >> 8 & 255) / 255.0F;
|
||||
float b = (float)(c & 255) / 255.0F;
|
||||
GlState.color(r, g, b, a);
|
||||
}
|
||||
|
||||
// private static void trect(int left, int top, int right, int bottom)
|
||||
// {
|
||||
// RenderBuffer worldrenderer = Tessellator.getBuffer();
|
||||
// worldrenderer.begin(7, DefaultVertexFormats.POSITION);
|
||||
// worldrenderer.pos((double)left, (double)bottom, 0.0D).endVertex();
|
||||
// worldrenderer.pos((double)right, (double)bottom, 0.0D).endVertex();
|
||||
// worldrenderer.pos((double)right, (double)top, 0.0D).endVertex();
|
||||
// worldrenderer.pos((double)left, (double)top, 0.0D).endVertex();
|
||||
// Tessellator.draw();
|
||||
// }
|
||||
|
||||
public static void txt_draw(int x, int y, int x1, int y1, int x2, int y2, int color, String str) {
|
||||
|
@ -88,7 +55,6 @@ public abstract class Drawing {
|
|||
FontChar glyph;
|
||||
char ch;
|
||||
int ncolor = color;
|
||||
// color(color);
|
||||
for(int z = 0; z < str.length(); z++) {
|
||||
ch = str.charAt(z);
|
||||
if(ch == Log.CHR_NLN) {
|
||||
|
@ -96,19 +62,11 @@ public abstract class Drawing {
|
|||
y += h;
|
||||
continue;
|
||||
}
|
||||
// else if(ch >= Log.CHR_ULINE && ch <= Log.CHR_FADE) {
|
||||
// continue;
|
||||
// }
|
||||
else if((ch >= Log.CHR_COLORS1 && ch <= Log.CHR_COLORE1) || (ch >= Log.CHR_COLORS2 && ch <= Log.CHR_COLORE2)) {
|
||||
// color(TextColor.getColor(ch) | (color & 0xff000000));
|
||||
ncolor = TextColor.getColor(ch) | (color & 0xff000000);
|
||||
continue;
|
||||
}
|
||||
// else if(ch == Log.CHR_FRESET) {
|
||||
// continue;
|
||||
// }
|
||||
else if(ch == Log.CHR_CRESET) {
|
||||
// color(color);
|
||||
ncolor = color;
|
||||
continue;
|
||||
}
|
||||
|
@ -128,7 +86,7 @@ public abstract class Drawing {
|
|||
if(x < x1 || y < y1 || x > x2 || y > y2) {
|
||||
break;
|
||||
}
|
||||
drawTexturedModalRect(rb, Font.XGLYPH * 16, Font.YGLYPH * 16, x, y, (ch & 0x0f) * Font.XGLYPH + glyph.s, ((ch & 0xf0) >> 4) * Font.YGLYPH, glyph.u, h, ncolor);
|
||||
putGlyph(rb, Font.XGLYPH * 16, Font.YGLYPH * 16, x, y, (ch & 0x0f) * Font.XGLYPH + glyph.s, ((ch & 0xf0) >> 4) * Font.YGLYPH, glyph.u, h, ncolor, 0.0);
|
||||
x += u;
|
||||
}
|
||||
Tessellator.draw();
|
||||
|
@ -138,7 +96,7 @@ public abstract class Drawing {
|
|||
GlState.enableTexture2D();
|
||||
}
|
||||
|
||||
public static void txt_draw_range(int start, int end, int x, int y, int x1, int y1, int x2, int y2, int back, String str) {
|
||||
public static void txt_overlay(int start, int end, int x, int y, int x1, int y1, int x2, int y2, int back, String str) {
|
||||
int h = Font.YGLYPH;
|
||||
int tx, ty, u, v;
|
||||
FontChar glyph;
|
||||
|
@ -186,7 +144,7 @@ public abstract class Drawing {
|
|||
// shd.setVec2("size", (float)u, (float)v);
|
||||
// shd.setVec4("glyph", (float)glyph.s, 0.0f, (float)glyph.u, (float)h);
|
||||
// shd.draw();
|
||||
drawRect(x, y, x + u, y + v, back);
|
||||
drawRect(x, y, u, v, back);
|
||||
}
|
||||
x += u;
|
||||
}
|
||||
|
@ -231,45 +189,6 @@ public abstract class Drawing {
|
|||
return new Vec2i(x - ix, y - iy);
|
||||
}
|
||||
|
||||
public static Vec2i txt_box(int x, int y, int x1, int y1, int x2, int y2, String str) {
|
||||
int h = Font.YGLYPH;
|
||||
int ix = x;
|
||||
// int iy = y;
|
||||
int tx, ty, u, v;
|
||||
FontChar glyph;
|
||||
char ch;
|
||||
for(int z = 0; z < str.length(); z++) {
|
||||
ch = str.charAt(z);
|
||||
if(ch == Log.CHR_NLN) {
|
||||
x = x1;
|
||||
y += h;
|
||||
continue;
|
||||
}
|
||||
else if(ch < Log.CHR_SPC) {
|
||||
continue;
|
||||
}
|
||||
if(ch >= 256)
|
||||
ch = Log.CHR_UNK;
|
||||
glyph = Font.SIZES[ch];
|
||||
if(glyph.u == 0 && glyph.v != 0)
|
||||
continue;
|
||||
else if(glyph.u == 0)
|
||||
glyph = Font.SIZES[Log.CHR_UNK];
|
||||
u = glyph.u + 3 - glyph.s;
|
||||
v = h;
|
||||
tx = ((x + u) > x2) ? x1 : x;
|
||||
ty = ((x + u) > x2) ? y + h : y;
|
||||
x = tx;
|
||||
y = ty;
|
||||
if(x < x1 || y < y1 || x > x2 || y > y2) {
|
||||
break;
|
||||
}
|
||||
x += u;
|
||||
ix = x > ix ? x : ix;
|
||||
}
|
||||
return new Vec2i(ix - 2, y + h);
|
||||
}
|
||||
|
||||
public static Vec2i txt_coord(int offset, int x, int y, int x1, int y1, int x2, int y2, String str) {
|
||||
int h = Font.YGLYPH;
|
||||
int tx, ty, u, v;
|
||||
|
@ -368,43 +287,129 @@ public abstract class Drawing {
|
|||
}
|
||||
return new Offset(pos, x, y);
|
||||
}
|
||||
|
||||
// public static void gfx_blit(int tex) {
|
||||
// ShaderContext shd = Shader.BLIT.use();
|
||||
// GlState.bindTexture(tex);
|
||||
// shd.draw();
|
||||
// shd.discard();
|
||||
// }
|
||||
|
||||
public static void drawGradientRect(int left, int top, int right, int bottom, int ctop, int cbottom)
|
||||
|
||||
private static void putGlyph(RenderBuffer rb, int tw, int th, int x, int y, int textureX, int textureY, int width, int height, int color, double depth)
|
||||
{
|
||||
float at = (float)(ctop >> 24 & 255) / 255.0F;
|
||||
float rt = (float)(ctop >> 16 & 255) / 255.0F;
|
||||
float gt = (float)(ctop >> 8 & 255) / 255.0F;
|
||||
float bt = (float)(ctop & 255) / 255.0F;
|
||||
float ab = (float)(cbottom >> 24 & 255) / 255.0F;
|
||||
float rb = (float)(cbottom >> 16 & 255) / 255.0F;
|
||||
float gb = (float)(cbottom >> 8 & 255) / 255.0F;
|
||||
float bb = (float)(cbottom & 255) / 255.0F;
|
||||
GlState.disableTexture2D();
|
||||
float xs = 1.0f / (float)tw;
|
||||
float ys = 1.0f / (float)th;
|
||||
rb.pos((double)(x + 0), (double)(y + height), depth).tex((double)((float)(textureX + 0) * xs), (double)((float)(textureY + height) * ys)).color(color).endVertex();
|
||||
rb.pos((double)(x + width), (double)(y + height), depth).tex((double)((float)(textureX + width) * xs), (double)((float)(textureY + height) * ys)).color(color).endVertex();
|
||||
rb.pos((double)(x + width), (double)(y + 0), depth).tex((double)((float)(textureX + width) * xs), (double)((float)(textureY + 0) * ys)).color(color).endVertex();
|
||||
rb.pos((double)(x + 0), (double)(y + 0), depth).tex((double)((float)(textureX + 0) * xs), (double)((float)(textureY + 0) * ys)).color(color).endVertex();
|
||||
}
|
||||
|
||||
public static void drawText(String str, int x, int y, int color, boolean shadow) {
|
||||
GlState.enableTexture2D();
|
||||
GlState.enableBlend();
|
||||
GlState.disableAlpha();
|
||||
GlState.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlState.shadeModel(7425);
|
||||
RenderBuffer buf = Tessellator.getBuffer();
|
||||
buf.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
buf.pos((double)right, (double)top, 0.0).color(rt, gt, bt, at).endVertex();
|
||||
buf.pos((double)left, (double)top, 0.0).color(rt, gt, bt, at).endVertex();
|
||||
buf.pos((double)left, (double)bottom, 0.0).color(rb, gb, bb, ab).endVertex();
|
||||
buf.pos((double)right, (double)bottom, 0.0).color(rb, gb, bb, ab).endVertex();
|
||||
GlState.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Font.bindTexture();
|
||||
RenderBuffer rb = Tessellator.getBuffer();
|
||||
rb.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
int ox = x;
|
||||
int ncolor = color;
|
||||
FontChar glyph;
|
||||
char ch;
|
||||
if(shadow) {
|
||||
int oy = y;
|
||||
int scolor = Util.mixColor(color, color & 0xff000000);
|
||||
scolor = Util.mixColor(scolor, scolor & 0xff000000);
|
||||
int bcolor = scolor;
|
||||
for(int z = 0; z < str.length(); z++) {
|
||||
ch = str.charAt(z);
|
||||
if(ch == Log.CHR_NLN) {
|
||||
x = ox;
|
||||
y += Font.YGLYPH;
|
||||
continue;
|
||||
}
|
||||
else if((ch >= Log.CHR_COLORS1 && ch <= Log.CHR_COLORE1) || (ch >= Log.CHR_COLORS2 && ch <= Log.CHR_COLORE2)) {
|
||||
bcolor = TextColor.getShadow(ch) | (scolor & 0xff000000);
|
||||
continue;
|
||||
}
|
||||
else if(ch == Log.CHR_CRESET) {
|
||||
bcolor = scolor;
|
||||
continue;
|
||||
}
|
||||
if(ch >= 256)
|
||||
ch = Log.CHR_UNK;
|
||||
glyph = Font.SIZES[ch];
|
||||
if(glyph.u == 0 && glyph.v != 0)
|
||||
continue;
|
||||
else if(glyph.u == 0)
|
||||
glyph = Font.SIZES[Log.CHR_UNK];
|
||||
putGlyph(rb, Font.XGLYPH * 16, Font.YGLYPH * 16, x + 1, y + 1, (ch & 0x0f) * Font.XGLYPH + glyph.s, ((ch & 0xf0) >> 4) * Font.YGLYPH, glyph.u, Font.YGLYPH, bcolor, -0.01);
|
||||
x += glyph.u + 3 - glyph.s;
|
||||
}
|
||||
x = ox;
|
||||
y = oy;
|
||||
}
|
||||
for(int z = 0; z < str.length(); z++) {
|
||||
ch = str.charAt(z);
|
||||
if(ch == Log.CHR_NLN) {
|
||||
x = ox;
|
||||
y += Font.YGLYPH;
|
||||
continue;
|
||||
}
|
||||
else if((ch >= Log.CHR_COLORS1 && ch <= Log.CHR_COLORE1) || (ch >= Log.CHR_COLORS2 && ch <= Log.CHR_COLORE2)) {
|
||||
ncolor = TextColor.getColor(ch) | (color & 0xff000000);
|
||||
continue;
|
||||
}
|
||||
else if(ch == Log.CHR_CRESET) {
|
||||
ncolor = color;
|
||||
continue;
|
||||
}
|
||||
if(ch >= 256)
|
||||
ch = Log.CHR_UNK;
|
||||
glyph = Font.SIZES[ch];
|
||||
if(glyph.u == 0 && glyph.v != 0)
|
||||
continue;
|
||||
else if(glyph.u == 0)
|
||||
glyph = Font.SIZES[Log.CHR_UNK];
|
||||
putGlyph(rb, Font.XGLYPH * 16, Font.YGLYPH * 16, x, y, (ch & 0x0f) * Font.XGLYPH + glyph.s, ((ch & 0xf0) >> 4) * Font.YGLYPH, glyph.u, Font.YGLYPH, ncolor, -0.02);
|
||||
x += glyph.u + 3 - glyph.s;
|
||||
}
|
||||
Tessellator.draw();
|
||||
GlState.shadeModel(7424);
|
||||
GlState.disableBlend();
|
||||
GlState.enableAlpha();
|
||||
GlState.enableTexture2D();
|
||||
}
|
||||
}
|
||||
|
||||
public static Vec2i getSize(String str) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int ix = 0;
|
||||
FontChar glyph;
|
||||
char ch;
|
||||
for(int z = 0; z < str.length(); z++) {
|
||||
ch = str.charAt(z);
|
||||
if(ch == Log.CHR_NLN) {
|
||||
ix = x > ix ? x : ix;
|
||||
x = 0;
|
||||
y += Font.YGLYPH;
|
||||
continue;
|
||||
}
|
||||
else if(ch < Log.CHR_SPC) {
|
||||
continue;
|
||||
}
|
||||
if(ch >= 256)
|
||||
ch = Log.CHR_UNK;
|
||||
glyph = Font.SIZES[ch];
|
||||
if(glyph.u == 0 && glyph.v != 0)
|
||||
continue;
|
||||
else if(glyph.u == 0)
|
||||
glyph = Font.SIZES[Log.CHR_UNK];
|
||||
x += glyph.u + 3 - glyph.s;
|
||||
ix = x > ix ? x : ix;
|
||||
}
|
||||
return new Vec2i(ix - 3, y + Font.YGLYPH);
|
||||
}
|
||||
|
||||
public static void draw4GradientRect(int left, int top, int right, int bottom, int lopleft, int topright, int btmleft, int btmright)
|
||||
|
||||
public static void drawGradient(int x, int y, int w, int h, int ctop, int cbottom)
|
||||
{
|
||||
GlState.disableTexture2D();
|
||||
GlState.enableBlend();
|
||||
|
@ -413,10 +418,10 @@ public abstract class Drawing {
|
|||
GlState.shadeModel(7425);
|
||||
RenderBuffer buf = Tessellator.getBuffer();
|
||||
buf.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
buf.pos((double)right, (double)top, 0.0).color(topright).endVertex();
|
||||
buf.pos((double)left, (double)top, 0.0).color(lopleft).endVertex();
|
||||
buf.pos((double)left, (double)bottom, 0.0).color(btmleft).endVertex();
|
||||
buf.pos((double)right, (double)bottom, 0.0).color(btmright).endVertex();
|
||||
buf.pos((double)(x + w), (double)y, 0.0).color(ctop).endVertex();
|
||||
buf.pos((double)x, (double)y, 0.0).color(ctop).endVertex();
|
||||
buf.pos((double)x, (double)(y + h), 0.0).color(cbottom).endVertex();
|
||||
buf.pos((double)(x + w), (double)(y + h), 0.0).color(cbottom).endVertex();
|
||||
Tessellator.draw();
|
||||
GlState.shadeModel(7424);
|
||||
GlState.disableBlend();
|
||||
|
@ -424,38 +429,40 @@ public abstract class Drawing {
|
|||
GlState.enableTexture2D();
|
||||
}
|
||||
|
||||
public static void drawRect(int left, int top, int right, int bottom, int color)
|
||||
public static void draw4Gradient(int x, int y, int w, int h, int lopleft, int topright, int btmleft, int btmright)
|
||||
{
|
||||
if (left < right)
|
||||
{
|
||||
int i = left;
|
||||
left = right;
|
||||
right = i;
|
||||
}
|
||||
|
||||
if (top < bottom)
|
||||
{
|
||||
int j = top;
|
||||
top = bottom;
|
||||
bottom = j;
|
||||
}
|
||||
|
||||
float f3 = (float)(color >> 24 & 255) / 255.0F;
|
||||
float f = (float)(color >> 16 & 255) / 255.0F;
|
||||
float f1 = (float)(color >> 8 & 255) / 255.0F;
|
||||
float f2 = (float)(color & 255) / 255.0F;
|
||||
RenderBuffer worldrenderer = Tessellator.getBuffer();
|
||||
GlState.disableTexture2D();
|
||||
GlState.enableBlend();
|
||||
GlState.disableAlpha();
|
||||
GlState.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlState.shadeModel(7425);
|
||||
RenderBuffer buf = Tessellator.getBuffer();
|
||||
buf.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
buf.pos((double)(x + w), (double)y, 0.0).color(topright).endVertex();
|
||||
buf.pos((double)x, (double)y, 0.0).color(lopleft).endVertex();
|
||||
buf.pos((double)x, (double)(y + h), 0.0).color(btmleft).endVertex();
|
||||
buf.pos((double)(x + w), (double)(y + h), 0.0).color(btmright).endVertex();
|
||||
Tessellator.draw();
|
||||
GlState.shadeModel(7424);
|
||||
GlState.disableBlend();
|
||||
GlState.enableAlpha();
|
||||
GlState.enableTexture2D();
|
||||
}
|
||||
|
||||
public static void drawRect(int x, int y, int w, int h, int color)
|
||||
{
|
||||
RenderBuffer rb = Tessellator.getBuffer();
|
||||
GlState.enableBlend();
|
||||
GlState.disableAlpha();
|
||||
GlState.disableTexture2D();
|
||||
GlState.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlState.shadeModel(7425);
|
||||
GlState.color(f, f1, f2, f3);
|
||||
worldrenderer.begin(7, DefaultVertexFormats.POSITION);
|
||||
worldrenderer.pos((double)left, (double)bottom, 0.0D).endVertex();
|
||||
worldrenderer.pos((double)right, (double)bottom, 0.0D).endVertex();
|
||||
worldrenderer.pos((double)right, (double)top, 0.0D).endVertex();
|
||||
worldrenderer.pos((double)left, (double)top, 0.0D).endVertex();
|
||||
GlState.color(color);
|
||||
rb.begin(7, DefaultVertexFormats.POSITION);
|
||||
rb.pos((double)x, (double)(y + h), 0.0D).endVertex();
|
||||
rb.pos((double)(x + w), (double)(y + h), 0.0D).endVertex();
|
||||
rb.pos((double)(x + w), (double)y, 0.0D).endVertex();
|
||||
rb.pos((double)x, (double)y, 0.0D).endVertex();
|
||||
Tessellator.draw();
|
||||
GlState.shadeModel(7424);
|
||||
GlState.enableTexture2D();
|
||||
|
@ -463,77 +470,59 @@ public abstract class Drawing {
|
|||
GlState.enableAlpha();
|
||||
GlState.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
// public static void gfx_draw_rect(int x, int y, int w, int h, int border, int top, int bottom, int b_top, int b_bottom) {
|
||||
// drawGradientRect(x, y, x + w, y + h, b_top, b_bottom);
|
||||
// drawGradientRect(x + border, y + border, x + w - border, y + h - border, top, bottom);
|
||||
// }
|
||||
|
||||
public static void drawRectColor(int x, int y, int w, int h, int color) {
|
||||
drawRect(x, y, x + w, y + h, color);
|
||||
|
||||
public static void drawBordered(int x, int y, int w, int h, int color, int border) {
|
||||
drawRect(x, y, w, h, border);
|
||||
drawRect(x + 1, y + 1, w - 2, h - 2, color);
|
||||
}
|
||||
|
||||
public static void drawGradient(int x, int y, int w, int h, int top, int bottom) {
|
||||
drawGradientRect(x, y, x + w, y + h, top, bottom);
|
||||
}
|
||||
|
||||
public static void drawRectBorder(int x, int y, int w, int h, int color, int border) {
|
||||
drawRect(x, y, x + w, y + h, border);
|
||||
drawRect(x + 1, y + 1, x + w - 1, y + h - 1, color);
|
||||
}
|
||||
|
||||
// public static void drawRect2Border(int x, int y, int w, int h, int color, int border) {
|
||||
// drawRect(x, y, x + w, y + h, border);
|
||||
// drawRect(x + 2, y + 2, x + w - 2, y + h - 2, color);
|
||||
// }
|
||||
|
||||
public static void drawRect2GradBorder(int x, int y, int w, int h, int color, int border, int lopleft, int topright, int btmleft, int btmright) {
|
||||
drawRect(x, y, x + w, y + h, border);
|
||||
draw4GradientRect(x + 1, y + 1, x + w - 1, y + h - 1, lopleft, topright, btmleft, btmright);
|
||||
drawRect(x + 2, y + 2, x + w - 2, y + h - 2, color);
|
||||
drawRect(x, y, w, h, border);
|
||||
draw4Gradient(x + 1, y + 1, w - 2, h - 2, lopleft, topright, btmleft, btmright);
|
||||
drawRect(x + 2, y + 2, w - 4, h - 4, color);
|
||||
}
|
||||
|
||||
public static void drawGradient2GradBorder(int x, int y, int w, int h, int top, int bottom, int border, int lopleft, int topright, int btmleft, int btmright) {
|
||||
drawRect(x, y, x + w, y + h, border);
|
||||
draw4GradientRect(x + 1, y + 1, x + w - 1, y + h - 1, lopleft, topright, btmleft, btmright);
|
||||
drawGradientRect(x + 2, y + 2, x + w - 2, y + h - 2, top, bottom);
|
||||
drawRect(x, y, w, h, border);
|
||||
draw4Gradient(x + 1, y + 1, w - 2, h - 2, lopleft, topright, btmleft, btmright);
|
||||
drawGradient(x + 2, y + 2, w - 4, h - 4, top, bottom);
|
||||
}
|
||||
|
||||
public static void drawGradient2Border(int x, int y, int w, int h, int top, int bottom, int b_top, int b_bottom) {
|
||||
drawGradientRect(x, y, x + w, y + h, b_top, b_bottom);
|
||||
drawGradientRect(x + 1, y + 1, x + w - 1, y + h - 1, top, bottom);
|
||||
drawGradient(x, y, w, h, b_top, b_bottom);
|
||||
drawGradient(x + 1, y + 1, w - 2, h - 2, top, bottom);
|
||||
}
|
||||
|
||||
public static Vec2i getSize(String str) {
|
||||
return txt_size(0, 0, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, str);
|
||||
}
|
||||
|
||||
public static int getWidth(String str) {
|
||||
return txt_size(0, 0, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, str).xpos;
|
||||
return getSize(str).xpos;
|
||||
}
|
||||
|
||||
public static int getBoxWidth(String str) {
|
||||
return txt_box(0, 0, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, str).xpos + 4;
|
||||
return getSize(str).xpos + 4;
|
||||
}
|
||||
|
||||
public static void drawTextbox(String str, int x, int y, int back) {
|
||||
Vec2i size = txt_box(x + 2, y, x + 2, y, Integer.MAX_VALUE, Integer.MAX_VALUE, str);
|
||||
drawRect(x, y, size.xpos + 2, size.ypos, back);
|
||||
txt_draw(x + 2, y, x + 2, y, Integer.MAX_VALUE, Integer.MAX_VALUE, 0xffffffff, str);
|
||||
Vec2i size = getSize(str);
|
||||
drawRect(x, y, size.xpos + 4, size.ypos, back);
|
||||
drawText(str, x + 2, y, 0xffffffff);
|
||||
}
|
||||
|
||||
public static void drawTextboxRight(String str, int x, int y, int back) {
|
||||
Vec2i size = getSize(str);
|
||||
drawTextbox(str, x - (size.xpos + 2), y, back);
|
||||
drawTextbox(str, x - getBoxWidth(str), y, back);
|
||||
}
|
||||
|
||||
public static void drawTextboxCentered(String str, int x, int y, int back) {
|
||||
Vec2i size = getSize(str);
|
||||
drawTextbox(str, x - (size.xpos + 2) / 2, y, back);
|
||||
drawTextbox(str, x - getBoxWidth(str) / 2, y, back);
|
||||
}
|
||||
|
||||
public static void drawText(String str, int x, int y, int color) {
|
||||
txt_draw(x, y, x, y, Integer.MAX_VALUE, Integer.MAX_VALUE, color, str);
|
||||
drawText(str, x, y, color, true);
|
||||
}
|
||||
|
||||
public static void drawTextCenteredN(String str, int x, int y, int color) {
|
||||
Vec2i size = getSize(str);
|
||||
drawText(str, x - size.xpos / 2, y, color, false);
|
||||
}
|
||||
|
||||
public static void drawTextCentered(String str, int x, int y, int color) {
|
||||
|
@ -551,11 +540,6 @@ public abstract class Drawing {
|
|||
drawText(str, x - size.xpos / 2, y - size.ypos, color);
|
||||
}
|
||||
|
||||
public static int mixColor(int c1, int c2) {
|
||||
return ((((c1 >> 24 & 255) + (c2 >> 24 & 255)) / 2) << 24) | ((((c1 >> 16 & 255) + (c2 >> 16 & 255)) / 2) << 16) | ((((c1 >> 8 & 255) + (c2 >> 8 & 255)) / 2) << 8) |
|
||||
(((c1 & 255) + (c2 & 255)) / 2);
|
||||
}
|
||||
|
||||
public static void drawScaledBackground(Game gm, String texture) {
|
||||
drawScaledBackground(gm, texture, 0, 0, gm.fb_x, gm.fb_y);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue