fix: lingering tooltips of side buttons

Fixes #3532
This commit is contained in:
raoulvdberge
2023-07-05 16:23:27 +02:00
parent 03c62700a3
commit 8872101e05
3 changed files with 4 additions and 16 deletions

View File

@@ -14,6 +14,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Fixed ### Fixed
- Fixed not being able to close GUIs anymore with autoselected search box mode. - Fixed not being able to close GUIs anymore with autoselected search box mode.
- Fixed lingering tooltips of side buttons.
## [1.12.1] - 2023-07-03 ## [1.12.1] - 2023-07-03

View File

@@ -155,12 +155,6 @@ public abstract class BaseScreen<T extends AbstractContainerMenu> extends Abstra
renderForeground(graphics, mouseX, mouseY); renderForeground(graphics, mouseX, mouseY);
for (Renderable renderable : this.renderables) {
if (renderable instanceof SideButton sideButton) {
sideButton.renderTooltip(graphics, mouseX, mouseY);
}
}
for (int i = 0; i < this.menu.slots.size(); ++i) { for (int i = 0; i < this.menu.slots.size(); ++i) {
Slot slot = menu.slots.get(i); Slot slot = menu.slots.get(i);

View File

@@ -22,15 +22,6 @@ public abstract class SideButton extends Button {
this.screen = screen; this.screen = screen;
} }
public void renderTooltip(GuiGraphics graphics, int mouseX, int mouseY) {
boolean isFocused = isFocused();
if (isHovered || isFocused) {
int x = isHovered ? mouseX : (this.getX() - screen.getGuiLeft()) + width;
int y = isHovered ? mouseY : (this.getY() - screen.getGuiTop()) + (height / 2);
screen.renderTooltip(graphics, x, y, getSideButtonTooltip());
}
}
@Override @Override
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
@@ -41,12 +32,14 @@ public abstract class SideButton extends Button {
renderButtonIcon(graphics, getX() + 1, getY() + 1); renderButtonIcon(graphics, getX() + 1, getY() + 1);
if (isHoveredOrFocused()) { if (isHovered) {
RenderSystem.enableBlend(); RenderSystem.enableBlend();
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.5f); RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.5f);
graphics.blit(BaseScreen.ICONS_TEXTURE, getX(), getY(), 238, 54, WIDTH, HEIGHT); graphics.blit(BaseScreen.ICONS_TEXTURE, getX(), getY(), 238, 54, WIDTH, HEIGHT);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.disableBlend(); RenderSystem.disableBlend();
screen.renderTooltip(graphics, mouseX, mouseY, getSideButtonTooltip());
} }
} }