1
0
Fork 0

fix ui scaling

This commit is contained in:
Sen 2025-06-12 21:30:36 +02:00
parent 836094a00b
commit 17bb2e57ab
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
6 changed files with 53 additions and 43 deletions

View file

@ -278,6 +278,8 @@ public class Client implements IThreadListener {
public static final String VERSION = Version.NAME + " Client " + Util.VERSION;
public static final int LOG_BUFFER = 32768;
public static final int MIN_WIDTH = 800;
public static final int MIN_HEIGHT = 450;
private static final LazyLoader<NioEventLoopGroup> CLIENT_NIO_EVENTLOOP = new LazyLoader<NioEventLoopGroup>()
{
protected NioEventLoopGroup load()
@ -409,9 +411,9 @@ public class Client implements IThreadListener {
@Variable(name = "win_sync", category = CVarCategory.WINDOW, min = -1, max = 16384, callback = SyncFunction.class, display = "Maximale Bildrate")
public int sync = 0;
@Variable(name = "win_width", category = CVarCategory.WINDOW, min = 1, max = 65536, display = "Fensterbreite")
@Variable(name = "win_width", category = CVarCategory.WINDOW, min = MIN_WIDTH, max = 65536, display = "Fensterbreite")
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 = MIN_HEIGHT, max = 65536, display = "Fensterhöhe")
public int ysize = 800;
@Variable(name = "win_pos_x", category = CVarCategory.WINDOW, min = -65536, max = 65536, display = "Fenster X-Position")
public int saved_xpos = 0x80000000;
@ -426,9 +428,10 @@ public class Client implements IThreadListener {
public int fb_y;
public int mouse_x;
public int mouse_y;
private int scale = 1;
@Variable(name = "gui_scale", category = CVarCategory.GUI, min = 1, max = 5, display = "Skalierung", unit = "x", callback = RedrawFunction.class)
private int scale = 1;
private int scaleVar = 1;
@Variable(name = "phy_sensitivity", category = CVarCategory.INPUT, min = 0.01f, max = 10.0f, display = "Mausempfindlichkeit", precision = 2, unit = "%")
public float sensitivity = 1.0f;
@ -575,7 +578,7 @@ public class Client implements IThreadListener {
Log.NETWORK.error(e, "Konnte nicht zu Server verbinden");
Client.this.schedule(new Runnable() {
public void run() {
Client.this.disconnected(e.toString());
Client.this.disconnected((e instanceof RuntimeException && !(e.getCause() instanceof RuntimeException) ? e.getCause() : e).toString());
}
});
return;
@ -1999,13 +2002,7 @@ public class Client implements IThreadListener {
GL11.glViewport(0, 0, x, y);
fb_raw_x = x;
fb_raw_y = y;
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);
this.refreshing = false;
}
this.rescale();
if(!fullscreen) {
xsize = x;
ysize = y;
@ -2109,8 +2106,12 @@ public class Client implements IThreadListener {
}
private void rescale() {
this.fb_x = Math.max(this.fb_raw_x / this.scale, 1);
this.fb_y = Math.max(this.fb_raw_y / this.scale, 1);
this.scale = this.scaleVar;
while(this.scale > 1 && (this.fb_raw_x / this.scale < MIN_WIDTH || this.fb_raw_y / this.scale < MIN_HEIGHT)) {
this.scale--;
}
this.fb_x = Math.max(this.fb_raw_x / this.scale, MIN_WIDTH);
this.fb_y = Math.max(this.fb_raw_y / this.scale, MIN_HEIGHT);
if(this.open != null) {
this.refreshing = true;
this.displayGuiScreen(this.open);
@ -2269,7 +2270,9 @@ public class Client implements IThreadListener {
this.initConsole();
this.startSound(true);
this.vidMode = Window.getDisplayMode();
Window.initWindow(this.saved_xpos, this.saved_ypos, this.xsize, this.ysize);
if(this.vidMode != null && (this.vidMode.width() < MIN_WIDTH || this.vidMode.height() < MIN_HEIGHT))
this.vidMode = null;
Window.initWindow(this.saved_xpos, this.saved_ypos, this.xsize, this.ysize, MIN_WIDTH, MIN_HEIGHT);
Window.setIcon(genTriwave(64, 64, 0x00000000, 0xffff0000, 0xff00ff00, 0xff0000ff, 0xff7f00ff, 0xff000000), 64, 64);
this.sync(this.sync);
// this.startSound(true);