MineLittlePony/src/common/java/com/minelittlepony/gui/Slider.java

45 lines
1.1 KiB
Java
Raw Normal View History

package com.minelittlepony.gui;
import net.minecraft.client.gui.GuiSlider;
import net.minecraft.client.gui.GuiPageButtonList.GuiResponder;
/**
* A slider for sliding.
*
* @author Sollace
*
*/
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) {
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;
private Slider owner;
2018-07-27 15:45:16 +02:00
private Responder(IGuiCallback<Float> callback) {
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) { }
}
}