port to forestry 4.2

This commit is contained in:
marcin212 committed 2016-10-20 02:56:31 +02:00
1 parent dbc5c1a564
commit f969f63b66
3697 files changed
+78372

No files matched your search

@@ -0,0 +1,61 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.controls.button;
import java.util.ArrayList;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.events.EventValueChanged;
import binnie.craftgui.events.EventMouse;
import java.util.List;
import binnie.craftgui.controls.core.IControlValue;
public class ControlEnumButton<T> extends ControlButton implements IControlValue<T>
{
public static final String eventEnumChanged = "eventEnumButtonChanged";
private T currentSelection;
private List<T> enumConstants;
@Override
public String getText() {
return this.currentSelection.toString();
}
@Override
public void onMouseClick(final EventMouse.Down event) {
int index = this.enumConstants.indexOf(this.currentSelection);
if (index < this.enumConstants.size() - 1) {
++index;
}
else {
index = 0;
}
final T newEnum = this.enumConstants.get(index);
this.setValue(newEnum);
}
@Override
public void setValue(final T selection) {
if (this.currentSelection != selection) {
this.currentSelection = selection;
this.callEvent(new EventValueChanged<Object>(this, this.getValue()));
}
}
public ControlEnumButton(final IWidget parent, final float x, final float y, final float width, final float height, final T[] values) {
super(parent, x, y, width, height, "");
this.enumConstants = new ArrayList<T>();
for (final T value : values) {
this.enumConstants.add(value);
}
if (values.length > 0) {
this.currentSelection = values[0];
}
}
@Override
public T getValue() {
return this.currentSelection;
}
}