debug overlay and others
This commit is contained in:
parent
8038516a66
commit
d629e8fb7b
4 changed files with 115 additions and 67 deletions
|
@ -32,6 +32,7 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -144,6 +145,7 @@ import game.window.WCF;
|
|||
import game.window.Wheel;
|
||||
import game.window.WindowEvent;
|
||||
import game.world.BlockPos;
|
||||
import game.world.BoundingBox;
|
||||
import game.world.Chunk;
|
||||
import game.world.Converter;
|
||||
import game.world.Facing;
|
||||
|
@ -245,6 +247,7 @@ public class Game implements IThreadListener {
|
|||
public boolean tileOverlay;
|
||||
public boolean itemCheat;
|
||||
public boolean dayCycle = true;
|
||||
public boolean showHud = true;
|
||||
|
||||
private int leftClickCounter;
|
||||
private int rightClickTimer;
|
||||
|
@ -745,11 +748,16 @@ public class Game implements IThreadListener {
|
|||
|
||||
public void renderHud() {
|
||||
this.setupOverlay();
|
||||
if(this.theWorld != null && this.open == null && this.thirdPersonView == 0) {
|
||||
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);
|
||||
if(this.theWorld != null && this.open == null && this.thirdPersonView == 0 && this.viewEntity != null) {
|
||||
if(this.drawDebug) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
if(this.theWorld != null && this.open == null) {
|
||||
int selected = // this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer() ? 9 : 0,
|
||||
|
@ -926,6 +934,8 @@ public class Game implements IThreadListener {
|
|||
}
|
||||
if(this.open != null)
|
||||
this.open.render();
|
||||
if(Bind.INFO.isDown())
|
||||
this.drawInfo();
|
||||
if(this.hudOverlay && !(this.open instanceof GuiConsole))
|
||||
this.drawOverlay();
|
||||
if(this.drawFps) { // && !(this.open instanceof GuiConsole)
|
||||
|
@ -2089,9 +2099,9 @@ public class Game implements IThreadListener {
|
|||
// public void complete(String[] comp) {
|
||||
//
|
||||
// }
|
||||
public void infolist(String[] list, int[] data) {
|
||||
|
||||
}
|
||||
// public void infolist(String[] list, int[] data) {
|
||||
//
|
||||
// }
|
||||
|
||||
public void disconnected(String msg) {
|
||||
Log.SYSTEM.info("Getrennt: %s", msg);
|
||||
|
@ -2511,7 +2521,7 @@ public class Game implements IThreadListener {
|
|||
});
|
||||
this.registerDebug(Keysym.U, "HUD umschalten", new DebugRunner() {
|
||||
public void execute(Keysym key) {
|
||||
|
||||
Game.this.showHud ^= true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2935,6 +2945,75 @@ public class Game implements IThreadListener {
|
|||
log.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatPing(int ping) {
|
||||
TextColor base;
|
||||
if(ping < 0) {
|
||||
base = TextColor.GRAY;
|
||||
}
|
||||
else if(ping < 80) {
|
||||
base = TextColor.DGREEN;
|
||||
}
|
||||
else if(ping < 160) {
|
||||
base = TextColor.GREEN;
|
||||
}
|
||||
else if(ping < 350) {
|
||||
base = TextColor.YELLOW;
|
||||
}
|
||||
else if(ping < 700) {
|
||||
base = TextColor.RED;
|
||||
}
|
||||
else {
|
||||
base = TextColor.DRED;
|
||||
}
|
||||
return base + (ping < 10000 ? String.format("%d", ping) + "ms" : String.format("%.1f", ((float)ping) / 1000.0f) + "s");
|
||||
}
|
||||
|
||||
public void drawInfo() {
|
||||
NetHandlerPlayClient netHandler = this.getNetHandler();
|
||||
if(netHandler != null) {
|
||||
Set<Entry<String, Integer>> list = netHandler.getPlayerList();
|
||||
int size = list.size();
|
||||
int w = size > 80 ? 4 : (size > 40 ? 3 : (size > 10 ? 2 : 1));
|
||||
w = Math.min(w, Math.max(1, this.fb_x / 300));
|
||||
int bx = 0;
|
||||
int by = 0;
|
||||
for(Entry<String, Integer> elem : list) {
|
||||
int x = this.fb_x / 2 - (w * 300) / 2 + bx * 300;
|
||||
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);
|
||||
if(++bx >= w) {
|
||||
bx = 0;
|
||||
++by;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void renderWorldDirections(float partialTicks) {
|
||||
GlState.enableBlend();
|
||||
GlState.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
WCF.glLineWidth(1.0F);
|
||||
GlState.disableTexture2D();
|
||||
GlState.depthMask(false);
|
||||
GlState.color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
WCF.glPushMatrix();
|
||||
// WCF.glMatrixMode(5888);
|
||||
// WCF.glLoadIdentity();
|
||||
WCF.glTranslatef(this.fb_x / 2, this.fb_y / 2, 0.0F);
|
||||
this.entityRenderer.rotateCamera(this.viewEntity, partialTicks);
|
||||
// WCF.glScalef(-1.0f, -1.0f, -1.0f);
|
||||
// Drawing.drawRectColor(0, 0, 10, 2, 0xff00ff00);
|
||||
RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 24D, 1D, 1D), 255, 0, 0, 255);
|
||||
RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, 1D, 24D), 0, 0, 255, 255);
|
||||
RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, -20D, 1D), 0, 255, 0, 255);
|
||||
WCF.glPopMatrix();
|
||||
GlState.depthMask(true);
|
||||
GlState.enableTexture2D();
|
||||
GlState.disableBlend();
|
||||
}
|
||||
|
||||
public void showDirDialog(final String title, final String def, final FileCallback callback) {
|
||||
new Thread(new Runnable() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue