mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-23 21:49:49 +00:00
Auto-format spaces to tabs (#2)
This commit is contained in:
1 parent
25be7fd254
commit
5bb4b5d9a5
756 files changed
+49198
-48489
No files matched your search
@@ -12,11 +12,22 @@ import binnie.core.resource.BinnieResource;
|
||||
import binnie.core.resource.ResourceType;
|
||||
import binnie.craftgui.controls.ControlText;
|
||||
import binnie.craftgui.controls.ControlTextCentered;
|
||||
import binnie.craftgui.core.*;
|
||||
import binnie.craftgui.core.Attribute;
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.ITooltip;
|
||||
import binnie.craftgui.core.ITooltipHelp;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import binnie.craftgui.core.Tooltip;
|
||||
import binnie.craftgui.core.TopLevelWidget;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.renderer.Renderer;
|
||||
import binnie.craftgui.events.EventWidget;
|
||||
import binnie.craftgui.minecraft.control.*;
|
||||
import binnie.craftgui.minecraft.control.ControlHelp;
|
||||
import binnie.craftgui.minecraft.control.ControlInfo;
|
||||
import binnie.craftgui.minecraft.control.ControlPowerSystem;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.craftgui.minecraft.control.ControlUser;
|
||||
import binnie.craftgui.minecraft.control.EnumHighlighting;
|
||||
import binnie.craftgui.resource.StyleSheetManager;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.resource.minecraft.CraftGUITexture;
|
||||
@@ -34,267 +45,267 @@ import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
|
||||
public abstract class Window extends TopLevelWidget implements INetwork.RecieveGuiNBT {
|
||||
private GuiCraftGUI gui;
|
||||
private ContainerCraftGUI container;
|
||||
private WindowInventory windowInventory;
|
||||
private ControlText title;
|
||||
protected float titleButtonLeft;
|
||||
protected float titleButtonRight;
|
||||
private StandardTexture bgText1;
|
||||
private StandardTexture bgText2;
|
||||
private boolean hasBeenInitialised;
|
||||
private EntityPlayer player;
|
||||
private IInventory entityInventory;
|
||||
private Side side;
|
||||
private GuiCraftGUI gui;
|
||||
private ContainerCraftGUI container;
|
||||
private WindowInventory windowInventory;
|
||||
private ControlText title;
|
||||
protected float titleButtonLeft;
|
||||
protected float titleButtonRight;
|
||||
private StandardTexture bgText1;
|
||||
private StandardTexture bgText2;
|
||||
private boolean hasBeenInitialised;
|
||||
private EntityPlayer player;
|
||||
private IInventory entityInventory;
|
||||
private Side side;
|
||||
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
final Deque<IWidget> queue = this.calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
final IWidget widget = queue.removeFirst();
|
||||
if (widget.isEnabled() && widget.isVisible()) {
|
||||
if (!widget.calculateIsMouseOver()) {
|
||||
continue;
|
||||
}
|
||||
if (widget instanceof ITooltip) {
|
||||
((ITooltip) widget).getTooltip(tooltip);
|
||||
if (tooltip.exists()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (widget.hasAttribute(Attribute.BlockTooltip)) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
final Deque<IWidget> queue = this.calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
final IWidget widget = queue.removeFirst();
|
||||
if (widget.isEnabled() && widget.isVisible()) {
|
||||
if (!widget.calculateIsMouseOver()) {
|
||||
continue;
|
||||
}
|
||||
if (widget instanceof ITooltip) {
|
||||
((ITooltip) widget).getTooltip(tooltip);
|
||||
if (tooltip.exists()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (widget.hasAttribute(Attribute.BlockTooltip)) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getHelpTooltip(final MinecraftTooltip tooltip) {
|
||||
final Deque<IWidget> queue = this.calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
final IWidget widget = queue.removeFirst();
|
||||
if (widget.isEnabled() && widget.isVisible()) {
|
||||
if (!widget.calculateIsMouseOver()) {
|
||||
continue;
|
||||
}
|
||||
if (widget instanceof ITooltipHelp) {
|
||||
((ITooltipHelp) widget).getHelpTooltip(tooltip);
|
||||
if (tooltip.exists()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (widget.hasAttribute(Attribute.BlockTooltip)) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void getHelpTooltip(final MinecraftTooltip tooltip) {
|
||||
final Deque<IWidget> queue = this.calculateMousedOverWidgets();
|
||||
while (!queue.isEmpty()) {
|
||||
final IWidget widget = queue.removeFirst();
|
||||
if (widget.isEnabled() && widget.isVisible()) {
|
||||
if (!widget.calculateIsMouseOver()) {
|
||||
continue;
|
||||
}
|
||||
if (widget instanceof ITooltipHelp) {
|
||||
((ITooltipHelp) widget).getHelpTooltip(tooltip);
|
||||
if (tooltip.exists()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (widget.hasAttribute(Attribute.BlockTooltip)) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract AbstractMod getMod();
|
||||
protected abstract AbstractMod getMod();
|
||||
|
||||
protected abstract String getName();
|
||||
protected abstract String getName();
|
||||
|
||||
public BinnieResource getBackgroundTextureFile(final int i) {
|
||||
return Binnie.Resource.getPNG(this.getMod(), ResourceType.GUI, this.getName() + ((i == 1) ? "" : i));
|
||||
}
|
||||
public BinnieResource getBackgroundTextureFile(final int i) {
|
||||
return Binnie.Resource.getPNG(this.getMod(), ResourceType.GUI, this.getName() + ((i == 1) ? "" : i));
|
||||
}
|
||||
|
||||
public boolean showHelpButton() {
|
||||
return Machine.getInterface(IInventoryMachine.class, this.getInventory()) != null;
|
||||
}
|
||||
public boolean showHelpButton() {
|
||||
return Machine.getInterface(IInventoryMachine.class, this.getInventory()) != null;
|
||||
}
|
||||
|
||||
public String showInfoButton() {
|
||||
IMachineInformation machineInformation = Machine.getInterface(IMachineInformation.class, this.getInventory());
|
||||
if (machineInformation != null) {
|
||||
return machineInformation.getInformation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public String showInfoButton() {
|
||||
IMachineInformation machineInformation = Machine.getInterface(IMachineInformation.class, this.getInventory());
|
||||
if (machineInformation != null) {
|
||||
return machineInformation.getInformation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Window(final float width, final float height, final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
this.titleButtonLeft = 8.0f;
|
||||
this.titleButtonRight = 8.0f;
|
||||
this.bgText1 = null;
|
||||
this.bgText2 = null;
|
||||
this.hasBeenInitialised = false;
|
||||
this.side = Side.CLIENT;
|
||||
this.side = side;
|
||||
this.setInventories(player, inventory);
|
||||
this.container = new ContainerCraftGUI(this);
|
||||
this.windowInventory = new WindowInventory(this);
|
||||
if (side == Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
this.setSize(new IPoint(width, height));
|
||||
this.gui = new GuiCraftGUI(this);
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
}
|
||||
(CraftGUI.Render = new Renderer(this.gui)).stylesheet(StyleSheetManager.getDefault());
|
||||
this.titleButtonLeft = -14.0f;
|
||||
if (this.showHelpButton()) {
|
||||
new ControlHelp(this, this.titleButtonLeft += 22.0f, 8.0f);
|
||||
}
|
||||
if (this.showInfoButton() != null) {
|
||||
new ControlInfo(this, this.titleButtonLeft += 22.0f, 8.0f, this.showInfoButton());
|
||||
}
|
||||
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeSize event) {
|
||||
if (Window.this.isClient() && Window.this.getGui() != null) {
|
||||
Window.this.getGui().resize(Window.this.getSize());
|
||||
if (Window.this.title != null) {
|
||||
Window.this.title.setSize(new IPoint(Window.this.w(), Window.this.title.h()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
public Window(final float width, final float height, final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
this.titleButtonLeft = 8.0f;
|
||||
this.titleButtonRight = 8.0f;
|
||||
this.bgText1 = null;
|
||||
this.bgText2 = null;
|
||||
this.hasBeenInitialised = false;
|
||||
this.side = Side.CLIENT;
|
||||
this.side = side;
|
||||
this.setInventories(player, inventory);
|
||||
this.container = new ContainerCraftGUI(this);
|
||||
this.windowInventory = new WindowInventory(this);
|
||||
if (side == Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
this.setSize(new IPoint(width, height));
|
||||
this.gui = new GuiCraftGUI(this);
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
}
|
||||
(CraftGUI.Render = new Renderer(this.gui)).stylesheet(StyleSheetManager.getDefault());
|
||||
this.titleButtonLeft = -14.0f;
|
||||
if (this.showHelpButton()) {
|
||||
new ControlHelp(this, this.titleButtonLeft += 22.0f, 8.0f);
|
||||
}
|
||||
if (this.showInfoButton() != null) {
|
||||
new ControlInfo(this, this.titleButtonLeft += 22.0f, 8.0f, this.showInfoButton());
|
||||
}
|
||||
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeSize event) {
|
||||
if (Window.this.isClient() && Window.this.getGui() != null) {
|
||||
Window.this.getGui().resize(Window.this.getSize());
|
||||
if (Window.this.title != null) {
|
||||
Window.this.title.setSize(new IPoint(Window.this.w(), Window.this.title.h()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setTitle(final String title) {
|
||||
(this.title = new ControlTextCentered(this, 12.0f, title)).setColour(4210752);
|
||||
}
|
||||
public void setTitle(final String title) {
|
||||
(this.title = new ControlTextCentered(this, 12.0f, title)).setColour(4210752);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final GuiCraftGUI getGui() {
|
||||
return this.gui;
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
public final GuiCraftGUI getGui() {
|
||||
return this.gui;
|
||||
}
|
||||
|
||||
public final ContainerCraftGUI getContainer() {
|
||||
return this.container;
|
||||
}
|
||||
public final ContainerCraftGUI getContainer() {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
public final WindowInventory getWindowInventory() {
|
||||
return this.windowInventory;
|
||||
}
|
||||
public final WindowInventory getWindowInventory() {
|
||||
return this.windowInventory;
|
||||
}
|
||||
|
||||
public final void initGui() {
|
||||
if (this.hasBeenInitialised) {
|
||||
return;
|
||||
}
|
||||
this.bgText1 = new StandardTexture(0, 0, 256, 256, this.getBackgroundTextureFile(1));
|
||||
if (this.getSize().x() > 256.0f) {
|
||||
this.bgText2 = new StandardTexture(0, 0, 256, 256, this.getBackgroundTextureFile(2));
|
||||
}
|
||||
if (!BinnieCore.proxy.checkTexture(this.bgText1.getTexture())) {
|
||||
this.bgText1 = null;
|
||||
this.bgText2 = null;
|
||||
}
|
||||
this.initialiseClient();
|
||||
this.hasBeenInitialised = true;
|
||||
}
|
||||
public final void initGui() {
|
||||
if (this.hasBeenInitialised) {
|
||||
return;
|
||||
}
|
||||
this.bgText1 = new StandardTexture(0, 0, 256, 256, this.getBackgroundTextureFile(1));
|
||||
if (this.getSize().x() > 256.0f) {
|
||||
this.bgText2 = new StandardTexture(0, 0, 256, 256, this.getBackgroundTextureFile(2));
|
||||
}
|
||||
if (!BinnieCore.proxy.checkTexture(this.bgText1.getTexture())) {
|
||||
this.bgText1 = null;
|
||||
this.bgText2 = null;
|
||||
}
|
||||
this.initialiseClient();
|
||||
this.hasBeenInitialised = true;
|
||||
}
|
||||
|
||||
public abstract void initialiseClient();
|
||||
public abstract void initialiseClient();
|
||||
|
||||
public void initialiseServer() {
|
||||
}
|
||||
public void initialiseServer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.colour(16777215);
|
||||
if (this.getBackground1() != null) {
|
||||
CraftGUI.Render.texture(this.getBackground1(), IPoint.ZERO);
|
||||
}
|
||||
if (this.getBackground2() != null) {
|
||||
CraftGUI.Render.texture(this.getBackground2(), new IPoint(256.0f, 0.0f));
|
||||
}
|
||||
CraftGUI.Render.colour(this.getColour());
|
||||
CraftGUI.Render.texture(CraftGUITexture.Window, this.getArea());
|
||||
}
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.colour(16777215);
|
||||
if (this.getBackground1() != null) {
|
||||
CraftGUI.Render.texture(this.getBackground1(), IPoint.ZERO);
|
||||
}
|
||||
if (this.getBackground2() != null) {
|
||||
CraftGUI.Render.texture(this.getBackground2(), new IPoint(256.0f, 0.0f));
|
||||
}
|
||||
CraftGUI.Render.colour(this.getColour());
|
||||
CraftGUI.Render.texture(CraftGUITexture.Window, this.getArea());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.Help).clear();
|
||||
ControlSlot.shiftClickActive = false;
|
||||
}
|
||||
@Override
|
||||
public void onUpdateClient() {
|
||||
ControlSlot.highlighting.get(EnumHighlighting.Help).clear();
|
||||
ControlSlot.shiftClickActive = false;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
public EntityPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public GameProfile getUsername() {
|
||||
return this.getPlayer().getGameProfile();
|
||||
}
|
||||
public GameProfile getUsername() {
|
||||
return this.getPlayer().getGameProfile();
|
||||
}
|
||||
|
||||
public ItemStack getHeldItemStack() {
|
||||
if (this.player != null) {
|
||||
return this.player.inventory.getItemStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ItemStack getHeldItemStack() {
|
||||
if (this.player != null) {
|
||||
return this.player.inventory.getItemStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return this.entityInventory;
|
||||
}
|
||||
public IInventory getInventory() {
|
||||
return this.entityInventory;
|
||||
}
|
||||
|
||||
public void setInventories(final EntityPlayer player2, final IInventory inventory) {
|
||||
this.player = player2;
|
||||
this.entityInventory = inventory;
|
||||
}
|
||||
public void setInventories(final EntityPlayer player2, final IInventory inventory) {
|
||||
this.player = player2;
|
||||
this.entityInventory = inventory;
|
||||
}
|
||||
|
||||
public void onClose() {
|
||||
}
|
||||
public void onClose() {
|
||||
}
|
||||
|
||||
public void setHeldItemStack(final ItemStack stack) {
|
||||
if (this.player != null) {
|
||||
this.player.inventory.setItemStack(stack);
|
||||
}
|
||||
}
|
||||
public void setHeldItemStack(final ItemStack stack) {
|
||||
if (this.player != null) {
|
||||
this.player.inventory.setItemStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isServer() {
|
||||
return !this.isClient();
|
||||
}
|
||||
public boolean isServer() {
|
||||
return !this.isClient();
|
||||
}
|
||||
|
||||
public boolean isClient() {
|
||||
return this.side == Side.CLIENT;
|
||||
}
|
||||
public boolean isClient() {
|
||||
return this.side == Side.CLIENT;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
if (this.getPlayer() != null) {
|
||||
return this.getPlayer().worldObj;
|
||||
}
|
||||
return BinnieCore.proxy.getWorld();
|
||||
}
|
||||
public World getWorld() {
|
||||
if (this.getPlayer() != null) {
|
||||
return this.getPlayer().worldObj;
|
||||
}
|
||||
return BinnieCore.proxy.getWorld();
|
||||
}
|
||||
|
||||
public void onInventoryUpdate() {
|
||||
}
|
||||
public void onInventoryUpdate() {
|
||||
}
|
||||
|
||||
public void sendClientAction(final String name, final NBTTagCompound action) {
|
||||
action.setString("type", name);
|
||||
final MessageCraftGUI packet = new MessageCraftGUI(action);
|
||||
BinnieCore.proxy.sendToServer(packet);
|
||||
}
|
||||
public void sendClientAction(final String name, final NBTTagCompound action) {
|
||||
action.setString("type", name);
|
||||
final MessageCraftGUI packet = new MessageCraftGUI(action);
|
||||
BinnieCore.proxy.sendToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound action) {
|
||||
if (side == Side.CLIENT && name.equals("username")) {
|
||||
final float w = this.w();
|
||||
final float titleButtonRight = this.titleButtonRight + 16.0f;
|
||||
this.titleButtonRight = titleButtonRight;
|
||||
final ControlUser controlUser = new ControlUser(this, w - titleButtonRight, 8.0f, action.getString("username"));
|
||||
this.titleButtonRight += 6.0f;
|
||||
}
|
||||
if (side == Side.CLIENT && name.equals("power-system")) {
|
||||
final float w2 = this.w();
|
||||
final float titleButtonRight2 = this.titleButtonRight + 16.0f;
|
||||
this.titleButtonRight = titleButtonRight2;
|
||||
final ControlPowerSystem controlPowerSystem = new ControlPowerSystem(this, w2 - titleButtonRight2, 8.0f, PowerSystem.get(action.getByte("system")));
|
||||
this.titleButtonRight += 6.0f;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound action) {
|
||||
if (side == Side.CLIENT && name.equals("username")) {
|
||||
final float w = this.w();
|
||||
final float titleButtonRight = this.titleButtonRight + 16.0f;
|
||||
this.titleButtonRight = titleButtonRight;
|
||||
final ControlUser controlUser = new ControlUser(this, w - titleButtonRight, 8.0f, action.getString("username"));
|
||||
this.titleButtonRight += 6.0f;
|
||||
}
|
||||
if (side == Side.CLIENT && name.equals("power-system")) {
|
||||
final float w2 = this.w();
|
||||
final float titleButtonRight2 = this.titleButtonRight + 16.0f;
|
||||
this.titleButtonRight = titleButtonRight2;
|
||||
final ControlPowerSystem controlPowerSystem = new ControlPowerSystem(this, w2 - titleButtonRight2, 8.0f, PowerSystem.get(action.getByte("system")));
|
||||
this.titleButtonRight += 6.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void onWindowInventoryChanged() {
|
||||
}
|
||||
public void onWindowInventoryChanged() {
|
||||
}
|
||||
|
||||
public Texture getBackground1() {
|
||||
return this.bgText1;
|
||||
}
|
||||
public Texture getBackground1() {
|
||||
return this.bgText1;
|
||||
}
|
||||
|
||||
public Texture getBackground2() {
|
||||
return this.bgText2;
|
||||
}
|
||||
public Texture getBackground2() {
|
||||
return this.bgText2;
|
||||
}
|
||||
|
||||
public static <T extends Window> T get(final IWidget widget) {
|
||||
return (T) widget.getSuperParent();
|
||||
}
|
||||
public static <T extends Window> T get(final IWidget widget) {
|
||||
return (T) widget.getSuperParent();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user