2018-05-13 18:43:49 +02:00
|
|
|
package com.minelittlepony.gui;
|
|
|
|
|
|
|
|
import net.minecraft.client.gui.GuiSlider;
|
|
|
|
import net.minecraft.client.gui.GuiPageButtonList.GuiResponder;
|
|
|
|
|
2018-07-27 14:27:32 +02:00
|
|
|
/**
|
|
|
|
* A slider for sliding.
|
|
|
|
*
|
|
|
|
* @author Sollace
|
|
|
|
*
|
|
|
|
*/
|
2018-05-13 18:43:49 +02:00
|
|
|
public class Slider extends GuiSlider {
|
|
|
|
|
|
|
|
private static Responder callback;
|
|
|
|
|
2018-07-27 15:45:16 +02:00
|
|
|
public Slider(int x, int y, float minIn, float maxIn, float defaultValue, GuiSlider.FormatHelper formatter, IGuiCallback<Float> action) {
|
2018-05-13 18:43:49 +02:00
|
|
|
super(callback = new Responder(action), 0, x, y, "", minIn, maxIn, defaultValue, formatter);
|
|
|
|
callback.owner = this;
|
|
|
|
callback = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final class Responder implements GuiResponder {
|
|
|
|
|
2018-07-27 15:45:16 +02:00
|
|
|
private final IGuiCallback<Float> action;
|
2018-05-13 18:43:49 +02:00
|
|
|
|
|
|
|
private Slider owner;
|
|
|
|
|
2018-07-27 15:45:16 +02:00
|
|
|
private Responder(IGuiCallback<Float> callback) {
|
2018-05-13 18:43:49 +02:00
|
|
|
action = callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setEntryValue(int id, boolean value) { }
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setEntryValue(int id, float value) {
|
|
|
|
owner.setSliderValue(action.perform(value), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setEntryValue(int id, String value) { }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|