Skip to content

Commit

Permalink
Merge pull request #98 from FTBTeam/feature/1.21/blur-control
Browse files Browse the repository at this point in the history
[1.21] Expose option to turn of background GUI blur
  • Loading branch information
desht authored Jul 19, 2024
2 parents 235c431 + 1a7e14a commit bb3e350
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions common/src/main/java/dev/ftb/mods/ftblibrary/ui/BaseScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public abstract class BaseScreen extends Panel {
private long lastClickTime = 0L;
private final Deque<ModalPanel> modalPanels;
private Widget focusedWidget = null;
private boolean renderBlur = true;

public BaseScreen() {
super(null);
Expand Down Expand Up @@ -104,6 +105,20 @@ public boolean onInit() {
return true;
}

/**
* @return if the GUI should render a blur effect behind it
*/
public boolean shouldRenderBlur() {
return renderBlur;
}

/**
* @param renderBlur sets if the GUI should render a blur effect behind it
*/
public void setRenderBlur(boolean renderBlur) {
this.renderBlur = renderBlur;
}

/**
* Should the GUI automatically close when Escape (or the inventory key - E by default) is pressed? Override this
* to return false if you need to implement custom close behaviour, e.g. a confirmation screen for unsaved changes.
Expand Down Expand Up @@ -338,6 +353,8 @@ public void drawBackground(GuiGraphics graphics, Theme theme, int x, int y, int
theme.drawGui(graphics, x, y, w, h, WidgetType.NORMAL);
}



public boolean drawDefaultBackground(GuiGraphics graphics) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ public void renderBackground(GuiGraphics matrixStack, int x, int y, float partia
}
}


@Override
protected void renderBlurredBackground(float f) {
if(wrappedGui.shouldRenderBlur()) {
super.renderBlurredBackground(f);
}
}

@Override
public void tick() {
super.tick();
Expand Down

0 comments on commit bb3e350

Please sign in to comment.