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,139 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.geometry.IArea;
import org.lwjgl.opengl.GL11;
import binnie.craftgui.minecraft.MinecraftTooltip;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import binnie.core.machines.Machine;
import binnie.core.machines.power.IProcess;
import binnie.craftgui.core.Tooltip;
import net.minecraft.inventory.IInventory;
import binnie.core.machines.TileEntityMachine;
import binnie.craftgui.minecraft.Window;
import binnie.core.machines.power.IPoweredMachine;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.geometry.Position;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlEnergyBar extends Control implements ITooltip
{
public static boolean isError;
private Position direction;
public ControlEnergyBar(final IWidget parent, final int x, final int y, final int width, final int height, final Position direction) {
super(parent, x, y, width, height);
this.direction = direction;
this.addAttribute(Attribute.MouseOver);
}
public IPoweredMachine getClientPower() {
final IInventory inventory = Window.get(this).getInventory();
final TileEntityMachine machine = (inventory instanceof TileEntityMachine) ? (TileEntityMachine) inventory : null;
if (machine == null) {
return null;
}
final IPoweredMachine clientPower = machine.getMachine().getInterface(IPoweredMachine.class);
return clientPower;
}
public float getPercentage() {
float percentage = 100.0f * this.getStoredEnergy() / this.getMaxEnergy();
if (percentage > 100.0f) {
percentage = 100.0f;
}
return percentage;
}
private float getStoredEnergy() {
return Window.get(this).getContainer().getPowerInfo().getStoredEnergy();
}
private float getMaxEnergy() {
return Window.get(this).getContainer().getPowerInfo().getMaxEnergy();
}
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.add((int) this.getPercentage() + "% charged");
tooltip.add(this.getStoredEnergy() + "/" + this.getMaxEnergy() + " RF");
}
@Override
public void getHelpTooltip(final Tooltip tooltip) {
tooltip.add("Energy Bar");
tooltip.add("Current: " + this.getStoredEnergy() + " RF (" + (int) this.getPercentage() + "%)");
tooltip.add("Capacity: " + this.getMaxEnergy() + " RF");
final IProcess process = Machine.getInterface(IProcess.class, Window.get(this).getInventory());
if (process != null) {
tooltip.add("Usage: " + (int) process.getEnergyPerTick() + " RF");
}
}
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(CraftGUITexture.EnergyBarBack, this.getArea());
final float percentage = this.getPercentage() / 100.0f;
CraftGUI.Render.colour(this.getColourFromPercentage(percentage));
final IArea area = this.getArea();
switch (this.direction) {
case Top:
case Bottom: {
final float height = area.size().y() * percentage;
area.setSize(new IPoint(area.size().x(), height));
break;
}
case Left:
case Right: {
final float width = area.size().x() * percentage;
area.setSize(new IPoint(width, area.size().y()));
break;
}
}
if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) {
final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.Help);
CraftGUI.Render.gradientRect(this.getArea().inset(1), c, c);
}
else if (ControlEnergyBar.isError) {
final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
CraftGUI.Render.gradientRect(this.getArea().inset(1), c, c);
}
CraftGUI.Render.texture(CraftGUITexture.EnergyBarGlow, area);
GL11.glColor3d(1.0, 1.0, 1.0);
CraftGUI.Render.texture(CraftGUITexture.EnergyBarGlass, this.getArea());
}
@Override
public void onRenderForeground() {
if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) {
final IArea area = this.getArea();
CraftGUI.Render.colour(MinecraftTooltip.getOutline(Tooltip.Type.Help));
CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
}
else if (ControlEnergyBar.isError) {
final IArea area = this.getArea();
CraftGUI.Render.colour(MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error));
CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
}
}
public int getColourFromPercentage(final float percentage) {
int colour = 16777215;
if (percentage > 0.5) {
final int r = (int) ((1.0 - 2.0 * (percentage - 0.5)) * 255.0);
colour = (r << 16) + 65280;
}
else {
final int g = (int) (255.0f * (2.0f * percentage));
colour = 16711680 + (g << 8);
}
return colour;
}
}
@@ -0,0 +1,106 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.minecraft.MinecraftTooltip;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.minecraft.CustomSlot;
import net.minecraft.entity.player.InventoryPlayer;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.minecraft.Window;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.core.machines.power.ErrorState;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlErrorState extends Control implements ITooltip
{
private ErrorState errorState;
private int type;
@Override
public void onRenderBackground() {
Object texture = CraftGUITexture.StateWarning;
if (this.errorState == null) {
texture = CraftGUITexture.StateNone;
}
else if (this.type == 0) {
texture = CraftGUITexture.StateError;
}
CraftGUI.Render.texture(texture, IPoint.ZERO);
super.onRenderBackground();
}
public ErrorState getError() {
return Window.get(this).getContainer().getErrorState();
}
@Override
public final void onUpdateClient() {
this.errorState = this.getError();
this.type = Window.get(this).getContainer().getErrorType();
ControlSlot.highlighting.get(EnumHighlighting.Error).clear();
ControlSlot.highlighting.get(EnumHighlighting.Warning).clear();
ControlLiquidTank.tankError.clear();
ControlEnergyBar.isError = false;
if (!this.isMouseOver() || this.errorState == null) {
return;
}
ControlEnergyBar.isError = this.errorState.isPowerError();
if (this.errorState.isItemError()) {
for (final int slot : this.errorState.getData()) {
int id = -1;
for (final CustomSlot cslot : Window.get(this).getContainer().getCustomSlots()) {
if (!(cslot.inventory instanceof InventoryPlayer) && cslot.getSlotIndex() == slot) {
id = cslot.slotNumber;
}
}
if (id >= 0) {
if (this.type == 0) {
ControlSlot.highlighting.get(EnumHighlighting.Error).add(id);
}
else {
ControlSlot.highlighting.get(EnumHighlighting.Warning).add(id);
}
}
}
}
if (this.errorState.isTankError()) {
for (final int slot : this.errorState.getData()) {
ControlLiquidTank.tankError.add(slot);
}
}
}
public ControlErrorState(final IWidget parent, final float x, final float y) {
super(parent, x, y, 16.0f, 16.0f);
this.type = 0;
this.addAttribute(Attribute.MouseOver);
}
@Override
public void getTooltip(final Tooltip tooltipOrig) {
final MinecraftTooltip tooltip = (MinecraftTooltip) tooltipOrig;
if (this.errorState != null) {
if (this.type == 0) {
tooltip.setType(MinecraftTooltip.Type.Error);
}
else {
tooltip.setType(MinecraftTooltip.Type.Warning);
}
tooltip.add(this.errorState.toString());
if (this.errorState.getTooltip().length() > 0) {
tooltip.add(this.errorState.getTooltip());
}
}
}
public ErrorState getErrorState() {
return this.errorState;
}
}
@@ -0,0 +1,40 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlHelp extends Control implements ITooltip
{
public ControlHelp(final IWidget parent, final float x, final float y) {
super(parent, x, y, 16.0f, 16.0f);
this.addAttribute(Attribute.MouseOver);
}
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(CraftGUITexture.HelpButton, this.getArea());
}
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.setType(Tooltip.Type.Help);
tooltip.add("Help");
tooltip.add("To activate help tooltips,");
tooltip.add("hold down the tab key and");
tooltip.add("mouse over controls.");
}
@Override
public void getHelpTooltip(final Tooltip tooltip) {
this.getTooltip(tooltip);
}
}
@@ -0,0 +1,27 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.IWidget;
import net.minecraft.util.IIcon;
import binnie.craftgui.controls.core.Control;
public class ControlIconDisplay extends Control
{
private IIcon icon;
public ControlIconDisplay(final IWidget parent, final float x, final float y, final IIcon icon) {
super(parent, x, y, 16.0f, 16.0f);
this.icon = null;
this.icon = icon;
}
@Override
public void onRenderForeground() {
CraftGUI.Render.iconItem(IPoint.ZERO, this.icon);
}
}
@@ -0,0 +1,27 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.resource.Texture;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.controls.core.Control;
public class ControlImage extends Control
{
private Object key;
public ControlImage(final IWidget parent, final float x, final float y, final Texture text) {
super(parent, x, y, text.w(), text.h());
this.key = null;
this.key = text;
}
@Override
public void onRenderForeground() {
CraftGUI.Render.texture(this.key, IPoint.ZERO);
}
}
@@ -0,0 +1,37 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlInfo extends Control implements ITooltip
{
private String info;
public ControlInfo(final IWidget parent, final float x, final float y, final String info) {
super(parent, x, y, 16.0f, 16.0f);
this.addAttribute(Attribute.MouseOver);
this.info = info;
}
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(CraftGUITexture.InfoButton, this.getArea());
}
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.setType(Tooltip.Type.Information);
tooltip.add("Info");
tooltip.add(this.info);
tooltip.setMaxWidth(200);
}
}
@@ -0,0 +1,92 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import net.minecraft.client.Minecraft;
import binnie.core.BinnieCore;
import org.lwjgl.opengl.GL11;
import binnie.craftgui.minecraft.Window;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.Attribute;
import net.minecraft.item.ItemStack;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlItemDisplay extends Control implements ITooltip
{
private ItemStack itemStack;
public boolean hastooltip;
private boolean rotating;
public void setTooltip() {
this.hastooltip = true;
this.addAttribute(Attribute.MouseOver);
}
public ControlItemDisplay(final IWidget parent, final float x, final float y) {
this(parent, x, y, 16.0f);
}
public ControlItemDisplay(final IWidget parent, final float f, final float y, final ItemStack stack, final boolean tooltip) {
this(parent, f, y, 16.0f);
this.setItemStack(stack);
if (tooltip) {
this.setTooltip();
}
}
public ControlItemDisplay(final IWidget parent, final float x, final float y, final float size) {
super(parent, x, y, size, size);
this.itemStack = null;
this.hastooltip = false;
this.rotating = false;
}
@Override
public void onRenderBackground() {
final IPoint relativeToWindow = this.getAbsolutePosition().sub(this.getSuperParent().getPosition());
if (relativeToWindow.x() > Window.get(this).getSize().x() + 100.0f || relativeToWindow.y() > Window.get(this).getSize().y() + 100.0f) {
return;
}
if (this.itemStack != null) {
if (this.getSize().x() != 16.0f) {
GL11.glPushMatrix();
final float scale = this.getSize().x() / 16.0f;
GL11.glScalef(scale, scale, 1.0f);
BinnieCore.proxy.getMinecraftInstance();
final float phase = Minecraft.getSystemTime() / 20.0f;
CraftGUI.Render.item(IPoint.ZERO, this.itemStack, this.rotating);
GL11.glPopMatrix();
}
else {
CraftGUI.Render.item(IPoint.ZERO, this.itemStack, this.rotating);
}
}
}
public void setItemStack(final ItemStack itemStack) {
this.itemStack = itemStack;
}
public ItemStack getItemStack() {
return this.itemStack;
}
@Override
public void getTooltip(final Tooltip tooltip) {
if (this.hastooltip && this.itemStack != null) {
tooltip.add(this.itemStack.getTooltip(((Window) this.getSuperParent()).getPlayer(), false));
}
super.getTooltip(tooltip);
}
public void setRotating() {
this.rotating = true;
}
}
@@ -0,0 +1,179 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import java.util.ArrayList;
import binnie.core.machines.Machine;
import binnie.core.machines.power.ITankMachine;
import binnie.core.machines.inventory.TankSlot;
import binnie.core.machines.inventory.MachineSide;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.Fluid;
import net.minecraft.client.renderer.texture.TextureMap;
import binnie.core.BinnieCore;
import binnie.craftgui.core.geometry.IArea;
import org.lwjgl.opengl.GL11;
import binnie.craftgui.minecraft.MinecraftTooltip;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import binnie.core.machines.power.TankInfo;
import binnie.craftgui.minecraft.Window;
import net.minecraft.nbt.NBTTagCompound;
import binnie.craftgui.events.EventMouse;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import java.util.List;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlLiquidTank extends Control implements ITooltip
{
public static List<Integer> tankError;
private int tankID;
private boolean horizontal;
public ControlLiquidTank(final IWidget parent, final int x, final int y) {
this(parent, x, y, false);
}
public ControlLiquidTank(final IWidget parent, final int x, final int y, final boolean horizontal) {
super(parent, x, y, horizontal ? 60.0f : 18.0f, horizontal ? 18.0f : 60.0f);
this.tankID = 0;
this.horizontal = false;
this.horizontal = horizontal;
this.addAttribute(Attribute.MouseOver);
this.addSelfEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(final EventMouse.Down event) {
if (event.getButton() == 0) {
final NBTTagCompound nbt = new NBTTagCompound();
nbt.setByte("id", (byte) ControlLiquidTank.this.tankID);
Window.get(ControlLiquidTank.this.getWidget()).sendClientAction("tank-click", nbt);
}
}
});
}
public void setTankID(final int tank) {
this.tankID = tank;
}
public TankInfo getTank() {
return Window.get(this).getContainer().getTankInfo(this.tankID);
}
public boolean isTankValid() {
return !this.getTank().isEmpty();
}
public int getTankCapacity() {
return (int) this.getTank().getCapacity();
}
@Override
public void onRenderBackground() {
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);
CraftGUI.Render.gradientRect(this.getArea().inset(1), c, c);
}
else if (ControlLiquidTank.tankError.contains(this.tankID)) {
final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
CraftGUI.Render.gradientRect(this.getArea().inset(1), c, c);
}
else if (this.getSuperParent().getMousedOverWidget() == this) {
if (Window.get(this).getGui().getDraggedItem() != null) {
CraftGUI.Render.gradientRect(this.getArea().inset(1), -1426089575, -1426089575);
}
else {
CraftGUI.Render.gradientRect(this.getArea().inset(1), -2130706433, -2130706433);
}
}
if (this.isTankValid()) {
final Object content = null;
final float height = this.horizontal ? 16.0f : 58.0f;
final int squaled = (int) (height * (this.getTank().getAmount() / this.getTank().getCapacity()));
final int yPos = (int) height + 1;
final Fluid fluid = this.getTank().liquid.getFluid();
final int hex = fluid.getColor(this.getTank().liquid);
final int r = (hex & 0xFF0000) >> 16;
final int g = (hex & 0xFF00) >> 8;
final int b = hex & 0xFF;
GL11.glColor4f(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
final IPoint pos = this.getAbsolutePosition();
final IPoint offset = new IPoint(0.0f, height - squaled);
final IArea limited = this.getArea().inset(1);
if (this.horizontal) {
limited.setSize(new IPoint(limited.w() - 1.0f, limited.h()));
}
CraftGUI.Render.limitArea(new IArea(limited.pos().add(pos).add(offset), limited.size().sub(offset)));
GL11.glEnable(3089);
BinnieCore.proxy.bindTexture(TextureMap.locationItemsTexture);
for (int y = 0; y < height; y += 16) {
for (int x = 0; x < (this.horizontal ? 58 : 16); x += 16) {
final IIcon icon = fluid.getIcon();
CraftGUI.Render.iconBlock(new IPoint(1 + x, 1 + y), icon);
}
}
GL11.glDisable(3089);
GL11.glDisable(3042);
}
}
@Override
public void onRenderForeground() {
CraftGUI.Render.texture(this.horizontal ? CraftGUITexture.HorizontalLiquidTankOverlay : CraftGUITexture.LiquidTankOverlay, IPoint.ZERO);
if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) {
final IArea area = this.getArea();
CraftGUI.Render.colour(MinecraftTooltip.getOutline(Tooltip.Type.Help));
CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
}
if (ControlLiquidTank.tankError.contains(this.tankID)) {
final IArea area = this.getArea();
CraftGUI.Render.colour(MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error));
CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
}
}
@Override
public void getHelpTooltip(final Tooltip tooltip) {
if (this.getTankSlot() != null) {
final TankSlot slot = this.getTankSlot();
tooltip.add(slot.getName());
tooltip.add("Capacity: " + this.getTankCapacity() + " mB");
tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
if (slot.isReadOnly()) {
tooltip.add("Output Only Tank");
}
tooltip.add("Accepts: " + ((slot.getValidator() == null) ? "Any Item" : slot.getValidator().getTooltip()));
}
}
@Override
public void getTooltip(final Tooltip tooltip) {
if (this.isTankValid()) {
final int percentage = (int) (100.0 * this.getTank().getAmount() / this.getTankCapacity());
tooltip.add(this.getTank().getName());
tooltip.add(percentage + "% full");
tooltip.add((int) this.getTank().getAmount() + " mB");
return;
}
tooltip.add("Empty");
}
private TankSlot getTankSlot() {
final ITankMachine tank = Machine.getInterface(ITankMachine.class, Window.get(this).getInventory());
return (tank != null) ? tank.getTankSlot(this.tankID) : null;
}
static {
ControlLiquidTank.tankError = new ArrayList<Integer>();
}
}
@@ -0,0 +1,16 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.geometry.Position;
import binnie.craftgui.resource.Texture;
import binnie.craftgui.core.IWidget;
public class ControlMachineProgress extends ControlProgress
{
public ControlMachineProgress(final IWidget parent, final int x, final int y, final Texture base, final Texture progress, final Position dir) {
super(parent, x, y, base, progress, dir);
}
}
@@ -0,0 +1,99 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import binnie.craftgui.minecraft.InventoryType;
import java.util.ArrayList;
import binnie.craftgui.core.IWidget;
import java.util.List;
import binnie.craftgui.controls.core.Control;
public class ControlPlayerInventory extends Control
{
private List<ControlSlot> slots;
public ControlPlayerInventory(final IWidget parent, final boolean wide) {
super(parent, (int) (parent.getSize().x() / 2.0f) - (wide ? 110 : 81), (int) parent.getSize().y() - (wide ? 54 : 76) - 12, wide ? 220 : 162, wide ? 54 : 76);
this.slots = new ArrayList<ControlSlot>();
for (int row = 0; row < 3; ++row) {
for (int column = 0; column < 9; ++column) {
final ControlSlot slot = new ControlSlot(this, (wide ? 58 : 0) + column * 18, row * 18);
this.slots.add(slot);
}
}
if (wide) {
for (int i1 = 0; i1 < 9; ++i1) {
final ControlSlot slot2 = new ControlSlot(this, i1 % 3 * 18, i1 / 3 * 18);
this.slots.add(slot2);
}
}
else {
for (int i1 = 0; i1 < 9; ++i1) {
final ControlSlot slot2 = new ControlSlot(this, i1 * 18, 58.0f);
this.slots.add(slot2);
}
}
this.create();
}
public ControlPlayerInventory(final IWidget parent) {
this(parent, false);
}
public ControlPlayerInventory(final IWidget parent, final int x, final int y) {
super(parent, x, y, 54.0f, 220.0f);
this.slots = new ArrayList<ControlSlot>();
for (int row = 0; row < 6; ++row) {
for (int column = 0; column < 6; ++column) {
final ControlSlot slot = new ControlSlot(this, column * 18, row * 18);
this.slots.add(slot);
}
}
this.create();
}
public void create() {
for (int row = 0; row < 3; ++row) {
for (int column = 0; column < 9; ++column) {
final ControlSlot slot = this.slots.get(column + row * 9);
slot.assign(InventoryType.Player, 9 + column + row * 9);
}
}
for (int i1 = 0; i1 < 9; ++i1) {
final ControlSlot slot2 = this.slots.get(27 + i1);
slot2.assign(InventoryType.Player, i1);
}
}
public void addItem(final ItemStack item) {
if (item == null) {
return;
}
for (final ControlSlot slot : this.slots) {
if (!slot.slot.getHasStack()) {
slot.slot.putStack(item);
}
}
}
public void addInventory(final IInventory inventory) {
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
this.addItem(inventory.getStackInSlot(i));
}
}
public ControlSlot getSlot(final int i) {
if (i < 0 || i >= this.slots.size()) {
return null;
}
return this.slots.get(i);
}
@Override
public void onUpdateClient() {
}
}
@@ -0,0 +1,38 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import binnie.core.machines.power.PowerSystem;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlPowerSystem extends Control implements ITooltip
{
private PowerSystem system;
public ControlPowerSystem(final IWidget parent, final float x, final float y, final PowerSystem system) {
super(parent, x, y, 16.0f, 16.0f);
this.addAttribute(Attribute.MouseOver);
this.system = system;
}
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(CraftGUITexture.PowerButton, this.getArea());
}
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.setType(Tooltip.Type.Power);
tooltip.add("Power Supply");
tooltip.add("Powered by " + this.system.getUnitName());
tooltip.setMaxWidth(200);
}
}
@@ -0,0 +1,31 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.geometry.Position;
import binnie.craftgui.resource.Texture;
public class ControlProgress extends ControlProgressBase
{
private Texture progressBlank;
private Texture progressBar;
private Position direction;
public ControlProgress(final IWidget parent, final int x, final int y, final Texture progressBlank, final Texture progressBar, final Position dir) {
super(parent, x, y, (progressBlank == null) ? 0.0f : progressBlank.w(), (progressBlank == null) ? 0.0f : progressBlank.h());
this.progressBlank = progressBlank;
this.progressBar = progressBar;
this.progress = 0.0f;
this.direction = dir;
}
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(this.progressBlank, this.getArea());
CraftGUI.Render.texturePercentage(this.progressBar, this.getArea(), this.direction, this.progress);
}
}
@@ -0,0 +1,93 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.core.machines.Machine;
import binnie.core.machines.power.IProcess;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.minecraft.Window;
import binnie.core.machines.power.ProcessInfo;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.controls.core.Control;
public class ControlProgressBase extends Control
{
protected float progress;
public ControlProgressBase(final IWidget parent, final float x, final float y, final float w, final float h) {
super(parent, x, y, w, h);
this.progress = 0.0f;
this.addAttribute(Attribute.MouseOver);
}
public void setProgress(final float progress) {
this.progress = progress;
if (this.progress < 0.0f) {
this.progress = 0.0f;
}
else if (this.progress > 1.0f) {
this.progress = 1.0f;
}
}
protected ProcessInfo getProcess() {
return Window.get(this).getContainer().getProcessInfo();
}
@Override
public void onUpdateClient() {
final ProcessInfo process = this.getProcess();
if (process != null) {
this.setProgress(process.getCurrentProgress() / 100.0f);
}
}
@Override
public void getHelpTooltip(final Tooltip tooltip) {
final ProcessInfo process = this.getProcess();
final IProcess machineProcess = Machine.getMachine(Window.get(this).getInventory()).getInterface(IProcess.class);
if (process != null) {
tooltip.add("Progress");
if (this.progress == 0.0f) {
tooltip.add("Not in Progress");
}
else if (process.getProcessTime() > 0) {
tooltip.add(machineProcess.getTooltip() + " (" + (int) process.getCurrentProgress() + "%)");
}
else {
tooltip.add("In Progress");
}
if (process.getProcessTime() > 0) {
tooltip.add("Time Left: " + convertTime((int) ((1.0f - this.progress) * process.getProcessTime())));
tooltip.add("Total Time: " + convertTime(process.getProcessTime()));
tooltip.add("Energy Cost: " + process.getProcessEnergy() * 10 + " RF");
}
else {
tooltip.add("Energy Cost: " + process.getEnergyPerTick() * 10.0f + " RF / tick");
}
}
}
public static String convertTime(final int time) {
int seconds = (int) (time / 20.0f);
int minutes = 0;
while (seconds >= 60) {
++minutes;
seconds -= 60;
}
String ts = "";
if (minutes > 0) {
ts = ts + minutes + " minute" + ((minutes == 1) ? "" : "s");
}
if (seconds > 0) {
if (ts.length() > 0) {
ts += " ";
}
ts = ts + seconds + " second" + ((seconds == 1) ? "" : "s");
}
return ts;
}
}
@@ -0,0 +1,105 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.resource.Texture;
import binnie.craftgui.core.geometry.TextJustification;
import org.lwjgl.opengl.GL11;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.geometry.IBorder;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.geometry.Position;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.controls.core.Control;
public class ControlSlide extends Control
{
private IArea expanded;
private IArea shrunk;
private boolean slideActive;
private Position anchor;
private String label;
public ControlSlide(final IWidget parent, final float x, final float y, final float w, final float h, final Position anchor2) {
super(parent, x, y, w, h);
this.slideActive = true;
this.label = null;
this.addAttribute(Attribute.MouseOver);
this.addAttribute(Attribute.BlockTooltip);
this.expanded = new IArea(this.getPosition(), this.getSize());
this.anchor = anchor2.opposite();
final float border = (this.anchor.x() != 0) ? (this.expanded.w() - 6.0f) : (this.expanded.h() - 6.0f);
this.shrunk = this.expanded.inset(new IBorder(this.anchor, border));
this.slideActive = false;
}
@Override
public void onRenderBackground() {
super.onRenderBackground();
if (this.label != null) {
final float lw = CraftGUI.Render.textWidth(this.label) + 16;
final float lh = CraftGUI.Render.textHeight() + 16;
final boolean hor = this.anchor.x() != 0;
final IArea ar = this.isSlideActive() ? this.expanded : this.shrunk;
IArea tabArea = new IArea(hor ? (-lh / 2.0f) : (-lw / 2.0f), hor ? (-lw / 2.0f) : (-lh / 2.0f), hor ? lh : lw, hor ? lw : lh);
final IPoint shift = new IPoint(ar.w() * (1 - this.anchor.x()) / 2.0f, ar.h() * (1 - this.anchor.y()) / 2.0f);
tabArea = tabArea.shift(shift.x() - (-3.0f + lh / 2.0f) * this.anchor.x(), shift.y() - (-3.0f + lh / 2.0f) * this.anchor.y());
Texture texture = CraftGUI.Render.getTexture(this.isSlideActive() ? CraftGUITexture.Tab : CraftGUITexture.TabDisabled).crop(this.anchor.opposite(), 8.0f);
CraftGUI.Render.texture(texture, tabArea);
texture = CraftGUI.Render.getTexture(CraftGUITexture.TabOutline).crop(this.anchor.opposite(), 8.0f);
CraftGUI.Render.texture(texture, tabArea.inset(2));
final IArea labelArea = new IArea(-lw / 2.0f, 0.0f, lw, lh);
GL11.glPushMatrix();
GL11.glTranslatef(shift.x() + this.anchor.x() * 2.0f, shift.y() + this.anchor.y() * 2.0f, 0.0f);
if (this.anchor.x() != 0) {
GL11.glRotatef(90.0f, 0.0f, 0.0f, this.anchor.x());
}
if (this.anchor.y() > 0) {
GL11.glTranslatef(0.0f, -lh, 0.0f);
}
CraftGUI.Render.text(labelArea, TextJustification.MiddleCenter, this.label, 16777215);
GL11.glPopMatrix();
}
CraftGUI.Render.texture(CraftGUITexture.Window, this.getArea());
final Object slideTexture = (this.anchor == Position.Bottom) ? CraftGUITexture.SlideDown : ((this.anchor == Position.Top) ? CraftGUITexture.SlideUp : ((this.anchor == Position.Left) ? CraftGUITexture.SlideLeft : CraftGUITexture.SlideRight));
CraftGUI.Render.texture(slideTexture, new IPoint((this.anchor.x() + 1.0f) * this.w() / 2.0f - 8.0f, (this.anchor.y() + 1.0f) * this.h() / 2.0f - 8.0f));
}
public boolean isSlideActive() {
return this.slideActive;
}
@Override
public void onUpdateClient() {
final boolean mouseOver = this.isMouseOverWidget(this.getRelativeMousePosition());
if (mouseOver != this.slideActive) {
this.setSlide(mouseOver);
}
}
@Override
public boolean isMouseOverWidget(final IPoint relativeMouse) {
return this.getArea().outset(this.isSlideActive() ? 16 : 8).outset(new IBorder(this.anchor.opposite(), 16.0f)).contains(relativeMouse);
}
@Override
public boolean isChildVisible(final IWidget child) {
return this.slideActive;
}
public void setSlide(final boolean b) {
this.slideActive = b;
final IArea area = this.isSlideActive() ? this.expanded : this.shrunk;
this.setSize(area.size());
this.setPosition(area.pos());
}
public void setLabel(final String l) {
this.label = l;
}
}
@@ -0,0 +1,211 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import java.util.HashMap;
import binnie.craftgui.minecraft.CustomSlot;
import binnie.core.machines.inventory.SlotValidator;
import net.minecraft.entity.player.InventoryPlayer;
import binnie.craftgui.minecraft.WindowInventory;
import binnie.core.machines.inventory.MachineSide;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.minecraft.InventoryType;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.IIcon;
import binnie.core.machines.inventory.InventorySlot;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.player.EntityPlayer;
import binnie.craftgui.minecraft.GuiCraftGUI;
import binnie.craftgui.minecraft.Window;
import binnie.craftgui.events.EventMouse;
import binnie.craftgui.core.IWidget;
import net.minecraft.inventory.Slot;
import java.util.List;
import java.util.Map;
public class ControlSlot extends ControlSlotBase
{
public static Map<EnumHighlighting, List<Integer>> highlighting;
public static boolean shiftClickActive;
public Slot slot;
public ControlSlot(final IWidget parent, final float x, final float y) {
super(parent, x, y);
this.slot = null;
this.addSelfEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(final EventMouse.Down event) {
if (ControlSlot.this.slot != null) {
final PlayerControllerMP playerController = ((Window) ControlSlot.this.getSuperParent()).getGui().getMinecraft().playerController;
final int windowId = ((Window) ControlSlot.this.getSuperParent()).getContainer().windowId;
final int slotNumber = ControlSlot.this.slot.slotNumber;
final int button = event.getButton();
Window.get(ControlSlot.this.getWidget()).getGui();
playerController.windowClick(windowId, slotNumber, button, GuiScreen.isShiftKeyDown() ? 1 : 0, ((Window) ControlSlot.this.getSuperParent()).getGui().getMinecraft().thePlayer);
}
}
});
}
public ControlSlot(final IWidget parent, final int x, final int y, final Slot slot) {
super(parent, x, y);
this.slot = null;
this.slot = slot;
}
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(CraftGUITexture.Slot, IPoint.ZERO);
if (this.slot == null) {
return;
}
final InventorySlot islot = this.getInventorySlot();
if (islot != null && islot.getValidator() != null) {
final IIcon icon = islot.getValidator().getIcon(!islot.getInputSides().isEmpty());
if (icon != null) {
CraftGUI.Render.iconItem(new IPoint(1.0f, 1.0f), icon);
}
}
boolean highlighted = false;
for (final Map.Entry<EnumHighlighting, List<Integer>> highlight : ControlSlot.highlighting.entrySet()) {
if (highlight.getKey() == EnumHighlighting.ShiftClick && !ControlSlot.shiftClickActive) {
continue;
}
if (highlighted || !highlight.getValue().contains(this.slot.slotNumber)) {
continue;
}
highlighted = true;
final int c = -1442840576 + Math.min(highlight.getKey().getColour(), 16777215);
CraftGUI.Render.gradientRect(new IArea(1.0f, 1.0f, 16.0f, 16.0f), c, c);
}
if (!highlighted && this.getSuperParent().getMousedOverWidget() == this) {
if (Window.get(this).getGui().getDraggedItem() != null && !this.slot.isItemValid(Window.get(this).getGui().getDraggedItem())) {
CraftGUI.Render.gradientRect(new IArea(1.0f, 1.0f, 16.0f, 16.0f), -1426089575, -1426089575);
}
else {
CraftGUI.Render.gradientRect(new IArea(1.0f, 1.0f, 16.0f, 16.0f), -2130706433, -2130706433);
}
}
}
@Override
public void onRenderOverlay() {
if (this.slot == null) {
return;
}
boolean highlighted = false;
for (final Map.Entry<EnumHighlighting, List<Integer>> highlight : ControlSlot.highlighting.entrySet()) {
if (highlight.getKey() == EnumHighlighting.ShiftClick && !ControlSlot.shiftClickActive) {
continue;
}
if (highlighted || !highlight.getValue().contains(this.slot.slotNumber)) {
continue;
}
highlighted = true;
final int c = highlight.getKey().getColour();
IArea area = this.getArea();
if (this.getParent() instanceof ControlSlotArray || this.getParent() instanceof ControlPlayerInventory) {
area = this.getParent().getArea();
area.setPosition(IPoint.ZERO.sub(this.getPosition()));
}
CraftGUI.Render.colour(c);
CraftGUI.Render.texture(CraftGUITexture.Outline, area.outset(1));
}
}
@Override
public void onUpdateClient() {
super.onUpdateClient();
if (this.slot == null) {
return;
}
if (this.isMouseOver() && GuiScreen.isShiftKeyDown()) {
Window.get(this).getContainer().setMouseOverSlot(this.slot);
ControlSlot.shiftClickActive = true;
}
if (Window.get(this).getGui().isHelpMode() && this.isMouseOver()) {
for (final ControlSlot slot2 : this.getControlSlots()) {
if (slot2.slot != null) {
ControlSlot.highlighting.get(EnumHighlighting.Help).add(slot2.slot.slotNumber);
}
}
}
}
private List<ControlSlot> getControlSlots() {
final List<ControlSlot> slots = new ArrayList<ControlSlot>();
if (this.getParent() instanceof ControlSlotArray || this.getParent() instanceof ControlPlayerInventory) {
for (final IWidget child : this.getParent().getWidgets()) {
slots.add((ControlSlot) child);
}
}
else {
slots.add(this);
}
return slots;
}
@Override
public ItemStack getItemStack() {
if (this.slot != null) {
return this.slot.getStack();
}
return null;
}
public ControlSlot assign(final int index) {
return this.assign(InventoryType.Machine, index);
}
public ControlSlot assign(final InventoryType inventory, final int index) {
if (this.slot != null) {
return this;
}
this.slot = ((Window) this.getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
return this;
}
@Override
public void getHelpTooltip(final Tooltip tooltip) {
if (this.slot == null) {
return;
}
final InventorySlot slot = this.getInventorySlot();
if (this.getInventorySlot() != null) {
tooltip.add(slot.getName());
tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
if (slot.isReadOnly()) {
tooltip.add("Pickup Only Slot");
}
tooltip.add("Accepts: " + ((slot.getValidator() == null) ? "Any Item" : slot.getValidator().getTooltip()));
}
else if (this.slot.inventory instanceof WindowInventory) {
final SlotValidator s = ((WindowInventory) this.slot.inventory).getValidator(this.slot.getSlotIndex());
tooltip.add("Accepts: " + ((s == null) ? "Any Item" : s.getTooltip()));
}
else if (this.slot.inventory instanceof InventoryPlayer) {
tooltip.add("Player Inventory");
}
}
public InventorySlot getInventorySlot() {
return (this.slot instanceof CustomSlot) ? ((CustomSlot) this.slot).getInventorySlot() : null;
}
static {
ControlSlot.highlighting = new HashMap<EnumHighlighting, List<Integer>>();
ControlSlot.shiftClickActive = false;
for (final EnumHighlighting h : EnumHighlighting.values()) {
ControlSlot.highlighting.put(h, new ArrayList<Integer>());
}
}
}
@@ -0,0 +1,71 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import java.util.Iterator;
import binnie.craftgui.minecraft.InventoryType;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import binnie.craftgui.core.IWidget;
import java.util.List;
import binnie.craftgui.controls.core.Control;
public class ControlSlotArray extends Control implements Iterable<ControlSlot>
{
private int rows;
private int columns;
private List<ControlSlot> slots;
public ControlSlotArray(final IWidget parent, final int x, final int y, final int columns, final int rows) {
super(parent, x, y, columns * 18, rows * 18);
this.slots = new ArrayList<ControlSlot>();
this.rows = rows;
this.columns = columns;
for (int row = 0; row < rows; ++row) {
for (int column = 0; column < columns; ++column) {
this.slots.add(this.createSlot(column * 18, row * 18));
}
}
}
public ControlSlot createSlot(final int x, final int y) {
return new ControlSlot(this, x, y);
}
public void setItemStacks(final ItemStack[] array) {
int i = 0;
for (final ItemStack item : array) {
if (i >= this.slots.size()) {
return;
}
this.slots.get(i).slot.putStack(item);
++i;
}
}
public ControlSlot getControlSlot(final int i) {
if (i < 0 || i >= this.slots.size()) {
return null;
}
return this.slots.get(i);
}
public ControlSlotArray create(final int[] index) {
return this.create(InventoryType.Machine, index);
}
public ControlSlotArray create(final InventoryType type, final int[] index) {
int i = 0;
for (final ControlSlot slot : this.slots) {
slot.assign(type, index[i++]);
}
return this;
}
@Override
public Iterator<ControlSlot> iterator() {
return this.slots.iterator();
}
}
@@ -0,0 +1,71 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import net.minecraft.item.ItemStack;
import binnie.craftgui.minecraft.Window;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.events.EventWidget;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public abstract class ControlSlotBase extends Control implements ITooltip
{
private ControlItemDisplay itemDisplay;
public ControlSlotBase(final IWidget parent, final float x, final float y) {
this(parent, x, y, 18);
}
public ControlSlotBase(final IWidget parent, final float x, final float y, final int size) {
super(parent, x, y, size, size);
this.addAttribute(Attribute.MouseOver);
this.itemDisplay = new ControlItemDisplay(this, 1.0f, 1.0f, size - 2);
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
@Override
public void onEvent(final EventWidget.ChangeSize event) {
if (ControlSlotBase.this.itemDisplay != null) {
ControlSlotBase.this.itemDisplay.setSize(ControlSlotBase.this.getSize().sub(new IPoint(2.0f, 2.0f)));
}
}
});
}
protected void setRotating() {
this.itemDisplay.setRotating();
}
@Override
public void onRenderBackground() {
final int size = (int) this.getSize().x();
CraftGUI.Render.texture(CraftGUITexture.Slot, this.getArea());
if (this.getSuperParent().getMousedOverWidget() == this) {
CraftGUI.Render.gradientRect(new IArea(new IPoint(1.0f, 1.0f), this.getArea().size().sub(new IPoint(2.0f, 2.0f))), -2130706433, -2130706433);
}
}
@Override
public void onUpdateClient() {
super.onUpdateClient();
this.itemDisplay.setItemStack(this.getItemStack());
}
@Override
public void getTooltip(final Tooltip tooltip) {
final ItemStack item = this.getItemStack();
if (item == null) {
return;
}
tooltip.add(item.getTooltip(((Window) this.getSuperParent()).getPlayer(), false));
}
public abstract ItemStack getItemStack();
}
@@ -0,0 +1,41 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.core.geometry.Position;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import binnie.core.machines.Machine;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.minecraft.Window;
import binnie.core.machines.inventory.IChargedSlots;
import binnie.craftgui.controls.core.Control;
public class ControlSlotCharge extends Control
{
private int slot;
float getCharge() {
final IChargedSlots slots = Machine.getInterface(IChargedSlots.class, Window.get(this).getInventory());
return (slots == null) ? 0.0f : slots.getCharge(this.slot);
}
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(CraftGUITexture.PanelBlack, this.getArea());
CraftGUI.Render.texturePercentage(CraftGUI.Render.getTexture(CraftGUITexture.SlotCharge), this.getArea().inset(1), Position.Bottom, this.getCharge());
}
public ControlSlotCharge(final IWidget parent, final int x, final int y, final int slot) {
super(parent, x, y, 4.0f, 18.0f);
this.slot = slot;
}
@Override
public void getHelpTooltip(final Tooltip tooltip) {
tooltip.add("Charge Remaining: " + (int) (this.getCharge() * 100.0f) + "%");
}
}
@@ -0,0 +1,45 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.geometry.IPoint;
import binnie.core.genetics.IItemStackRepresentitive;
import net.minecraft.item.ItemStack;
import binnie.craftgui.controls.tab.ControlTabBar;
import binnie.craftgui.controls.tab.ControlTab;
public class ControlTabIcon<T> extends ControlTab<T>
{
private ControlItemDisplay item;
public ControlTabIcon(final ControlTabBar<T> parent, final float x, final float y, final float w, final float h, final T value) {
super(parent, x, y, w, h, value);
this.item = new ControlItemDisplay(this, -8.0f + w / 2.0f, -8.0f + h / 2.0f);
this.item.hastooltip = false;
}
public ItemStack getItemStack() {
if (this.value instanceof IItemStackRepresentitive) {
return ((IItemStackRepresentitive) this.value).getItemStackRepresentitive();
}
return null;
}
@Override
public void onUpdateClient() {
super.onUpdateClient();
this.item.setItemStack(this.getItemStack());
final float x = ((ControlTabBar) this.getParent()).getDirection().x();
this.item.setOffset(new IPoint((this.isCurrentSelection() || this.isMouseOver()) ? 0.0f : (-4.0f * x), 0.0f));
}
public boolean hasOutline() {
return false;
}
public int getOutlineColour() {
return 16777215;
}
}
@@ -0,0 +1,42 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.resource.minecraft.CraftGUITexture;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.Attribute;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.ITooltip;
import binnie.craftgui.controls.core.Control;
public class ControlUser extends Control implements ITooltip
{
private String username;
String team;
public ControlUser(final IWidget parent, final float x, final float y, final String username) {
super(parent, x, y, 16.0f, 16.0f);
this.username = "";
this.team = "";
this.addAttribute(Attribute.MouseOver);
this.username = username;
}
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(CraftGUITexture.UserButton, this.getArea());
}
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.setType(Tooltip.Type.User);
tooltip.add("Owner");
if (this.username != "") {
tooltip.add(this.username);
}
tooltip.setMaxWidth(200);
}
}
@@ -0,0 +1,36 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.craftgui.minecraft.control;
import binnie.craftgui.core.Tooltip;
import binnie.craftgui.minecraft.MinecraftTooltip;
public enum EnumHighlighting
{
Error,
Warning,
Help,
ShiftClick;
int getColour() {
switch (this) {
case Error: {
return MinecraftTooltip.getOutline(MinecraftTooltip.Type.Error);
}
case Help: {
return MinecraftTooltip.getOutline(Tooltip.Type.Help);
}
case ShiftClick: {
return 16776960;
}
case Warning: {
return MinecraftTooltip.getOutline(MinecraftTooltip.Type.Warning);
}
default: {
return 0;
}
}
}
}