Fixed GuiReplaySpeedSlider's Display String incorrectly resetting upon Window resize
This commit is contained in:
@@ -30,11 +30,12 @@ public class GuiReplaySpeedSlider extends GuiAdvancedButton {
|
|||||||
|
|
||||||
public void copyValueFrom(GuiReplaySpeedSlider other) {
|
public void copyValueFrom(GuiReplaySpeedSlider other) {
|
||||||
sliderValue = other.sliderValue;
|
sliderValue = other.sliderValue;
|
||||||
|
recalculateDisplayString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
sliderValue = 9f / 38f;
|
sliderValue = 9f / 38f;
|
||||||
displayString = displayKey + ": 1x";
|
recalculateDisplayString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float convertScale(float value) {
|
public static float convertScale(float value) {
|
||||||
@@ -104,7 +105,7 @@ public class GuiReplaySpeedSlider extends GuiAdvancedButton {
|
|||||||
if(ReplayMod.replaySender.getReplaySpeed() != 0) {
|
if(ReplayMod.replaySender.getReplaySpeed() != 0) {
|
||||||
ReplayMod.replaySender.setReplaySpeed(convertScale(normalizedToReal(sliderValue)));
|
ReplayMod.replaySender.setReplaySpeed(convertScale(normalizedToReal(sliderValue)));
|
||||||
}
|
}
|
||||||
this.displayString = displayKey + ": " + translate(convertScale(normalizedToReal(sliderValue)));
|
recalculateDisplayString();
|
||||||
}
|
}
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(buttonTextures);
|
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_) {
|
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);
|
return MathHelper.clamp_float((this.snapToStepClamp(p_148266_1_) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user