Skip to content

Commit

Permalink
Remove unnecessary tooltip rendering from seismic vibrator as we alre…
Browse files Browse the repository at this point in the history
…ady display the information in the neighboring screen and the tooltip feels clunky
  • Loading branch information
pupnewfster committed Sep 22, 2024
1 parent 05aad4d commit 1548616
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
24 changes: 1 addition & 23 deletions src/main/java/mekanism/client/gui/element/GuiArrowSelection.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package mekanism.client.gui.element;

import com.mojang.blaze3d.vertex.PoseStack;
import java.util.function.Supplier;
import mekanism.client.gui.GuiUtils;
import mekanism.client.gui.IGuiWrapper;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
Expand All @@ -15,12 +13,10 @@ public class GuiArrowSelection extends GuiTexturedElement {

private static final ResourceLocation ARROW = MekanismUtils.getResource(ResourceType.GUI, "arrow_selection.png");

private final Supplier<Component> textComponentSupplier;
private final Supplier<Component> targetText;

public GuiArrowSelection(IGuiWrapper gui, int x, int y, Supplier<Component> textComponentSupplier, Supplier<Component> targetText) {
public GuiArrowSelection(IGuiWrapper gui, int x, int y, Supplier<Component> targetText) {
super(ARROW, gui, x, y, 33, 19);
this.textComponentSupplier = textComponentSupplier;
this.targetText = targetText;
}

Expand All @@ -30,24 +26,6 @@ public boolean isMouseOver(double xAxis, double yAxis) {
return this.active && this.visible && xAxis >= getX() + 16 && xAxis < getRight() - 1 && yAxis >= getY() + 1 && yAxis < getBottom() - 1;
}

@Override
public void renderToolTip(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY) {
super.renderToolTip(guiGraphics, mouseX, mouseY);
Component component = textComponentSupplier.get();
if (component != null) {
int tooltipX = mouseX + 5;
int tooltipY = mouseY - 5;
PoseStack pose = guiGraphics.pose();
pose.pushPose();
//Mirror vanilla's tooltip rendering offset
pose.translate(0, 0, 400);
GuiUtils.renderBackgroundTexture(guiGraphics, GuiInnerScreen.SCREEN, GuiInnerScreen.SCREEN_SIZE, GuiInnerScreen.SCREEN_SIZE, tooltipX - 3, tooltipY - 4, getStringWidth(component) + 6, 16, 256, 256);
//Note: This doesn't need to be a scrolling string as the background is resized to fit it
drawString(guiGraphics, component, tooltipX, tooltipY, screenTextColor(), false);
pose.popPose();
}
}

@Override
public void renderForeground(GuiGraphics guiGraphics, int mouseX, int mouseY) {
super.renderForeground(guiGraphics, mouseX, mouseY);
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/mekanism/client/gui/item/GuiSeismicReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,7 @@ protected void addGuiElements() {
}));
addRenderableWidget(new GuiInnerScreen(this, 74, 11, 51, 160));
scrollBar = addRenderableWidget(new GuiScrollBar(this, 126, 25, 132, blockList::size, () -> 1));
addRenderableWidget(new GuiArrowSelection(this, 76, 81, () -> {
int currentLayer = scrollBar.getCurrentSelection();
if (currentLayer >= 0) {
return blockList.get(blockList.size() - 1 - currentLayer).block().getName();
}
return null;
}, () -> TextComponentUtil.build(minHeight + getCurrentLayer())));
addRenderableWidget(new GuiArrowSelection(this, 76, 81, () -> TextComponentUtil.build(minHeight + getCurrentLayer())));
upButton = addRenderableWidget(new MekanismImageButton(this, 126, 11, 14,
MekanismUtils.getResource(ResourceType.GUI_BUTTON, "up.png"), (element, mouseX, mouseY) -> scrollBar.adjustScroll(1)));
downButton = addRenderableWidget(new MekanismImageButton(this, 126, 157, 14,
Expand Down

0 comments on commit 1548616

Please sign in to comment.