mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-26 15:03:14 +00:00
More null annotations
This commit is contained in:
1 parent
16b955b443
commit
da8a833485
96 files changed
+573
-360
No files matched your search
@@ -35,6 +35,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -53,9 +54,10 @@ public class WindowFieldKit extends Window {
|
||||
private float analyseProgress;
|
||||
private boolean isAnalysing;
|
||||
private Map<IChromosomeType, String> info;
|
||||
@Nullable
|
||||
private ItemStack prev;
|
||||
|
||||
public WindowFieldKit(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
public WindowFieldKit(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
super(280, 230, player, inventory, side);
|
||||
this.glassOffsetX = 0;
|
||||
this.glassOffsetY = 0;
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -46,7 +47,7 @@ public class WindowGenesis extends Window {
|
||||
private ControlListBox<Gene> geneOptions;
|
||||
private Panel panelPickup;
|
||||
|
||||
public WindowGenesis(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
public WindowGenesis(final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
super(342, 228, player, inventory, side);
|
||||
}
|
||||
|
||||
@@ -149,7 +150,7 @@ public class WindowGenesis extends Window {
|
||||
this.refreshTemplate(null);
|
||||
}
|
||||
|
||||
private void refreshTemplate(final IChromosomeType selection) {
|
||||
private void refreshTemplate(@Nullable final IChromosomeType selection) {
|
||||
final List<Gene> genes = new ArrayList<>();
|
||||
final IChromosomeType[] arr$;
|
||||
final IChromosomeType[] chromos = arr$ = Binnie.GENETICS.getChromosomeMap(this.root).keySet().toArray(new IChromosomeType[0]);
|
||||
|
||||
@@ -51,18 +51,15 @@ public class ControlList<T> extends Control implements IControlValue<T> {
|
||||
final IWidget child = this.optionWidgets.get(value);
|
||||
this.parent.ensureVisible(child.y(), child.y() + child.h(), this.h());
|
||||
}
|
||||
this.getParent().callEvent(new EventValueChanged<Object>(this.getParent(), value));
|
||||
this.parent.callEvent(new EventValueChanged<Object>(this.parent, value));
|
||||
}
|
||||
|
||||
public void setOptions(final Collection<T> options) {
|
||||
this.deleteAllChildren();
|
||||
this.allOptions.clear();
|
||||
for (final T option : options) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final IWidget optionWidget = ((ControlListBox<T>) this.getParent()).createOption(option, 0);
|
||||
if (optionWidget != null) {
|
||||
this.allOptions.put(option, optionWidget);
|
||||
}
|
||||
final IWidget optionWidget = this.parent.createOption(option, 0);
|
||||
this.allOptions.put(option, optionWidget);
|
||||
}
|
||||
this.filterOptions();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@ public class ControlListBox<T> extends ControlScrollableContent<ControlList<T>>
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
this.setScrollableContent(new ControlList<>(this, 1, 1, this.w() - 2 - this.scrollBarSize, this.h() - 2, this.getContent().getDefaultValue()));
|
||||
ControlList<T> content = this.getContent();
|
||||
T defaultValue = content.getDefaultValue();
|
||||
ControlList<T> child = new ControlList<>(this, 1, 1, this.w() - 2 - this.scrollBarSize, this.h() - 2, defaultValue);
|
||||
this.setScrollableContent(child);
|
||||
this.addEventHandler(new EventKey.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventKey.Down event) {
|
||||
|
||||
@@ -2,15 +2,20 @@ package binnie.craftgui.core;
|
||||
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface ITopLevelWidget extends IWidget {
|
||||
void setMousePosition(final int p0, final int p1);
|
||||
|
||||
IPoint getAbsoluteMousePosition();
|
||||
|
||||
@Nullable
|
||||
IWidget getFocusedWidget();
|
||||
|
||||
@Nullable
|
||||
IWidget getMousedOverWidget();
|
||||
|
||||
@Nullable
|
||||
IWidget getDraggedWidget();
|
||||
|
||||
boolean isFocused(final IWidget p0);
|
||||
|
||||
@@ -5,9 +5,11 @@ import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.events.Event;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public interface IWidget {
|
||||
@Nullable
|
||||
IWidget getParent();
|
||||
|
||||
void deleteChild(final IWidget p0);
|
||||
@@ -98,8 +100,10 @@ public interface IWidget {
|
||||
|
||||
void onDelete();
|
||||
|
||||
<T> T getWidget(final Class<T> p0);
|
||||
@Nullable
|
||||
<T> T getWidget(final Class<T> widgetClass);
|
||||
|
||||
@Nullable
|
||||
IArea getCroppedZone();
|
||||
|
||||
void setCroppedZone(final IWidget p0, final IArea p1);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package binnie.craftgui.core;
|
||||
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -13,8 +15,11 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
@Nullable
|
||||
IWidget mousedOverWidget;
|
||||
@Nullable
|
||||
IWidget draggedWidget;
|
||||
@Nullable
|
||||
IWidget focusedWidget;
|
||||
protected IPoint mousePosition;
|
||||
IPoint dragStart;
|
||||
@@ -47,7 +52,7 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
});
|
||||
}
|
||||
|
||||
public void setMousedOverWidget(final IWidget widget) {
|
||||
public void setMousedOverWidget(@Nullable final IWidget widget) {
|
||||
if (this.mousedOverWidget == widget) {
|
||||
return;
|
||||
}
|
||||
@@ -60,11 +65,11 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
}
|
||||
}
|
||||
|
||||
public void setDraggedWidget(final IWidget widget) {
|
||||
public void setDraggedWidget(@Nullable final IWidget widget) {
|
||||
this.setDraggedWidget(widget, -1);
|
||||
}
|
||||
|
||||
public void setDraggedWidget(final IWidget widget, final int button) {
|
||||
public void setDraggedWidget(@Nullable final IWidget widget, final int button) {
|
||||
if (this.draggedWidget == widget) {
|
||||
return;
|
||||
}
|
||||
@@ -77,7 +82,7 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
}
|
||||
}
|
||||
|
||||
public void setFocusedWidget(final IWidget widget) {
|
||||
public void setFocusedWidget(@Nullable final IWidget widget) {
|
||||
IWidget newWidget = widget;
|
||||
if (this.focusedWidget == newWidget) {
|
||||
return;
|
||||
@@ -95,16 +100,19 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IWidget getMousedOverWidget() {
|
||||
return this.mousedOverWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IWidget getDraggedWidget() {
|
||||
return this.draggedWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IWidget getFocusedWidget() {
|
||||
return this.focusedWidget;
|
||||
}
|
||||
@@ -137,6 +145,7 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IWidget calculateMousedOverWidget() {
|
||||
final Deque<IWidget> queue = this.calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
@@ -167,8 +176,9 @@ public abstract class TopLevelWidget extends Widget implements ITopLevelWidget {
|
||||
private Collection<IWidget> getQueuedWidgets(final IWidget widget) {
|
||||
final List<IWidget> widgets = new ArrayList<>();
|
||||
boolean addChildren = true;
|
||||
if (widget.isCroppedWidet()) {
|
||||
addChildren = widget.getCroppedZone().contains(widget.getCropWidget().getRelativeMousePosition());
|
||||
IArea croppedZone = widget.getCroppedZone();
|
||||
if (croppedZone != null) {
|
||||
addChildren = croppedZone.contains(widget.getCropWidget().getRelativeMousePosition());
|
||||
}
|
||||
if (addChildren) {
|
||||
final ListIterator<IWidget> li = widget.getWidgets().listIterator(widget.getWidgets().size());
|
||||
|
||||
@@ -6,19 +6,23 @@ import binnie.craftgui.events.Event;
|
||||
import binnie.craftgui.events.EventHandler;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
|
||||
public class Widget implements IWidget {
|
||||
@Nullable
|
||||
private final IWidget parent;
|
||||
private List<IWidget> subWidgets;
|
||||
private List<IWidgetAttribute> attributes;
|
||||
private IPoint position;
|
||||
private IPoint size;
|
||||
private IPoint offset;
|
||||
@Nullable
|
||||
IArea cropArea;
|
||||
@Nullable
|
||||
IWidget cropWidget;
|
||||
boolean cropped;
|
||||
int colour;
|
||||
@@ -26,7 +30,7 @@ public class Widget implements IWidget {
|
||||
private boolean enabled;
|
||||
private boolean visible;
|
||||
|
||||
public Widget(final IWidget parent) {
|
||||
public Widget(@Nullable final IWidget parent) {
|
||||
this.subWidgets = new ArrayList<>();
|
||||
this.attributes = new ArrayList<>();
|
||||
this.position = IPoint.ZERO;
|
||||
@@ -38,7 +42,9 @@ public class Widget implements IWidget {
|
||||
this.enabled = true;
|
||||
this.visible = true;
|
||||
this.parent = parent;
|
||||
parent.addWidget(this);
|
||||
if (parent != null) {
|
||||
parent.addWidget(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,13 +79,14 @@ public class Widget implements IWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public final IWidget getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ITopLevelWidget getSuperParent() {
|
||||
return (ITopLevelWidget) (this.isTopLevel() ? this : this.parent.getSuperParent());
|
||||
return (ITopLevelWidget) (this.parent == null ? this : this.parent.getSuperParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,6 +144,7 @@ public class Widget implements IWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IArea getCroppedZone() {
|
||||
return this.cropArea;
|
||||
}
|
||||
@@ -150,12 +158,14 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public final IPoint getAbsolutePosition() {
|
||||
return this.isTopLevel() ? this.getPosition() : this.getParent().getAbsolutePosition().add(this.getPosition());
|
||||
IWidget parent = this.getParent();
|
||||
return parent == null ? this.getPosition() : parent.getAbsolutePosition().add(this.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IPoint getOriginalAbsolutePosition() {
|
||||
return this.isTopLevel() ? this.getOriginalPosition() : this.getParent().getOriginalPosition().sub(this.getOriginalPosition());
|
||||
IWidget parent = this.getParent();
|
||||
return parent == null ? this.getOriginalPosition() : parent.getOriginalPosition().sub(this.getOriginalPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,11 +248,8 @@ public class Widget implements IWidget {
|
||||
((EventHandler<Event>)handler).onEvent(event);
|
||||
}
|
||||
}
|
||||
try {
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
child.recieveEvent(event);
|
||||
}
|
||||
} catch (ConcurrentModificationException e) {
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
child.recieveEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +260,8 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public final IPoint getRelativeMousePosition() {
|
||||
return this.isTopLevel() ? this.getMousePosition() : this.getParent().getRelativeMousePosition().sub(this.getPosition());
|
||||
IWidget parent = this.getParent();
|
||||
return parent == null ? this.getMousePosition() : parent.getRelativeMousePosition().sub(this.getPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -309,7 +317,7 @@ public class Widget implements IWidget {
|
||||
@Override
|
||||
public final boolean calculateIsMouseOver() {
|
||||
final IPoint mouse = this.getRelativeMousePosition();
|
||||
if (!this.cropped) {
|
||||
if (!this.cropped || this.cropArea == null) {
|
||||
return this.isMouseOverWidget(mouse);
|
||||
}
|
||||
final IWidget cropRelative = (this.cropWidget != null) ? this.cropWidget : this;
|
||||
@@ -351,8 +359,9 @@ public class Widget implements IWidget {
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (this.enabled) {
|
||||
if (!this.isTopLevel()) {
|
||||
if (!this.getParent().isEnabled() || !this.getParent().isChildEnabled(this)) {
|
||||
IWidget parent = this.getParent();
|
||||
if (parent != null) {
|
||||
if (!parent.isEnabled() || !parent.isChildEnabled(this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -364,8 +373,9 @@ public class Widget implements IWidget {
|
||||
@Override
|
||||
public final boolean isVisible() {
|
||||
if (this.visible) {
|
||||
if (!this.isTopLevel()) {
|
||||
if (!this.getParent().isVisible() || !this.getParent().isChildVisible(this)) {
|
||||
IWidget parent = this.getParent();
|
||||
if (parent != null) {
|
||||
if (!parent.isVisible() || !parent.isChildVisible(this)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -437,12 +447,13 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getWidget(final Class<T> x) {
|
||||
@Nullable
|
||||
public <T> T getWidget(final Class<T> widgetClass) {
|
||||
for (final IWidget child : this.getWidgets()) {
|
||||
if (x.isInstance(child)) {
|
||||
if (widgetClass.isInstance(child)) {
|
||||
return (T) child;
|
||||
}
|
||||
final T found = child.getWidget(x);
|
||||
final T found = child.getWidget(widgetClass);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
@@ -468,10 +479,10 @@ public class Widget implements IWidget {
|
||||
|
||||
@Override
|
||||
public boolean isDescendant(final IWidget widget) {
|
||||
IWidget clss = this;
|
||||
while (clss != widget) {
|
||||
clss = clss.getParent();
|
||||
if (clss == null) {
|
||||
IWidget parentWidget = this;
|
||||
while (parentWidget != widget) {
|
||||
parentWidget = parentWidget.getParent();
|
||||
if (parentWidget == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class RenderUtil {
|
||||
@@ -158,7 +159,7 @@ public class RenderUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawFluid(IPoint pos, FluidStack fluid) {
|
||||
public static void drawFluid(IPoint pos, @Nullable FluidStack fluid) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TextureRenderer {
|
||||
private static void renderTexturePadded(final IArea area, final IArea texture, final IBorder padding) {
|
||||
int borderLeft = padding.l();
|
||||
@@ -117,7 +119,7 @@ public class TextureRenderer {
|
||||
return this.styleSheet.getTexture(key);
|
||||
}
|
||||
|
||||
public void setTexture(final Texture texture) {
|
||||
public void setTexture(@Nullable final Texture texture) {
|
||||
if (texture != null) {
|
||||
BinnieCore.getBinnieProxy().bindTexture(texture.getFilename());
|
||||
}
|
||||
@@ -127,7 +129,7 @@ public class TextureRenderer {
|
||||
this.texture(this.getTexture(texture), position);
|
||||
}
|
||||
|
||||
public void texture(final Texture texture, final IPoint position) {
|
||||
public void texture(@Nullable final Texture texture, final IPoint position) {
|
||||
if (texture == null) {
|
||||
return;
|
||||
}
|
||||
@@ -141,7 +143,7 @@ public class TextureRenderer {
|
||||
this.texture(this.getTexture(window), area);
|
||||
}
|
||||
|
||||
public void texture(final Texture texture, final IArea area) {
|
||||
public void texture(@Nullable final Texture texture, final IArea area) {
|
||||
if (texture == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class ContainerCraftGUI extends Container {
|
||||
private PowerInfo syncedPower;
|
||||
private ProcessInfo syncedProcess;
|
||||
private int errorType;
|
||||
@Nullable
|
||||
private ErrorState error;
|
||||
private int mousedOverSlotNumber;
|
||||
private final Set<EntityPlayer> crafters = Sets.newConcurrentHashSet();
|
||||
@@ -79,25 +80,28 @@ public class ContainerCraftGUI extends Container {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slot getSlot(final int par1) {
|
||||
if (par1 < 0 || par1 >= this.inventorySlots.size()) {
|
||||
@Nullable
|
||||
public Slot getSlot(final int index) {
|
||||
if (index < 0 || index >= this.inventorySlots.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.inventorySlots.get(par1);
|
||||
return this.inventorySlots.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot(final int par1, final ItemStack par2ItemStack) {
|
||||
if (this.getSlot(par1) != null) {
|
||||
this.getSlot(par1).putStack(par2ItemStack);
|
||||
public void putStackInSlot(final int index, final ItemStack par2ItemStack) {
|
||||
Slot slot = this.getSlot(index);
|
||||
if (slot != null) {
|
||||
slot.putStack(par2ItemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStacksInSlots(final ItemStack[] par1ArrayOfItemStack) {
|
||||
for (int i = 0; i < par1ArrayOfItemStack.length; ++i) {
|
||||
if (this.getSlot(i) != null) {
|
||||
this.getSlot(i).putStack(par1ArrayOfItemStack[i]);
|
||||
Slot slot = this.getSlot(i);
|
||||
if (slot != null) {
|
||||
slot.putStack(par1ArrayOfItemStack[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,7 +115,8 @@ public class ContainerCraftGUI extends Container {
|
||||
if (inventory.dispenseOnClose(i)) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack != null) {
|
||||
stack = new TransferRequest(stack, par1EntityPlayer.inventory).transfer(true);
|
||||
TransferRequest transferRequest = new TransferRequest(stack, par1EntityPlayer.inventory);
|
||||
stack = transferRequest.transfer(true);
|
||||
if (stack != null) {
|
||||
par1EntityPlayer.dropItem(stack, false);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -30,6 +31,7 @@ import java.util.List;
|
||||
public class GuiCraftGUI extends GuiContainer {
|
||||
IPoint mousePos;
|
||||
private Window window;
|
||||
@Nullable
|
||||
private ItemStack draggedItem;
|
||||
|
||||
@Override
|
||||
@@ -63,6 +65,7 @@ public class GuiCraftGUI extends GuiContainer {
|
||||
this.window.initGui();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getDraggedItem() {
|
||||
return this.draggedItem;
|
||||
}
|
||||
|
||||
@@ -46,9 +46,11 @@ import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
|
||||
public abstract class Window extends TopLevelWidget implements INetwork.RecieveGuiNBT {
|
||||
@Nullable
|
||||
private GuiCraftGUI gui;
|
||||
private ContainerCraftGUI container;
|
||||
private WindowInventory windowInventory;
|
||||
@Nullable
|
||||
private ControlText title;
|
||||
protected int titleButtonLeft;
|
||||
protected int titleButtonRight;
|
||||
@@ -57,6 +59,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
@Nullable
|
||||
private StandardTexture bgText2;
|
||||
private boolean hasBeenInitialised;
|
||||
@Nullable
|
||||
private EntityPlayer player;
|
||||
@Nullable
|
||||
private IInventory entityInventory;
|
||||
@@ -118,6 +121,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
return Machine.getInterface(IInventoryMachine.class, this.getInventory()) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String showInfoButton() {
|
||||
IMachineInformation machineInformation = Machine.getInterface(IMachineInformation.class, this.getInventory());
|
||||
if (machineInformation != null) {
|
||||
@@ -126,7 +130,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
return null;
|
||||
}
|
||||
|
||||
public Window(final int width, final int height, final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
public Window(final int width, final int height, final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
this.titleButtonLeft = 8;
|
||||
this.titleButtonRight = 8;
|
||||
this.bgText1 = null;
|
||||
@@ -150,8 +154,9 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
if (this.showHelpButton()) {
|
||||
new ControlHelp(this, this.titleButtonLeft += 22, 8);
|
||||
}
|
||||
if (this.showInfoButton() != null) {
|
||||
new ControlInfo(this, this.titleButtonLeft += 22, 8, this.showInfoButton());
|
||||
String showInfoButton = this.showInfoButton();
|
||||
if (showInfoButton != null) {
|
||||
new ControlInfo(this, this.titleButtonLeft += 22, 8, showInfoButton);
|
||||
}
|
||||
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
@@ -171,6 +176,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nullable
|
||||
public final GuiCraftGUI getGui() {
|
||||
return this.gui;
|
||||
}
|
||||
@@ -231,6 +237,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
return this.getPlayer().getGameProfile();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getHeldItemStack() {
|
||||
if (this.player != null) {
|
||||
return this.player.inventory.getItemStack();
|
||||
@@ -243,7 +250,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
return this.entityInventory;
|
||||
}
|
||||
|
||||
public void setInventories(final EntityPlayer player2, final IInventory inventory) {
|
||||
public void setInventories(final EntityPlayer player2, @Nullable final IInventory inventory) {
|
||||
this.player = player2;
|
||||
this.entityInventory = inventory;
|
||||
}
|
||||
@@ -302,10 +309,12 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
public void onWindowInventoryChanged() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Texture getBackground1() {
|
||||
return this.bgText1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Texture getBackground2() {
|
||||
return this.bgText2;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ public class ControlImage extends Control {
|
||||
|
||||
public ControlImage(final IWidget parent, final int x, final int y, final Texture text) {
|
||||
super(parent, x, y, text.w(), text.h());
|
||||
this.key = null;
|
||||
this.key = text;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ import binnie.craftgui.minecraft.Window;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ControlItemDisplay extends Control implements ITooltip {
|
||||
@Nullable
|
||||
private ItemStack itemStack;
|
||||
public boolean hastooltip;
|
||||
private boolean rotating;
|
||||
@@ -68,6 +71,7 @@ public class ControlItemDisplay extends Control implements ITooltip {
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getItemStack() {
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.renderer.RenderUtil;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.minecraft.GuiCraftGUI;
|
||||
import binnie.craftgui.minecraft.MinecraftTooltip;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
@@ -26,6 +27,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -75,17 +77,20 @@ public class ControlLiquidTank extends Control implements ITooltip {
|
||||
@Override
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
CraftGUI.render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTank : CraftGUITexture.LiquidTank, IPoint.ZERO);
|
||||
if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) {
|
||||
final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help);
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
|
||||
} else if (ControlLiquidTank.tankError.contains(this.tankID)) {
|
||||
final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
|
||||
} else if (this.getSuperParent().getMousedOverWidget() == this) {
|
||||
if (Window.get(this).getGui().getDraggedItem() != null) {
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), -1426089575, -1426089575);
|
||||
} else {
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), -2130706433, -2130706433);
|
||||
GuiCraftGUI gui = Window.get(this).getGui();
|
||||
if (gui != null) {
|
||||
if (this.isMouseOver() && gui.isHelpMode()) {
|
||||
final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help);
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
|
||||
} else if (ControlLiquidTank.tankError.contains(this.tankID)) {
|
||||
final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
|
||||
} else if (this.getSuperParent().getMousedOverWidget() == this) {
|
||||
if (gui.getDraggedItem() != null) {
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), -1426089575, -1426089575);
|
||||
} else {
|
||||
RenderUtil.drawGradientRect(this.getArea().inset(1), -2130706433, -2130706433);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.isTankValid()) {
|
||||
@@ -128,7 +133,8 @@ public class ControlLiquidTank extends Control implements ITooltip {
|
||||
@Override
|
||||
public void onRenderForeground(int guiWidth, int guiHeight) {
|
||||
CraftGUI.render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTankOverlay : CraftGUITexture.LiquidTankOverlay, IPoint.ZERO);
|
||||
if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) {
|
||||
GuiCraftGUI gui = Window.get(this).getGui();
|
||||
if (this.isMouseOver() && gui != null && gui.isHelpMode()) {
|
||||
final IArea area = this.getArea();
|
||||
RenderUtil.setColour(MinecraftTooltip.getOutline(Tooltip.Type.Help));
|
||||
CraftGUI.render.texture(CraftGUITexture.Outline, area.outset(1));
|
||||
@@ -167,6 +173,7 @@ public class ControlLiquidTank extends Control implements ITooltip {
|
||||
tooltip.add("Empty");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TankSlot getTankSlot() {
|
||||
final ITankMachine tank = Machine.getInterface(ITankMachine.class, Window.get(this).getInventory());
|
||||
return (tank != null) ? tank.getTankSlot(this.tankID) : null;
|
||||
|
||||
@@ -14,7 +14,10 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ControlDatabaseIndividualDisplay extends ControlItemDisplay implements ITooltip {
|
||||
@Nullable
|
||||
private IAlleleSpecies species;
|
||||
EnumDiscoveryState discovered;
|
||||
|
||||
@@ -24,7 +27,7 @@ public class ControlDatabaseIndividualDisplay extends ControlItemDisplay impleme
|
||||
|
||||
public void setSpecies(final IAlleleSpecies species, EnumDiscoveryState state) {
|
||||
final ISpeciesRoot speciesRoot = Binnie.GENETICS.getSpeciesRoot(species);
|
||||
final BreedingSystem system = Binnie.GENETICS.getSystem(speciesRoot.getUID());
|
||||
final BreedingSystem system = Binnie.GENETICS.getSystem(speciesRoot);
|
||||
final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species.getUID()));
|
||||
super.setItemStack(system.getSpeciesRoot().getMemberStack(ind, system.getDefaultType()));
|
||||
this.species = species;
|
||||
|
||||
Reference in new issue
Block a user