fix sliders

This commit is contained in:
Daniella / Tove 2024-05-27 12:45:04 +02:00
parent 498c2a61ff
commit a021901ad7
2 changed files with 8 additions and 8 deletions

View file

@ -39,9 +39,9 @@ public class IntSlider extends Component {
@Override
public void draw(int x, int y) {
Gui.drawRect(x, y + 13, x + 151, y + 14, GUIManager.sliderBackground);
Gui.drawRect((int) Math.floor(x + f * 150), y + 11, (int) Math.floor(x + f * 150) + 1, y + 16, GUIManager.sliderColor);
fontRenderer.drawString(sliderText.apply(Math.round(f * mapper + adder)), x + 150 + 4, y + 10, GUIManager.sliderColor);
Gui.drawRect(x, y + 13, x + 141, y + 14, GUIManager.sliderBackground);
Gui.drawRect((int) Math.floor(x + f * 140), y + 11, (int) Math.floor(x + f * 140) + 1, y + 16, GUIManager.sliderColor);
fontRenderer.drawString(sliderText.apply(Math.round(f * mapper + adder)), x + 140 + 4, y + 10, GUIManager.sliderColor);
}
@Override
@ -94,7 +94,7 @@ public class IntSlider extends Component {
return;
}
if(mouseButton == 0) {
f = Math.max(Math.min(x, 100), 0) / 100f;
f = Math.max(Math.min(x, 140), 0) / 140f;
handle.getContent().set(field, Math.round(f * mapper + adder));
handle.updated(field);

View file

@ -39,9 +39,9 @@ public class Slider extends Component {
@Override
public void draw(int x, int y) {
Gui.drawRect(x, y + 13, x + 151, y + 14, GUIManager.sliderBackground);
Gui.drawRect((int) Math.floor(x + f * 150), y + 11, (int) Math.floor(x + f * 150) + 1, y + 16, GUIManager.sliderColor);
fontRenderer.drawString(sliderText.apply(f * mapper + adder), x + 150 + 4, y + 10, GUIManager.sliderColor);
Gui.drawRect(x, y + 13, x + 141, y + 14, GUIManager.sliderBackground);
Gui.drawRect((int) Math.floor(x + f * 140), y + 11, (int) Math.floor(x + f * 140) + 1, y + 16, GUIManager.sliderColor);
fontRenderer.drawString(sliderText.apply(f * mapper + adder), x + 140 + 4, y + 10, GUIManager.sliderColor);
}
@Override
@ -92,7 +92,7 @@ public class Slider extends Component {
return;
}
if(mouseButton == 0) {
f = Math.max(Math.min(x, 100), 0) / 100f;
f = Math.max(Math.min(x, 140), 0) / 140f;
handle.getContent().set(field, f * mapper + adder);
handle.updated(field);