fix fonts
This commit is contained in:
parent
cd7a739c5d
commit
6114da126a
14 changed files with 124 additions and 81 deletions
|
@ -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<String, Integer> 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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -72,6 +72,8 @@ public class GuiStyle extends GuiOptions implements DropdownCallback<String>, 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"));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -103,7 +103,7 @@ public class TileEntitySignRenderer extends TileEntitySpecialRenderer<TileEntity
|
|||
// {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.75f, 0.75f, 0.75f);
|
||||
Drawing.drawTextCenteredN(s, 0, j * (Font.YGLYPH - 3) - 32, 0xff000000);
|
||||
Drawing.drawTextCenteredN(s, 0, j * (18 - 3) - 30, 0xff000000);
|
||||
GL11.glPopMatrix();
|
||||
// }
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
BIN
client/src/main/resources/textures/font_old.png
Normal file
BIN
client/src/main/resources/textures/font_old.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
BIN
client/src/main/resources/textures/font_tiny.png
Normal file
BIN
client/src/main/resources/textures/font_tiny.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -60,7 +60,7 @@ class TagList extends Tag {
|
|||
sb.append(',');
|
||||
sb.append('\n').append(prefix).append(this.list.get(z).toString(indent, depth + 1));
|
||||
}
|
||||
return sb.append('\n').append(Util.repeatString(' ', indent * depth)).append('}').toString();
|
||||
return sb.append('\n').append(Util.repeatString(' ', indent * depth)).append(']').toString();
|
||||
}
|
||||
|
||||
public Tag copy() {
|
||||
|
|
|
@ -14,35 +14,7 @@ import common.collect.Sets;
|
|||
import common.color.TextColor;
|
||||
import common.log.Log;
|
||||
import server.Server;
|
||||
import server.command.commands.CommandAdmin;
|
||||
import server.command.commands.CommandBlock;
|
||||
import server.command.commands.CommandClear;
|
||||
import server.command.commands.CommandFind;
|
||||
import server.command.commands.CommandHelp;
|
||||
import server.command.commands.CommandKick;
|
||||
import server.command.commands.CommandMessage;
|
||||
import server.command.commands.CommandMilk;
|
||||
import server.command.commands.CommandOfflinetp;
|
||||
import server.command.commands.CommandPasswd;
|
||||
import server.command.commands.CommandPlayers;
|
||||
import server.command.commands.CommandPotion;
|
||||
import server.command.commands.CommandPubkey;
|
||||
import server.command.commands.CommandRegister;
|
||||
import server.command.commands.CommandRegkey;
|
||||
import server.command.commands.CommandRemove;
|
||||
import server.command.commands.CommandRevoke;
|
||||
import server.command.commands.CommandSave;
|
||||
import server.command.commands.CommandSeed;
|
||||
import server.command.commands.CommandShutdown;
|
||||
import server.command.commands.CommandSpawn;
|
||||
import server.command.commands.CommandSv;
|
||||
import server.command.commands.CommandTele;
|
||||
import server.command.commands.CommandTime;
|
||||
import server.command.commands.CommandTp;
|
||||
import server.command.commands.CommandUsers;
|
||||
import server.command.commands.CommandWarp;
|
||||
import server.command.commands.CommandWeather;
|
||||
import server.command.commands.CommandWorld;
|
||||
import server.command.commands.*;
|
||||
|
||||
public class CommandEnvironment {
|
||||
private final Server server;
|
||||
|
@ -293,6 +265,7 @@ public class CommandEnvironment {
|
|||
this.registerExecutable(new CommandSeed());
|
||||
this.registerExecutable(new CommandSv());
|
||||
this.registerExecutable(new CommandClear());
|
||||
this.registerExecutable(new CommandEntity());
|
||||
|
||||
this.registerExecutable(new CommandHelp(this));
|
||||
}
|
||||
|
|
|
@ -8,6 +8,11 @@ public enum UserPolicy {
|
|||
return true;
|
||||
}
|
||||
},
|
||||
NO_PLAYERS("Objekt ist ein Spieler") {
|
||||
public boolean applies(CommandEnvironment env, Executor exec, User user) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
NON_ADMINS("Spieler ist ein Admin") {
|
||||
public boolean applies(CommandEnvironment env, Executor exec, User user) {
|
||||
return !user.isAdmin() || exec.isConsole();
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package server.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.Entity;
|
||||
import common.tags.TagObject;
|
||||
import common.util.BlockPos;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.command.UserPolicy;
|
||||
|
||||
public class CommandEntity extends Command {
|
||||
public CommandEntity() {
|
||||
super("entity");
|
||||
|
||||
this.addEntityList("entities", false, UserPolicy.NO_PLAYERS);
|
||||
this.setParamsOptional();
|
||||
this.addTag("tag");
|
||||
}
|
||||
|
||||
public Object exec(CommandEnvironment env, Executor exec, List<Entity> 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;
|
||||
}
|
||||
}
|
|
@ -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<String> 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<String> list = Lists.newArrayList();
|
||||
for(Entry<String, Parameter> entry : command.parameters().entrySet()) {
|
||||
for(Entry<String, Parameter> 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue