mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Added a tooltip color event. (#4595)
This commit is contained in:
1 parent
dbf2beb6fa
commit
01f573dbaa
3 files changed
+115
-3
No files matched your search
@@ -241,4 +241,74 @@ public abstract class RenderTooltipEvent extends Event
|
||||
public PostText(@Nonnull ItemStack stack, @Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer fr, int width, int height)
|
||||
{ super(stack, textLines, x, y, fr, width, height); }
|
||||
}
|
||||
|
||||
/**
|
||||
* This event is fired when the colours for the tooltip background are determined.
|
||||
*/
|
||||
public static class Color extends RenderTooltipEvent
|
||||
{
|
||||
private final int originalBackground;
|
||||
private final int originalBorderStart;
|
||||
private final int originalBorderEnd;
|
||||
private int background;
|
||||
private int borderStart;
|
||||
private int borderEnd;
|
||||
|
||||
public Color(@Nonnull ItemStack stack, @Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer fr, int background, int borderStart,
|
||||
int borderEnd)
|
||||
{
|
||||
super(stack, textLines, x, y, fr);
|
||||
this.originalBackground = background;
|
||||
this.originalBorderStart = borderStart;
|
||||
this.originalBorderEnd = borderEnd;
|
||||
this.background = background;
|
||||
this.borderStart = borderStart;
|
||||
this.borderEnd = borderEnd;
|
||||
}
|
||||
|
||||
public int getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
public void setBackground(int background)
|
||||
{
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
public int getBorderStart()
|
||||
{
|
||||
return borderStart;
|
||||
}
|
||||
|
||||
public void setBorderStart(int borderStart)
|
||||
{
|
||||
this.borderStart = borderStart;
|
||||
}
|
||||
|
||||
public int getBorderEnd()
|
||||
{
|
||||
return borderEnd;
|
||||
}
|
||||
|
||||
public void setBorderEnd(int borderEnd)
|
||||
{
|
||||
this.borderEnd = borderEnd;
|
||||
}
|
||||
|
||||
public int getOriginalBackground()
|
||||
{
|
||||
return originalBackground;
|
||||
}
|
||||
|
||||
public int getOriginalBorderStart()
|
||||
{
|
||||
return originalBorderStart;
|
||||
}
|
||||
|
||||
public int getOriginalBorderEnd()
|
||||
{
|
||||
return originalBorderEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -371,14 +371,19 @@ public class GuiUtils
|
||||
}
|
||||
|
||||
final int zLevel = 300;
|
||||
final int backgroundColor = 0xF0100010;
|
||||
int backgroundColor = 0xF0100010;
|
||||
int borderColorStart = 0x505000FF;
|
||||
int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
|
||||
RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, textLines, tooltipX, tooltipY, font, backgroundColor, borderColorStart, borderColorEnd);
|
||||
MinecraftForge.EVENT_BUS.post(colorEvent);
|
||||
backgroundColor = colorEvent.getBackground();
|
||||
borderColorStart = colorEvent.getBorderStart();
|
||||
borderColorEnd = colorEvent.getBorderEnd();
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(zLevel, tooltipX - 4, tooltipY - 3, tooltipX - 3, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 3, tooltipY - 3, tooltipX + tooltipTextWidth + 4, tooltipY + tooltipHeight + 3, backgroundColor, backgroundColor);
|
||||
final int borderColorStart = 0x505000FF;
|
||||
final int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3 + 1, tooltipX - 3 + 1, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
drawGradientRect(zLevel, tooltipX + tooltipTextWidth + 2, tooltipY - 3 + 1, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 3 - 1, borderColorStart, borderColorEnd);
|
||||
drawGradientRect(zLevel, tooltipX - 3, tooltipY - 3, tooltipX + tooltipTextWidth + 3, tooltipY - 3 + 1, borderColorStart, borderColorStart);
|
||||
|
||||
Reference in new issue
Block a user