Class GuiUtils
- java.lang.Object
-
- net.minecraftforge.fml.client.gui.GuiUtils
-
public class GuiUtils extends java.lang.Object
This class provides several methods and constants used by the Config GUI classes.- Author:
- bspkrs
-
-
Field Summary
Fields Modifier and Type Field Description private static ItemStack
cachedTooltipStack
static int[]
colorCodes
static int
DEFAULT_BACKGROUND_COLOR
static int
DEFAULT_BORDER_COLOR_END
static int
DEFAULT_BORDER_COLOR_START
static java.lang.String
INVALID
static java.lang.String
RESET_CHAR
static java.lang.String
UNDO_CHAR
static java.lang.String
VALID
-
Constructor Summary
Constructors Constructor Description GuiUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
Deprecated.static void
drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
Deprecated.static void
drawContinuousTexturedBox(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler.static void
drawContinuousTexturedBox(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler.static void
drawContinuousTexturedBox(MatrixStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler.static void
drawContinuousTexturedBox(MatrixStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler.static void
drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
Deprecated.static void
drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
Deprecated.static void
drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
static void
drawHoveringText(MatrixStack mStack, java.util.List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
Draws a tooltip box on the screen with text in it.static void
drawHoveringText(MatrixStack mStack, java.util.List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
static void
drawHoveringText(ItemStack stack, MatrixStack mStack, java.util.List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
Use this version if calling from somewhere where ItemStack context is available.static void
drawHoveringText(ItemStack stack, MatrixStack mStack, java.util.List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
static void
drawInscribedRect(MatrixStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
static void
drawInscribedRect(MatrixStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
static void
drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel)
Deprecated.static void
drawTexturedModalRect(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, float zLevel)
static int
getColorCode(char c, boolean isLighter)
static void
postItemToolTip()
Must be called fromGuiScreen.renderToolTip
afterGuiScreen.drawHoveringText
is called.static void
preItemToolTip(ItemStack stack)
Must be called fromGuiScreen.renderToolTip
beforeGuiScreen.drawHoveringText
is called.
-
-
-
Field Detail
-
DEFAULT_BACKGROUND_COLOR
public static final int DEFAULT_BACKGROUND_COLOR
- See Also:
- Constant Field Values
-
DEFAULT_BORDER_COLOR_START
public static final int DEFAULT_BORDER_COLOR_START
- See Also:
- Constant Field Values
-
DEFAULT_BORDER_COLOR_END
public static final int DEFAULT_BORDER_COLOR_END
- See Also:
- Constant Field Values
-
UNDO_CHAR
public static final java.lang.String UNDO_CHAR
- See Also:
- Constant Field Values
-
RESET_CHAR
public static final java.lang.String RESET_CHAR
- See Also:
- Constant Field Values
-
VALID
public static final java.lang.String VALID
- See Also:
- Constant Field Values
-
INVALID
public static final java.lang.String INVALID
- See Also:
- Constant Field Values
-
colorCodes
public static int[] colorCodes
-
cachedTooltipStack
@Nonnull private static ItemStack cachedTooltipStack
-
-
Method Detail
-
getColorCode
public static int getColorCode(char c, boolean isLighter)
-
drawContinuousTexturedBox
@Deprecated public static void drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
Deprecated.Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. It is assumed that the desired texture ResourceLocation object has been bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).- Parameters:
x
- x axis offsety
- y axis offsetu
- bound resource location image x offsetv
- bound resource location image y offsetwidth
- the desired box widthheight
- the desired box heighttextureWidth
- the width of the box texture in the resource location imagetextureHeight
- the height of the box texture in the resource location imageborderSize
- the size of the box's borderszLevel
- the zLevel to draw at
-
drawContinuousTexturedBox
@Deprecated public static void drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
Deprecated.Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. The provided ResourceLocation object will be bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).- Parameters:
res
- the ResourceLocation object that contains the desired imagex
- x axis offsety
- y axis offsetu
- bound resource location image x offsetv
- bound resource location image y offsetwidth
- the desired box widthheight
- the desired box heighttextureWidth
- the width of the box texture in the resource location imagetextureHeight
- the height of the box texture in the resource location imageborderSize
- the size of the box's borderszLevel
- the zLevel to draw at
-
drawContinuousTexturedBox
@Deprecated public static void drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
Deprecated.Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. The provided ResourceLocation object will be bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).- Parameters:
res
- the ResourceLocation object that contains the desired imagex
- x axis offsety
- y axis offsetu
- bound resource location image x offsetv
- bound resource location image y offsetwidth
- the desired box widthheight
- the desired box heighttextureWidth
- the width of the box texture in the resource location imagetextureHeight
- the height of the box texture in the resource location imagetopBorder
- the size of the box's top borderbottomBorder
- the size of the box's bottom borderleftBorder
- the size of the box's left borderrightBorder
- the size of the box's right borderzLevel
- the zLevel to draw at
-
drawContinuousTexturedBox
@Deprecated public static void drawContinuousTexturedBox(int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
Deprecated.Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. It is assumed that the desired texture ResourceLocation object has been bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).- Parameters:
x
- x axis offsety
- y axis offsetu
- bound resource location image x offsetv
- bound resource location image y offsetwidth
- the desired box widthheight
- the desired box heighttextureWidth
- the width of the box texture in the resource location imagetextureHeight
- the height of the box texture in the resource location imagetopBorder
- the size of the box's top borderbottomBorder
- the size of the box's bottom borderleftBorder
- the size of the box's left borderrightBorder
- the size of the box's right borderzLevel
- the zLevel to draw at
-
drawTexturedModalRect
@Deprecated public static void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel)
Deprecated.
-
drawContinuousTexturedBox
public static void drawContinuousTexturedBox(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. It is assumed that the desired texture ResourceLocation object has been bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).- Parameters:
matrixStack
- the gui matrix stackx
- x axis offsety
- y axis offsetu
- bound resource location image x offsetv
- bound resource location image y offsetwidth
- the desired box widthheight
- the desired box heighttextureWidth
- the width of the box texture in the resource location imagetextureHeight
- the height of the box texture in the resource location imageborderSize
- the size of the box's borderszLevel
- the zLevel to draw at
-
drawContinuousTexturedBox
public static void drawContinuousTexturedBox(MatrixStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int borderSize, float zLevel)
Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. The provided ResourceLocation object will be bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).- Parameters:
matrixStack
- the gui matrix stackres
- the ResourceLocation object that contains the desired imagex
- x axis offsety
- y axis offsetu
- bound resource location image x offsetv
- bound resource location image y offsetwidth
- the desired box widthheight
- the desired box heighttextureWidth
- the width of the box texture in the resource location imagetextureHeight
- the height of the box texture in the resource location imageborderSize
- the size of the box's borderszLevel
- the zLevel to draw at
-
drawContinuousTexturedBox
public static void drawContinuousTexturedBox(MatrixStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. The provided ResourceLocation object will be bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).- Parameters:
matrixStack
- the gui matrix stackres
- the ResourceLocation object that contains the desired imagex
- x axis offsety
- y axis offsetu
- bound resource location image x offsetv
- bound resource location image y offsetwidth
- the desired box widthheight
- the desired box heighttextureWidth
- the width of the box texture in the resource location imagetextureHeight
- the height of the box texture in the resource location imagetopBorder
- the size of the box's top borderbottomBorder
- the size of the box's bottom borderleftBorder
- the size of the box's left borderrightBorder
- the size of the box's right borderzLevel
- the zLevel to draw at
-
drawContinuousTexturedBox
public static void drawContinuousTexturedBox(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight, int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
Draws a textured box of any size (smallest size is borderSize * 2 square) based on a fixed size textured box with continuous borders and filler. It is assumed that the desired texture ResourceLocation object has been bound using Minecraft.getMinecraft().getTextureManager().bindTexture(resourceLocation).- Parameters:
matrixStack
- the gui matrix stackx
- x axis offsety
- y axis offsetu
- bound resource location image x offsetv
- bound resource location image y offsetwidth
- the desired box widthheight
- the desired box heighttextureWidth
- the width of the box texture in the resource location imagetextureHeight
- the height of the box texture in the resource location imagetopBorder
- the size of the box's top borderbottomBorder
- the size of the box's bottom borderleftBorder
- the size of the box's left borderrightBorder
- the size of the box's right borderzLevel
- the zLevel to draw at
-
drawTexturedModalRect
public static void drawTexturedModalRect(MatrixStack matrixStack, int x, int y, int u, int v, int width, int height, float zLevel)
-
preItemToolTip
public static void preItemToolTip(@Nonnull ItemStack stack)
Must be called fromGuiScreen.renderToolTip
beforeGuiScreen.drawHoveringText
is called.- Parameters:
stack
- The stack for which a tooltip is about to be drawn.
-
postItemToolTip
public static void postItemToolTip()
Must be called fromGuiScreen.renderToolTip
afterGuiScreen.drawHoveringText
is called.
-
drawHoveringText
public static void drawHoveringText(MatrixStack mStack, java.util.List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
-
drawHoveringText
public static void drawHoveringText(MatrixStack mStack, java.util.List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
Draws a tooltip box on the screen with text in it. Automatically positions the box relative to the mouse to match Mojang's implementation. Automatically wraps text when there is not enough space on the screen to display the text without wrapping. Can have a maximum width set to avoid creating very wide tooltips.- Parameters:
textLines
- the lines of text to be drawn in a hovering tooltip box.mouseX
- the mouse X positionmouseY
- the mouse Y positionscreenWidth
- the available screen width for the tooltip to drawn inscreenHeight
- the available screen height for the tooltip to drawn inmaxTextWidth
- the maximum width of the text in the tooltip box. Set to a negative number to have no max width.backgroundColor
- The background color of the boxborderColorStart
- The starting color of the box borderborderColorEnd
- The ending color of the box border. The border color will be smoothly interpolated between the start and end values.font
- the font for drawing the text in the tooltip box
-
drawHoveringText
public static void drawHoveringText(@Nonnull ItemStack stack, MatrixStack mStack, java.util.List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
-
drawHoveringText
public static void drawHoveringText(@Nonnull ItemStack stack, MatrixStack mStack, java.util.List<? extends ITextProperties> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, int backgroundColor, int borderColorStart, int borderColorEnd, FontRenderer font)
Use this version if calling from somewhere where ItemStack context is available.
-
drawGradientRect
public static void drawGradientRect(Matrix4f mat, int zLevel, int left, int top, int right, int bottom, int startColor, int endColor)
-
drawInscribedRect
public static void drawInscribedRect(MatrixStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight)
-
drawInscribedRect
public static void drawInscribedRect(MatrixStack mStack, int x, int y, int boundsWidth, int boundsHeight, int rectWidth, int rectHeight, boolean centerX, boolean centerY)
-
-