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 |
Loading…
Add table
Add a link
Reference in a new issue