add float scaling
This commit is contained in:
parent
f3117767fd
commit
be0ab15153
2 changed files with 23 additions and 13 deletions
|
@ -238,8 +238,8 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
public static class RedrawFunction implements IntFunction {
|
||||
public void apply(IntVar cv, int value) {
|
||||
public static class RedrawFunction implements FloatFunction {
|
||||
public void apply(FloatVar cv, float value) {
|
||||
Client.CLIENT.rescale();
|
||||
}
|
||||
}
|
||||
|
@ -414,8 +414,8 @@ public class Client implements IThreadListener {
|
|||
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 = "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;
|
||||
|
@ -1963,8 +1963,8 @@ 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);
|
||||
fb_x = Math.max((int)((float)x / this.scale), 1);
|
||||
fb_y = Math.max((int)((float)y / this.scale), 1);
|
||||
if(this.open != null) {
|
||||
this.refreshing = true;
|
||||
this.displayGuiScreen(this.open);
|
||||
|
@ -1988,8 +1988,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 = x / this.scale;
|
||||
mouse_y = y / this.scale;
|
||||
mouse_x = (int)((float)x / this.scale);
|
||||
mouse_y = (int)((float)y / this.scale);
|
||||
mouseFirst = false;
|
||||
if(open != null && Bind.isInputEnabled() && Button.isMouseDown() /* && !(win->mouse & 0xfc) */ && !ctrl()) {
|
||||
// if(mouse_clickx < 0 || mouse_clicky < 0) {
|
||||
|
@ -2073,8 +2073,9 @@ 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);
|
||||
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) {
|
||||
this.refreshing = true;
|
||||
this.displayGuiScreen(this.open);
|
||||
|
@ -2172,12 +2173,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)
|
||||
GL11.glScalef((float)this.scale, (float)this.scale, 1.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(x * this.scale, y * this.scale, width * this.scale, height * this.scale);
|
||||
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)
|
||||
|
|
|
@ -104,4 +104,13 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue