gui and text drawing, gui misc

This commit is contained in:
Sen 2025-03-19 21:54:09 +01:00
parent c906760bd4
commit 4ec8affe85
37 changed files with 799 additions and 646 deletions

View file

@ -735,7 +735,7 @@ public class Game implements IThreadListener {
Drawing.drawTextbox(String.format(TextColor.GREEN + "%d " + TextColor.GRAY + "/ " + TextColor.NEON + "%d", value, max), x, y, 0x3f000000);
// Drawing.drawRectColor(x, y + 20, 250, 10, 0xff000000);
Drawing.drawRect2GradBorder(x, y + 20, 250, 10, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff9f9f9f, 0xff9f9f9f, 0xff6f6f6f);
Drawing.drawGradient(x + 2 + 246 - w, y + 20 + 2, w, 6, color | 0xff000000, Drawing.mixColor(color | 0xff000000, 0xff000000));
Drawing.drawGradient(x + 2 + 246 - w, y + 20 + 2, w, 6, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
return y + 40;
}
@ -744,7 +744,7 @@ public class Game implements IThreadListener {
// Drawing.drawRectColor(x, y + 20, 250, 10, 0xff000000);
// Drawing.drawRectColor(x, y + 20, (int)(250.0f * fill), 10, color | 0xff000000);
Drawing.drawRect2GradBorder(x, y + 20, 250, 10, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff9f9f9f, 0xff9f9f9f, 0xff6f6f6f);
Drawing.drawGradient(x + 2, y + 20 + 2, (int)(246.0f * fill), 6, color | 0xff000000, Drawing.mixColor(color | 0xff000000, 0xff000000));
Drawing.drawGradient(x + 2, y + 20 + 2, (int)(246.0f * fill), 6, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000));
return y + 40;
}
@ -755,10 +755,8 @@ public class Game implements IThreadListener {
this.renderWorldDirections((float)Timing.tick_fraction);
}
else {
Drawing.drawRectColor(this.fb_x / 2 - 1, this.fb_y / 2 - 16, 2, 32,
this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf);
Drawing.drawRectColor(this.fb_x / 2 - 16, this.fb_y / 2 - 1, 32, 2,
this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf);
Drawing.drawRect(this.fb_x / 2 - 1, this.fb_y / 2 - 16, 2, 32, this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf);
Drawing.drawRect(this.fb_x / 2 - 16, this.fb_y / 2 - 1, 32, 2, this.pointed != null && this.pointed.type != ObjectType.MISS ? 0xffffffff : 0xffcfcfcf);
}
}
if(this.theWorld != null && this.open == null) {
@ -775,7 +773,7 @@ public class Game implements IThreadListener {
ItemStack itemstack = this.thePlayer != null ? this.thePlayer.inventory.getCurrentItem() : null;
String current = itemstack != null ? itemstack.getItem().getHotbarText(this.thePlayer, itemstack) : "";
if(!current.isEmpty())
Drawing.drawTextUpward(current, this.fb_x / 2, this.fb_y - 80, 0xffffffff);
Drawing.drawTextUpward(current, this.fb_x / 2, this.fb_y - 60, 0xffffffff);
}
if(this.theWorld != null && !(this.open instanceof GuiConsole)) {
int x = this.fb_x / 2;
@ -793,8 +791,7 @@ public class Game implements IThreadListener {
entity.getMaxHealth() + TextColor.GRAY + "]";
Drawing.drawTextboxCentered(s, x, y, 0x3f000000);
Drawing.drawRect2GradBorder(x - 200, y + 20, 400, 10, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff9f9f9f, 0xff9f9f9f, 0xff6f6f6f);
Drawing.drawGradient(x - 200 + 2, y + 20 + 2, (int)(396.0f * ((float)entity.getHealth() / (float)entity.getMaxHealth())), 6, entity.getColor() | 0xff000000,
Drawing.mixColor(entity.getColor() | 0xff000000, 0xff000000));
Drawing.drawGradient(x - 200 + 2, y + 20 + 2, (int)(396.0f * ((float)entity.getHealth() / (float)entity.getMaxHealth())), 6, entity.getColor() | 0xff000000, Util.mixColor(entity.getColor() | 0xff000000, 0xff000000));
// Drawing.drawRectColor(x - 200, y + 20, 400, 10, 0xff000000);
// Drawing.drawRectColor(x - 200, y + 20, , 0xff000000 | );
y += 40;
@ -813,9 +810,9 @@ public class Game implements IThreadListener {
String name = (potion.isBadEffect() ? TextColor.ORANGE : TextColor.ACID) + potion.getDisplay() + PotionHelper.getPotionPotency(effect.getAmplifier());
String desc = TextColor.NEON + Potion.getDurationString(effect);
// Drawing.drawRectColor(x, y, 250, Font.DEFAULT.yglyph + 2, color | 0xff000000);
Drawing.drawGradient2GradBorder(x, y, 250, Font.YGLYPH + 4, color | 0xff000000, Drawing.mixColor(color | 0xff000000, 0xff000000), 0xff202020, 0xffcfcfcf, 0xff9f9f9f, 0xff9f9f9f, 0xff6f6f6f);
Drawing.drawText(name, x + 2 + 2, y + 2, 0xffffffff);
Drawing.drawTextRight(desc, x + 250 - 2, y + 2, 0xffffffff);
Drawing.drawGradient2GradBorder(x, y, 250, Font.YGLYPH + 4, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000), 0xff202020, 0xffcfcfcf, 0xff9f9f9f, 0xff9f9f9f, 0xff6f6f6f);
Drawing.drawText(name, x + 4, y + 2, 0xffffffff);
Drawing.drawTextRight(desc, x + 250 - 4, y + 2, 0xffffffff);
y += 24;
}
}
@ -950,11 +947,7 @@ public class Game implements IThreadListener {
this.renderStats();
}
else {
String str = String.format("%s%.2f", framecode(), Timing.framerate);
Drawing.txt_draw(0, 0,
0, 0,
this.fb_x, this.fb_y,
0xffffffff, str);
Drawing.drawText(String.format("%s%.2f", framecode(), Timing.framerate), 0, 0, 0xffffffff);
}
}
GlState.enableBlend();
@ -994,10 +987,7 @@ public class Game implements IThreadListener {
// if(str)
// (*jsys.env)->ReleaseStringUTFChars(jsys.env, jstr, str);
// gui_render_text(elem, 0, 0, sys.style.text_label, sys.work_buf);
Drawing.txt_draw(0, 0,
0, 0,
this.fb_x, this.fb_y,
0xffffffff, draw);
Drawing.drawText(draw, 0, 0, 0xffffffff);
str = this.getRight(false);
// str = jstr ? (*jsys.env)->GetStringUTFChars(jsys.env, jstr, NULL) : NULL;
@ -1008,8 +998,7 @@ public class Game implements IThreadListener {
sb.append('\n');
sb.append(perf.getName());
}
Drawing.txt_draw(x1 + 0, y1, x1 + 0, y1, x1 + 120, y2,
this.style.text_label, sb.toString());
Drawing.drawText(sb.toString(), x1 + 0, y1, 0xffffffff);
// pos = 0;
sb.setLength(0);
for(PerfSection perf : PerfSection.values()) {
@ -1017,8 +1006,7 @@ public class Game implements IThreadListener {
sb.append('\n');
sb.append(String.format("%.3f ms", (float)perf.getLast() / 1000.0f));
}
Drawing.txt_draw(x1 + 120, y1, x1 + 120, y1, x1 + 240, y2,
this.style.text_label, sb.toString());
Drawing.drawText(sb.toString(), x1 + 120, y1, 0xffffffff);
// pos = 0;
sb.setLength(0);
long total = PerfSection.getTotal(true);
@ -1027,12 +1015,10 @@ public class Game implements IThreadListener {
sb.append('\n');
sb.append(String.format("%.2f %%", ((float)perf.getLast() / (float)total) * 100.0f));
}
Drawing.txt_draw(x1 + 240, y1, x1 + 240, y1, x1 + 320, y2,
this.style.text_label, sb.toString());
Drawing.drawText(sb.toString(), x1 + 240, y1, 0xffffffff);
if(str != null) {
y1 = Font.YGLYPH * 10;
Drawing.txt_draw(x1, y1, x1, y1, x1 + 320, y1 + Font.YGLYPH * 12,
this.style.text_label, str);
Drawing.drawText(str, x1, y1, 0xffffffff);
// (*jsys.env)->ReleaseStringUTFChars(jsys.env, jstr, str);
}
}
@ -2992,7 +2978,7 @@ public class Game implements IThreadListener {
int y = 10 + by * Font.YGLYPH;
Drawing.drawGradient(x, y, 300, Font.YGLYPH, 0x7f404040, 0x7f000000);
Drawing.drawText(elem.getKey(), x + 4, y, 0xffffffff);
Drawing.drawTextRight(formatPing(elem.getValue()), x + 299, y, 0xffffffff);
Drawing.drawTextRight(formatPing(elem.getValue()), x + 300 - 4, y, 0xffffffff);
if(++bx >= w) {
bx = 0;
++by;