Added a setFPS() method to GuiVideoFramerateSlider to programmatically change the FPS value

This commit is contained in:
CrushedPixel
2015-07-27 23:58:08 +02:00
parent 4a5f66cab9
commit 0494b9cffe

View File

@@ -12,9 +12,8 @@ public class GuiVideoFramerateSlider extends GuiAdvancedButton {
private float sliderValue;
public GuiVideoFramerateSlider(int xPos, int yPos, int initialFramerate, String displayKey) {
super(xPos, yPos, 150, 20, "", null, null);
this.sliderValue = normalizeValue(initialFramerate);
this.displayString = displayKey + ": " + translate(initialFramerate);
this.displayKey = displayKey;
setFPS(initialFramerate);
}
private String translate(int value) {
@@ -47,6 +46,11 @@ public class GuiVideoFramerateSlider extends GuiAdvancedButton {
return denormalizeValue(sliderValue);
}
public void setFPS(int fps) {
this.sliderValue = normalizeValue(fps);
this.displayString = displayKey + ": " + translate(fps);
}
private float normalizeValue(int val) {
return (val - 10) / 110f;
}