diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 180cbd1..afa24bf 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -238,6 +238,12 @@ public class Client implements IThreadListener { } } + public static class RedrawFunction implements IntFunction { + public void apply(IntVar cv, int value) { + Client.CLIENT.rescale(); + } + } + public static class LevelFunction implements EnumFunction { public void apply(EnumVar cv, LogLevel 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") 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") public int xsize = 1280; @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; @Variable(name = "win_pos_y", category = CVarCategory.WINDOW, min = -65536, max = 65536, display = "Fenster Y-Position") 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_y; + public int mouse_x; + public int mouse_y; + + @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; @@ -1112,7 +1124,7 @@ public class Client implements IThreadListener { 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.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.tpscode(), this.tickrate < 1.0f ? 1.0f / this.tickrate : this.tickrate, 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) { GL11.glViewport(0, 0, x, y); - fb_x = x; - fb_y = 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); @@ -1971,9 +1985,11 @@ public class Client implements IThreadListener { private void mouse(int x, int y) { if(!mouseFirst && open == null) - this.moveCamera((float)(x - mouse_x) * sensitivity, (float)(mouse_y - y) * sensitivity); - mouse_x = x; - mouse_y = y; + this.moveCamera((float)(x - mouse_raw_x) * sensitivity, (float)(mouse_raw_y - y) * sensitivity); + mouse_raw_x = x; + mouse_raw_y = y; + 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) { @@ -2056,7 +2072,9 @@ public class Client implements IThreadListener { // open.restyle(); } - private void redraw() { + 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); if(this.open != null) { this.refreshing = true; this.displayGuiScreen(this.open); @@ -2150,10 +2168,16 @@ public class Client implements IThreadListener { GL11.glClear(256); GL11.glMatrixMode(GL11.GL_PROJECTION); 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.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.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(x * this.scale, y * this.scale, width * this.scale, height * this.scale); } private void addFrame(long runningTime) @@ -2350,23 +2374,23 @@ public class Client implements IThreadListener { if(this.saving) return; this.saving = true; - final int stride = ((this.fb_x * 3) & 3) != 0 ? 4 + ((this.fb_x * 3) & ~3) : (this.fb_x * 3); - final ByteBuffer data = ByteBuffer.allocateDirect(stride * this.fb_y).order(ByteOrder.nativeOrder()); - GL11.glReadPixels(0, 0, this.fb_x, this.fb_y, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, data); + 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_raw_y).order(ByteOrder.nativeOrder()); + GL11.glReadPixels(0, 0, this.fb_raw_x, this.fb_raw_y, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, data); new Thread(new Runnable() { 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); - byte[] conv = new byte[Client.this.fb_x * Client.this.fb_y * 3]; - for(int l = 0; l < Client.this.fb_y; l++) { - System.arraycopy(pixels, l * stride, conv, (Client.this.fb_y - 1 - l) * Client.this.fb_x * 3, Client.this.fb_x * 3); + byte[] conv = new byte[Client.this.fb_raw_x * Client.this.fb_raw_y * 3]; + for(int l = 0; l < Client.this.fb_raw_y; l++) { + 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); - int[] img = new int[Client.this.fb_x * Client.this.fb_y]; + 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_raw_x * Client.this.fb_raw_y]; 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; } - 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"); dir.mkdirs(); diff --git a/client/src/main/java/client/gui/element/Element.java b/client/src/main/java/client/gui/element/Element.java index f5f8b88..3d25fb2 100644 --- a/client/src/main/java/client/gui/element/Element.java +++ b/client/src/main/java/client/gui/element/Element.java @@ -220,7 +220,7 @@ public abstract class Element { int x2 = this.size_x - (this.margin_x1 + this.margin_x2); int y2 = this.size_y - (this.margin_y1 + this.margin_y2); // 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); // } // if(this.type == ElemType.CUSTOM) diff --git a/client/src/main/java/client/gui/element/Textbox.java b/client/src/main/java/client/gui/element/Textbox.java index 7a03abe..dd69674 100644 --- a/client/src/main/java/client/gui/element/Textbox.java +++ b/client/src/main/java/client/gui/element/Textbox.java @@ -242,7 +242,7 @@ abstract class Textbox extends Element { int y1 = this.pos_y + this.margin_y1; int x2 = this.size_x - (this.margin_x1 + this.margin_x2); 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); 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); diff --git a/client/src/main/java/client/gui/options/GuiDisplay.java b/client/src/main/java/client/gui/options/GuiDisplay.java index 22262d0..585ae0f 100644 --- a/client/src/main/java/client/gui/options/GuiDisplay.java +++ b/client/src/main/java/client/gui/options/GuiDisplay.java @@ -1,5 +1,6 @@ package client.gui.options; +import client.gui.Font; import client.gui.Formatter; import client.gui.element.Dropdown; import client.gui.element.DropdownCallback; @@ -13,6 +14,7 @@ import client.window.Button; import client.window.DisplayMode; import client.window.Window; import common.color.TextColor; +import common.util.ExtMath; public class GuiDisplay extends GuiOptions { 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) { + int maxModes = ExtMath.clampi((height - 120) / Font.YGLYPH, 4, 28); DisplayMode[] dmodes = Window.getDisplayModes(); if(dmodes != null && dmodes.length > 0) { int offset = 0; int pos = 0; int num = dmodes.length; - if(dmodes.length > DisplayMode.VID_MODES) { - offset = dmodes.length - DisplayMode.VID_MODES; - num = DisplayMode.VID_MODES; + if(dmodes.length > maxModes) { + offset = dmodes.length - maxModes; + num = maxModes; } DisplayMode[] modes = new DisplayMode[num]; 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("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.addSelector("chunk_build_time", 490, 440, 440, 24); super.init(width, height); diff --git a/client/src/main/java/client/gui/options/GuiOptions.java b/client/src/main/java/client/gui/options/GuiOptions.java index 51258d8..bcff178 100644 --- a/client/src/main/java/client/gui/options/GuiOptions.java +++ b/client/src/main/java/client/gui/options/GuiOptions.java @@ -18,14 +18,14 @@ public abstract class GuiOptions extends Gui { this.shift(); int x = 0; int y = 0; - for(GuiOptions gui : PAGES) { - this.add( // gui == this ? new SelectedButton(240 * x, 24 * y, 240, 24, gui, gui.getTitle()) : - new NavButton(240 * x, 24 * y, 240, 24, gui, gui.getTitle())); + for(int z = 0; z < PAGES.length; z++) { + GuiOptions gui = PAGES[z]; + this.add(new NavButton(z == PAGES.length - 1 ? width - 210 : 210 * x, 24 * y, 210, 24, gui, gui.getTitle())); if(++x == 4) { x = 0; ++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")); } } diff --git a/client/src/main/java/client/renderer/EntityRenderer.java b/client/src/main/java/client/renderer/EntityRenderer.java index 6caa036..71968c7 100755 --- a/client/src/main/java/client/renderer/EntityRenderer.java +++ b/client/src/main/java/client/renderer/EntityRenderer.java @@ -590,7 +590,7 @@ public class EntityRenderer { // 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.glLoadIdentity(); @@ -668,7 +668,7 @@ public class EntityRenderer { // 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.glLoadIdentity(); @@ -970,12 +970,12 @@ public class EntityRenderer { this.setupFog(-1, partialTicks); GL11.glMatrixMode(GL11.GL_PROJECTION); 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); renderglobal.renderSky(partialTicks); GL11.glMatrixMode(GL11.GL_PROJECTION); 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); } @@ -1092,7 +1092,7 @@ public class EntityRenderer { { GL11.glMatrixMode(GL11.GL_PROJECTION); 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.glPushMatrix(); this.setupFog(0, partialTicks); @@ -1103,7 +1103,7 @@ public class EntityRenderer { GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); 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); } } diff --git a/client/src/main/java/client/window/DisplayMode.java b/client/src/main/java/client/window/DisplayMode.java index 9ab016f..8d2e079 100644 --- a/client/src/main/java/client/window/DisplayMode.java +++ b/client/src/main/java/client/window/DisplayMode.java @@ -1,8 +1,6 @@ package client.window; public class DisplayMode { - public static final int VID_MODES = 28; - public final int width; public final int height; public final int refresh;