Skip to content

Commit

Permalink
Merge pull request #96 from FTBTeam/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
MichaelHillcox authored Jun 28, 2024
2 parents 71f0f8c + 235c431 commit aa0e6ac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ private Panel getDoubleClickTarget() {
return modalPanels.isEmpty() ? this : modalPanels.peekFirst();
}

public int getMaxZLevel() {
return modalPanels.stream().map(ModalPanel::getExtraZlevel).max(Integer::compare).orElse(0);
}

@Override
public boolean mousePressed(MouseButton button) {
if (button == MouseButton.BACK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,16 @@ protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {

wrappedGui.addMouseOverText(tooltipList);

int zLevel = wrappedGui.getMaxZLevel() + 100;

graphics.pose().pushPose();
if (!tooltipList.shouldRender()) {
wrappedGui.getIngredientUnderMouse().ifPresent(underMouse -> {
if (underMouse.tooltip()) {
var ingredient = underMouse.ingredient();
if (ingredient instanceof ItemStack stack && !stack.isEmpty()) {
graphics.pose().pushPose();
graphics.pose().translate(0, 0, tooltipList.zOffsetItemTooltip);
graphics.pose().translate(0, 0, zLevel);
graphics.renderTooltip(theme.getFont(), (ItemStack) ingredient, mouseX, mouseY);
graphics.pose().popPose();
}
}
});
Expand All @@ -154,12 +155,12 @@ protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
.reduce((c1, c2) -> c1.copy().append("\n").append(c2))
.orElse(Component.empty())
);
graphics.pose().translate(0, 0, 600);
graphics.pose().translate(0, 0, zLevel);
graphics.setColor(1f, 1f, 1f, 0.8f);
graphics.renderTooltip(theme.getFont(), lines, DefaultTooltipPositioner.INSTANCE, mouseX, Math.max(mouseY, 18));
graphics.setColor(1f, 1f, 1f, 1f);
graphics.pose().translate(0, 0, -600);
}
graphics.pose().popPose();

tooltipList.reset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,26 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTi

wrappedGui.addMouseOverText(tooltipList);

int zLevel = wrappedGui.getMaxZLevel() + 100;

graphics.pose().pushPose();
if (!tooltipList.shouldRender()) {
wrappedGui.getIngredientUnderMouse().ifPresent(underMouse -> {
if (underMouse.tooltip()) {
var ingredient = underMouse.ingredient();
if (ingredient instanceof ItemStack stack && !stack.isEmpty()) {
graphics.pose().pushPose();
graphics.pose().translate(0, 0, tooltipList.zOffsetItemTooltip);
graphics.pose().translate(0, 0, zLevel);
graphics.renderTooltip(theme.getFont(), (ItemStack) ingredient, mouseX, mouseY);
graphics.pose().popPose();
}
}
});
} else {
graphics.pose().translate(0, 0, 600);
graphics.pose().translate(0, 0, zLevel);
graphics.setColor(1f, 1f, 1f, 0.8f);
graphics.renderTooltip(theme.getFont(), tooltipList.getLines(), Optional.empty(), mouseX, Math.max(mouseY, 18));
graphics.setColor(1f, 1f, 1f, 1f);
graphics.pose().translate(0, 0, -600);
}
graphics.pose().popPose();

tooltipList.reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

public class TooltipList {
private final List<Component> lines = new ArrayList<>();
public int zOffset = 950;
public int zOffsetItemTooltip = 0;
public int backgroundColor = 0xC0100010;
public int borderColorStart = 0x505000FF;
public int borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
Expand All @@ -24,8 +22,6 @@ public boolean shouldRender() {

public void reset() {
lines.clear();
zOffset = 950;
zOffsetItemTooltip = 0;
backgroundColor = 0xC0100010;
borderColorStart = 0x505000FF;
borderColorEnd = (borderColorStart & 0xFEFEFE) >> 1 | borderColorStart & 0xFF000000;
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.daemon=false
# Mod
mod_id=ftblibrary
readable_name=FTB Library
mod_version=2100.1.1
mod_version=2100.1.2
mod_author=FTB Team

# Maven
Expand All @@ -16,12 +16,12 @@ minecraft_version=1.21

# Deps
forge_version=49.0.31
neoforge_version=21.0.14-beta
neoforge_version=21.0.40-beta
neoforge_loader_version=4
fabric_loader_version=0.15.11
fabric_api_version=0.100.1+1.21

architectury_version=13.0.1
architectury_version=13.0.2

# There are too many of these now
rei_version=16.0.729
Expand Down

0 comments on commit aa0e6ac

Please sign in to comment.