limit ups values to multiples of 60, allow unlimited ups

This commit is contained in:
yugecin 2018-10-02 21:37:08 +02:00
parent 677de45366
commit 4aebbf2cae
No known key found for this signature in database
GPG Key ID: 2C5AC035A7068E44
3 changed files with 36 additions and 7 deletions

View File

@ -252,9 +252,11 @@ public class DisplayContainer implements ErrorDumpable, SkinChangedListener {
} }
Display.processMessages(); Display.processMessages();
if (targetUpdatesPerSecond >= 60) {
Display.sync(targetUpdatesPerSecond); Display.sync(targetUpdatesPerSecond);
} }
} }
}
public void setup() throws Exception { public void setup() throws Exception {
width = height = width2 = height2 = -1; width = height = width2 = height2 = -1;

View File

@ -60,7 +60,7 @@ public class FpsRenderState implements ResolutionChangedListener {
} }
private String getText(int value, String unit) { private String getText(int value, String unit) {
if (OPTION_USE_FPS_DELTAS.state) { if (OPTION_USE_FPS_DELTAS.state || value > 1000) {
return String.format("%.2fms", 1000f / value); return String.format("%.2fms", 1000f / value);
} }
return value + " " + unit; return value + " " + unit;

View File

@ -214,16 +214,34 @@ public class Options {
} }
}; };
public static final NumericOption OPTION_TARGET_UPS = new NumericOption("target UPS", "targetUPS", "Higher values result in less input lag and smoother cursor trail, but may cause high CPU usage.", 480, 20, 1000) { public static final int[] targetUPS = { 60, 120, 240, 480, 960, 1000, -1 };
public static final NumericOption OPTION_TARGET_UPS = new NumericOption("target UPS", "targetUPS", "Higher values result in less input lag and smoother cursor trail, but may cause high CPU usage.", 2, 0, targetUPS.length - 1) {
@Override @Override
public String getValueString () { public String getValueString () {
return String.format("%dups", val); if (targetUPS[val] == -1) {
return "unlimited";
}
return String.valueOf(targetUPS[val]);
} }
@Override @Override
public void setValue ( int value){ public void setValue(int value) {
if (value < 0 || targetUPS.length <= value) {
return;
}
final int ups = targetUPS[value];
final int fps = targetFPS[targetFPSIndex];
super.setValue(value); super.setValue(value);
displayContainer.setUPS(value); displayContainer.setUPS(ups);
if (ups != -1 && fps > ups) {
for (int i = targetFPSIndex - 1; i >= 0; i--) {
if (targetFPS[i] >= ups) {
OPTION_TARGET_FPS.clickListItem(i);
break;
}
}
}
} }
}; };
@ -255,7 +273,16 @@ public class Options {
@Override @Override
public void clickListItem(int index){ public void clickListItem(int index){
targetFPSIndex = index; targetFPSIndex = index;
displayContainer.setFPS(targetFPS[targetFPSIndex]); int fps = targetFPS[targetFPSIndex];
displayContainer.setFPS(fps);
if (targetUPS[OPTION_TARGET_UPS.val] < fps) {
for (int i = 0; i < targetUPS.length; i++) {
if (targetUPS[i] >= fps) {
OPTION_TARGET_UPS.setValue(i);
break;
}
}
}
} }
@Override @Override