Compare commits

..

No commits in common. "be0ab1515386baed9284f6ea800fb6c19f9ca577" and "414dc668ffb5b15f87b02027ee6cec6faac91137" have entirely different histories.

8 changed files with 39 additions and 75 deletions

View file

@ -238,12 +238,6 @@ 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 void apply(EnumVar cv, LogLevel value) {
Log.setLevel(value);
@ -396,6 +390,10 @@ 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")
@ -404,18 +402,8 @@ 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.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 = "%")
public float sensitivity = 1.0f;
@ -1124,7 +1112,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_raw_x, this.fb_raw_y,
(float)PerfSection.getTotal(false) / 1000.0f, this.fb_x, this.fb_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,
@ -1961,10 +1949,8 @@ public class Client implements IThreadListener {
private void fbsize(int x, int y) {
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 = x;
fb_y = y;
if(this.open != null) {
this.refreshing = true;
this.displayGuiScreen(this.open);
@ -1985,11 +1971,9 @@ public class Client implements IThreadListener {
private void mouse(int x, int y) {
if(!mouseFirst && open == null)
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);
this.moveCamera((float)(x - mouse_x) * sensitivity, (float)(mouse_y - y) * sensitivity);
mouse_x = x;
mouse_y = y;
mouseFirst = false;
if(open != null && Bind.isInputEnabled() && Button.isMouseDown() /* && !(win->mouse & 0xfc) */ && !ctrl()) {
// if(mouse_clickx < 0 || mouse_clicky < 0) {
@ -2072,10 +2056,7 @@ public class Client implements IThreadListener {
// open.restyle();
}
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);
private void redraw() {
if(this.open != null) {
this.refreshing = true;
this.displayGuiScreen(this.open);
@ -2169,16 +2150,10 @@ public class Client implements IThreadListener {
GL11.glClear(256);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0.0D, (double)this.fb_raw_x, (double)this.fb_raw_y, 0.0D, 1000.0D, 3000.0D);
GL11.glOrtho(0.0D, (double)this.fb_x, (double)this.fb_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.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)
@ -2375,23 +2350,23 @@ public class Client implements IThreadListener {
if(this.saving)
return;
this.saving = true;
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);
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);
new Thread(new Runnable() {
public void run() {
byte[] pixels = new byte[stride * Client.this.fb_raw_y];
byte[] pixels = new byte[stride * Client.this.fb_y];
data.get(pixels);
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);
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);
}
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];
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];
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_raw_x, Client.this.fb_raw_y, img, 0, Client.this.fb_raw_x);
image.setRGB(0, 0, Client.this.fb_x, Client.this.fb_y, img, 0, Client.this.fb_x);
File dir = new File("screenshots");
dir.mkdirs();

View file

@ -104,13 +104,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);
}
}
}

View file

@ -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) {
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.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);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
// }
// 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 x2 = this.size_x - (this.margin_x1 + this.margin_x2);
int y2 = this.size_y - (this.margin_y1 + this.margin_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.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);
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);

View file

@ -1,6 +1,5 @@
package client.gui.options;
import client.gui.Font;
import client.gui.Formatter;
import client.gui.element.Dropdown;
import client.gui.element.DropdownCallback;
@ -14,7 +13,6 @@ 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"};
@ -25,15 +23,14 @@ 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 > maxModes) {
offset = dmodes.length - maxModes;
num = maxModes;
if(dmodes.length > DisplayMode.VID_MODES) {
offset = dmodes.length - DisplayMode.VID_MODES;
num = DisplayMode.VID_MODES;
}
DisplayMode[] modes = new DisplayMode[num];
DisplayMode selected = dmodes[num + offset - 1];
@ -84,7 +81,6 @@ 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);

View file

@ -18,14 +18,14 @@ public abstract class GuiOptions extends Gui {
this.shift();
int x = 0;
int y = 0;
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()));
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()));
if(++x == 4) {
x = 0;
++y;
}
}
this.add(new NavButton(210, height - 24, width - 420, 24, GuiMenu.INSTANCE, "Zurück"));
this.add(new NavButton(width - 240, 0, 240, 24, GuiMenu.INSTANCE, "Zurück"));
}
}

View file

@ -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_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * SQRT_2);
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_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_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * 2.0F);
Project.gluPerspective(this.getFOVModifier(partialTicks, false), (float)this.gm.fb_x / (float)this.gm.fb_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_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * 2.0F);
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_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_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * SQRT_2);
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_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_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * 4.0F);
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_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_raw_x / (float)this.gm.fb_raw_y, 0.05F, this.farPlaneDistance * SQRT_2);
Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.gm.fb_x / (float)this.gm.fb_y, 0.05F, this.farPlaneDistance * SQRT_2);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
}

View file

@ -1,6 +1,8 @@
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;