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,72 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.controls;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.events.EventValueChanged;
import binnie.craftgui.events.EventHandler;
import binnie.craftgui.events.EventMouse;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.geometry.TextJustification;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.controls.core.IControlValue;
import binnie.craftgui.controls.core.Control;
public class ControlCheckbox extends Control implements IControlValue<Boolean>
{
boolean value;
String text;
public ControlCheckbox(final IWidget parent, final float x, final float y, final boolean bool) {
this(parent, x, y, 0.0f, "", bool);
}
public ControlCheckbox(final IWidget parent, final float x, final float y, final float w, final String text, final boolean bool) {
super(parent, x, y, (w > 16.0f) ? w : 16.0f, 16.0f);
this.text = text;
this.value = bool;
if (w > 16.0f) {
new ControlText(this, new IArea(16.0f, 1.0f, w - 16.0f, 16.0f), text, TextJustification.MiddleCenter).setColour(4473924);
}
this.addAttribute(Attribute.MouseOver);
this.addEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(final EventMouse.Down event) {
ControlCheckbox.this.toggleValue();
}
}.setOrigin(EventHandler.Origin.Self, this));
}
protected void onValueChanged(final boolean value) {
}
@Override
public Boolean getValue() {
return this.value;
}
@Override
public void setValue(final Boolean value) {
this.value = value;
this.onValueChanged(value);
this.callEvent(new EventValueChanged<Object>(this, value));
}
public void toggleValue() {
this.setValue(Boolean.valueOf(!this.getValue()));
}
@Override
public void onRenderBackground() {
Object texture = this.getValue() ? CraftGUITexture.CheckboxChecked : CraftGUITexture.Checkbox;
if (this.isMouseOver()) {
texture = (this.getValue() ? CraftGUITexture.CheckboxCheckedHighlighted : CraftGUITexture.CheckboxHighlighted);
}
CraftGUI.Render.texture(texture, IPoint.ZERO);
}
}