mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-24 05:54:47 +00:00
Move some craftguis
This commit is contained in:
1 parent
fff40b966d
commit
49d80c847e
57 files changed
+114
-99
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package binnie.extratrees.kitchen.craftgui;
|
||||
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.MinecraftGUI;
|
||||
import binnie.craftgui.window.Panel;
|
||||
|
||||
public class ControlDropDownMenu extends Panel {
|
||||
public boolean stayOpenOnChildClick;
|
||||
|
||||
public ControlDropDownMenu(final IWidget parent, final int x, final int y, final int width, final int height) {
|
||||
super(parent, x, y, width, 2, MinecraftGUI.PanelType.Gray);
|
||||
this.stayOpenOnChildClick = false;
|
||||
this.addAttribute(Attribute.CanFocus);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package binnie.extratrees.kitchen.craftgui;
|
||||
|
||||
import binnie.craftgui.controls.button.ControlButton;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
|
||||
public abstract class ControlDropdownButton extends ControlButton {
|
||||
public ControlDropdownButton(final IWidget parent, final int x, final int y, final int width, final int height, final String text) {
|
||||
super(parent, x, y, width, height, text);
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
ControlDropDownMenu menu = ControlDropdownButton.this.getWidget(ControlDropDownMenu.class);
|
||||
ControlDropdownButton.this.deleteChild(ControlDropdownButton.this.getWidget(ControlDropDownMenu.class));
|
||||
if (ControlDropdownButton.this.getWidget(ControlDropDownMenu.class) == null) {
|
||||
menu = ControlDropdownButton.this.createDropDownMenu();
|
||||
Window.get(ControlDropdownButton.this.getWidget()).setFocusedWidget(menu);
|
||||
} else {
|
||||
ControlDropdownButton.this.deleteChild(ControlDropdownButton.this.getWidget(ControlDropDownMenu.class));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract ControlDropDownMenu createDropDownMenu();
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package binnie.extratrees.kitchen.craftgui;
|
||||
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.renderer.RenderUtil;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
|
||||
public class ControlFluidDisplay extends Control implements ITooltip {
|
||||
FluidStack itemStack;
|
||||
public boolean hastooltip;
|
||||
|
||||
public void setTooltip() {
|
||||
this.hastooltip = true;
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
}
|
||||
|
||||
public ControlFluidDisplay(final IWidget parent, final int x, final int y) {
|
||||
this(parent, x, y, 16);
|
||||
}
|
||||
|
||||
public ControlFluidDisplay(final IWidget parent, final int x, final int y, final FluidStack stack, final boolean tooltip) {
|
||||
this(parent, x, y, 16);
|
||||
this.setItemStack(stack);
|
||||
if (tooltip) {
|
||||
this.setTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
public ControlFluidDisplay(final IWidget parent, final int x, final int y, final int size) {
|
||||
super(parent, x, y, size, size);
|
||||
this.itemStack = null;
|
||||
this.hastooltip = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderForeground(int guiWidth, int guiHeight) {
|
||||
if (this.itemStack == null) {
|
||||
return;
|
||||
}
|
||||
final IPoint relativeToWindow = this.getAbsolutePosition().sub(this.getSuperParent().getPosition());
|
||||
if (relativeToWindow.x() > Window.get(this).getSize().x() + 100 || relativeToWindow.y() > Window.get(this).getSize().y() + 100) {
|
||||
return;
|
||||
}
|
||||
if (this.itemStack != null) {
|
||||
final Fluid fluid = this.itemStack.getFluid();
|
||||
final int hex = fluid.getColor(this.itemStack);
|
||||
final int r = (hex & 0xFF0000) >> 16;
|
||||
final int g = (hex & 0xFF00) >> 8;
|
||||
final int b = hex & 0xFF;
|
||||
final ResourceLocation iconRL = this.itemStack.getFluid().getStill();
|
||||
TextureAtlasSprite icon = FMLClientHandler.instance().getClient().getTextureMapBlocks().getAtlasSprite(iconRL.toString());
|
||||
GlStateManager.color(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 771);
|
||||
if (this.getSize().x() != 16) {
|
||||
GlStateManager.pushMatrix();
|
||||
final float scale = this.getSize().x() / 16.0f;
|
||||
GlStateManager.scale(scale, scale, 1.0f);
|
||||
RenderUtil.drawSprite(IPoint.ZERO, icon);
|
||||
GlStateManager.popMatrix();
|
||||
} else {
|
||||
RenderUtil.drawSprite(IPoint.ZERO, icon);
|
||||
}
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
}
|
||||
|
||||
public void setItemStack(final FluidStack itemStack) {
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
if (this.hastooltip && this.itemStack != null) {
|
||||
tooltip.add(this.itemStack.getLocalizedName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package binnie.extratrees.kitchen.craftgui;
|
||||
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.renderer.RenderUtil;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ControlSlotFluid extends Control implements ITooltip {
|
||||
ControlFluidDisplay itemDisplay;
|
||||
FluidStack fluidStack;
|
||||
|
||||
public ControlSlotFluid(final IWidget parent, final int x, final int y, final FluidStack fluid) {
|
||||
this(parent, x, y, 18, fluid);
|
||||
}
|
||||
|
||||
public ControlSlotFluid(final IWidget parent, final int x, final int y, final int size, final FluidStack fluid) {
|
||||
super(parent, x, y, size, size);
|
||||
this.addAttribute(Attribute.MouseOver);
|
||||
this.itemDisplay = new ControlFluidDisplay(this, 1, 1, size - 2);
|
||||
this.fluidStack = fluid;
|
||||
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeSize event) {
|
||||
if (ControlSlotFluid.this.itemDisplay != null) {
|
||||
ControlSlotFluid.this.itemDisplay.setSize(ControlSlotFluid.this.getSize().sub(new IPoint(2, 2)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
final int size = (int) this.getSize().x();
|
||||
CraftGUI.render.texture(CraftGUITexture.Slot, this.getArea());
|
||||
if (this.getSuperParent().getMousedOverWidget() == this) {
|
||||
RenderUtil.drawGradientRect(new IArea(new IPoint(1, 1), this.getArea().size().sub(new IPoint(2, 2))), -2130706433, -2130706433);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
super.onUpdateClient();
|
||||
this.itemDisplay.setItemStack(this.getFluidStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
final FluidStack item = this.getFluidStack();
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
tooltip.add(item.getFluid().getLocalizedName(item));
|
||||
}
|
||||
|
||||
public FluidStack getFluidStack() {
|
||||
return this.fluidStack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package binnie.extratrees.kitchen.craftgui;
|
||||
|
||||
import binnie.craftgui.controls.core.IControlValue;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.minecraft.control.ControlSlotBase;
|
||||
import binnie.extratrees.alcohol.Glassware;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ControlSlotGlassware extends ControlSlotBase implements IControlValue<Glassware> {
|
||||
Glassware glassware;
|
||||
|
||||
public ControlSlotGlassware(final IWidget parent, final int x, final int y, final Glassware glassware) {
|
||||
super(parent, x, y);
|
||||
this.glassware = glassware;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Glassware getValue() {
|
||||
return this.glassware;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(final Glassware value) {
|
||||
this.glassware = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.glassware.get(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package binnie.extratrees.kitchen.craftgui;
|
||||
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.events.EventMouse;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ControlTankSlot extends ControlSlotFluid {
|
||||
int tankID;
|
||||
|
||||
public ControlTankSlot(final IWidget parent, final int x, final int y, final int i) {
|
||||
super(parent, x, y, null);
|
||||
this.tankID = 0;
|
||||
this.tankID = i;
|
||||
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) ControlTankSlot.this.tankID);
|
||||
Window.get(ControlTankSlot.this.getWidget()).sendClientAction("tank-click", nbt);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
this.fluidStack = Window.get(this).getContainer().getTankInfo(this.tankID).liquid;
|
||||
final int height = 16 * (((this.fluidStack == null) ? 0 : this.fluidStack.amount) / 1000);
|
||||
this.itemDisplay.setCroppedZone(this.itemDisplay, new IArea(0, 16 - height, 16, 16));
|
||||
super.onUpdateClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
super.onRenderBackground(guiWidth, guiHeight);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package binnie.extratrees.kitchen.craftgui;
|
||||
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.craftgui.minecraft.Window;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
||||
public class WindowBottleRack extends Window {
|
||||
public WindowBottleRack(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
super(248, 180, player, inventory, side);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
return new WindowBottleRack(player, inventory, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractMod getMod() {
|
||||
return ExtraTrees.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackgroundTextureName() {
|
||||
return "BottleBank";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
for (int i = 0; i < 36; ++i) {
|
||||
final int x = i % 12;
|
||||
final int y = i / 12;
|
||||
new ControlTankSlot(this, 16 + x * 18, 32 + y * 18, i);
|
||||
}
|
||||
new ControlPlayerInventory(this);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user