aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/gui/widgets')
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java70
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java32
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java123
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java39
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java13
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java15
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java3
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java11
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java74
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java108
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java32
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java21
12 files changed, 290 insertions, 251 deletions
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java
index 8f729771f6..525618589b 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java
@@ -1,36 +1,34 @@
package gregtech.api.gui.widgets;
-import java.awt.Rectangle;
-import java.util.List;
-
-import org.lwjgl.opengl.GL11;
-
import codechicken.nei.api.API;
import codechicken.nei.api.INEIGuiAdapter;
-import gregtech.api.enums.Dyes;
import gregtech.api.enums.GT_Values;
import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.net.GT_Packet_GtTileEntityGuiRequest;
import gregtech.common.GT_Proxy;
+import java.awt.Rectangle;
+import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
+import org.lwjgl.opengl.GL11;
/**
* Let's you access a GregTech IGregTechTileEntity's covers as tabs on the GUI's sides
*/
public class GT_GuiCoverTabLine extends GT_GuiTabLine {
// Names of the block a cover could be on
- private final static String[] SIDES = new String[]{
+ private static final String[] SIDES = new String[] {
"GT5U.interface.coverTabs.down",
"GT5U.interface.coverTabs.up",
"GT5U.interface.coverTabs.north",
"GT5U.interface.coverTabs.south",
"GT5U.interface.coverTabs.west",
- "GT5U.interface.coverTabs.east"};
+ "GT5U.interface.coverTabs.east"
+ };
// Not sure there's a point in JIT translation but that's what this is
private String[] translatedSides;
@@ -39,7 +37,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
/**
* Let's you access an IGregTechTileEntity's covers as tabs on the GUI's sides
- *
+ *
* @param gui GT_ITabRenderer gui which this tab line attaches to
* @param tabLineLeft left position of the tab line in relation to the gui
* @param tabLineTop top position of the tab line in relation to the gui
@@ -56,9 +54,19 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
* @param tile The IGregTechTileEntity the covers of which we are accessing
* @param colorization The colorization of the GUI we are adding tabs to
*/
- public GT_GuiCoverTabLine(GT_GUIContainerMetaTile_Machine gui, int tabLineLeft, int tabLineTop, int tabHeight,
- int tabWidth, int tabSpacing, DisplayStyle xDir, DisplayStyle yDir, DisplayStyle displayMode,
- GT_GuiTabIconSet tabBackground, IGregTechTileEntity tile, int colorization) {
+ public GT_GuiCoverTabLine(
+ GT_GUIContainerMetaTile_Machine gui,
+ int tabLineLeft,
+ int tabLineTop,
+ int tabHeight,
+ int tabWidth,
+ int tabSpacing,
+ DisplayStyle xDir,
+ DisplayStyle yDir,
+ DisplayStyle displayMode,
+ GT_GuiTabIconSet tabBackground,
+ IGregTechTileEntity tile,
+ int colorization) {
super(gui, 6, tabLineLeft, tabLineTop, tabHeight, tabWidth, tabSpacing, xDir, yDir, displayMode, tabBackground);
this.tile = tile;
this.colorization = colorization;
@@ -76,12 +84,13 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
addCoverToTabs(tSide, cover);
}
}
- }
+ }
@Override
protected void drawBackground(float parTicks, int mouseX, int mouseY) {
// Apply this tile's coloration to draw the background
- GL11.glColor3ub((byte) ((colorization >> 16) & 0xFF), (byte) ((colorization >> 8) & 0xFF), (byte) (colorization & 0xFF));
+ GL11.glColor3ub((byte) ((colorization >> 16) & 0xFF), (byte) ((colorization >> 8) & 0xFF), (byte)
+ (colorization & 0xFF));
super.drawBackground(parTicks, mouseX, mouseY);
}
@@ -89,13 +98,13 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
protected void tabClicked(int tabId, int mouseButton) {
if (mouseButton == 0 && mTabs[tabId].enabled) {
GT_Values.NW.sendToServer(new GT_Packet_GtTileEntityGuiRequest(
- this.tile.getXCoord(),
- this.tile.getYCoord(),
- this.tile.getZCoord(),
- tabId + GT_Proxy.GUI_ID_COVER_SIDE_BASE,
- this.tile.getWorld().provider.dimensionId,
- Minecraft.getMinecraft().thePlayer.getEntityId(),
- 0));
+ this.tile.getXCoord(),
+ this.tile.getYCoord(),
+ this.tile.getZCoord(),
+ tabId + GT_Proxy.GUI_ID_COVER_SIDE_BASE,
+ this.tile.getWorld().provider.dimensionId,
+ Minecraft.getMinecraft().thePlayer.getEntityId(),
+ 0));
}
}
@@ -108,7 +117,6 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
boolean enabled = this.tile.getCoverBehaviorAtSideNew(side).hasCoverGUI();
this.setTab(side, cover, null, getTooltipForCoverTab(side, cover, enabled));
this.setTabEnabled(side, enabled);
-
}
/**
@@ -119,12 +127,13 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
* @return This cover tab's tooltip
*/
private String[] getTooltipForCoverTab(byte side, ItemStack cover, boolean enabled) {
- List<String> tooltip = cover.getTooltip(Minecraft.getMinecraft().thePlayer, true);
- tooltip.set(0,
+ List<String> tooltip = cover.getTooltip(Minecraft.getMinecraft().thePlayer, true);
+ tooltip.set(
+ 0,
(enabled ? EnumChatFormatting.UNDERLINE : EnumChatFormatting.DARK_GRAY)
- + getSideDescription(side)
- + (enabled ? EnumChatFormatting.RESET + ": " : ": " + EnumChatFormatting.RESET)
- + tooltip.get(0));
+ + getSideDescription(side)
+ + (enabled ? EnumChatFormatting.RESET + ": " : ": " + EnumChatFormatting.RESET)
+ + tooltip.get(0));
return tooltip.toArray(new String[0]);
}
@@ -138,7 +147,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
if (this.translatedSides[side] == null) {
this.translatedSides[side] = StatCollector.translateToLocal(SIDES[side]);
}
- return this.translatedSides[side] ;
+ return this.translatedSides[side];
}
return null;
}
@@ -146,7 +155,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
/**
* Hide any NEI slots that would intersect with a cover tab
*/
- static class CoverTabLineNEIHandler extends INEIGuiAdapter{
+ static class CoverTabLineNEIHandler extends INEIGuiAdapter {
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
Rectangle neiSlotArea = new Rectangle(x, y, w, h);
@@ -155,7 +164,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
if (!tabLine.visible) {
return false;
}
- for (int i = 0; i < tabLine.mTabs.length; i++ ) {
+ for (int i = 0; i < tabLine.mTabs.length; i++) {
if (tabLine.mTabs[i] != null && tabLine.mTabs[i].getBounds().intersects(neiSlotArea)) {
return true;
}
@@ -164,6 +173,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
return false;
}
}
+
static {
API.registerNEIGuiHandler(new CoverTabLineNEIHandler());
}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java
index 045730dd7f..7a57c49515 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java
@@ -3,15 +3,14 @@ package gregtech.api.gui.widgets;
import codechicken.lib.gui.GuiDraw;
import gregtech.api.interfaces.IGuiScreen;
import gregtech.api.util.GT_UtilityClient;
+import java.awt.*;
+import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
-import java.awt.*;
-import java.util.List;
-
public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement {
private GT_GuiIcon bgIcon;
@@ -42,14 +41,13 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement {
this.gui = gui;
this.bgIcon = bgIcon;
item = null;
- rectangle = new Rectangle(x, y, 18, 18);
+ rectangle = new Rectangle(x, y, 18, 18);
gui.addElement(this);
}
public GT_GuiFakeItemButton setItem(ItemStack i) {
item = i;
- if (getMimicSlot())
- updateTooltip();
+ if (getMimicSlot()) updateTooltip();
return this;
}
@@ -57,7 +55,7 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement {
itemTooltips = item == null ? null : GT_UtilityClient.getTooltip(item, true);
}
- public ItemStack getItem(){
+ public ItemStack getItem() {
return item;
}
@@ -95,8 +93,7 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement {
@Override
public void onRemoved() {
- if (mimicSlot)
- gui.removeToolTip(tooltip);
+ if (mimicSlot) gui.removeToolTip(tooltip);
}
@Override
@@ -106,8 +103,8 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
- if (bgIcon != null){
- GT_GuiIcon.render(bgIcon, xPosition-1, yPosition-1, 18, 18,0,true);
+ if (bgIcon != null) {
+ GT_GuiIcon.render(bgIcon, xPosition - 1, yPosition - 1, 18, 18, 0, true);
}
if (item != null) {
@@ -115,10 +112,15 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
}
- gui.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer(), Minecraft.getMinecraft().getTextureManager(), item, xPosition, yPosition);
-
- if (item.getItem() instanceof ItemBlock)
- GL11.glPopAttrib();
+ gui.getItemRenderer()
+ .renderItemAndEffectIntoGUI(
+ gui.getFontRenderer(),
+ Minecraft.getMinecraft().getTextureManager(),
+ item,
+ xPosition,
+ yPosition);
+
+ if (item.getItem() instanceof ItemBlock) GL11.glPopAttrib();
}
if (getMimicSlot())
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
index 0d6c2da243..37e1a6d960 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java
@@ -1,61 +1,59 @@
package gregtech.api.gui.widgets;
-import java.util.Arrays;
-
import gregtech.api.interfaces.IGuiIcon;
+import java.util.Arrays;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
-public enum GT_GuiIcon implements IGuiIcon{
- BUTTON_NORMAL (0, 0, 0),
- BUTTON_DOWN (0, 32, 0),
- BUTTON_HIGHLIGHT (0, 32*2, 0),
- BUTTON_HIGHLIGHT_DOWN (0, 32*3, 0),
- BUTTON_DISABLED (0, 32*4, 0),
-
- DISABLE (0, 0, 32),
- REDSTONE_OFF (0, 32, 32),
- REDSTONE_ON (0, 32*2, 32),
- CHECKMARK (0, 32*3, 32),
- CROSS (0, 32*4, 32),
- WHITELIST (0, 32*5, 32),
- BLACKLIST (0, 32*6, 32),
- PROGRESS (0, 32*7, 32),
-
- EXPORT (0, 0, 32*2),
- IMPORT (0, 32, 32*2),
- ALLOW_INPUT (0, 32*2, 32*2),
- BLOCK_INPUT (0, 32*3, 32*2),
- GREEN_ARROW_UP (0, 32*4, 32*2),
- GREEN_ARROW_DOWN (0, 32*5, 32*2),
- CYCLIC (0, 32*6, 32*2),
-
- SLOT_DARKGRAY (1, 176,0,18,18),
- SLOT_GRAY (1, 176,18,18,18),
-
- TAB_NORMAL (2, 0, 0,18,20),
- TAB_HIGHLIGHT (2, 18, 0,18,20),
- TAB_DISABLED (2, 18*2, 0,18,20),
- TAB_NORMAL_BRONZE (2, 0, 20,18,20),
- TAB_HIGHLIGHT_BRONZE (2, 18, 20,18,20),
- TAB_DISABLED_BRONZE (2, 18*2, 20,18,20),
- TAB_NORMAL_STEEL (2, 0,2*20,18,20),
- TAB_HIGHLIGHT_STEEL (2, 18,2*20,18,20),
- TAB_DISABLED_STEEL (2, 18*2,2*20,18,20),
- TAB_NORMAL_BRICK (2, 0,3*20,18,20),
- TAB_HIGHLIGHT_BRICK (2, 18,3*20,18,20),
- TAB_DISABLED_BRICK (2, 18*2,3*20,18,20),
- TAB_INFO_GRAY (2, 220, 0,18,20),
- TAB_INFO_BLUE (2,220+18, 0,18,20),
-;
-
+public enum GT_GuiIcon implements IGuiIcon {
+ BUTTON_NORMAL(0, 0, 0),
+ BUTTON_DOWN(0, 32, 0),
+ BUTTON_HIGHLIGHT(0, 32 * 2, 0),
+ BUTTON_HIGHLIGHT_DOWN(0, 32 * 3, 0),
+ BUTTON_DISABLED(0, 32 * 4, 0),
+
+ DISABLE(0, 0, 32),
+ REDSTONE_OFF(0, 32, 32),
+ REDSTONE_ON(0, 32 * 2, 32),
+ CHECKMARK(0, 32 * 3, 32),
+ CROSS(0, 32 * 4, 32),
+ WHITELIST(0, 32 * 5, 32),
+ BLACKLIST(0, 32 * 6, 32),
+ PROGRESS(0, 32 * 7, 32),
+
+ EXPORT(0, 0, 32 * 2),
+ IMPORT(0, 32, 32 * 2),
+ ALLOW_INPUT(0, 32 * 2, 32 * 2),
+ BLOCK_INPUT(0, 32 * 3, 32 * 2),
+ GREEN_ARROW_UP(0, 32 * 4, 32 * 2),
+ GREEN_ARROW_DOWN(0, 32 * 5, 32 * 2),
+ CYCLIC(0, 32 * 6, 32 * 2),
+
+ SLOT_DARKGRAY(1, 176, 0, 18, 18),
+ SLOT_GRAY(1, 176, 18, 18, 18),
+
+ TAB_NORMAL(2, 0, 0, 18, 20),
+ TAB_HIGHLIGHT(2, 18, 0, 18, 20),
+ TAB_DISABLED(2, 18 * 2, 0, 18, 20),
+ TAB_NORMAL_BRONZE(2, 0, 20, 18, 20),
+ TAB_HIGHLIGHT_BRONZE(2, 18, 20, 18, 20),
+ TAB_DISABLED_BRONZE(2, 18 * 2, 20, 18, 20),
+ TAB_NORMAL_STEEL(2, 0, 2 * 20, 18, 20),
+ TAB_HIGHLIGHT_STEEL(2, 18, 2 * 20, 18, 20),
+ TAB_DISABLED_STEEL(2, 18 * 2, 2 * 20, 18, 20),
+ TAB_NORMAL_BRICK(2, 0, 3 * 20, 18, 20),
+ TAB_HIGHLIGHT_BRICK(2, 18, 3 * 20, 18, 20),
+ TAB_DISABLED_BRICK(2, 18 * 2, 3 * 20, 18, 20),
+ TAB_INFO_GRAY(2, 220, 0, 18, 20),
+ TAB_INFO_BLUE(2, 220 + 18, 0, 18, 20),
+ ;
private static final int T_SIZE = 256;
private static ResourceLocation[] TEXTURES = {
- new ResourceLocation("gregtech", "textures/gui/GuiButtons.png"),
- new ResourceLocation("gregtech", "textures/gui/GuiCover.png"),
- new ResourceLocation("gregtech", "textures/gui/GuiTabs.png"),
+ new ResourceLocation("gregtech", "textures/gui/GuiButtons.png"),
+ new ResourceLocation("gregtech", "textures/gui/GuiCover.png"),
+ new ResourceLocation("gregtech", "textures/gui/GuiTabs.png"),
};
public final int x, y, width, height;
@@ -72,25 +70,34 @@ public enum GT_GuiIcon implements IGuiIcon{
}
GT_GuiIcon(int texID, int x, int y) {
- this(texID, x, y,32,32,null);
+ this(texID, x, y, 32, 32, null);
}
+
GT_GuiIcon(int texID, int x, int y, int width, int height) {
- this(texID, x, y, width, height,null);
+ this(texID, x, y, width, height, null);
}
- public static void render(IGuiIcon icon, double x, double y, double width, double height, double zLevel,
- boolean doDraw) {
+
+ public static void render(
+ IGuiIcon icon, double x, double y, double width, double height, double zLevel, boolean doDraw) {
render(icon, x, y, width, height, zLevel, doDraw, false);
}
- public static void render(IGuiIcon icon, double x, double y, double width, double height, double zLevel,
- boolean doDraw, boolean flipHoritontally) {
+ public static void render(
+ IGuiIcon icon,
+ double x,
+ double y,
+ double width,
+ double height,
+ double zLevel,
+ boolean doDraw,
+ boolean flipHoritontally) {
Tessellator tess = Tessellator.instance;
if (doDraw) {
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURES[icon.getTexId()]);
tess.startDrawingQuads();
}
double minU = (double) (icon.getX() + (flipHoritontally ? icon.getWidth() : 0)) / T_SIZE;
- double maxU = (double) (icon.getX() + (flipHoritontally ? 0: icon.getWidth())) / T_SIZE;
+ double maxU = (double) (icon.getX() + (flipHoritontally ? 0 : icon.getWidth())) / T_SIZE;
double minV = (double) icon.getY() / T_SIZE;
double maxV = (double) (icon.getY() + icon.getHeight()) / T_SIZE;
tess.addVertexWithUV(x, y + height, zLevel, minU, maxV);
@@ -98,11 +105,9 @@ public enum GT_GuiIcon implements IGuiIcon{
tess.addVertexWithUV(x + width, y + 0, zLevel, maxU, minV);
tess.addVertexWithUV(x, y + 0, zLevel, minU, minV);
- if (icon.getOverlay() != null)
- render(icon.getOverlay(), x, y, width, height, zLevel, false);
+ if (icon.getOverlay() != null) render(icon.getOverlay(), x, y, width, height, zLevel, false);
- if (doDraw)
- tess.draw();
+ if (doDraw) tess.draw();
}
/**
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java
index 9de9b03df4..fd9a879902 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java
@@ -1,10 +1,10 @@
package gregtech.api.gui.widgets;
import gregtech.api.interfaces.IGuiScreen;
+import java.awt.Rectangle;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import org.lwjgl.opengl.GL11;
-import java.awt.Rectangle;
public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElement {
public static final int DEFAULT_WIDTH = 16;
@@ -16,7 +16,6 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
private GT_GuiTooltip tooltip;
-
public GT_GuiIconButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon icon) {
super(id, x, y, DEFAULT_WIDTH, DEFAULT_HEIGHT, "");
this.gui = gui;
@@ -28,8 +27,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
@Override
public void onInit() {
- if (tooltip != null)
- gui.addToolTip(tooltip);
+ if (tooltip != null) gui.addToolTip(tooltip);
xPosition = x0 + gui.getGuiLeft();
yPosition = y0 + gui.getGuiTop();
}
@@ -41,12 +39,14 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
- if (this.tooltip != null)
- this.tooltip.enabled = true;
+ if (this.tooltip != null) this.tooltip.enabled = true;
if (this.visible) {
- //moused over
- this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + width && mouseY < this.yPosition + height;
+ // moused over
+ this.field_146123_n = mouseX >= this.xPosition
+ && mouseY >= this.yPosition
+ && mouseX < this.xPosition + width
+ && mouseY < this.yPosition + height;
mouseDragged(mc, mouseX, mouseY);
@@ -56,17 +56,15 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
int x = xPosition;
int y = yPosition;
- if(!this.field_146123_n) {
- // GL11.glColor4f(200F/255F, 210F/255F, 1, 1);
- }
- else
- GL11.glColor4f(1, 1, 1, 1);
+ if (!this.field_146123_n) {
+ // GL11.glColor4f(200F/255F, 210F/255F, 1, 1);
+ } else GL11.glColor4f(1, 1, 1, 1);
GT_GuiIcon.render(getButtonTexture(this.field_146123_n), x, y, width, height, 0, true);
GL11.glColor4f(1, 1, 1, 1);
if (icon != null) {
- GT_GuiIcon.render(icon, x, y, width, height , 0, true);
+ GT_GuiIcon.render(icon, x, y, width, height, 0, true);
}
GL11.glPopAttrib();
@@ -76,13 +74,11 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
@Override
public void mouseReleased(int mouseX, int mouseY) {
this.gui.clearSelectedButton();
- if(mousePressed(Minecraft.getMinecraft(), mouseX, mouseY))
- this.gui.buttonClicked(this);
+ if (mousePressed(Minecraft.getMinecraft(), mouseX, mouseY)) this.gui.buttonClicked(this);
}
public GT_GuiIcon getButtonTexture(boolean mouseOver) {
- if (!enabled)
- return GT_GuiIcon.BUTTON_DISABLED;
+ if (!enabled) return GT_GuiIcon.BUTTON_DISABLED;
if (this.equals(this.gui.getSelectedButton()))
return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN;
@@ -92,6 +88,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
public GT_GuiIcon getIcon() {
return icon;
}
+
public GT_GuiIconButton setIcon(GT_GuiIcon icon) {
this.icon = icon;
return this;
@@ -102,10 +99,8 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen
}
public GT_GuiIconButton setTooltipText(String... text) {
- if (tooltip == null)
- tooltip = new GT_GuiTooltip(getBounds(), text);
- else
- tooltip.setToolTipText(text);
+ if (tooltip == null) tooltip = new GT_GuiTooltip(getBounds(), text);
+ else tooltip.setToolTipText(text);
return this;
}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java
index e7b6b9971d..113b19711b 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java
@@ -13,7 +13,15 @@ public class GT_GuiIconCheckButton extends GT_GuiIconButton {
this(gui, id, x, y, checkedIcon, normalIcon, null, null);
}
- public GT_GuiIconCheckButton(IGuiScreen gui, int id, int x, int y, GT_GuiIcon checkedIcon, GT_GuiIcon normalIcon, String checkedTooltip, String normalTooltip) {
+ public GT_GuiIconCheckButton(
+ IGuiScreen gui,
+ int id,
+ int x,
+ int y,
+ GT_GuiIcon checkedIcon,
+ GT_GuiIcon normalIcon,
+ String checkedTooltip,
+ String normalTooltip) {
super(gui, id, x, y, normalIcon);
this.checkedIcon = checkedIcon;
this.normalIcon = normalIcon;
@@ -23,8 +31,7 @@ public class GT_GuiIconCheckButton extends GT_GuiIconButton {
@Override
public GT_GuiIcon getButtonTexture(boolean mouseOver) {
- if (!enabled)
- return GT_GuiIcon.BUTTON_DISABLED;
+ if (!enabled) return GT_GuiIcon.BUTTON_DISABLED;
if (this.equals(super.gui.getSelectedButton()))
return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT_DOWN : GT_GuiIcon.BUTTON_DOWN;
return mouseOver ? GT_GuiIcon.BUTTON_HIGHLIGHT : GT_GuiIcon.BUTTON_NORMAL;
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java
index e2ba53e4c9..3e2ac1e296 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java
@@ -1,11 +1,10 @@
package gregtech.api.gui.widgets;
import gregtech.api.interfaces.IGuiScreen;
+import java.awt.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiTextField;
-import java.awt.*;
-
public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGuiElement {
private final int x0, y0;
private final IGuiScreen gui;
@@ -44,7 +43,17 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu
@Override
public boolean textboxKeyTyped(char c, int key) {
- if (validChar(c, key) || c == 1 || c == 3 || c == 22 || c == 24 || key == 14 || key == 199 || key == 203 || key == 205 || key == 207 || key == 211) {
+ if (validChar(c, key)
+ || c == 1
+ || c == 3
+ || c == 22
+ || c == 24
+ || key == 14
+ || key == 199
+ || key == 203
+ || key == 205
+ || key == 207
+ || key == 211) {
return super.textboxKeyTyped(c, key);
}
return false;
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java
index 1fb25ecb1a..105e919149 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java
@@ -1,8 +1,7 @@
package gregtech.api.gui.widgets;
-import java.awt.Rectangle;
-
import gregtech.api.util.GT_TooltipDataCache.TooltipData;
+import java.awt.Rectangle;
import net.minecraft.inventory.Slot;
public class GT_GuiSlotTooltip extends GT_GuiTooltip {
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java
index d4f7df6d2c..2bb28fb929 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java
@@ -1,13 +1,13 @@
package gregtech.api.gui.widgets;
+import gregtech.api.util.GT_TooltipDataCache.TooltipData;
import java.awt.Rectangle;
-import gregtech.api.util.GT_TooltipDataCache.TooltipData;
+public class GT_GuiSmartTooltip extends GT_GuiTooltip {
+ public interface TooltipVisibilityProvider {
+ boolean shouldShowTooltip();
+ }
-public class GT_GuiSmartTooltip extends GT_GuiTooltip{
- public interface TooltipVisibilityProvider {
- boolean shouldShowTooltip();
- }
private final TooltipVisibilityProvider visibilityProvider;
public GT_GuiSmartTooltip(Rectangle bounds, TooltipVisibilityProvider visibilityProvider, TooltipData data) {
@@ -21,5 +21,4 @@ public class GT_GuiSmartTooltip extends GT_GuiTooltip{
// If disabled by super, stay disabled.
this.enabled = this.enabled && this.visibilityProvider.shouldShowTooltip();
}
-
}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java
index 60672db880..1bb2f6dbb7 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java
@@ -1,16 +1,14 @@
package gregtech.api.gui.widgets;
-import java.awt.Rectangle;
-
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL12;
-
import gregtech.api.gui.widgets.GT_GuiTabLine.GT_GuiTabIconSet;
import gregtech.api.gui.widgets.GT_GuiTabLine.GT_ITabRenderer;
import gregtech.api.interfaces.IGuiIcon;
+import java.awt.Rectangle;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
/**
* A tab to be attached to a tab line
@@ -18,10 +16,7 @@ import net.minecraft.item.ItemStack;
public class GT_GuiTab {
private static final int SLOT_SIZE = 18;
- public boolean
- visible = true,
- mousedOver,
- enabled = true;
+ public boolean visible = true, mousedOver, enabled = true;
private Rectangle bounds;
private GT_GuiTabIconSet tabBackground;
@@ -33,7 +28,7 @@ public class GT_GuiTab {
/**
* A tab to be attached to a tab line
- *
+ *
* @param gui IGregTechTileEntity the tab line this tab belongs to is attached to
* @param id both the ID and position in the tab line of this tab
* @param bounds bounds of this tab
@@ -43,8 +38,15 @@ public class GT_GuiTab {
* @param tooltipText tooltip of this tab
* @param flipHorizontally whether to draw this tab on the right side of the IGregTechTileEntity
*/
- public GT_GuiTab( GT_ITabRenderer gui, int id, Rectangle bounds, GT_GuiTabIconSet tabBackground, ItemStack item,
- IGuiIcon overlay, String[] tooltipText, boolean flipHorizontally) {
+ public GT_GuiTab(
+ GT_ITabRenderer gui,
+ int id,
+ Rectangle bounds,
+ GT_GuiTabIconSet tabBackground,
+ ItemStack item,
+ IGuiIcon overlay,
+ String[] tooltipText,
+ boolean flipHorizontally) {
this.gui = gui;
this.bounds = bounds;
this.item = item;
@@ -56,13 +58,13 @@ public class GT_GuiTab {
this.flipHorizontally = flipHorizontally;
}
- public GT_GuiTab( GT_ITabRenderer gui, int id, Rectangle bounds, GT_GuiTabIconSet tabBackground) {
+ public GT_GuiTab(GT_ITabRenderer gui, int id, Rectangle bounds, GT_GuiTabIconSet tabBackground) {
this(gui, id, bounds, tabBackground, null, null, null, false);
}
/**
* Set this tab's tooltip text
- *
+ *
* @param text
* @return This tab for chaining
*/
@@ -70,8 +72,7 @@ public class GT_GuiTab {
if (tooltip == null) {
tooltip = new GT_GuiTooltip(bounds, text);
gui.addToolTip(tooltip);
- }
- else {
+ } else {
tooltip.setToolTipText(text);
}
return this;
@@ -86,21 +87,28 @@ public class GT_GuiTab {
/**
* Draw the background texture for this tab
- *
+ *
* @param mouseX
* @param mouseY
* @param parTicks
*/
public void drawBackground(int mouseX, int mouseY, float parTicks) {
if (this.visible) {
- GT_GuiIcon.render(getBackgroundTexture(), bounds.x, bounds.y, bounds.width, bounds.height, 1, true,
- this.flipHorizontally);
+ GT_GuiIcon.render(
+ getBackgroundTexture(),
+ bounds.x,
+ bounds.y,
+ bounds.width,
+ bounds.height,
+ 1,
+ true,
+ this.flipHorizontally);
}
}
/**
* Draw overlay textures and items atop the background texture
- *
+ *
* @param mouseX
* @param mouseY
* @param parTicks
@@ -119,19 +127,22 @@ public class GT_GuiTab {
}
if (item != null) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
-
+
if (item.getItem() instanceof ItemBlock) {
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
}
int margin = (bounds.height - SLOT_SIZE);
- gui.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer(),
- Minecraft.getMinecraft().getTextureManager(), item,
- bounds.x + (this.flipHorizontally ? 0 : margin), bounds.y + margin);
-
- if (item.getItem() instanceof ItemBlock)
- GL11.glPopAttrib();
-
+ gui.getItemRenderer()
+ .renderItemAndEffectIntoGUI(
+ gui.getFontRenderer(),
+ Minecraft.getMinecraft().getTextureManager(),
+ item,
+ bounds.x + (this.flipHorizontally ? 0 : margin),
+ bounds.y + margin);
+
+ if (item.getItem() instanceof ItemBlock) GL11.glPopAttrib();
+
GL11.glPopAttrib();
}
}
@@ -141,8 +152,7 @@ public class GT_GuiTab {
* @return the texture this tab should currently use as it's background
*/
protected IGuiIcon getBackgroundTexture() {
- if (!enabled)
- return tabBackground.disabled;
+ if (!enabled) return tabBackground.disabled;
return mousedOver ? tabBackground.highlight : tabBackground.normal;
}
@@ -156,11 +166,11 @@ public class GT_GuiTab {
/**
* Reposition this tab on the screen
- *
+ *
* @param xPos
* @param yPos
*/
public void setPosition(int xPos, int yPos) {
- this.bounds = new Rectangle( xPos, yPos, bounds.width, bounds.height);
+ this.bounds = new Rectangle(xPos, yPos, bounds.width, bounds.height);
}
}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java
index e7ac596dee..ff0ccc2ac1 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java
@@ -1,13 +1,11 @@
package gregtech.api.gui.widgets;
-import java.awt.Rectangle;
-
-import org.lwjgl.opengl.GL11;
-
import gregtech.api.interfaces.IGuiIcon;
+import java.awt.Rectangle;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
+import org.lwjgl.opengl.GL11;
/**
* Draws clickable and configurable tabs on the left or right side of another GUI
@@ -20,11 +18,11 @@ public class GT_GuiTabLine {
public IGuiIcon disabled;
public IGuiIcon normal;
public IGuiIcon highlight;
-
+
public GT_GuiTabIconSet(IGuiIcon normalIcon, IGuiIcon highlightIcon, IGuiIcon disabledIcon) {
- this. normal = normalIcon;
- this. highlight = highlightIcon;
- this. disabled = disabledIcon;
+ this.normal = normalIcon;
+ this.highlight = highlightIcon;
+ this.disabled = disabledIcon;
}
}
@@ -32,11 +30,12 @@ public class GT_GuiTabLine {
* Controls the rendering style of the tab line
*/
public static enum DisplayStyle {
- NONE((byte)0),
- NORMAL((byte)1),
- INVERSE((byte)-1);
+ NONE((byte) 0),
+ NORMAL((byte) 1),
+ INVERSE((byte) -1);
private byte value;
+
DisplayStyle(byte value) {
this.value = value;
}
@@ -52,43 +51,37 @@ public class GT_GuiTabLine {
*/
public interface GT_ITabRenderer {
int getGuiLeft();
+
int getGuiTop();
+
int getXSize();
RenderItem getItemRenderer();
+
FontRenderer getFontRenderer();
- void addToolTip(GT_GuiTooltip tooltip);
+ void addToolTip(GT_GuiTooltip tooltip);
+
boolean removeToolTip(GT_GuiTooltip tooltip);
}
// The tabs are arranged according to their index in this array
protected final GT_GuiTab[] mTabs;
- private int
- tabLineLeft,
- tabLineTop,
- tabHeight,
- tabWidth,
- tabSpacing;
-
+ private int tabLineLeft, tabLineTop, tabHeight, tabWidth, tabSpacing;
+
// In which direction to draw the tab line
- private DisplayStyle
- xDir,
- yDir;
+ private DisplayStyle xDir, yDir;
// Whether to display on the right side of the GT_ITabRenderer instead of left
- protected boolean
- flipHorizontally,
- visible;
+ protected boolean flipHorizontally, visible;
private GT_GuiTabIconSet tabBackground;
private GT_ITabRenderer gui;
-
/**
* Draws clickable and configurable tabs on the left or right side of a GT_ITabRenderer
- *
+ *
* @param gui GT_ITabRenderer gui which this tab line attaches to
* @param numTabs number of tab positions in this tab line
* @param tabLineLeft left position of the tab line in relation to the gui
@@ -104,8 +97,18 @@ public class GT_GuiTabLine {
* (NORMAL), on it's right side (INVERSE) or not at all (NONE)
* @param tabBackground the set of textures used to draw this tab line's tab backgrounds
*/
- public GT_GuiTabLine(GT_ITabRenderer gui, int numTabs, int tabLineLeft, int tabLineTop, int tabHeight, int tabWidth,
- int tabSpacing, DisplayStyle xDir, DisplayStyle yDir, DisplayStyle displayMode, GT_GuiTabIconSet tabBackground) {
+ public GT_GuiTabLine(
+ GT_ITabRenderer gui,
+ int numTabs,
+ int tabLineLeft,
+ int tabLineTop,
+ int tabHeight,
+ int tabWidth,
+ int tabSpacing,
+ DisplayStyle xDir,
+ DisplayStyle yDir,
+ DisplayStyle displayMode,
+ GT_GuiTabIconSet tabBackground) {
this.gui = gui;
this.mTabs = new GT_GuiTab[numTabs];
this.tabLineLeft = tabLineLeft;
@@ -123,34 +126,37 @@ public class GT_GuiTabLine {
/**
* Creates a new tab at the specified position with the given parameters.
* This class handles the positioning.
- *
+ *
* @param tabId
* @param item
* @param overlay
* @param text
*/
public void setTab(int tabId, ItemStack item, IGuiIcon overlay, String[] text) {
- mTabs[tabId] = new GT_GuiTab( this.gui, tabId, getBoundsForTab(tabId),
- this.tabBackground, item, overlay, text, this.flipHorizontally);
+ mTabs[tabId] = new GT_GuiTab(
+ this.gui,
+ tabId,
+ getBoundsForTab(tabId),
+ this.tabBackground,
+ item,
+ overlay,
+ text,
+ this.flipHorizontally);
}
/**
* Get the bounds a given tab should occupy
- *
+ *
* @param tabId
* @return
*/
protected Rectangle getBoundsForTab(int tabId) {
- return new Rectangle (
- getTabX(tabId),
- getTabY(tabId),
- this.tabWidth,
- this.tabHeight);
+ return new Rectangle(getTabX(tabId), getTabY(tabId), this.tabWidth, this.tabHeight);
}
/**
* Enable or disable a tab. Disabled tabs have a dark background.
- *
+ *
* @param tabId
* @param value
*/
@@ -159,13 +165,12 @@ public class GT_GuiTabLine {
mTabs[tabId].enabled = value;
}
}
-
/**
* Draw the tabs for this tab bar
* GT_ITabRenderer must call this method on drawGuiContainerBackgroundLayer
* or on drawScreen.
- *
+ *
* @param parTicks
* @param mouseX
* @param mouseY
@@ -183,7 +188,7 @@ public class GT_GuiTabLine {
/**
* Draw the tab's backgrounds first
- *
+ *
* @param parTicks
* @param mouseX
* @param mouseY
@@ -198,7 +203,7 @@ public class GT_GuiTabLine {
/**
* Draw anything that overlays the tab's background texture
- *
+ *
* @param parTicks
* @param mouseX
* @param mouseY
@@ -214,13 +219,13 @@ public class GT_GuiTabLine {
/**
* Call tabClick for every tab that was clicked.
* GT_ITabRenderer must call this method on mouseClicked.
- *
+ *
* @param mouseX
* @param mouseY
* @param mouseButton
*/
public void onMouseClicked(int mouseX, int mouseY, int mouseButton) {
- for(int tabId = 0; tabId < mTabs.length; tabId++) {
+ for (int tabId = 0; tabId < mTabs.length; tabId++) {
if (mTabs[tabId] != null && mTabs[tabId].getBounds().contains(mouseX, mouseY)) {
tabClicked(tabId, mouseButton);
return;
@@ -230,11 +235,11 @@ public class GT_GuiTabLine {
/**
* Act on a tab being clicked.
- *
+ *
* @param tabId
* @param mouseButton
*/
- protected void tabClicked(int tabId, int mouseButton) { }
+ protected void tabClicked(int tabId, int mouseButton) {}
/**
* Reposition ourselves whenever the GT_ITabRenderer does so.
@@ -250,18 +255,19 @@ public class GT_GuiTabLine {
/**
* Get the proper X position for a given tab
- *
+ *
* @param tabId
* @return
*/
private int getTabX(int tabId) {
- return this.gui.getGuiLeft() + (flipHorizontally ? (gui.getXSize() - tabLineLeft - tabWidth) : tabLineLeft)
- + (tabId * (tabWidth + tabSpacing) * xDir.getValue());
+ return this.gui.getGuiLeft()
+ + (flipHorizontally ? (gui.getXSize() - tabLineLeft - tabWidth) : tabLineLeft)
+ + (tabId * (tabWidth + tabSpacing) * xDir.getValue());
}
/**
* Get the proper Y position for a given tab
- *
+ *
* @param tabId
* @return
*/
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java
index 21648b74fe..ab755eb2c3 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java
@@ -1,15 +1,13 @@
package gregtech.api.gui.widgets;
+import gregtech.api.util.GT_TooltipDataCache.TooltipData;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Objects;
-
import org.lwjgl.input.Keyboard;
-import gregtech.api.util.GT_TooltipDataCache.TooltipData;
public class GT_GuiTooltip {
protected Rectangle bounds;
@@ -20,7 +18,7 @@ public class GT_GuiTooltip {
/**
* Used to create a tooltip that will appear over the specified bounds.
* This will initially be a "static" tooltip that doesn't respect verbosity levels or respond to the shift key.
- *
+ *
* @param bounds
* @param text
*/
@@ -32,7 +30,7 @@ public class GT_GuiTooltip {
/**
* Used to create a tooltip that will appear over the specified bounds.
* This will initially be a "dynamic" tooltip that respects verbosity levels and responds to the shift key.
- *
+ *
* @param bounds
* @param data
*/
@@ -43,10 +41,10 @@ public class GT_GuiTooltip {
}
private TooltipData sanitizeTooltipData(TooltipData data) {
- if (data.text == null){
+ if (data.text == null) {
data.text = Arrays.asList(new String[0]);
}
- if (data.shiftText == null){
+ if (data.shiftText == null) {
data.shiftText = Arrays.asList(new String[0]);
}
return data;
@@ -65,12 +63,11 @@ public class GT_GuiTooltip {
/**
* Called once this tooltip has been determined to be enabled
*/
- protected void updateText() {
- }
+ protected void updateText() {}
/**
* Used to set a "static" tooltip that doesn't respect verbosity levels or respond to the shift key
- *
+ *
* @param text
*/
public void setToolTipText(String... text) {
@@ -80,17 +77,17 @@ public class GT_GuiTooltip {
/**
* Used to set a "dynamic" tooltip that respects verbosity levels and responds to the shift key
- *
+ *
* @param data
*/
public void setToolTipText(TooltipData data) {
// Trust that the tooltips have already been formatted and colored, just make sure it has no nulls
this.data = sanitizeTooltipData(data);
}
-
+
/**
* Apply tooltip colors in case the text doesn't contain them and return as tooltip data
- *
+ *
* @param text
* @return colored tooltip lines as list
*/
@@ -100,18 +97,15 @@ public class GT_GuiTooltip {
list = new ArrayList<>(text.length);
for (int i = 0; i < text.length; i++) {
if (text[i] == null) continue;
- if (list.isEmpty())
- list.add("\u00a7f" + text[i]);
- else
- list.add("\u00a77" + text[i]);
+ if (list.isEmpty()) list.add("\u00a7f" + text[i]);
+ else list.add("\u00a77" + text[i]);
}
} else {
list = Collections.emptyList();
}
- return new TooltipData(list, list) ;
+ return new TooltipData(list, list);
}
-
public List<String> getToolTipText() {
return this.displayedText;
}
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java
index abee1774f9..1c31670071 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java
@@ -1,16 +1,19 @@
package gregtech.api.gui.widgets;
-import net.minecraft.client.gui.FontRenderer;
-
import java.util.ArrayList;
import java.util.List;
+import net.minecraft.client.gui.FontRenderer;
public class GT_GuiTooltipManager {
public interface GT_IToolTipRenderer {
int getGuiLeft();
+
int getGuiTop();
+
int getXSize();
+
FontRenderer getFontRenderer();
+
void drawHoveringText(List<String> text, int mouseX, int mouseY, FontRenderer font);
}
@@ -29,8 +32,8 @@ public class GT_GuiTooltipManager {
}
public final void onTick(GT_IToolTipRenderer render, int mouseX, int mouseY) {
- if ((Math.abs(mouseX-lastMouseX) < 2 ) && (Math.abs(mouseY-lastMouseY) < 2 )) {
- mouseStopped = Math.min(mouseStopped+1, 50);
+ if ((Math.abs(mouseX - lastMouseX) < 2) && (Math.abs(mouseY - lastMouseY) < 2)) {
+ mouseStopped = Math.min(mouseStopped + 1, 50);
} else {
mouseStopped = 0;
}
@@ -43,7 +46,9 @@ public class GT_GuiTooltipManager {
for (GT_GuiTooltip tip : tips) {
// Give the tooltip the opportunity to decide whether they should be enabled
tip.onTick();
- if (tip.enabled && (!tip.isDelayed() || mouseStopped > DELAY) && tip.getBounds().contains(mouseX, mouseY)) {
+ if (tip.enabled
+ && (!tip.isDelayed() || mouseStopped > DELAY)
+ && tip.getBounds().contains(mouseX, mouseY)) {
tip.updateText();
drawTooltip(tip, mouseX, mouseY, render);
break;
@@ -53,10 +58,9 @@ public class GT_GuiTooltipManager {
private void drawTooltip(GT_GuiTooltip tip, int mouseX, int mouseY, GT_IToolTipRenderer render) {
List<String> text = tip.getToolTipText();
- if (text == null)
- return;
+ if (text == null) return;
- if (mouseX > render.getGuiLeft() + render.getXSize()/2) {
+ if (mouseX > render.getGuiLeft() + render.getXSize() / 2) {
int maxWidth = 0;
for (String s : text) {
int w = render.getFontRenderer().getStringWidth(s);
@@ -69,5 +73,4 @@ public class GT_GuiTooltipManager {
render.drawHoveringText(text, mouseX, mouseY, render.getFontRenderer());
}
-
}