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,66 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.controls.button;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.craftgui.events.EventHandler;
import binnie.craftgui.events.EventButtonClicked;
import binnie.craftgui.events.EventMouse;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.controls.core.Control;
public class ControlButton extends Control
{
private ControlText textWidget;
private String text;
public ControlButton(final IWidget parent, final float x, final float y, final float width, final float height) {
super(parent, x, y, width, height);
this.addAttribute(Attribute.MouseOver);
this.addEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(final EventMouse.Down event) {
ControlButton.this.callEvent(new EventButtonClicked(ControlButton.this.getWidget()));
ControlButton.this.onMouseClick(event);
}
}.setOrigin(EventHandler.Origin.Self, this));
}
protected void onMouseClick(final EventMouse.Down event) {
}
public ControlButton(final IWidget parent, final float x, final float y, final float width, final float height, final String text) {
this(parent, x, y, width, height);
this.text = text;
this.textWidget = new ControlText(this, this.getArea(), text, TextJustification.MiddleCenter);
}
@Override
public void onUpdateClient() {
if (this.textWidget != null) {
this.textWidget.setValue(this.getText());
}
}
public String getText() {
return this.text;
}
@Override
public void onRenderBackground() {
Object texture = CraftGUITexture.ButtonDisabled;
if (this.isMouseOver()) {
texture = CraftGUITexture.ButtonHighlighted;
}
else if (this.isEnabled()) {
texture = CraftGUITexture.Button;
}
CraftGUI.Render.texture(texture, this.getArea());
}
}
@@ -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;
}
}
@@ -0,0 +1,23 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.controls.button;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.events.EventToggleButtonClicked;
import binnie.craftgui.events.EventMouse;
public class ControlToggleButton extends ControlButton
{
boolean toggled;
@Override
public void onMouseClick(final EventMouse.Down event) {
this.callEvent(new EventToggleButtonClicked(this, this.toggled));
}
public ControlToggleButton(final IWidget parent, final int x, final int y, final int width, final int height) {
super(parent, x, y, width, height);
}
}