diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 6fb50f5..d73b54b 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -241,8 +241,8 @@ public class Client implements IThreadListener { } } - public static class RedrawFunction implements FloatFunction { - public void apply(FloatVar cv, float value) { + public static class RedrawFunction implements IntFunction { + public void apply(IntVar cv, int value) { Client.CLIENT.rescale(); } } @@ -253,6 +253,13 @@ public class Client implements IThreadListener { } } + public static class FontFunction implements BoolFunction { + public void apply(BoolVar cv, boolean value) { + Font.load(value); + Client.CLIENT.rescale(); + } + } + private interface DebugRunner { void execute(Keysym key); } @@ -420,8 +427,8 @@ public class Client implements IThreadListener { public int mouse_x; public int mouse_y; - @Variable(name = "gui_scale", category = CVarCategory.GUI, min = 1.0f, max = 5.0f, display = "Skalierung der Benutzeroberfläche", precision = 1, unit = "%", callback = RedrawFunction.class) - private float scale = 1.0f; + @Variable(name = "gui_scale", category = CVarCategory.GUI, min = 1, max = 5, display = "Skalierung der Benutzeroberfläche", unit = "x", callback = RedrawFunction.class) + private int scale = 1; @Variable(name = "phy_sensitivity", category = CVarCategory.INPUT, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%") public float sensitivity = 1.0f; @@ -463,6 +470,8 @@ public class Client implements IThreadListener { public Style style = Style.DEFAULT; @Variable(name = "gui_scroll_lines", category = CVarCategory.GUI, min = 1, max = 10, display = "Scrollbreite", unit = "Zeilen") public int scrollLines = 3; + @Variable(name = "gui_font_tiny", category = CVarCategory.GUI, display = "Kleine Schriftart", callback = FontFunction.class) + public boolean tinyFont = false; @@ -978,10 +987,10 @@ public class Client implements IThreadListener { String name = (potion.isBadEffect() ? TextColor.ORANGE : TextColor.ACID) + effect.getEffectName(); String desc = TextColor.NEON + effect.getDurationString(); // Drawing.drawRectColor(x, y, 250, Font.DEFAULT.yglyph + 2, color | 0xff000000); - Drawing.drawRectBorder(x, y, 250, Font.YGLYPH + 4, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff6f6f6f); - Drawing.drawGradient(x + 2, y + 2, effect.isInfinite() ? 246 : ((int)(246.0f * ((float)effect.getRemaining() / (float)effect.getDuration()))), Font.YGLYPH, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000)); - Drawing.drawText(name, x + 4, y + 2, 0xffffffff); - Drawing.drawTextRight(desc, x + 250 - 4, y + 2, 0xffffffff); + Drawing.drawRectBorder(x, y, 250, Font.YGLYPH + 6, 0xff000000, 0xff202020, 0xffcfcfcf, 0xff6f6f6f); + Drawing.drawGradient(x + 2, y + 2, effect.isInfinite() ? 246 : ((int)(246.0f * ((float)effect.getRemaining() / (float)effect.getDuration()))), Font.YGLYPH + 2, color | 0xff000000, Util.mixColor(color | 0xff000000, 0xff000000)); + Drawing.drawText(name, x + 4, y + 3, 0xffffffff); + Drawing.drawTextRight(desc, x + 250 - 4, y + 3, 0xffffffff); y += 24; } } @@ -1990,8 +1999,8 @@ public class Client implements IThreadListener { GL11.glViewport(0, 0, x, y); fb_raw_x = x; fb_raw_y = y; - fb_x = Math.max((int)((float)x / this.scale), 1); - fb_y = Math.max((int)((float)y / this.scale), 1); + fb_x = Math.max(x / this.scale, 1); + fb_y = Math.max(y / this.scale, 1); if(this.open != null) { this.refreshing = true; this.displayGuiScreen(this.open); @@ -2015,8 +2024,8 @@ public class Client implements IThreadListener { this.moveCamera((float)(x - mouse_raw_x) * sensitivity, (float)(mouse_raw_y - y) * sensitivity); mouse_raw_x = x; mouse_raw_y = y; - mouse_x = (int)((float)x / this.scale); - mouse_y = (int)((float)y / this.scale); + mouse_x = x / this.scale; + mouse_y = y / this.scale; mouseFirst = false; if(open != null && Bind.isInputEnabled() && Button.isMouseDown() /* && !(win->mouse & 0xfc) */ && !ctrl()) { // if(mouse_clickx < 0 || mouse_clicky < 0) { @@ -2100,9 +2109,8 @@ public class Client implements IThreadListener { } private void rescale() { - Font.setScale(this.scale); - this.fb_x = Math.max((int)((float)this.fb_raw_x / this.scale), 1); - this.fb_y = Math.max((int)((float)this.fb_raw_y / this.scale), 1); + this.fb_x = Math.max(this.fb_raw_x / this.scale, 1); + this.fb_y = Math.max(this.fb_raw_y / this.scale, 1); if(this.open != null) { this.refreshing = true; this.displayGuiScreen(this.open); @@ -2200,12 +2208,12 @@ public class Client implements IThreadListener { GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); - if(this.scale != 1.0f) - GL11.glScalef(this.scale, this.scale, 1.0f); + if(this.scale != 1) + GL11.glScalef((float)this.scale, (float)this.scale, 1.0f); } public void scissor(int x, int y, int width, int height) { - GL11.glScissor((int)((float)x * this.scale), (int)((float)y * this.scale), (int)((float)width * this.scale), (int)((float)height * this.scale)); + GL11.glScissor(x * this.scale, y * this.scale, width * this.scale, height * this.scale); } private void addFrame(long runningTime) @@ -2255,7 +2263,7 @@ public class Client implements IThreadListener { this.registerDebug(); System.gc(); System.gc(); - Font.load(); + Font.load(false); GlState.enableBlend(); GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.initConsole(); @@ -3226,10 +3234,10 @@ public class Client implements IThreadListener { int by = 0; for(Entry elem : this.playerList.entrySet()) { 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 + 300 - 4, y, 0xffffffff); + int y = 10 + by * (Font.YGLYPH + 2); + Drawing.drawGradient(x, y, 300, Font.YGLYPH + 2, 0x7f404040, 0x7f000000); + Drawing.drawText(elem.getKey(), x + 4, y + 1, 0xffffffff); + Drawing.drawTextRight(formatPing(elem.getValue()), x + 300 - 4, y + 1, 0xffffffff); if(++bx >= w) { bx = 0; ++by; diff --git a/client/src/main/java/client/gui/Font.java b/client/src/main/java/client/gui/Font.java index 0b3f9bd..2ddfabe 100644 --- a/client/src/main/java/client/gui/Font.java +++ b/client/src/main/java/client/gui/Font.java @@ -13,8 +13,9 @@ import common.log.Log; public class Font { public static final FontChar[] SIZES = new FontChar[256]; - public static final int XGLYPH = 12; - public static final int YGLYPH = 18; + + public static int XGLYPH = 12; + public static int YGLYPH = 14; private static int texture; @@ -72,10 +73,12 @@ public class Font { } } - public static void load() { + public static void load(boolean tiny) { + XGLYPH = tiny ? 6 : 12; + YGLYPH = tiny ? 7 : 14; BufferedImage img = null; try { - img = TextureUtil.readImage(FileUtils.getResource("textures/font.png")); + img = TextureUtil.readImage(FileUtils.getResource("textures/font" + (tiny ? "_tiny" : "") + ".png")); } catch(FileNotFoundException e) { Log.IO.error("Konnte Font-Textur nicht laden: Datei nicht vorhanden"); @@ -104,13 +107,4 @@ public class Font { texture = 0; } } - - public static void setScale(float scale) { - if(texture != 0) { - GlState.bindTexture(texture); - boolean linear = scale % 1.0f > 0.0f; - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, linear ? GL11.GL_LINEAR : GL11.GL_NEAREST); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, linear ? GL11.GL_LINEAR : GL11.GL_NEAREST); - } - } } diff --git a/client/src/main/java/client/gui/container/GuiContainer.java b/client/src/main/java/client/gui/container/GuiContainer.java index 7f1eeff..967dfa5 100755 --- a/client/src/main/java/client/gui/container/GuiContainer.java +++ b/client/src/main/java/client/gui/container/GuiContainer.java @@ -6,6 +6,7 @@ import java.util.Set; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL13; +import client.gui.Font; import client.gui.Gui; import client.gui.element.InventoryButton; import client.renderer.Drawing; @@ -1104,7 +1105,7 @@ public abstract class GuiContainer extends Gui // int y = ; // x = x * 2 + this.container_x; // y = y * 2 + this.container_y; - Drawing.drawTextRight(s, xPosition + 32, yPosition + 17, 0xffffffff); + Drawing.drawTextRight(s, xPosition + 32, yPosition + 33 - Font.YGLYPH, 0xffffffff); } if (stack.isItemDamaged()) diff --git a/client/src/main/java/client/gui/options/GuiStyle.java b/client/src/main/java/client/gui/options/GuiStyle.java index 7905591..db064b5 100644 --- a/client/src/main/java/client/gui/options/GuiStyle.java +++ b/client/src/main/java/client/gui/options/GuiStyle.java @@ -72,6 +72,8 @@ public class GuiStyle extends GuiOptions implements DropdownCallback, Bu new SelectableButton(10 + (z % 3) * 320, 360 + (z / 3) * 40, 300, 24, callback, theme.name, theme == this.gm.style)); z++; } + + this.addSelector("gui_font_tiny", 10, height - 124, 300, 24); String[] values = new String[] {"VALUE 1", "VALUE 2"}; this.add(new Dropdown(10, height - 74, 300, 24, false, values, values[1], values[0], this, "DROPDOWN")); diff --git a/client/src/main/java/client/renderer/Drawing.java b/client/src/main/java/client/renderer/Drawing.java index 16c9962..1ce4933 100644 --- a/client/src/main/java/client/renderer/Drawing.java +++ b/client/src/main/java/client/renderer/Drawing.java @@ -507,8 +507,8 @@ public abstract class Drawing { public static void drawTextbox(String str, int x, int y, int back) { Vec2i size = getSize(str); - drawRect(x, y, size.xpos + 4, size.ypos, back); - drawText(str, x + 2, y, 0xffffffff); + drawRect(x, y, size.xpos + 4, size.ypos + 2, back); + drawText(str, x + 2, y + 1, 0xffffffff); } public static void drawTextboxRight(String str, int x, int y, int back) { diff --git a/client/src/main/java/client/renderer/tileentity/TileEntitySignRenderer.java b/client/src/main/java/client/renderer/tileentity/TileEntitySignRenderer.java index 22d543c..deabd4a 100755 --- a/client/src/main/java/client/renderer/tileentity/TileEntitySignRenderer.java +++ b/client/src/main/java/client/renderer/tileentity/TileEntitySignRenderer.java @@ -103,7 +103,7 @@ public class TileEntitySignRenderer extends TileEntitySpecialRenderer entities, TagObject tag) { + int done = 0; + for(Entity entity : entities) { + if(entity.isEntityAlive()) { + BlockPos pos = entity.getPosition(); + TagObject etag = new TagObject(); + entity.writeTags(etag); + if(tag == null) { + exec.logConsole("************************************************************"); + exec.logConsole("Daten von %s bei %d, %d, %d in %s:", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getFormattedName(false)); + exec.logConsole(etag.format(4)); + } + else { + etag.merge(tag); + entity.readTags(etag); + exec.logConsole("Daten von %s bei %d, %d, %d in %s geändert", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getFormattedName(false)); + } + done++; + } + } + if(tag != null && done > 1) + exec.logConsole("Daten von %d Objekten geändert", done); + return done; + } +} diff --git a/server/src/main/java/server/command/commands/CommandHelp.java b/server/src/main/java/server/command/commands/CommandHelp.java index c92d042..9a667ab 100644 --- a/server/src/main/java/server/command/commands/CommandHelp.java +++ b/server/src/main/java/server/command/commands/CommandHelp.java @@ -1,5 +1,6 @@ package server.command.commands; +import java.util.Collection; import java.util.List; import java.util.Map.Entry; import java.util.function.Function; @@ -12,24 +13,24 @@ import server.command.Command; import server.command.CommandEnvironment; import server.command.Executor; import server.command.Parameter; +import server.command.RunException; +import server.command.StringCompleter; public class CommandHelp extends Command { public CommandHelp(CommandEnvironment env) { super("help"); this.setParamsOptional(); - this.addEnum("command", CachedExecutable.class, env.getExecutables().values()); + this.addString("command", false, new StringCompleter() { + public Collection complete(CommandEnvironment env) { + return env.getExecutables().keySet(); + } + }); } - public void exec(CommandEnvironment env, Executor exec, CachedExecutable command) { - if(command == null) { - for(CachedExecutable cmd : env.getExecutables().values()) { - this.exec(env, exec, cmd); - } - return; - } + private void formatCommand(CommandEnvironment env, Executor exec, CachedExecutable cmd) { List list = Lists.newArrayList(); - for(Entry entry : command.parameters().entrySet()) { + for(Entry entry : cmd.parameters().entrySet()) { Parameter param = entry.getValue(); boolean required = param.neededIn(env); if(entry.getKey().length() == 1 && !param.positional() && param.shorthand()) { @@ -42,7 +43,7 @@ public class CommandHelp extends Command { }, param.parsers()))) + (required ? ">" : "]")); } } - for(Parameter param : command.positionals()) { + for(Parameter param : cmd.positionals()) { boolean required = param.neededIn(env); list.add((required ? "<" : "[") + (param.parsers().size() == 1 && param.parsers().get(0).getName().equals(param.name()) ? param.name() : @@ -52,6 +53,19 @@ public class CommandHelp extends Command { } }, param.parsers())) + (required ? ">" : "]")); } - exec.logConsole("%s %s", command.name(), Util.buildLines(" ", list)); + exec.logConsole("%s %s", cmd.name(), Util.buildLines(" ", list)); + } + + public void exec(CommandEnvironment env, Executor exec, String command) { + if(command == null) { + for(CachedExecutable cmd : env.getExecutables().values()) { + this.formatCommand(env, exec, cmd); + } + return; + } + CachedExecutable cmd = env.getExecutables().get(command); + if(cmd == null) + throw new RunException("Befehl '%s' ist nicht bekannt", command); + this.formatCommand(env, exec, cmd); } }