Fixed GuiReplaySpeedSlider's Display String incorrectly resetting upon Window resize

This commit is contained in:
CrushedPixel
2015-08-21 17:04:31 +02:00
parent 6f35b175fd
commit 959a4c3ce1

View File

@@ -30,11 +30,12 @@ public class GuiReplaySpeedSlider extends GuiAdvancedButton {
public void copyValueFrom(GuiReplaySpeedSlider other) {
sliderValue = other.sliderValue;
recalculateDisplayString();
}
public void reset() {
sliderValue = 9f / 38f;
displayString = displayKey + ": 1x";
recalculateDisplayString();
}
public static float convertScale(float value) {
@@ -104,7 +105,7 @@ public class GuiReplaySpeedSlider extends GuiAdvancedButton {
if(ReplayMod.replaySender.getReplaySpeed() != 0) {
ReplayMod.replaySender.setReplaySpeed(convertScale(normalizedToReal(sliderValue)));
}
this.displayString = displayKey + ": " + translate(convertScale(normalizedToReal(sliderValue)));
recalculateDisplayString();
}
mc.getTextureManager().bindTexture(buttonTextures);
@@ -117,6 +118,10 @@ public class GuiReplaySpeedSlider extends GuiAdvancedButton {
}
}
private void recalculateDisplayString() {
this.displayString = displayKey + ": " + translate(convertScale(normalizedToReal(sliderValue)));
}
public float normalizeValue(float p_148266_1_) {
return MathHelper.clamp_float((this.snapToStepClamp(p_148266_1_) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F);
}