mirror of
https://github.com/GTNewHorizons/EnderCore.git
synced 2026-11-20 03:59:35 +00:00
Add changes from latest EIO merge
This commit is contained in:
1 parent
93c0f3fcc9
commit
c6f189b9dd
5 files changed
+67
-22
No files matched your search
@@ -1,6 +1,5 @@
|
||||
package com.enderio.core.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -42,10 +41,10 @@ import cpw.mods.fml.common.Optional;
|
||||
public abstract class GuiContainerBase extends GuiContainer implements ToolTipRenderer, IGuiScreen, INEIGuiHandler {
|
||||
|
||||
protected ToolTipManager ttMan = new ToolTipManager();
|
||||
protected List<IGuiOverlay> overlays = new ArrayList<IGuiOverlay>();
|
||||
protected List<IGuiOverlay> overlays = Lists.newArrayList();
|
||||
protected List<TextFieldEnder> textFields = Lists.newArrayList();
|
||||
protected List<VScrollbar> scrollbars = new ArrayList<VScrollbar>();
|
||||
protected List<GhostSlot> ghostSlots = new ArrayList<GhostSlot>();
|
||||
protected List<VScrollbar> scrollbars = Lists.newArrayList();
|
||||
protected List<GhostSlot> ghostSlots = Lists.newArrayList();
|
||||
|
||||
protected GhostSlot hoverGhostSlot;
|
||||
protected VScrollbar draggingScrollbar;
|
||||
@@ -71,8 +70,8 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char c, int key) {
|
||||
GuiTextField focused = null;
|
||||
for (GuiTextField f : textFields) {
|
||||
TextFieldEnder focused = null;
|
||||
for (TextFieldEnder f : textFields) {
|
||||
if (f.isFocused()) {
|
||||
focused = f;
|
||||
}
|
||||
@@ -105,7 +104,9 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
|
||||
// If there is a focused text field, attempt to type into it
|
||||
if(focused != null) {
|
||||
String old = focused.getText();
|
||||
if(focused.textboxKeyTyped(c, key)) {
|
||||
onTextFieldChanged(focused, old);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -128,6 +129,16 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
super.keyTyped(c, key);
|
||||
}
|
||||
|
||||
protected final void setText(TextFieldEnder tf, String newText) {
|
||||
String old = tf.getText();
|
||||
tf.setText(newText);
|
||||
onTextFieldChanged(tf, old);
|
||||
}
|
||||
|
||||
protected void onTextFieldChanged(TextFieldEnder tf, String old) {
|
||||
|
||||
}
|
||||
|
||||
public boolean hideOverlays() {
|
||||
for (IGuiOverlay overlay : overlays) {
|
||||
if(overlay.isVisible()) {
|
||||
@@ -219,7 +230,7 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
if(button == 1) {
|
||||
for (TextFieldEnder tf : textFields) {
|
||||
if(tf.contains(x, y)) {
|
||||
tf.setText("");
|
||||
setText(tf, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -340,10 +351,7 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
|
||||
if(draggingScrollbar == null) {
|
||||
if(hoverGhostSlot != null && mc.thePlayer.inventory.getItemStack() == null) {
|
||||
ItemStack stack = hoverGhostSlot.getStack();
|
||||
if(stack != null) {
|
||||
renderToolTip(stack, par1, par2);
|
||||
}
|
||||
drawGhostSlotTooltip(hoverGhostSlot, par1, par2);
|
||||
}
|
||||
|
||||
ttMan.drawTooltips(this, par1, par2);
|
||||
@@ -399,6 +407,13 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
zLevel = 0.0F;
|
||||
}
|
||||
|
||||
protected void drawGhostSlotTooltip(GhostSlot slot, int mouseX, int mouseY) {
|
||||
ItemStack stack = slot.getStack();
|
||||
if(stack != null) {
|
||||
renderToolTip(stack, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawGhostSlots(int mouseX, int mouseY) {
|
||||
if(ghostSlots.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -23,7 +23,8 @@ public class IconButton extends GuiButton {
|
||||
private int yOrigin;
|
||||
|
||||
protected IGuiScreen gui;
|
||||
|
||||
protected String[] toolTipText;
|
||||
|
||||
private GuiToolTip toolTip;
|
||||
private int marginY = 0;
|
||||
private int marginX = 0;
|
||||
@@ -43,6 +44,17 @@ public class IconButton extends GuiButton {
|
||||
} else {
|
||||
toolTip.setToolTipText(tooltipText);
|
||||
}
|
||||
this.toolTipText = tooltipText;
|
||||
}
|
||||
|
||||
protected void setToolTip(GuiToolTip newToolTip) {
|
||||
if (toolTip != null) {
|
||||
gui.removeToolTip(toolTip);
|
||||
}
|
||||
toolTip = newToolTip;
|
||||
if (toolTip != null) {
|
||||
gui.addToolTip(toolTip);
|
||||
}
|
||||
}
|
||||
|
||||
public final Rectangle getBounds() {
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.enderio.core.client.gui.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import com.enderio.core.api.client.gui.IGuiScreen;
|
||||
import com.enderio.core.api.client.render.IWidgetIcon;
|
||||
import com.enderio.core.client.gui.widget.GuiToolTip;
|
||||
import com.enderio.core.client.render.EnderWidget;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class ToggleButton extends IconButton {
|
||||
|
||||
@@ -12,8 +16,7 @@ public class ToggleButton extends IconButton {
|
||||
private final IWidgetIcon unselectedIcon;
|
||||
private final IWidgetIcon selectedIcon;
|
||||
|
||||
private String[] selectedTooltip;
|
||||
private String[] unselectedTooltip;
|
||||
private GuiToolTip selectedTooltip, unselectedTooltip;
|
||||
private boolean paintSelectionBorder;
|
||||
|
||||
public ToggleButton(IGuiScreen gui, int id, int x, int y, IWidgetIcon unselectedIcon, IWidgetIcon selectedIcon) {
|
||||
@@ -67,17 +70,18 @@ public class ToggleButton extends IconButton {
|
||||
}
|
||||
|
||||
public void setSelectedToolTip(String... tt) {
|
||||
this.selectedTooltip = tt;
|
||||
String[] combinedTooltip = ArrayUtils.addAll(toolTipText, tt);
|
||||
selectedTooltip = new GuiToolTip(getBounds(), Lists.newArrayList(combinedTooltip));
|
||||
setSelected(selected);
|
||||
}
|
||||
|
||||
public void setUnselectedToolTip(String... tt) {
|
||||
this.unselectedTooltip = tt;
|
||||
String[] combinedTooltip = ArrayUtils.addAll(toolTipText, tt);
|
||||
unselectedTooltip = new GuiToolTip(getBounds(), Lists.newArrayList(combinedTooltip));
|
||||
setSelected(selected);
|
||||
}
|
||||
|
||||
public void setPaintSelectedBorder(boolean b) {
|
||||
this.paintSelectionBorder = b;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.enderio.core.api.common.util.ITankAccess;
|
||||
import com.enderio.core.common.util.FluidUtil;
|
||||
@@ -166,4 +166,18 @@ public abstract class BlockEnder extends Block {
|
||||
return te.shouldDoWorkThisTick(interval, offset);
|
||||
}
|
||||
}
|
||||
|
||||
//Because the vanilla method takes floats...
|
||||
public void setBlockBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public void setBlockBounds(AxisAlignedBB bb) {
|
||||
setBlockBounds(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
@@ -55,15 +55,15 @@ public class BlockCoord {
|
||||
this(mop.blockX, mop.blockY, mop.blockZ);
|
||||
}
|
||||
|
||||
public Block getBlock(World world) {
|
||||
public Block getBlock(IBlockAccess world) {
|
||||
return world.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
public int getMetadata(World world) {
|
||||
public int getMetadata(IBlockAccess world) {
|
||||
return world.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity(World world) {
|
||||
public TileEntity getTileEntity(IBlockAccess world) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user