/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package thegame.layers.options;
import java.util.List;
import thegame.gui.GameMenuElement;
import thegame.gui.SelectionMenuCell;
import thegame.gui.SelectionMenuComponent;
import thegame.layers.Options;
/**
*
* @author www.b23prodtm.info
*/
public class FieldSlider<VALUE> extends Field<VALUE> {
public FieldSlider(String name, VALUE[] values, VALUE currentDefaultValue) {
super(name, values, currentDefaultValue);
}
@Override
public SelectionMenuComponent makeOptionSlider(Options options, SelectionMenuComponent parent, List<SelectionMenuCell> menu) {
for (final VALUE v : values) {
Runnable validate;
Runnable invalidate;
validate = new Runnable() {
public void run() {
currentValue = v;
}
};
invalidate = new Runnable() {
public void run() {
currentValue = defaultValue;
}
};
GameMenuElement._addToMenu(options.gui, menu, v.toString(), validate, invalidate);
}
return new SelectionMenuComponent(options.gui, name, parent, menu, SelectionMenuComponent.VERTICAL_LAYOUT);
}
}