diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-01-30 10:56:42 -0800 |
---|---|---|
committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-30 10:56:42 -0800 |
commit | 0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a (patch) | |
tree | 1e2c649f3a6ce3f6b2babd0098a5f4819e9cd0b6 /src/main/java/gregtech/api/gui/widgets | |
parent | f8cc82edeb9810c45cba762d733a2c909a302faa (diff) | |
download | GT5-Unofficial-0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a.tar.gz GT5-Unofficial-0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a.tar.bz2 GT5-Unofficial-0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a.zip |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/gregtech/api/gui/widgets')
12 files changed, 167 insertions, 182 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 d5e383ed50..639b402856 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java @@ -1,34 +1,33 @@ package gregtech.api.gui.widgets; -import codechicken.nei.api.API; -import codechicken.nei.api.INEIGuiAdapter; -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; +import codechicken.nei.api.API; +import codechicken.nei.api.INEIGuiAdapter; +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; + /** * 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 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" - }; + 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" }; // Not sure there's a point in JIT translation but that's what this is private String[] translatedSides; @@ -38,35 +37,24 @@ 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 - * @param tabHeight height of a tab - * @param tabWidth width of a tab - * @param tabSpacing pixels between each tab - * @param xDir whether to extend the line horizontally to the right (NORMAL), - * the left (INVERSE) or not at all (NONE) - * @param yDir whether to extend the line vertically down (NORMAL), up (INVERSE) - * or not at all (NONE) - * @param displayMode whether to display on the left side of the GT_ITabRenderer - * (NORMAL), on it's right side (INVERSE) or not at all (NONE) + * @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 + * @param tabHeight height of a tab + * @param tabWidth width of a tab + * @param tabSpacing pixels between each tab + * @param xDir whether to extend the line horizontally to the right (NORMAL), the left (INVERSE) or not at + * all (NONE) + * @param yDir whether to extend the line vertically down (NORMAL), up (INVERSE) or not at all (NONE) + * @param displayMode whether to display on the left side of the GT_ITabRenderer (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 - * @param tile The IGregTechTileEntity the covers of which we are accessing - * @param colorization The colorization of the GUI we are adding tabs to + * @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; @@ -89,27 +77,31 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { @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); } @Override 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)); + 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)); } } /** * Add the cover on this side of the IGregTechTileEntity to the tabs + * * @param side * @param cover */ @@ -121,6 +113,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { /** * Decorate the cover's tooltips according to the side it's on and on whether the tab is enabled or not + * * @param side * @param cover * @param enabled @@ -130,8 +123,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { final List<String> tooltip = cover.getTooltip(Minecraft.getMinecraft().thePlayer, true); tooltip.set( 0, - (enabled ? EnumChatFormatting.UNDERLINE : EnumChatFormatting.DARK_GRAY) - + getSideDescription(side) + (enabled ? EnumChatFormatting.UNDERLINE : EnumChatFormatting.DARK_GRAY) + getSideDescription(side) + (enabled ? EnumChatFormatting.RESET + ": " : ": " + EnumChatFormatting.RESET) + tooltip.get(0)); return tooltip.toArray(new String[0]); @@ -139,6 +131,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { /** * Get the translated name for a side of the IGregTechTileEntity + * * @param side * @return translated name for a side of the IGregTechTileEntity */ @@ -156,6 +149,7 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine { * Hide any NEI slots that would intersect with a cover tab */ static class CoverTabLineNEIHandler extends INEIGuiAdapter { + @Override public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) { final Rectangle neiSlotArea = new Rectangle(x, y, w, h); 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 7a57c49515..bfeb84d762 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java @@ -1,16 +1,19 @@ 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 codechicken.lib.gui.GuiDraw; +import gregtech.api.interfaces.IGuiScreen; +import gregtech.api.util.GT_UtilityClient; + public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement { private GT_GuiIcon bgIcon; @@ -19,6 +22,7 @@ public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement { private int xPosition, yPosition; private List<String> itemTooltips; private final GT_GuiTooltip tooltip = new GT_GuiTooltip(null) { + @Override public List<String> getToolTipText() { return itemTooltips; @@ -112,26 +116,24 @@ 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); + gui.getItemRenderer().renderItemAndEffectIntoGUI( + gui.getFontRenderer(), + Minecraft.getMinecraft().getTextureManager(), + item, + xPosition, + yPosition); if (item.getItem() instanceof ItemBlock) GL11.glPopAttrib(); } - if (getMimicSlot()) - if (getBounds().contains(mouseX - gui.getGuiLeft(), mouseY - gui.getGuiTop())) { - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glColorMask(true, true, true, false); - GuiDraw.drawGradientRect(xPosition, yPosition, 16, 16, 0x80ffffff, 0x80ffffff); - GL11.glColorMask(true, true, true, true); - // no glEnable, state will be recovered by glPopAttrib - } + if (getMimicSlot()) if (getBounds().contains(mouseX - gui.getGuiLeft(), mouseY - gui.getGuiTop())) { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glColorMask(true, true, true, false); + GuiDraw.drawGradientRect(xPosition, yPosition, 16, 16, 0x80ffffff, 0x80ffffff); + GL11.glColorMask(true, true, true, true); + // no glEnable, state will be recovered by glPopAttrib + } GL11.glPopAttrib(); } 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 43fbe0711c..01c8671678 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java @@ -1,12 +1,15 @@ package gregtech.api.gui.widgets; -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; +import gregtech.api.interfaces.IGuiIcon; + public enum GT_GuiIcon implements IGuiIcon { + BUTTON_NORMAL(0, 0, 0), BUTTON_DOWN(0, 32, 0), BUTTON_HIGHLIGHT(0, 32 * 2, 0), @@ -52,15 +55,12 @@ public enum GT_GuiIcon implements IGuiIcon { 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), - ; + 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"), - }; + 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"), }; public final int x, y, width, height; public final IGuiIcon overlay; @@ -83,20 +83,13 @@ public enum GT_GuiIcon implements IGuiIcon { 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()]); 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 fd9a879902..01bbccc599 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java @@ -1,12 +1,16 @@ 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 gregtech.api.interfaces.IGuiScreen; + public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElement { + public static final int DEFAULT_WIDTH = 16; public static final int DEFAULT_HEIGHT = 16; @@ -43,8 +47,7 @@ public class GT_GuiIconButton extends GuiButton implements IGuiScreen.IGuiElemen if (this.visible) { // moused over - this.field_146123_n = mouseX >= this.xPosition - && mouseY >= this.yPosition + this.field_146123_n = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + width && mouseY < this.yPosition + height; @@ -57,7 +60,7 @@ 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); + // 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); 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 113b19711b..636ff0bc26 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java @@ -3,6 +3,7 @@ package gregtech.api.gui.widgets; import gregtech.api.interfaces.IGuiScreen; public class GT_GuiIconCheckButton extends GT_GuiIconButton { + private final GT_GuiIcon checkedIcon; private final GT_GuiIcon normalIcon; private final String checkedTooltip; @@ -13,15 +14,8 @@ 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; 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 3e2ac1e296..b2430f7b76 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,14 @@ 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 gregtech.api.interfaces.IGuiScreen; + public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGuiElement { + private final int x0, y0; private final IGuiScreen gui; public final int id; @@ -43,8 +46,7 @@ public class GT_GuiIntegerTextBox extends GuiTextField implements IGuiScreen.IGu @Override public boolean textboxKeyTyped(char c, int key) { - if (validChar(c, key) - || c == 1 + if (validChar(c, key) || c == 1 || c == 3 || c == 22 || c == 24 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 105e919149..015c8c7697 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java @@ -1,10 +1,13 @@ package gregtech.api.gui.widgets; -import gregtech.api.util.GT_TooltipDataCache.TooltipData; import java.awt.Rectangle; + import net.minecraft.inventory.Slot; +import gregtech.api.util.GT_TooltipDataCache.TooltipData; + public class GT_GuiSlotTooltip extends GT_GuiTooltip { + private final Slot slot; public GT_GuiSlotTooltip(Slot slot, TooltipData data) { 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 2bb28fb929..ffae5c30e6 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java @@ -1,10 +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(); } 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 1bb2f6dbb7..661ed81fce 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java @@ -1,19 +1,23 @@ package gregtech.api.gui.widgets; -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; +import gregtech.api.gui.widgets.GT_GuiTabLine.GT_GuiTabIconSet; +import gregtech.api.gui.widgets.GT_GuiTabLine.GT_ITabRenderer; +import gregtech.api.interfaces.IGuiIcon; + /** * A tab to be attached to a tab line */ public class GT_GuiTab { + private static final int SLOT_SIZE = 18; public boolean visible = true, mousedOver, enabled = true; @@ -29,24 +33,17 @@ 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 - * @param tabBackground set of background textures - * @param item item to draw atop the background texture, not colored - * @param overlay texture to draw atop the background texture, not colored - * @param tooltipText tooltip of this tab + * @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 + * @param tabBackground set of background textures + * @param item item to draw atop the background texture, not colored + * @param overlay texture to draw atop the background texture, not colored + * @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; @@ -133,13 +130,12 @@ public class GT_GuiTab { 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); + 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(); 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 ff0ccc2ac1..cb94a81dfa 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java @@ -1,20 +1,25 @@ package gregtech.api.gui.widgets; -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; +import gregtech.api.interfaces.IGuiIcon; + /** * Draws clickable and configurable tabs on the left or right side of another GUI */ public class GT_GuiTabLine { + /** * Defines a set of textures a tab line can use to render it's tab backgrounds */ public static class GT_GuiTabIconSet { + public IGuiIcon disabled; public IGuiIcon normal; public IGuiIcon highlight; @@ -30,6 +35,7 @@ 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); @@ -46,10 +52,11 @@ public class GT_GuiTabLine { } /** - * A GUI should implement these methods as well as call the tab line's - * onMouseClicked, onInit and drawTabs for the tab line to attach to it properly. + * A GUI should implement these methods as well as call the tab line's onMouseClicked, onInit and drawTabs for the + * tab line to attach to it properly. */ public interface GT_ITabRenderer { + int getGuiLeft(); int getGuiTop(); @@ -82,32 +89,22 @@ public class GT_GuiTabLine { /** * 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 - * @param tabLineTop top position of the tab line in relation to the gui - * @param tabHeight height of a tab - * @param tabWidth width of a tab - * @param tabSpacing pixels between each tab - * @param xDir whether to extend the line horizontally to the right (NORMAL), - * the left (INVERSE) or not at all (NONE) - * @param yDir whether to extend the line vertically down (NORMAL), up (INVERSE) - * or not at all (NONE) - * @param displayMode whether to display on the left side of the GT_ITabRenderer - * (NORMAL), on it's right side (INVERSE) or not at all (NONE) + * @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 + * @param tabLineTop top position of the tab line in relation to the gui + * @param tabHeight height of a tab + * @param tabWidth width of a tab + * @param tabSpacing pixels between each tab + * @param xDir whether to extend the line horizontally to the right (NORMAL), the left (INVERSE) or not at + * all (NONE) + * @param yDir whether to extend the line vertically down (NORMAL), up (INVERSE) or not at all (NONE) + * @param displayMode whether to display on the left side of the GT_ITabRenderer (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, + 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]; @@ -124,8 +121,7 @@ public class GT_GuiTabLine { } /** - * Creates a new tab at the specified position with the given parameters. - * This class handles the positioning. + * Creates a new tab at the specified position with the given parameters. This class handles the positioning. * * @param tabId * @param item @@ -167,9 +163,8 @@ public class GT_GuiTabLine { } /** - * Draw the tabs for this tab bar - * GT_ITabRenderer must call this method on drawGuiContainerBackgroundLayer - * or on drawScreen. + * Draw the tabs for this tab bar GT_ITabRenderer must call this method on drawGuiContainerBackgroundLayer or on + * drawScreen. * * @param parTicks * @param mouseX @@ -217,8 +212,7 @@ public class GT_GuiTabLine { } /** - * Call tabClick for every tab that was clicked. - * GT_ITabRenderer must call this method on mouseClicked. + * Call tabClick for every tab that was clicked. GT_ITabRenderer must call this method on mouseClicked. * * @param mouseX * @param mouseY @@ -242,8 +236,7 @@ public class GT_GuiTabLine { protected void tabClicked(int tabId, int mouseButton) {} /** - * Reposition ourselves whenever the GT_ITabRenderer does so. - * GT_ITabRenderer must call this method on Init. + * Reposition ourselves whenever the GT_ITabRenderer does so. GT_ITabRenderer must call this method on Init. */ public void onInit() { for (int i = 0; i < mTabs.length; i++) { @@ -260,8 +253,7 @@ public class GT_GuiTabLine { * @return */ private int getTabX(int tabId) { - return this.gui.getGuiLeft() - + (flipHorizontally ? (gui.getXSize() - tabLineLeft - tabWidth) : tabLineLeft) + return this.gui.getGuiLeft() + (flipHorizontally ? (gui.getXSize() - tabLineLeft - tabWidth) : tabLineLeft) + (tabId * (tabWidth + tabSpacing) * xDir.getValue()); } 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 ab755eb2c3..1162630d5e 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java @@ -1,13 +1,15 @@ 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 org.lwjgl.input.Keyboard; +import gregtech.api.util.GT_TooltipDataCache.TooltipData; + public class GT_GuiTooltip { protected Rectangle bounds; @@ -16,8 +18,8 @@ public class GT_GuiTooltip { public boolean enabled = true; /** - * 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. + * 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 @@ -28,8 +30,8 @@ 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. + * 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 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 1c31670071..a74f5adda5 100644 --- a/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java @@ -2,10 +2,13 @@ package gregtech.api.gui.widgets; 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(); @@ -46,9 +49,7 @@ 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; |