mirror of
https://github.com/GTNewHorizons/WirelessCraftingTerminal.git
synced 2026-11-19 03:39:26 +00:00
Switch to AE2 tab button, text field
This commit is contained in:
1 parent
c5bcb1841b
commit
104d89c0c8
6 files changed
+7
-286
No files matched your search
@@ -4,12 +4,12 @@ import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.helpers.Reflected;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTabButton;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
|
||||
+1
-3
@@ -4,11 +4,11 @@ import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTabButton;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
|
||||
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
|
||||
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
|
||||
@@ -57,8 +57,6 @@ public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraf
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
// Hide "go back to wireless terminal" button as it opens the wrong GUI
|
||||
this.buttonList.remove(this.buttonList.size() - 1);
|
||||
|
||||
if (this.myIcon != null) {
|
||||
this.buttonList.add(
|
||||
|
||||
+5
-9
@@ -12,7 +12,9 @@ import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.me.SlotME;
|
||||
@@ -44,9 +46,7 @@ import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTabButton;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTrashButton;
|
||||
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.MEGuiTextField;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.container.slot.SlotTrash;
|
||||
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
|
||||
@@ -388,13 +388,9 @@ public class GuiWirelessCraftingTerminal extends AEBaseGui implements ISortSourc
|
||||
Settings.TERMINAL_STYLE,
|
||||
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
|
||||
|
||||
this.searchField = new MEGuiTextField(this.fontRendererObj, SEARCH_X, SEARCH_Y, SEARCH_WIDTH, SEARCH_HEIGHT);
|
||||
|
||||
this.searchField.setEnableBackgroundDrawing(false);
|
||||
this.searchField.setMaxStringLength(25);
|
||||
this.searchField.setTextColor(0xFFFFFF);
|
||||
this.searchField.setVisible(true);
|
||||
this.searchField.setEnabled(true);
|
||||
this.searchField = new MEGuiTextField(SEARCH_WIDTH, SEARCH_HEIGHT);
|
||||
this.searchField.x = SEARCH_X;
|
||||
this.searchField.y = SEARCH_Y;
|
||||
|
||||
this.buttonList.add(
|
||||
this.craftingStatusBtn = new GuiTabButton(
|
||||
|
||||
-141
@@ -1,141 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui.widgets;
|
||||
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class GuiTabButton extends GuiButton implements ITooltip {
|
||||
private final RenderItem itemRenderer;
|
||||
private final String message;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
|
||||
public GuiTabButton(final int x, final int y, final int ico, final String message, final RenderItem ir) {
|
||||
super(0, 0, 16, "");
|
||||
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
this.myIcon = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Using itemstack as an icon
|
||||
*
|
||||
* @param x x pos of button
|
||||
* @param y y pos of button
|
||||
* @param ico used icon
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton(final int x, final int y, final ItemStack ico, final String message, final RenderItem ir) {
|
||||
super(0, 0, 16, "");
|
||||
this.xPosition = x;
|
||||
this.yPosition = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
this.myItem = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(final Minecraft minecraft, final int x, final int y) {
|
||||
if (this.visible) {
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png"));
|
||||
this.field_146123_n = x >= this.xPosition
|
||||
&& y >= this.yPosition
|
||||
&& x < this.xPosition + this.width
|
||||
&& y < this.yPosition + this.height;
|
||||
|
||||
int uv_x = (this.hideEdge > 0 ? 11 : 13);
|
||||
|
||||
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
||||
|
||||
// this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, 0, 25, 22 );
|
||||
|
||||
if (this.myIcon >= 0) {
|
||||
final int uv_y = (int) Math.floor(this.myIcon / 16);
|
||||
uv_x = this.myIcon - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect(
|
||||
offsetX + this.xPosition + 3, this.yPosition + 6, uv_x * 16, uv_y * 16, 16, 16);
|
||||
}
|
||||
|
||||
this.mouseDragged(minecraft, x, y);
|
||||
|
||||
if (this.myItem != null) {
|
||||
this.zLevel = 100.0F;
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
final FontRenderer fontrenderer = minecraft.fontRenderer;
|
||||
// this.itemRenderer.renderItemAndEffectIntoGUI( fontrenderer, minecraft.renderEngine, this.myItem,
|
||||
// offsetX + this.xPosition + 3, this.yPosition + 6 );
|
||||
this.itemRenderer.renderItemIntoGUI(
|
||||
fontrenderer,
|
||||
minecraft.renderEngine,
|
||||
this.myItem,
|
||||
offsetX + this.xPosition + 3,
|
||||
this.yPosition + 6,
|
||||
false);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
return this.xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
return this.yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
public int getHideEdge() {
|
||||
return this.hideEdge;
|
||||
}
|
||||
|
||||
public void setHideEdge(final int hideEdge) {
|
||||
this.hideEdge = hideEdge;
|
||||
}
|
||||
}
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
/**
|
||||
* A modified version of the Minecraft text field.
|
||||
* You can initialize it over the full element span.
|
||||
* The mouse click area is increased to the full element
|
||||
* subtracted with the defined padding.
|
||||
*
|
||||
* The rendering does pay attention to the size of the '_' caret.
|
||||
*/
|
||||
public class MEGuiTextField extends GuiTextField {
|
||||
private static final int PADDING = 2;
|
||||
|
||||
private final int _xPos;
|
||||
private final int _yPos;
|
||||
private final int _width;
|
||||
private final int _height;
|
||||
|
||||
/**
|
||||
* Uses the values to instantiate a padded version of a text field.
|
||||
* Pays attention to the '_' caret.
|
||||
*
|
||||
* @param fontRenderer renderer for the strings
|
||||
* @param xPos absolute left position
|
||||
* @param yPos absolute top position
|
||||
* @param width absolute width
|
||||
* @param height absolute height
|
||||
*/
|
||||
public MEGuiTextField(
|
||||
final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height) {
|
||||
super(fontRenderer, xPos, yPos, width, height - 2 * PADDING);
|
||||
|
||||
this._xPos = xPos;
|
||||
this._yPos = yPos;
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(final int xPos, final int yPos, final int button) {
|
||||
super.mouseClicked(xPos, yPos, button);
|
||||
|
||||
final boolean requiresFocus = this.isMouseIn(xPos, yPos);
|
||||
|
||||
this.setFocused(requiresFocus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the mouse is within the element
|
||||
*
|
||||
* @param xCoord current x coord of the mouse
|
||||
* @param yCoord current y coord of the mouse
|
||||
*
|
||||
* @return true if mouse position is within the text field area
|
||||
*/
|
||||
public boolean isMouseIn(final int xCoord, final int yCoord) {
|
||||
final boolean withinXRange = xCoord >= this._xPos && xCoord <= this._xPos + this._width;
|
||||
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
|
||||
|
||||
return withinXRange && withinYRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextBox() {
|
||||
if (this.getVisible()) {
|
||||
if (this.isFocused()) {
|
||||
drawRect(
|
||||
this.xPosition - 1,
|
||||
this.yPosition,
|
||||
this.xPosition + this.width - 1,
|
||||
this.yPosition + this.height + 2,
|
||||
0xFF606060);
|
||||
} else {
|
||||
drawRect(
|
||||
this.xPosition - 1,
|
||||
this.yPosition,
|
||||
this.xPosition + this.width - 1,
|
||||
this.yPosition + this.height + 2,
|
||||
0xFFA8A8A8);
|
||||
}
|
||||
super.drawTextBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package net.p455w0rd.wirelesscraftingterminal.common.container;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.util.ItemSorters;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord> {
|
||||
|
||||
private final String myName;
|
||||
private final ICraftingCPU cpu;
|
||||
private final long size;
|
||||
private final int processors;
|
||||
|
||||
public CraftingCPURecord(final long size, final int coProcessors, final ICraftingCPU server) {
|
||||
this.size = size;
|
||||
this.processors = coProcessors;
|
||||
this.cpu = server;
|
||||
this.myName = server.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@Nonnull final CraftingCPURecord o) {
|
||||
final int a = ItemSorters.compareLong(o.getProcessors(), this.getProcessors());
|
||||
if (a != 0) {
|
||||
return a;
|
||||
}
|
||||
return ItemSorters.compareLong(o.getSize(), this.getSize());
|
||||
}
|
||||
|
||||
public ICraftingCPU getCpu() {
|
||||
return this.cpu;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return this.myName;
|
||||
}
|
||||
|
||||
int getProcessors() {
|
||||
return this.processors;
|
||||
}
|
||||
|
||||
long getSize() {
|
||||
return this.size;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user