mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-25 22:44:38 +00:00
port to forestry 4.2
This commit is contained in:
1 parent
dbc5c1a564
commit
f969f63b66
3697 files changed
+78372
No files matched your search
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public enum Attribute implements IWidgetAttribute
|
||||
{
|
||||
MouseOver,
|
||||
CanFocus,
|
||||
NeedsDeletion,
|
||||
AlwaysOnTop,
|
||||
BlockTooltip;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import binnie.craftgui.core.renderer.Renderer;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUIResourceManager;
|
||||
|
||||
public class CraftGUI
|
||||
{
|
||||
public static CraftGUIResourceManager ResourceManager;
|
||||
public static Renderer Render;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public interface ITooltip
|
||||
{
|
||||
void getTooltip(final Tooltip p0);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public interface ITooltipHelp
|
||||
{
|
||||
void getHelpTooltip(final Tooltip p0);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
public interface ITopLevelWidget extends IWidget
|
||||
{
|
||||
void setMousePosition(final int p0, final int p1);
|
||||
|
||||
IPoint getAbsoluteMousePosition();
|
||||
|
||||
IWidget getFocusedWidget();
|
||||
|
||||
IWidget getMousedOverWidget();
|
||||
|
||||
IWidget getDraggedWidget();
|
||||
|
||||
boolean isFocused(final IWidget p0);
|
||||
|
||||
boolean isMouseOver(final IWidget p0);
|
||||
|
||||
boolean isDragged(final IWidget p0);
|
||||
|
||||
void updateTopLevel();
|
||||
|
||||
void widgetDeleted(final IWidget p0);
|
||||
|
||||
IPoint getDragDistance();
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.Event;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
public interface IWidget
|
||||
{
|
||||
IWidget getParent();
|
||||
|
||||
void deleteChild(final IWidget p0);
|
||||
|
||||
void deleteAllChildren();
|
||||
|
||||
ITopLevelWidget getSuperParent();
|
||||
|
||||
boolean isTopLevel();
|
||||
|
||||
IPoint getPosition();
|
||||
|
||||
IPoint pos();
|
||||
|
||||
void setPosition(final IPoint p0);
|
||||
|
||||
IPoint getSize();
|
||||
|
||||
IPoint size();
|
||||
|
||||
void setSize(final IPoint p0);
|
||||
|
||||
IPoint getOriginalPosition();
|
||||
|
||||
IPoint getAbsolutePosition();
|
||||
|
||||
IPoint getOriginalAbsolutePosition();
|
||||
|
||||
IPoint getOffset();
|
||||
|
||||
IArea getArea();
|
||||
|
||||
IArea area();
|
||||
|
||||
void setOffset(final IPoint p0);
|
||||
|
||||
IPoint getMousePosition();
|
||||
|
||||
IPoint getRelativeMousePosition();
|
||||
|
||||
void setColour(final int p0);
|
||||
|
||||
int getColour();
|
||||
|
||||
void render();
|
||||
|
||||
void updateClient();
|
||||
|
||||
void enable();
|
||||
|
||||
void disable();
|
||||
|
||||
void show();
|
||||
|
||||
void hide();
|
||||
|
||||
boolean calculateIsMouseOver();
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
boolean isVisible();
|
||||
|
||||
boolean isFocused();
|
||||
|
||||
boolean isMouseOver();
|
||||
|
||||
boolean isDragged();
|
||||
|
||||
boolean isChildVisible(final IWidget p0);
|
||||
|
||||
boolean isChildEnabled(final IWidget p0);
|
||||
|
||||
boolean canMouseOver();
|
||||
|
||||
boolean canFocus();
|
||||
|
||||
IWidget addWidget(final IWidget p0);
|
||||
|
||||
List<IWidget> getWidgets();
|
||||
|
||||
void callEvent(final Event p0);
|
||||
|
||||
void recieveEvent(final Event p0);
|
||||
|
||||
void onUpdateClient();
|
||||
|
||||
void delete();
|
||||
|
||||
void onDelete();
|
||||
|
||||
<T> T getWidget(final Class<T> p0);
|
||||
|
||||
IArea getCroppedZone();
|
||||
|
||||
void setCroppedZone(final IWidget p0, final IArea p1);
|
||||
|
||||
boolean isCroppedWidet();
|
||||
|
||||
IWidget getCropWidget();
|
||||
|
||||
boolean isMouseOverWidget(final IPoint p0);
|
||||
|
||||
int getLevel();
|
||||
|
||||
boolean isDescendant(final IWidget p0);
|
||||
|
||||
List<IWidgetAttribute> getAttributes();
|
||||
|
||||
boolean hasAttribute(final IWidgetAttribute p0);
|
||||
|
||||
boolean addAttribute(final IWidgetAttribute p0);
|
||||
|
||||
<E extends Event> void addEventHandler(final EventHandler<E> p0);
|
||||
|
||||
<E extends Event> void addSelfEventHandler(final EventHandler<E> p0);
|
||||
|
||||
boolean contains(final IPoint p0);
|
||||
|
||||
float x();
|
||||
|
||||
float y();
|
||||
|
||||
float w();
|
||||
|
||||
float h();
|
||||
|
||||
void onRender(final RenderStage p0);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public interface IWidgetAttribute
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
public enum RenderStage
|
||||
{
|
||||
PreChildren,
|
||||
PostChildren,
|
||||
PostSiblings;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Tooltip
|
||||
{
|
||||
List<String> tooltip;
|
||||
ITooltipType type;
|
||||
public int maxWidth;
|
||||
|
||||
public Tooltip() {
|
||||
this.tooltip = new ArrayList<String>();
|
||||
this.type = Type.Standard;
|
||||
this.maxWidth = 256;
|
||||
}
|
||||
|
||||
public void add(final String string) {
|
||||
this.tooltip.add(string);
|
||||
}
|
||||
|
||||
public String getLine(final int index) {
|
||||
final String string = this.getList().get(index);
|
||||
return string;
|
||||
}
|
||||
|
||||
public void add(final List list) {
|
||||
for (final Object obj : list) {
|
||||
this.tooltip.add((String) obj);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getList() {
|
||||
return this.tooltip;
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
return this.tooltip.size() > 0;
|
||||
}
|
||||
|
||||
public void setType(final ITooltipType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setMaxWidth(final int w) {
|
||||
this.maxWidth = w;
|
||||
}
|
||||
|
||||
public ITooltipType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void add(final ItemStack item, final String string) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
item.writeToNBT(nbt);
|
||||
nbt.setByte("nbt-type", (byte) 105);
|
||||
this.add("~~~" + nbt.toString() + "~~~" + string);
|
||||
}
|
||||
|
||||
public void add(final FluidStack item, final String string) {
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
item.writeToNBT(nbt);
|
||||
nbt.setByte("nbt-type", (byte) 102);
|
||||
this.add("~~~" + nbt.toString() + "~~~" + string);
|
||||
}
|
||||
|
||||
public enum Type implements ITooltipType
|
||||
{
|
||||
Standard,
|
||||
Help,
|
||||
Information,
|
||||
User,
|
||||
Power;
|
||||
}
|
||||
|
||||
public interface ITooltipType
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import java.util.ListIterator;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
public abstract class TopLevelWidget extends Widget implements ITopLevelWidget
|
||||
{
|
||||
IWidget mousedOverWidget;
|
||||
IWidget draggedWidget;
|
||||
IWidget focusedWidget;
|
||||
protected IPoint mousePosition;
|
||||
IPoint dragStart;
|
||||
|
||||
public TopLevelWidget() {
|
||||
super(null);
|
||||
this.mousedOverWidget = null;
|
||||
this.draggedWidget = null;
|
||||
this.focusedWidget = null;
|
||||
this.mousePosition = new IPoint(0.0f, 0.0f);
|
||||
this.dragStart = IPoint.ZERO;
|
||||
this.addEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
TopLevelWidget.this.setDraggedWidget(TopLevelWidget.this.mousedOverWidget, event.getButton());
|
||||
TopLevelWidget.this.setFocusedWidget(TopLevelWidget.this.mousedOverWidget);
|
||||
}
|
||||
});
|
||||
this.addEventHandler(new EventMouse.Up.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Up event) {
|
||||
TopLevelWidget.this.setDraggedWidget(null);
|
||||
}
|
||||
});
|
||||
this.addEventHandler(new EventWidget.StartDrag.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.StartDrag event) {
|
||||
TopLevelWidget.this.dragStart = TopLevelWidget.this.getRelativeMousePosition();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setMousedOverWidget(final IWidget widget) {
|
||||
if (this.mousedOverWidget == widget) {
|
||||
return;
|
||||
}
|
||||
if (this.mousedOverWidget != null) {
|
||||
this.callEvent(new EventWidget.EndMouseOver(this.mousedOverWidget));
|
||||
}
|
||||
this.mousedOverWidget = widget;
|
||||
if (this.mousedOverWidget != null) {
|
||||
this.callEvent(new EventWidget.StartMouseOver(this.mousedOverWidget));
|
||||
}
|
||||
}
|
||||
|
||||
public void setDraggedWidget(final IWidget widget) {
|
||||
this.setDraggedWidget(widget, -1);
|
||||
}
|
||||
|
||||
public void setDraggedWidget(final IWidget widget, final int button) {
|
||||
if (this.draggedWidget == widget) {
|
||||
return;
|
||||
}
|
||||
if (this.draggedWidget != null) {
|
||||
this.callEvent(new EventWidget.EndDrag(this.draggedWidget));
|
||||
}
|
||||
this.draggedWidget = widget;
|
||||
if (this.draggedWidget != null) {
|
||||
this.callEvent(new EventWidget.StartDrag(this.draggedWidget, button));
|
||||
}
|
||||
}
|
||||
|
||||
public void setFocusedWidget(final IWidget widget) {
|
||||
IWidget newWidget = widget;
|
||||
if (this.focusedWidget == newWidget) {
|
||||
return;
|
||||
}
|
||||
if (newWidget != null && !newWidget.canFocus()) {
|
||||
newWidget = null;
|
||||
}
|
||||
if (this.focusedWidget != null) {
|
||||
this.callEvent(new EventWidget.LoseFocus(this.focusedWidget));
|
||||
}
|
||||
this.focusedWidget = newWidget;
|
||||
if (this.focusedWidget != null) {
|
||||
this.callEvent(new EventWidget.GainFocus(this.focusedWidget));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getMousedOverWidget() {
|
||||
return this.mousedOverWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getDraggedWidget() {
|
||||
return this.draggedWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget getFocusedWidget() {
|
||||
return this.focusedWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOver(final IWidget widget) {
|
||||
return this.getMousedOverWidget() == widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDragged(final IWidget widget) {
|
||||
return this.getDraggedWidget() == widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFocused(final IWidget widget) {
|
||||
return this.getFocusedWidget() == widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTopLevel() {
|
||||
this.setMousedOverWidget(this.calculateMousedOverWidget());
|
||||
if (this.getFocusedWidget() != null && (!this.getFocusedWidget().isVisible() || !this.getFocusedWidget().isEnabled())) {
|
||||
this.setFocusedWidget(null);
|
||||
}
|
||||
if (!Mouse.isButtonDown(0)) {
|
||||
if (this.draggedWidget != null) {
|
||||
this.setDraggedWidget(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IWidget calculateMousedOverWidget() {
|
||||
final Deque<IWidget> queue = this.calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
final IWidget widget = queue.removeFirst();
|
||||
if (widget.isEnabled() && widget.isVisible()) {
|
||||
if (!widget.canMouseOver()) {
|
||||
continue;
|
||||
}
|
||||
if (widget.isEnabled() && widget.isVisible() && widget.canMouseOver() && widget.calculateIsMouseOver()) {
|
||||
return widget;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Deque<IWidget> calculateMousedOverWidgets() {
|
||||
final Deque<IWidget> list = new ArrayDeque<IWidget>();
|
||||
for (final IWidget widget : this.getQueuedWidgets(this)) {
|
||||
if (widget.calculateIsMouseOver()) {
|
||||
list.addLast(widget);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private Collection<IWidget> getQueuedWidgets(final IWidget widget) {
|
||||
final List<IWidget> widgets = new ArrayList<IWidget>();
|
||||
boolean addChildren = true;
|
||||
if (widget.isCroppedWidet()) {
|
||||
addChildren = widget.getCroppedZone().contains(widget.getCropWidget().getRelativeMousePosition());
|
||||
}
|
||||
if (addChildren) {
|
||||
final ListIterator<IWidget> li = widget.getWidgets().listIterator(widget.getWidgets().size());
|
||||
while (li.hasPrevious()) {
|
||||
final IWidget child = li.previous();
|
||||
widgets.addAll(this.getQueuedWidgets(child));
|
||||
}
|
||||
}
|
||||
widgets.add(widget);
|
||||
return widgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMousePosition(final int x, final int y) {
|
||||
final float dx = x - this.mousePosition.x();
|
||||
final float dy = y - this.mousePosition.y();
|
||||
if (dx != 0.0f || dy != 0.0f) {
|
||||
if (this.getDraggedWidget() != null) {
|
||||
this.callEvent(new EventMouse.Drag(this.getDraggedWidget(), dx, dy));
|
||||
}
|
||||
else {
|
||||
this.callEvent(new EventMouse.Move(this, dx, dy));
|
||||
}
|
||||
}
|
||||
if (this.mousePosition.x() != x || this.mousePosition.y() != y) {
|
||||
this.mousePosition = new IPoint(x, y);
|
||||
this.setMousedOverWidget(this.calculateMousedOverWidget());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPoint getAbsoluteMousePosition() {
|
||||
return this.mousePosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDeleted(final IWidget widget) {
|
||||
if (this.isMouseOver(widget)) {
|
||||
this.setMousedOverWidget(null);
|
||||
}
|
||||
if (this.isDragged(widget)) {
|
||||
this.setDraggedWidget(null);
|
||||
}
|
||||
if (this.isFocused(widget)) {
|
||||
this.setFocusedWidget(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPoint getDragDistance() {
|
||||
return this.getRelativeMousePosition().sub(this.dragStart);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,517 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import java.util.ConcurrentModificationException;
|
||||
|
||||
import binnie.craftgui.events.Event;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Widget implements IWidget
|
||||
{
|
||||
private IWidget parent;
|
||||
private List<IWidget> subWidgets;
|
||||
private List<IWidgetAttribute> attributes;
|
||||
private IPoint position;
|
||||
private IPoint size;
|
||||
private IPoint offset;
|
||||
IArea cropArea;
|
||||
IWidget cropWidget;
|
||||
boolean cropped;
|
||||
int colour;
|
||||
private Collection<EventHandler> globalEventHandlers;
|
||||
private boolean enabled;
|
||||
private boolean visible;
|
||||
|
||||
public Widget(final IWidget parent) {
|
||||
this.parent = null;
|
||||
this.subWidgets = new ArrayList<IWidget>();
|
||||
this.attributes = new ArrayList<IWidgetAttribute>();
|
||||
this.position = new IPoint(0.0f, 0.0f);
|
||||
this.size = new IPoint(0.0f, 0.0f);
|
||||
this.offset = new IPoint(0.0f, 0.0f);
|
||||
this.cropped = false;
|
||||
this.colour = 16777215;
|
||||
this.globalEventHandlers = new ArrayList<EventHandler>();
|
||||
this.enabled = true;
|
||||
this.visible = true;
|
||||
this.parent = parent;
|
||||
if (parent != null) {
|
||||
parent.addWidget(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IWidgetAttribute> getAttributes() {
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttribute(final IWidgetAttribute attribute) {
|
||||
return this.attributes.contains(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAttribute(final IWidgetAttribute attribute) {
|
||||
return this.attributes.add(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void deleteChild(final IWidget child) {
|
||||
if (child == null) {
|
||||
return;
|
||||
}
|
||||
child.delete();
|
||||
this.subWidgets.remove(child);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void deleteAllChildren() {
|
||||
while (!this.subWidgets.isEmpty()) {
|
||||
this.deleteChild(this.subWidgets.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IWidget getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ITopLevelWidget getSuperParent() {
|
||||
return (ITopLevelWidget) (this.isTopLevel() ? this : this.parent.getSuperParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IWidget addWidget(final IWidget widget) {
|
||||
if (this.subWidgets.size() != 0 && this.subWidgets.get(this.subWidgets.size() - 1).hasAttribute(Attribute.AlwaysOnTop)) {
|
||||
this.subWidgets.add(this.subWidgets.size() - 1, widget);
|
||||
}
|
||||
else {
|
||||
this.subWidgets.add(widget);
|
||||
}
|
||||
this.onAddChild(widget);
|
||||
return widget;
|
||||
}
|
||||
|
||||
protected void onAddChild(final IWidget widget) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<IWidget> getWidgets() {
|
||||
return this.subWidgets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isTopLevel() {
|
||||
return this instanceof ITopLevelWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint pos() {
|
||||
return this.position.add(this.offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint size() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IArea area() {
|
||||
return this.getArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getPosition() {
|
||||
return this.pos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IArea getArea() {
|
||||
return new IArea(IPoint.ZERO, this.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getOriginalPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IArea getCroppedZone() {
|
||||
return this.cropArea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCroppedZone(final IWidget relative, final IArea area) {
|
||||
this.cropArea = area;
|
||||
this.cropped = true;
|
||||
this.cropWidget = relative;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getAbsolutePosition() {
|
||||
return this.isTopLevel() ? this.getPosition() : this.getParent().getAbsolutePosition().add(this.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getOriginalAbsolutePosition() {
|
||||
return this.isTopLevel() ? this.getOriginalPosition() : this.getParent().getOriginalPosition().sub(this.getOriginalPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getSize() {
|
||||
return this.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getOffset() {
|
||||
return this.offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setPosition(final IPoint vector) {
|
||||
if (!vector.equals(this.position)) {
|
||||
this.position = new IPoint(vector);
|
||||
this.callEvent(new EventWidget.ChangePosition(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setSize(final IPoint vector) {
|
||||
if (!vector.equals(this.size)) {
|
||||
this.size = new IPoint(vector);
|
||||
this.callEvent(new EventWidget.ChangeSize(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setOffset(final IPoint vector) {
|
||||
if (vector != this.offset) {
|
||||
this.offset = new IPoint(vector);
|
||||
this.callEvent(new EventWidget.ChangeOffset(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setColour(final int colour) {
|
||||
if (this.colour != colour) {
|
||||
this.colour = colour;
|
||||
this.callEvent(new EventWidget.ChangeColour(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int getColour() {
|
||||
return this.colour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMouseOver() {
|
||||
return this.hasAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFocus() {
|
||||
return this.hasAttribute(Attribute.CanFocus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEventHandler(final EventHandler handler) {
|
||||
this.globalEventHandlers.add(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSelfEventHandler(final EventHandler handler) {
|
||||
this.addEventHandler(handler.setOrigin(EventHandler.Origin.Self, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void callEvent(final Event event) {
|
||||
this.getSuperParent().recieveEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void recieveEvent(final Event event) {
|
||||
for (final EventHandler handler : this.globalEventHandlers) {
|
||||
if (handler.handles(event)) {
|
||||
handler.onEvent(event);
|
||||
}
|
||||
}
|
||||
try {
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
child.recieveEvent(event);
|
||||
}
|
||||
} catch (ConcurrentModificationException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getMousePosition() {
|
||||
return this.getSuperParent().getAbsoluteMousePosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getRelativeMousePosition() {
|
||||
return this.isTopLevel() ? this.getMousePosition() : this.getParent().getRelativeMousePosition().sub(this.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCroppedWidet() {
|
||||
return this.cropped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IWidget getCropWidget() {
|
||||
return (this.cropWidget == null) ? this : this.cropWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void render() {
|
||||
if (this.isVisible()) {
|
||||
CraftGUI.Render.preRender(this);
|
||||
this.onRender(RenderStage.PreChildren);
|
||||
for (final IWidget widget : this.getWidgets()) {
|
||||
widget.render();
|
||||
}
|
||||
for (final IWidget widget : this.getWidgets()) {
|
||||
CraftGUI.Render.preRender(widget);
|
||||
widget.onRender(RenderStage.PostSiblings);
|
||||
CraftGUI.Render.postRender(widget);
|
||||
}
|
||||
this.onRender(RenderStage.PostChildren);
|
||||
CraftGUI.Render.postRender(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void updateClient() {
|
||||
if (!this.isVisible()) {
|
||||
return;
|
||||
}
|
||||
if (this.getSuperParent() == this) {
|
||||
((ITopLevelWidget) this).updateTopLevel();
|
||||
}
|
||||
this.onUpdateClient();
|
||||
final List<IWidget> deletedWidgets = new ArrayList<IWidget>();
|
||||
for (final IWidget widget : this.getWidgets()) {
|
||||
if (widget.hasAttribute(Attribute.NeedsDeletion)) {
|
||||
deletedWidgets.add(widget);
|
||||
}
|
||||
else {
|
||||
widget.updateClient();
|
||||
}
|
||||
}
|
||||
for (final IWidget widget : deletedWidgets) {
|
||||
this.deleteChild(widget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean calculateIsMouseOver() {
|
||||
final IPoint mouse = this.getRelativeMousePosition();
|
||||
if (!this.cropped) {
|
||||
return this.isMouseOverWidget(mouse);
|
||||
}
|
||||
final IWidget cropRelative = (this.cropWidget != null) ? this.cropWidget : this;
|
||||
final IPoint pos = IPoint.sub(cropRelative.getAbsolutePosition(), this.getAbsolutePosition());
|
||||
final IPoint size = new IPoint(this.cropArea.size().x(), this.cropArea.size().y());
|
||||
final boolean inCrop = mouse.x() > pos.x() && mouse.y() > pos.y() && mouse.x() < pos.x() + size.x() && mouse.y() < pos.y() + size.y();
|
||||
return inCrop && this.isMouseOverWidget(mouse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMouseOverWidget(final IPoint relativeMouse) {
|
||||
return this.getArea().contains(relativeMouse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void enable() {
|
||||
this.enabled = true;
|
||||
this.callEvent(new EventWidget.Enable(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void disable() {
|
||||
this.enabled = false;
|
||||
this.callEvent(new EventWidget.Disable(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void show() {
|
||||
this.visible = true;
|
||||
this.callEvent(new EventWidget.Show(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void hide() {
|
||||
this.visible = false;
|
||||
this.callEvent(new EventWidget.Hide(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (this.enabled) {
|
||||
if (!this.isTopLevel()) {
|
||||
if (!this.getParent().isEnabled() || !this.getParent().isChildEnabled(this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isVisible() {
|
||||
if (this.visible) {
|
||||
if (!this.isTopLevel()) {
|
||||
if (!this.getParent().isVisible() || !this.getParent().isChildVisible(this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isFocused() {
|
||||
return this.getSuperParent().isFocused(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isDragged() {
|
||||
return this.getSuperParent().isDragged(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isMouseOver() {
|
||||
return this.getSuperParent().isMouseOver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildVisible(final IWidget child) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildEnabled(final IWidget child) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRender(final RenderStage stage) {
|
||||
if (stage == RenderStage.PreChildren) {
|
||||
this.onRenderBackground();
|
||||
}
|
||||
if (stage == RenderStage.PostChildren) {
|
||||
this.onRenderForeground();
|
||||
}
|
||||
if (stage == RenderStage.PostSiblings) {
|
||||
this.onRenderOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
public void onRenderBackground() {
|
||||
}
|
||||
|
||||
public void onRenderForeground() {
|
||||
}
|
||||
|
||||
public void onRenderOverlay() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void delete() {
|
||||
this.getSuperParent().widgetDeleted(this);
|
||||
this.onDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDelete() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getWidget(final Class<T> x) {
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
if (x.isInstance(child)) {
|
||||
return (T) child;
|
||||
}
|
||||
final T found = child.getWidget(x);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean contains(final IPoint position) {
|
||||
return this.getArea().contains(position);
|
||||
}
|
||||
|
||||
public void scheduleDeletion() {
|
||||
this.addAttribute(Attribute.NeedsDeletion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
final int level = (this.getParent() == null) ? 0 : this.getParent().getLevel();
|
||||
final int index = (this.getParent() == null) ? 0 : this.getParent().getWidgets().indexOf(this);
|
||||
return level + index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDescendant(final IWidget widget) {
|
||||
IWidget clss = this;
|
||||
while (clss != widget) {
|
||||
clss = clss.getParent();
|
||||
if (clss == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float x() {
|
||||
return this.pos().x();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float y() {
|
||||
return this.pos().y();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float w() {
|
||||
return this.size().x();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float h() {
|
||||
return this.size().y();
|
||||
}
|
||||
|
||||
public IWidget getWidget() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
import binnie.craftgui.events.EventValueChanged;
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
|
||||
public class CraftGUIUtil
|
||||
{
|
||||
public static void alignToWidget(final IWidget target, final IWidget relativeTo) {
|
||||
final IPoint startPos = target.getAbsolutePosition();
|
||||
final IPoint endPos = relativeTo.getAbsolutePosition();
|
||||
moveWidget(target, endPos.sub(startPos));
|
||||
}
|
||||
|
||||
public static void moveWidget(final IWidget target, final IPoint movement) {
|
||||
target.setPosition(target.getPosition().add(movement));
|
||||
}
|
||||
|
||||
public static void horizontalGrid(final float px, final float py, final IWidget... widgets) {
|
||||
horizontalGrid(px, py, TextJustification.MiddleCenter, 0.0f, widgets);
|
||||
}
|
||||
|
||||
public static void horizontalGrid(final float px, final float py, final TextJustification just, final float spacing, final IWidget... widgets) {
|
||||
float x = 0.0f;
|
||||
float h = 0.0f;
|
||||
for (final IWidget widget : widgets) {
|
||||
h = Math.max(h, widget.getSize().y());
|
||||
}
|
||||
for (final IWidget widget : widgets) {
|
||||
widget.setPosition(new IPoint(px + x, py + (h - widget.getSize().y()) * just.yOffset));
|
||||
x += widget.getSize().x() + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
public static void verticalGrid(final float px, final float py, final IWidget... widgets) {
|
||||
horizontalGrid(px, py, TextJustification.MiddleCenter, 0.0f, widgets);
|
||||
}
|
||||
|
||||
public static void verticalGrid(final float px, final float py, final TextJustification just, final float spacing, final IWidget... widgets) {
|
||||
float y = 0.0f;
|
||||
float w = 0.0f;
|
||||
for (final IWidget widget : widgets) {
|
||||
w = Math.max(w, widget.getSize().x());
|
||||
}
|
||||
for (final IWidget widget : widgets) {
|
||||
widget.setPosition(new IPoint(px + (w - widget.getSize().x()) * just.xOffset, py + y));
|
||||
y += widget.getSize().y() + spacing;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void linkWidgets(final IControlValue<T> tab, final IControlValue<T> target) {
|
||||
tab.addSelfEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
target.setValue((T) event.getValue());
|
||||
}
|
||||
});
|
||||
target.addSelfEventHandler(new EventValueChanged.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventValueChanged event) {
|
||||
tab.setValue((T) event.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public class IArea
|
||||
{
|
||||
private IPoint pos;
|
||||
private IPoint size;
|
||||
|
||||
public IArea(final IArea area) {
|
||||
this(area.pos().x(), area.pos().y(), area.size().x(), area.size().y());
|
||||
}
|
||||
|
||||
public IArea(final IPoint pos, final IPoint size) {
|
||||
this(pos.x(), pos.y(), size.x(), size.y());
|
||||
}
|
||||
|
||||
public IArea(final float xywh) {
|
||||
this(xywh, xywh, xywh, xywh);
|
||||
}
|
||||
|
||||
public IArea(final float xy, final float wh) {
|
||||
this(xy, xy, wh, wh);
|
||||
}
|
||||
|
||||
public IArea(final float x, final float y, final float wh) {
|
||||
this(x, y, wh, wh);
|
||||
}
|
||||
|
||||
public IArea(final float x, final float y, final float w, final float h) {
|
||||
this.setPosition(new IPoint(x, y));
|
||||
this.setSize(new IPoint(w, h));
|
||||
}
|
||||
|
||||
public IPoint pos() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public IPoint getPosition() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
public void setPosition(final IPoint position) {
|
||||
this.pos = position.copy();
|
||||
}
|
||||
|
||||
public IPoint size() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IPoint getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public void setSize(final IPoint size) {
|
||||
this.size = size.copy();
|
||||
}
|
||||
|
||||
public boolean contains(final IPoint position) {
|
||||
return position.x() >= this.pos().x() && position.y() >= this.pos.y() && position.x() <= this.pos().x() + this.size().x() && position.y() <= this.pos().y() + this.size().y();
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return this.pos().x();
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return this.pos().y();
|
||||
}
|
||||
|
||||
public float w() {
|
||||
return this.size().x();
|
||||
}
|
||||
|
||||
public float h() {
|
||||
return this.size().y();
|
||||
}
|
||||
|
||||
public float x(final float n) {
|
||||
return this.pos.x(n);
|
||||
}
|
||||
|
||||
public float y(final float n) {
|
||||
return this.pos.y(n);
|
||||
}
|
||||
|
||||
public float w(final float n) {
|
||||
return this.size.x(n);
|
||||
}
|
||||
|
||||
public float h(final float n) {
|
||||
return this.size.y(n);
|
||||
}
|
||||
|
||||
public IArea inset(final IBorder border) {
|
||||
return new IArea(this.x() + border.l(), this.y() + border.t(), this.w() - border.l() - border.r(), this.h() - border.t() - border.b());
|
||||
}
|
||||
|
||||
public IArea outset(final int outset) {
|
||||
return this.outset(new IBorder(outset));
|
||||
}
|
||||
|
||||
public IArea outset(final IBorder border) {
|
||||
return new IArea(this.x() - border.l(), this.y() - border.t(), this.w() + border.l() + border.r(), this.h() + border.t() + border.b());
|
||||
}
|
||||
|
||||
public IArea inset(final int inset) {
|
||||
return this.inset(new IBorder(inset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.w() + "x" + this.h() + "@" + this.x() + "," + this.y();
|
||||
}
|
||||
|
||||
public IArea shift(final float dx, final float f) {
|
||||
return new IArea(this.x() + dx, this.y() + f, this.w(), this.h());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public class IBorder
|
||||
{
|
||||
public static final IBorder ZERO;
|
||||
float t;
|
||||
float b;
|
||||
float l;
|
||||
float r;
|
||||
|
||||
public IBorder(final float pad) {
|
||||
this(pad, pad, pad, pad);
|
||||
}
|
||||
|
||||
public IBorder(final float tb, final float rl) {
|
||||
this(tb, rl, tb, rl);
|
||||
}
|
||||
|
||||
public IBorder(final float t, final float rl, final float b) {
|
||||
this(t, rl, b, rl);
|
||||
}
|
||||
|
||||
public IBorder(final float t, final float r, final float b, final float l) {
|
||||
this.t = t;
|
||||
this.b = b;
|
||||
this.l = l;
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public IBorder(final Position edge, final float n) {
|
||||
this((edge == Position.Top) ? n : 0.0f, (edge == Position.Right) ? n : 0.0f, (edge == Position.Bottom) ? n : 0.0f, (edge == Position.Left) ? n : 0.0f);
|
||||
}
|
||||
|
||||
public IBorder(final IBorder padding) {
|
||||
this(padding.t(), padding.r(), padding.b(), padding.l());
|
||||
}
|
||||
|
||||
public float t() {
|
||||
return this.t;
|
||||
}
|
||||
|
||||
public float b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public float l() {
|
||||
return this.l;
|
||||
}
|
||||
|
||||
public float r() {
|
||||
return this.r;
|
||||
}
|
||||
|
||||
public float t(final float n) {
|
||||
return this.t = n;
|
||||
}
|
||||
|
||||
public float b(final float n) {
|
||||
return this.b = n;
|
||||
}
|
||||
|
||||
public float l(final float n) {
|
||||
return this.l = n;
|
||||
}
|
||||
|
||||
public float r(final float n) {
|
||||
return this.r = n;
|
||||
}
|
||||
|
||||
public boolean isNonZero() {
|
||||
return this.t != 0.0f || this.r != 0.0f || this.l != 0.0f || this.r != 0.0f;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint tl() {
|
||||
return new IPoint(this.l(), this.t());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint tr() {
|
||||
return new IPoint(this.r(), this.t());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint bl() {
|
||||
return new IPoint(this.l(), this.b());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IPoint br() {
|
||||
return new IPoint(this.r(), this.b());
|
||||
}
|
||||
|
||||
public IBorder add(final IBorder o) {
|
||||
return new IBorder(this.t() + o.t(), this.r() + o.r(), this.b() + o.b(), this.l() + o.l());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.t() + "-" + this.r() + "-" + this.b() + "-" + this.l();
|
||||
}
|
||||
|
||||
static {
|
||||
ZERO = new IBorder(0.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public class IPoint
|
||||
{
|
||||
public static final IPoint ZERO;
|
||||
float x;
|
||||
float y;
|
||||
|
||||
public IPoint(final float x, final float y) {
|
||||
this.x = 0.0f;
|
||||
this.y = 0.0f;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public IPoint(final IPoint o) {
|
||||
this.x = 0.0f;
|
||||
this.y = 0.0f;
|
||||
this.x = o.x();
|
||||
this.y = o.y();
|
||||
}
|
||||
|
||||
public static IPoint add(final IPoint a, final IPoint b) {
|
||||
return new IPoint(a.x() + b.x(), a.y() + b.y());
|
||||
}
|
||||
|
||||
public static IPoint sub(final IPoint a, final IPoint b) {
|
||||
return new IPoint(a.x() - b.x(), a.y() - b.y());
|
||||
}
|
||||
|
||||
public IPoint sub(final IPoint a) {
|
||||
return sub(this, a);
|
||||
}
|
||||
|
||||
public IPoint add(final IPoint other) {
|
||||
return add(this, other);
|
||||
}
|
||||
|
||||
public IPoint add(final float dx, final float dy) {
|
||||
return add(this, new IPoint(dx, dy));
|
||||
}
|
||||
|
||||
public IPoint copy() {
|
||||
return new IPoint(this);
|
||||
}
|
||||
|
||||
public float x() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public float y() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void xy(final float x, final float y) {
|
||||
this.x(x);
|
||||
this.y(y);
|
||||
}
|
||||
|
||||
public float x(final float x) {
|
||||
return this.x = x;
|
||||
}
|
||||
|
||||
public float y(final float y) {
|
||||
return this.y = y;
|
||||
}
|
||||
|
||||
public boolean equals(final IPoint other) {
|
||||
return this.x() == other.x() && this.y() == other.y();
|
||||
}
|
||||
|
||||
static {
|
||||
ZERO = new IPoint(0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public enum Position
|
||||
{
|
||||
Top(0, -1),
|
||||
Bottom(0, 1),
|
||||
Left(-1, 0),
|
||||
Right(1, 0);
|
||||
|
||||
int x;
|
||||
int y;
|
||||
|
||||
private Position(final int x, final int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int x() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int y() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public Position opposite() {
|
||||
switch (this) {
|
||||
case Bottom: {
|
||||
return Position.Top;
|
||||
}
|
||||
case Left: {
|
||||
return Position.Right;
|
||||
}
|
||||
case Right: {
|
||||
return Position.Left;
|
||||
}
|
||||
case Top: {
|
||||
return Position.Bottom;
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.geometry;
|
||||
|
||||
public enum TextJustification
|
||||
{
|
||||
TopLeft(0.0f, 0.0f),
|
||||
TopCenter(0.5f, 0.0f),
|
||||
TopRight(1.0f, 0.0f),
|
||||
MiddleLeft(0.0f, 0.5f),
|
||||
MiddleCenter(0.5f, 0.5f),
|
||||
MiddleRight(1.0f, 0.5f),
|
||||
BottomLeft(0.0f, 1.0f),
|
||||
BottomCenter(0.5f, 1.0f),
|
||||
BottomRight(1.0f, 1.0f);
|
||||
|
||||
float xOffset;
|
||||
float yOffset;
|
||||
|
||||
private TextJustification(final float xOffset, final float yOffset) {
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
}
|
||||
|
||||
public float getXOffset() {
|
||||
return this.xOffset;
|
||||
}
|
||||
|
||||
public float getYOffset() {
|
||||
return this.yOffset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.renderer;
|
||||
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.core.geometry.TextJustification;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.resource.IStyleSheet;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.minecraft.GuiCraftGUI;
|
||||
|
||||
public class Renderer
|
||||
{
|
||||
GuiCraftGUI gui;
|
||||
int currentColour;
|
||||
Texture currentTexture;
|
||||
IStyleSheet stylesheet;
|
||||
|
||||
public Renderer(final GuiCraftGUI gui) {
|
||||
this.currentColour = 16777215;
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
public final void preRender(final IWidget widget) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(widget.getPosition().x(), widget.getPosition().y(), 0.0f);
|
||||
this.colour(widget.getColour());
|
||||
if (widget.isCroppedWidet()) {
|
||||
final IWidget cropRelative = (widget.getCropWidget() != null) ? widget.getCropWidget() : widget;
|
||||
final IPoint pos = cropRelative.getAbsolutePosition();
|
||||
final IArea cropZone = widget.getCroppedZone();
|
||||
GL11.glEnable(3089);
|
||||
this.limitArea(new IArea(pos.add(cropZone.pos()), cropZone.size()));
|
||||
|
||||
}
|
||||
GL11.glDisable(2929);
|
||||
}
|
||||
|
||||
public final void postRender(final IWidget widget) {
|
||||
if (widget.isCroppedWidet()) {
|
||||
GL11.glDisable(3089);
|
||||
}
|
||||
GL11.glEnable(2929);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void colour(final int hex) {
|
||||
this.currentColour = hex;
|
||||
int a = (hex & 0xFF000000) >> 24;
|
||||
final int r = (hex & 0xFF0000) >> 16;
|
||||
final int g = (hex & 0xFF00) >> 8;
|
||||
final int b = hex & 0xFF;
|
||||
if (a < 0) {
|
||||
a += 256;
|
||||
}
|
||||
if (a > 0 && a != 255) {
|
||||
GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||
GL11.glEnable(3042);
|
||||
}
|
||||
else {
|
||||
GL11.glColor3f(r / 255.0f, g / 255.0f, b / 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public Texture getTexture(final Object key) {
|
||||
if (key instanceof Texture) {
|
||||
return (Texture) key;
|
||||
}
|
||||
return this.stylesheet.getTexture(key);
|
||||
}
|
||||
|
||||
public void setTexture(final Texture texture) {
|
||||
if (texture != this.currentTexture && texture != null) {
|
||||
BinnieCore.proxy.bindTexture(texture.getFilename());
|
||||
}
|
||||
this.colour(this.currentColour);
|
||||
}
|
||||
|
||||
public void texture(final Object texture, final IPoint position) {
|
||||
this.texture(this.getTexture(texture), position);
|
||||
}
|
||||
|
||||
public void texture(final Texture texture, final IPoint position) {
|
||||
if (texture == null) {
|
||||
return;
|
||||
}
|
||||
this.setTexture(texture);
|
||||
final IPoint point = position.sub(new IPoint(texture.getBorder().l(), texture.getBorder().t()));
|
||||
final IArea textureArea = texture.getArea().outset(texture.getBorder());
|
||||
this.gui.renderTexture(point, textureArea);
|
||||
}
|
||||
|
||||
public void texture(final Object window, final IArea area) {
|
||||
this.texture(this.getTexture(window), area);
|
||||
}
|
||||
|
||||
public void texture(final Texture texture, final IArea area) {
|
||||
if (texture == null) {
|
||||
return;
|
||||
}
|
||||
this.setTexture(texture);
|
||||
final IArea textureArea = texture.getArea().outset(texture.getBorder());
|
||||
final IArea targetArea = area.outset(texture.getBorder());
|
||||
if (textureArea.w() == targetArea.w() && textureArea.h() == targetArea.h()) {
|
||||
this.gui.renderTexture(targetArea.pos(), textureArea);
|
||||
}
|
||||
else {
|
||||
this.gui.renderTexturePadded(targetArea, textureArea, texture.getTotalPadding());
|
||||
}
|
||||
}
|
||||
|
||||
public void stylesheet(final IStyleSheet sheet) {
|
||||
this.stylesheet = sheet;
|
||||
}
|
||||
|
||||
public int textWidth(final String text) {
|
||||
return this.gui.getFontRenderer().getStringWidth(text);
|
||||
}
|
||||
|
||||
public int textHeight() {
|
||||
return (this.gui.getFontRenderer() == null) ? 0 : this.gui.getFontRenderer().FONT_HEIGHT;
|
||||
}
|
||||
|
||||
public void text(final IPoint pos, final String text, final int colour) {
|
||||
this.text(new IArea(pos, new IPoint(500.0f, 500.0f)), TextJustification.TopLeft, text, colour);
|
||||
}
|
||||
|
||||
public void text(final IArea area, final TextJustification justification, final String text, final int colour) {
|
||||
final IPoint pos = area.pos();
|
||||
if (area.size().x() <= 0.0f) {
|
||||
return;
|
||||
}
|
||||
final List<String> wrappedStrings = this.gui.getFontRenderer().listFormattedStringToWidth(text, (int) area.size().x());
|
||||
final float totalHeight = wrappedStrings.size() * this.textHeight();
|
||||
float posY = area.pos().y();
|
||||
if (area.size().y() > totalHeight) {
|
||||
posY += (area.size().y() - totalHeight) * justification.getYOffset();
|
||||
}
|
||||
for (final String string : wrappedStrings) {
|
||||
final float stringWidth = this.textWidth(string);
|
||||
float posX = area.size().x() - stringWidth;
|
||||
posX *= justification.getXOffset();
|
||||
GL11.glDisable(2929);
|
||||
this.gui.getFontRenderer().drawString(string, (int) (pos.x() + posX), (int) posY, colour);
|
||||
posY += this.textHeight();
|
||||
}
|
||||
GL11.glColor3f(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
public void solid(final IArea area, final int colour) {
|
||||
this.gui.drawRect(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), 0xFF000000 | colour);
|
||||
}
|
||||
|
||||
public void solidAlpha(final IArea area, final int c1) {
|
||||
this.gui.drawGradientArea(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), c1, c1);
|
||||
}
|
||||
|
||||
public void gradientRect(final IArea area, final int c1, final int c2) {
|
||||
this.gui.drawGradientArea(area.pos().x(), area.pos().y(), area.pos().x() + area.size().x(), area.pos().y() + area.size().y(), c1, c2);
|
||||
}
|
||||
|
||||
public void item(final IPoint pos, final ItemStack item) {
|
||||
this.gui.renderItem(pos, item, false);
|
||||
}
|
||||
|
||||
public void item(final IPoint pos, final ItemStack item, final boolean rotating) {
|
||||
this.gui.renderItem(pos, item, rotating);
|
||||
}
|
||||
|
||||
public void iconBlock(final IPoint pos, final IIcon icon) {
|
||||
this.gui.renderIcon(pos, icon, TextureMap.locationBlocksTexture);
|
||||
}
|
||||
|
||||
public void iconItem(final IPoint pos, final IIcon icon) {
|
||||
this.gui.renderIcon(pos, icon, TextureMap.locationItemsTexture);
|
||||
}
|
||||
|
||||
public void limitArea(final IArea area) {
|
||||
this.gui.limitArea(area);
|
||||
}
|
||||
|
||||
public float textHeight(final String text, final float width) {
|
||||
return this.gui.getFontRenderer().listFormattedStringToWidth(text, (int) width).size() * this.textHeight();
|
||||
}
|
||||
|
||||
public void texturePercentage(final Texture texture, final IArea area, final Position direction, final float percentage) {
|
||||
final float dist = (direction == Position.Top || direction == Position.Bottom) ? (percentage * texture.h()) : (percentage * texture.w());
|
||||
final float dim = (direction == Position.Top || direction == Position.Bottom) ? texture.h() : texture.w();
|
||||
float x = area.pos().x();
|
||||
float y = area.pos().y();
|
||||
float w = area.size().x();
|
||||
float h = area.size().y();
|
||||
switch (direction) {
|
||||
case Top: {
|
||||
h *= percentage;
|
||||
break;
|
||||
}
|
||||
case Right: {
|
||||
x += (1.0f - percentage) * w;
|
||||
w *= percentage;
|
||||
break;
|
||||
}
|
||||
case Left: {
|
||||
w *= percentage;
|
||||
break;
|
||||
}
|
||||
case Bottom: {
|
||||
y += h - (int) (percentage * h);
|
||||
h *= percentage;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.texture(texture.crop(direction, dim - dist), new IArea(x, y, w, h));
|
||||
}
|
||||
|
||||
public void test(final IWidget widget) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.core.renderer;
|
||||
|
||||
public enum TextureType
|
||||
{
|
||||
Stretched,
|
||||
Tiled;
|
||||
}
|
||||
Reference in new issue
Block a user