improve ping drawing + tab overlay
This commit is contained in:
parent
ecbc21d712
commit
05e00d389b
2 changed files with 29 additions and 55 deletions
|
@ -281,11 +281,9 @@ public class Client implements IThreadListener {
|
|||
public static final int LOG_BUFFER = 32768;
|
||||
public static final int MIN_WIDTH = 800;
|
||||
public static final int MIN_HEIGHT = 450;
|
||||
private static final LazyLoader<NioEventLoopGroup> CLIENT_NIO_EVENTLOOP = new LazyLoader<NioEventLoopGroup>()
|
||||
{
|
||||
protected NioEventLoopGroup load()
|
||||
{
|
||||
return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build());
|
||||
private static final LazyLoader<NioEventLoopGroup> CLIENT_NIO_EVENTLOOP = new LazyLoader<NioEventLoopGroup>() {
|
||||
protected NioEventLoopGroup load() {
|
||||
return new NioEventLoopGroup(0, new ThreadFactoryBuilder().setNameFormat("Netty Client IO #%d").setDaemon(true).build());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2998,62 +2996,38 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
private static String formatPing(int ping) {
|
||||
TextColor base;
|
||||
if(ping < 0) {
|
||||
base = TextColor.GRAY;
|
||||
private void drawPing(int x, int y, int ping) {
|
||||
int bars;
|
||||
TextColor color;
|
||||
if(ping < 0 || ping >= 20000) {
|
||||
bars = 0;
|
||||
color = ping < 0 ? TextColor.GRAY : TextColor.DRED;
|
||||
}
|
||||
else if(ping < 80) {
|
||||
base = TextColor.DGREEN;
|
||||
bars = ping < 50 ? 8 : 7;
|
||||
color = TextColor.GREEN;
|
||||
}
|
||||
else if(ping < 160) {
|
||||
base = TextColor.GREEN;
|
||||
bars = ping < 120 ? 6 : 5;
|
||||
color = TextColor.DGREEN;
|
||||
}
|
||||
else if(ping < 350) {
|
||||
base = TextColor.YELLOW;
|
||||
bars = ping < 220 ? 4 : 3;
|
||||
color = TextColor.YELLOW;
|
||||
}
|
||||
else if(ping < 700) {
|
||||
base = TextColor.RED;
|
||||
bars = ping < 500 ? 2 : 1;
|
||||
color = TextColor.RED;
|
||||
}
|
||||
else {
|
||||
base = TextColor.DRED;
|
||||
bars = 1;
|
||||
color = TextColor.DRED;
|
||||
}
|
||||
return base + (ping < 10000 ? String.format("%d", ping) + "ms" : String.format("%.1f", ((float)ping) / 1000.0f) + "s");
|
||||
Drawing.drawTextRight(color + (ping < 10000 ? String.format("%d", ping) + "ms" : String.format("%.1f", ((float)ping) / 1000.0f) + "s"), x - 18, y, 0xffffffff);
|
||||
for(int z = 0; z < bars; z++) {
|
||||
Drawing.drawRect(x - 15 + z * 2, y + 8 - z + Font.YGLYPH - 10 + (Font.YGLYPH < 8 ? 1 : 0), 1, z + 1, 0xff000000 | color.color);
|
||||
}
|
||||
|
||||
/*
|
||||
private void drawPing(int width, int xPos, int yPos, int ping) {
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.gm.getTextureManager().bindTexture(icons);
|
||||
int rectX = 0;
|
||||
int rectWidth = 0;
|
||||
if(ping < 0 || ping >= 20000) {
|
||||
rectWidth = 5;
|
||||
}
|
||||
else if(ping < 150) {
|
||||
rectWidth = 0;
|
||||
}
|
||||
else if(ping < 300) {
|
||||
rectWidth = 1;
|
||||
}
|
||||
else if(ping < 600) {
|
||||
rectWidth = 2;
|
||||
}
|
||||
else if(ping < 1000) {
|
||||
rectWidth = 3;
|
||||
}
|
||||
else {
|
||||
rectWidth = 4;
|
||||
}
|
||||
|
||||
String str = this.formatPing(ping);
|
||||
|
||||
this.zLevel += 100.0F;
|
||||
this.drawTexturedModalRect(xPos + width - 11, yPos, 0 + rectX * 10, 176 + rectWidth * 8, 10, 8);
|
||||
SKC.drawString(str, xPos + width - (11 + 1 + SKC.getStringWidth(str)), yPos, -1);
|
||||
this.zLevel -= 100.0F;
|
||||
}
|
||||
*/
|
||||
|
||||
public void drawInfo() {
|
||||
ClientPlayer netHandler = this.getNetHandler();
|
||||
|
@ -3066,9 +3040,9 @@ public class Client implements IThreadListener {
|
|||
for(Entry<String, Integer> elem : this.playerList.entrySet()) {
|
||||
int x = this.fbX / 2 - (w * 300) / 2 + bx * 300;
|
||||
int y = 10 + by * (Font.YGLYPH + 2);
|
||||
Drawing.drawGradient(x, y, 300, Font.YGLYPH + 2, 0x7f404040, 0x7f000000);
|
||||
Drawing.drawGradient(x, y, 300, Font.YGLYPH + 2, 0x7f404040, 0x7f101010, 0x7f5f5f5f, 0x7f000000);
|
||||
Drawing.drawText(elem.getKey(), x + 4, y + 1, 0xffffffff);
|
||||
Drawing.drawTextRight(formatPing(elem.getValue()), x + 300 - 4, y + 1, 0xffffffff);
|
||||
drawPing(x + 300 - 4, y + 1, elem.getValue());
|
||||
if(++bx >= w) {
|
||||
bx = 0;
|
||||
++by;
|
||||
|
|
|
@ -488,7 +488,7 @@ public abstract class Drawing {
|
|||
int corner = Util.mixColor(topleft, btmright);
|
||||
drawRect(x, y, w - 1, 1, topleft);
|
||||
drawRect(x, y + 1, 1, h - 1, topleft);
|
||||
drawRect(x + w - 1, y + 1, 1, 1, corner);
|
||||
drawRect(x + w - 1, y, 1, 1, corner);
|
||||
drawRect(x, y + h - 1, 1, 1, corner);
|
||||
drawRect(x + w - 1, y + 1, 1, h - 1, btmright);
|
||||
drawRect(x + 1, y + h - 1, w - 2, 1, btmright);
|
||||
|
@ -499,7 +499,7 @@ public abstract class Drawing {
|
|||
int corner = Util.mixColor(topleft, btmright);
|
||||
drawRect(x, y, w - 1, 1, topleft);
|
||||
drawRect(x, y + 1, 1, h - 1, topleft);
|
||||
drawRect(x + w - 1, y + 1, 1, 1, corner);
|
||||
drawRect(x + w - 1, y, 1, 1, corner);
|
||||
drawRect(x, y + h - 1, 1, 1, corner);
|
||||
drawRect(x + w - 1, y + 1, 1, h - 1, btmright);
|
||||
drawRect(x + 1, y + h - 1, w - 2, 1, btmright);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue