Compare commits

..

2 commits

Author SHA1 Message Date
Sen
be0ab15153
add float scaling 2025-05-29 16:40:33 +02:00
Sen
f3117767fd
add basic scaling 2025-05-29 16:12:19 +02:00
8 changed files with 75 additions and 39 deletions

View file

@ -238,6 +238,12 @@ public class Client implements IThreadListener {
} }
} }
public static class RedrawFunction implements FloatFunction {
public void apply(FloatVar cv, float value) {
Client.CLIENT.rescale();
}
}
public static class LevelFunction implements EnumFunction<LogLevel> { public static class LevelFunction implements EnumFunction<LogLevel> {
public void apply(EnumVar cv, LogLevel value) { public void apply(EnumVar cv, LogLevel value) {
Log.setLevel(value); Log.setLevel(value);
@ -390,10 +396,6 @@ public class Client implements IThreadListener {
@Variable(name = "win_sync", category = CVarCategory.WINDOW, min = -1, max = 16384, callback = SyncFunction.class, display = "Maximale Bildrate") @Variable(name = "win_sync", category = CVarCategory.WINDOW, min = -1, max = 16384, callback = SyncFunction.class, display = "Maximale Bildrate")
public int sync = 0; public int sync = 0;
public int width;
public int height;
public int mouse_x;
public int mouse_y;
@Variable(name = "win_width", category = CVarCategory.WINDOW, min = 1, max = 65536, display = "Fensterbreite") @Variable(name = "win_width", category = CVarCategory.WINDOW, min = 1, max = 65536, display = "Fensterbreite")
public int xsize = 1280; public int xsize = 1280;
@Variable(name = "win_height", category = CVarCategory.WINDOW, min = 1, max = 65536, display = "Fensterhöhe") @Variable(name = "win_height", category = CVarCategory.WINDOW, min = 1, max = 65536, display = "Fensterhöhe")
@ -402,8 +404,18 @@ public class Client implements IThreadListener {
public int saved_xpos = 0x80000000; public int saved_xpos = 0x80000000;
@Variable(name = "win_pos_y", category = CVarCategory.WINDOW, min = -65536, max = 65536, display = "Fenster Y-Position") @Variable(name = "win_pos_y", category = CVarCategory.WINDOW, min = -65536, max = 65536, display = "Fenster Y-Position")
public int saved_ypos = 0x80000000; public int saved_ypos = 0x80000000;
public int fb_raw_x;
public int fb_raw_y;
private int mouse_raw_x;
private int mouse_raw_y;
public int fb_x; public int fb_x;
public int fb_y; public int fb_y;
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 = "phy_sensitivity", category = CVarCategory.INPUT, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%") @Variable(name = "phy_sensitivity", category = CVarCategory.INPUT, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%")
public float sensitivity = 1.0f; public float sensitivity = 1.0f;
@ -1112,7 +1124,7 @@ public class Client implements IThreadListener {
GL11.glGetString(GL11.GL_RENDERER), GL11.glGetString(GL11.GL_VENDOR), GL11.glGetString(GL11.GL_RENDERER), GL11.glGetString(GL11.GL_VENDOR),
this.framecode(), this.framerate < 1.0f ? 1.0f / this.framerate : this.framerate, this.framerate < 1.0f ? "SPF" : "FPS", this.framecode(), this.framerate < 1.0f ? 1.0f / this.framerate : this.framerate, this.framerate < 1.0f ? "SPF" : "FPS",
this.vsync ? TextColor.DGRAY + "VSYNC" : (this.syncLimited ? TextColor.GREEN + "" + this.syncLimit : TextColor.RED + "UNL"), this.vsync ? TextColor.DGRAY + "VSYNC" : (this.syncLimited ? TextColor.GREEN + "" + this.syncLimit : TextColor.RED + "UNL"),
(float)PerfSection.getTotal(false) / 1000.0f, this.fb_x, this.fb_y, (float)PerfSection.getTotal(false) / 1000.0f, this.fb_raw_x, this.fb_raw_y,
this.fullscreen ? " @ " + (this.vidMode == null ? "?" : this.vidMode.refresh) + " Hz" : "", this.fullscreen ? " @ " + (this.vidMode == null ? "?" : this.vidMode.refresh) + " Hz" : "",
this.tpscode(), this.tickrate < 1.0f ? 1.0f / this.tickrate : this.tickrate, this.tpscode(), this.tickrate < 1.0f ? 1.0f / this.tickrate : this.tickrate,
this.tickrate < 1.0f ? "SPT" : "TPS", (float)this.tickTarget / 1000.0f, this.tickrate < 1.0f ? "SPT" : "TPS", (float)this.tickTarget / 1000.0f,
@ -1949,8 +1961,10 @@ public class Client implements IThreadListener {
private void fbsize(int x, int y) { private void fbsize(int x, int y) {
GL11.glViewport(0, 0, x, y); GL11.glViewport(0, 0, x, y);
fb_x = x; fb_raw_x = x;
fb_y = y; fb_raw_y = y;
fb_x = Math.max((int)((float)x / this.scale), 1);
fb_y = Math.max((int)((float)y / this.scale), 1);
if(this.open != null) { if(this.open != null) {
this.refreshing = true; this.refreshing = true;
this.displayGuiScreen(this.open); this.displayGuiScreen(this.open);
@ -1971,9 +1985,11 @@ public class Client implements IThreadListener {
private void mouse(int x, int y) { private void mouse(int x, int y) {
if(!mouseFirst && open == null) if(!mouseFirst && open == null)
this.moveCamera((float)(x - mouse_x) * sensitivity, (float)(mouse_y - y) * sensitivity); this.moveCamera((float)(x - mouse_raw_x) * sensitivity, (float)(mouse_raw_y - y) * sensitivity);
mouse_x = x; mouse_raw_x = x;
mouse_y = y; mouse_raw_y = y;
mouse_x = (int)((float)x / this.scale);
mouse_y = (int)((float)y / this.scale);
mouseFirst = false; mouseFirst = false;
if(open != null && Bind.isInputEnabled() && Button.isMouseDown() /* && !(win->mouse & 0xfc) */ && !ctrl()) { if(open != null && Bind.isInputEnabled() && Button.isMouseDown() /* && !(win->mouse & 0xfc) */ && !ctrl()) {
// if(mouse_clickx < 0 || mouse_clicky < 0) { // if(mouse_clickx < 0 || mouse_clicky < 0) {
@ -2056,7 +2072,10 @@ public class Client implements IThreadListener {
// open.restyle(); // open.restyle();
} }
private void redraw() { 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);
if(this.open != null) { if(this.open != null) {
this.refreshing = true; this.refreshing = true;
this.displayGuiScreen(this.open); this.displayGuiScreen(this.open);
@ -2150,10 +2169,16 @@ public class Client implements IThreadListener {
GL11.glClear(256); GL11.glClear(256);
GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
GL11.glOrtho(0.0D, (double)this.fb_x, (double)this.fb_y, 0.0D, 1000.0D, 3000.0D); GL11.glOrtho(0.0D, (double)this.fb_raw_x, (double)this.fb_raw_y, 0.0D, 1000.0D, 3000.0D);
GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
GL11.glTranslatef(0.0F, 0.0F, -2000.0F); GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
if(this.scale != 1.0f)
GL11.glScalef(this.scale, 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));
} }
private void addFrame(long runningTime) private void addFrame(long runningTime)
@ -2350,23 +2375,23 @@ public class Client implements IThreadListener {
if(this.saving) if(this.saving)
return; return;
this.saving = true; this.saving = true;
final int stride = ((this.fb_x * 3) & 3) != 0 ? 4 + ((this.fb_x * 3) & ~3) : (this.fb_x * 3); final int stride = ((this.fb_raw_x * 3) & 3) != 0 ? 4 + ((this.fb_raw_x * 3) & ~3) : (this.fb_raw_x * 3);
final ByteBuffer data = ByteBuffer.allocateDirect(stride * this.fb_y).order(ByteOrder.nativeOrder()); final ByteBuffer data = ByteBuffer.allocateDirect(stride * this.fb_raw_y).order(ByteOrder.nativeOrder());
GL11.glReadPixels(0, 0, this.fb_x, this.fb_y, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, data); GL11.glReadPixels(0, 0, this.fb_raw_x, this.fb_raw_y, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, data);
new Thread(new Runnable() { new Thread(new Runnable() {
public void run() { public void run() {
byte[] pixels = new byte[stride * Client.this.fb_y]; byte[] pixels = new byte[stride * Client.this.fb_raw_y];
data.get(pixels); data.get(pixels);
byte[] conv = new byte[Client.this.fb_x * Client.this.fb_y * 3]; byte[] conv = new byte[Client.this.fb_raw_x * Client.this.fb_raw_y * 3];
for(int l = 0; l < Client.this.fb_y; l++) { for(int l = 0; l < Client.this.fb_raw_y; l++) {
System.arraycopy(pixels, l * stride, conv, (Client.this.fb_y - 1 - l) * Client.this.fb_x * 3, Client.this.fb_x * 3); System.arraycopy(pixels, l * stride, conv, (Client.this.fb_raw_y - 1 - l) * Client.this.fb_raw_x * 3, Client.this.fb_raw_x * 3);
} }
BufferedImage image = new BufferedImage(Client.this.fb_x, Client.this.fb_y, BufferedImage.TYPE_INT_ARGB); BufferedImage image = new BufferedImage(Client.this.fb_raw_x, Client.this.fb_raw_y, BufferedImage.TYPE_INT_ARGB);
int[] img = new int[Client.this.fb_x * Client.this.fb_y]; int[] img = new int[Client.this.fb_raw_x * Client.this.fb_raw_y];
for(int z = 0; z < img.length; z++) { for(int z = 0; z < img.length; z++) {
img[z] = (int)(conv[(z * 3) + 2] & 0xff) | ((int)(conv[(z * 3) + 1] & 0xff) << 8) | ((int)(conv[(z * 3) + 0] & 0xff) << 16) | 0xff000000; img[z] = (int)(conv[(z * 3) + 2] & 0xff) | ((int)(conv[(z * 3) + 1] & 0xff) << 8) | ((int)(conv[(z * 3) + 0] & 0xff) << 16) | 0xff000000;
} }
image.setRGB(0, 0, Client.this.fb_x, Client.this.fb_y, img, 0, Client.this.fb_x); image.setRGB(0, 0, Client.this.fb_raw_x, Client.this.fb_raw_y, img, 0, Client.this.fb_raw_x);
File dir = new File("screenshots"); File dir = new File("screenshots");
dir.mkdirs(); dir.mkdirs();

View file

@ -104,4 +104,13 @@ public class Font {
texture = 0; 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);
}
}
} }

View file

@ -220,7 +220,7 @@ public abstract class Element {
int x2 = this.size_x - (this.margin_x1 + this.margin_x2); int x2 = this.size_x - (this.margin_x1 + this.margin_x2);
int y2 = this.size_y - (this.margin_y1 + this.margin_y2); int y2 = this.size_y - (this.margin_y1 + this.margin_y2);
// if(elem.type == ElemType.FIELD) { // if(elem.type == ElemType.FIELD) {
GL11.glScissor(x1 < 0 ? 0 : x1, (this.gm.fb_y - (y1 + y2)) < 0 ? 0 : (this.gm.fb_y - (y1 + y2)), x2 < 0 ? 0 : x2, y2 < 0 ? 0 : y2); this.gm.scissor(x1 < 0 ? 0 : x1, (this.gm.fb_y - (y1 + y2)) < 0 ? 0 : (this.gm.fb_y - (y1 + y2)), x2 < 0 ? 0 : x2, y2 < 0 ? 0 : y2);
GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glEnable(GL11.GL_SCISSOR_TEST);
// } // }
// if(this.type == ElemType.CUSTOM) // if(this.type == ElemType.CUSTOM)

View file

@ -242,7 +242,7 @@ abstract class Textbox extends Element {
int y1 = this.pos_y + this.margin_y1; int y1 = this.pos_y + this.margin_y1;
int x2 = this.size_x - (this.margin_x1 + this.margin_x2); int x2 = this.size_x - (this.margin_x1 + this.margin_x2);
int y2 = this.size_y - (this.margin_y1 + this.margin_y2); int y2 = this.size_y - (this.margin_y1 + this.margin_y2);
GL11.glScissor(x1 < 0 ? 0 : x1, (this.gm.fb_y - (y1 + y2)) < 0 ? 0 : (this.gm.fb_y - (y1 + y2)), x2 < 0 ? 0 : x2, y2 < 0 ? 0 : y2); this.gm.scissor(x1 < 0 ? 0 : x1, (this.gm.fb_y - (y1 + y2)) < 0 ? 0 : (this.gm.fb_y - (y1 + y2)), x2 < 0 ? 0 : x2, y2 < 0 ? 0 : y2);
GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glEnable(GL11.GL_SCISSOR_TEST);
Drawing.drawRect(this.getCursorX(x1, x2), this.getCursorY(y1, y2), 1, Font.YGLYPH, 0xff000000 | (~Util.mixColor(this.gm.style.field_top, this.gm.style.field_btm))); Drawing.drawRect(this.getCursorX(x1, x2), this.getCursorY(y1, y2), 1, Font.YGLYPH, 0xff000000 | (~Util.mixColor(this.gm.style.field_top, this.gm.style.field_btm)));
GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glDisable(GL11.GL_SCISSOR_TEST);

View file

@ -1,5 +1,6 @@
package client.gui.options; package client.gui.options;
import client.gui.Font;
import client.gui.Formatter; import client.gui.Formatter;
import client.gui.element.Dropdown; import client.gui.element.Dropdown;
import client.gui.element.DropdownCallback; import client.gui.element.DropdownCallback;
@ -13,6 +14,7 @@ import client.window.Button;
import client.window.DisplayMode; import client.window.DisplayMode;
import client.window.Window; import client.window.Window;
import common.color.TextColor; import common.color.TextColor;
import common.util.ExtMath;
public class GuiDisplay extends GuiOptions { public class GuiDisplay extends GuiOptions {
private static final String[] DISTANCES = new String[] {"Gruselig", "Winzig", "Gering", "Normal", "Weit"}; private static final String[] DISTANCES = new String[] {"Gruselig", "Winzig", "Gering", "Normal", "Weit"};
@ -23,14 +25,15 @@ public class GuiDisplay extends GuiOptions {
} }
public void init(int width, int height) { public void init(int width, int height) {
int maxModes = ExtMath.clampi((height - 120) / Font.YGLYPH, 4, 28);
DisplayMode[] dmodes = Window.getDisplayModes(); DisplayMode[] dmodes = Window.getDisplayModes();
if(dmodes != null && dmodes.length > 0) { if(dmodes != null && dmodes.length > 0) {
int offset = 0; int offset = 0;
int pos = 0; int pos = 0;
int num = dmodes.length; int num = dmodes.length;
if(dmodes.length > DisplayMode.VID_MODES) { if(dmodes.length > maxModes) {
offset = dmodes.length - DisplayMode.VID_MODES; offset = dmodes.length - maxModes;
num = DisplayMode.VID_MODES; num = maxModes;
} }
DisplayMode[] modes = new DisplayMode[num]; DisplayMode[] modes = new DisplayMode[num];
DisplayMode selected = dmodes[num + offset - 1]; DisplayMode selected = dmodes[num + offset - 1];
@ -81,6 +84,7 @@ public class GuiDisplay extends GuiOptions {
this.addSelector("hotbar_size", 490, 320, 440, 24); this.addSelector("hotbar_size", 490, 320, 440, 24);
this.addSelector("gl_fov", 30, 400, 440, 24); this.addSelector("gl_fov", 30, 400, 440, 24);
this.addSelector("gui_scale", 490, 400, 440, 24);
this.distanceSlider = this.addSelector("chunk_view_distance", 30, 440, 440, 24); this.distanceSlider = this.addSelector("chunk_view_distance", 30, 440, 440, 24);
this.addSelector("chunk_build_time", 490, 440, 440, 24); this.addSelector("chunk_build_time", 490, 440, 440, 24);
super.init(width, height); super.init(width, height);

View file

@ -18,14 +18,14 @@ public abstract class GuiOptions extends Gui {
this.shift(); this.shift();
int x = 0; int x = 0;
int y = 0; int y = 0;
for(GuiOptions gui : PAGES) { for(int z = 0; z < PAGES.length; z++) {
this.add( // gui == this ? new SelectedButton(240 * x, 24 * y, 240, 24, gui, gui.getTitle()) : GuiOptions gui = PAGES[z];
new NavButton(240 * x, 24 * y, 240, 24, gui, gui.getTitle())); this.add(new NavButton(z == PAGES.length - 1 ? width - 210 : 210 * x, 24 * y, 210, 24, gui, gui.getTitle()));
if(++x == 4) { if(++x == 4) {
x = 0; x = 0;
++y; ++y;
} }
} }
this.add(new NavButton(width - 240, 0, 240, 24, GuiMenu.INSTANCE, "Zurück")); this.add(new NavButton(210, height - 24, width - 420, 24, GuiMenu.INSTANCE, "Zurück"));
} }
} }

View file

@ -590,7 +590,7 @@ public class EntityRenderer {
// SKC.glScaled(this.cameraZoom, this.cameraZoom, 1.0D); // SKC.glScaled(this.cameraZoom, this.cameraZoom, 1.0D);
// } // }
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_y, 0.05F, this.farPlaneDistance * SQRT_2); Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * SQRT_2);
GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
@ -668,7 +668,7 @@ public class EntityRenderer {
// SKC.glTranslatef((float)(-(xOffset * 2 - 1)) * f, 0.0F, 0.0F); // SKC.glTranslatef((float)(-(xOffset * 2 - 1)) * f, 0.0F, 0.0F);
// } // }
Project.gluPerspective(this.getFOVModifier(partialTicks, false), (float)this.gm.fb_x / (float)this.gm.fb_y, 0.05F, this.farPlaneDistance * 2.0F); Project.gluPerspective(this.getFOVModifier(partialTicks, false), (float)this.gm.fb_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * 2.0F);
GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
@ -970,12 +970,12 @@ public class EntityRenderer {
this.setupFog(-1, partialTicks); this.setupFog(-1, partialTicks);
GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_y, 0.05F, this.farPlaneDistance * 2.0F); Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * 2.0F);
GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_MODELVIEW);
renderglobal.renderSky(partialTicks); renderglobal.renderSky(partialTicks);
GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_y, 0.05F, this.farPlaneDistance * SQRT_2); Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * SQRT_2);
GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_MODELVIEW);
} }
@ -1092,7 +1092,7 @@ public class EntityRenderer {
{ {
GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_y, 0.05F, this.farPlaneDistance * 4.0F); Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * 4.0F);
GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix(); GL11.glPushMatrix();
this.setupFog(0, partialTicks); this.setupFog(0, partialTicks);
@ -1103,7 +1103,7 @@ public class EntityRenderer {
GL11.glPopMatrix(); GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_y, 0.05F, this.farPlaneDistance * SQRT_2); Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * SQRT_2);
GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_MODELVIEW);
} }
} }

View file

@ -1,8 +1,6 @@
package client.window; package client.window;
public class DisplayMode { public class DisplayMode {
public static final int VID_MODES = 28;
public final int width; public final int width;
public final int height; public final int height;
public final int refresh; public final int refresh;