Skip to content

Commit

Permalink
fix: connection arrow sometimes renders in front of entry
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Jan 8, 2024
1 parent a452bfd commit 795e471
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public void renderBackground(GuiGraphics guiGraphics) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShader(GameRenderer::getPositionTexShader);

//note we cannot translate -z here because even -1 immediately pushes us behind the scene -> not visible
if (!this.category.getBackgroundParallaxLayers().isEmpty()) {
this.category.getBackgroundParallaxLayers().forEach(layer -> {
this.renderBackgroundParallaxLayer(guiGraphics, layer, innerX, innerY, innerWidth, innerHeight, this.scrollX, this.scrollY, scale, xOffset, yOffset, this.currentZoom);
Expand Down Expand Up @@ -243,6 +244,7 @@ private void renderEntries(GuiGraphics guiGraphics, int mouseX, int mouseY) {

guiGraphics.pose().pushPose();
guiGraphics.pose().scale(this.currentZoom, this.currentZoom, 1.0f);

for (var entry : this.category.getEntries().values()) {
var displayState = this.getEntryDisplayState(entry);
var isHovered = this.isEntryHovered(entry, xOffset, yOffset, mouseX, mouseY);
Expand All @@ -257,6 +259,10 @@ private void renderEntries(GuiGraphics guiGraphics, int mouseX, int mouseY) {
//we translate instead of applying the offset to the entry x/y to avoid jittering when moving
guiGraphics.pose().translate(xOffset, yOffset, 0);


//we apply a z offset to push the entries before the connection arrows
guiGraphics.pose().translate(0 ,0, 10);

//As of 1.20 this is not necessary, in fact it causes the entry to render behind the bg
//guiGraphics.pose().translate(0, 0, -10); //push the whole entry behind the frame

Expand Down Expand Up @@ -294,7 +300,7 @@ private void renderEntries(GuiGraphics guiGraphics, int mouseX, int mouseY) {

//testing
guiGraphics.pose().pushPose();
guiGraphics.pose().translate(0, 0, 11); //and push the unread icon in front of the icon
guiGraphics.pose().translate(0, 0, 11); //and push the unread icon in front of the background and icon (they are at Z 10)
//if focused we go to the right of our normal button (instead of down, like mc buttons do)
BookContentScreen.drawFromTexture(guiGraphics, this.bookOverviewScreen.getBook(),
entry.getX() * ENTRY_GRID_SCALE + ENTRY_GAP + 16 + 2,
Expand Down Expand Up @@ -368,7 +374,7 @@ private void renderConnections(GuiGraphics guiGraphics, BookEntry entry, float x

for (var parent : entry.getParents()) {

int blitOffset = 0;
int blitOffset = 0; //note: any negative blit offset will move it behind our category background
this.connectionRenderer.setBlitOffset(blitOffset);
guiGraphics.pose().pushPose();
guiGraphics.pose().translate(xOffset, yOffset, 0);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ group=com.klikli_dev
mod_id=modonomicon
mod_name=Modonomicon
mod_license=MIT AND CC-BY-4.0
mod_version=1.48.0
mod_version=1.48.1
mod_authors=Kli Kli
mod_description=Data-driven minecraft in-game documentation with progress visualization.

Expand Down

0 comments on commit 795e471

Please sign in to comment.