mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-10-26 14:24:23 +00:00
text and search bar improve
This commit is contained in:
1 parent
9d95dec6af
commit
6e7fcff757
5 files changed
+104
-18
No files matched your search
@@ -0,0 +1,93 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
public class FCGuiTextField extends GuiTextField {
|
||||
private static final int PADDING = 2;
|
||||
private String tooltip;
|
||||
|
||||
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 FCGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height) {
|
||||
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth('_'), 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 = this._xPos <= xCoord && xCoord < this._xPos + this._width;
|
||||
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
|
||||
|
||||
return withinXRange && withinYRange;
|
||||
}
|
||||
|
||||
public void setMessage(String t)
|
||||
{
|
||||
tooltip = t;
|
||||
}
|
||||
|
||||
public class TooltipProvider implements ITooltip
|
||||
{
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
return _xPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
return _yPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return _height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() { return _width; }
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return getVisible();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,12 @@ import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
|
||||
@@ -135,7 +137,7 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
|
||||
}
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - Ae2ReflectClient.getReservedSpace(this), 4210752 );
|
||||
this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - Ae2ReflectClient.getReservedSpace(this), 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,8 +13,10 @@ import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
|
||||
@@ -109,7 +111,7 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
|
||||
}
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - Ae2ReflectClient.getReservedSpace(this), 4210752 );
|
||||
this.fontRendererObj.drawString( StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - Ae2ReflectClient.getReservedSpace(this), 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,7 +34,6 @@ import com.glodblock.github.client.gui.container.FCBasePartContainer;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.network.CPacketInventoryAction;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
@@ -67,8 +66,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
|
||||
public FCBaseMonitorContain monitorableContainer;
|
||||
private GuiTabButton craftingStatusBtn;
|
||||
private GuiImgButton craftingStatusImgBtn;
|
||||
private MEGuiTextField searchField;
|
||||
private String myName;
|
||||
private FCGuiTextField searchField;
|
||||
private int perRow = 9;
|
||||
private int reservedSpace = 0;
|
||||
private boolean customSortOrder = true;
|
||||
@@ -111,14 +109,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
|
||||
|
||||
this.viewCell = te instanceof IViewCellStorage;
|
||||
|
||||
if( te instanceof PartFluidPatternTerminal)
|
||||
{
|
||||
this.myName = NameConst.GUI_FLUID_PATTERN_TERMINAL;
|
||||
}
|
||||
if (te instanceof PartFluidPatternTerminalEx)
|
||||
{
|
||||
this.myName = NameConst.GUI_FLUID_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
}
|
||||
|
||||
public void postUpdate( final List<IAEItemStack> list )
|
||||
@@ -283,7 +273,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.buttonList.add( this.terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings.getSetting( Settings.TERMINAL_STYLE ) ) );
|
||||
offset += 20;
|
||||
|
||||
this.searchField = new MEGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
|
||||
this.searchField = new FCGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
|
||||
this.searchField.setEnableBackgroundDrawing( false );
|
||||
this.searchField.setMaxStringLength( 25 );
|
||||
this.searchField.setTextColor( 0xFFFFFF );
|
||||
|
||||
@@ -65,9 +65,8 @@ public class GuiIngredientBuffer extends AEBaseGui {
|
||||
|
||||
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
Tessellator tess = Tessellator.instance;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
renderFluidIntoGui(tess, TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
|
||||
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
|
||||
fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
|
||||
}
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
@@ -75,8 +74,8 @@ public class GuiIngredientBuffer extends AEBaseGui {
|
||||
mouseRegions.render(mouseX, mouseY);
|
||||
}
|
||||
|
||||
public void renderFluidIntoGui(Tessellator tess, int x, int y, int width, int height,
|
||||
@Nullable IAEFluidStack aeFluidStack, int capacity) {
|
||||
public void renderFluidIntoGui(int x, int y, int width, int height,
|
||||
@Nullable IAEFluidStack aeFluidStack, int capacity) {
|
||||
if (aeFluidStack != null) {
|
||||
GL11.glDisable(2896);
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
|
||||
Reference in new issue
Block a user