Split the blur into world, menu and widget blurs
The world or panorama keeps its animated background blur, while glass behind menus and behind widgets (buttons, the dock, the account chip) each get a fixed blur of their own. Glass is left out when its blur is 0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.saturnclient.ui;
|
||||
|
||||
import org.saturnclient.common.provider.Providers;
|
||||
import org.saturnclient.ui.components.Sidebar;
|
||||
import org.saturnclient.ui.elements.ImageTexture;
|
||||
import org.saturnclient.ui.elements.Panel;
|
||||
@@ -39,9 +38,6 @@ public abstract class PanelScreen extends SaturnScreen {
|
||||
|
||||
@Override
|
||||
public final void ui() {
|
||||
// The panels are frosted themselves, so the rest of the game stays clear.
|
||||
blurBackground = !Providers.saturn.supportsGlass();
|
||||
|
||||
panelWidth = Math.min(MAX_WIDTH, width - MARGIN * 2 - Sidebar.WIDTH - GAP);
|
||||
panelHeight = Math.min(MAX_HEIGHT, height - MARGIN * 2);
|
||||
|
||||
|
||||
@@ -55,19 +55,33 @@ public interface RenderScope {
|
||||
|
||||
/**
|
||||
* Frosts a rounded rectangle for a translucent background to be drawn over:
|
||||
* the game behind the screen, blurred, cut to exactly the shape
|
||||
* {@link #drawRoundedRectangle} draws. Draws nothing on versions without
|
||||
* glass.
|
||||
* the game behind the screen, blurred by {@code blur}, cut to exactly the
|
||||
* shape {@link #drawRoundedRectangle} draws. Draws nothing on versions
|
||||
* without glass.
|
||||
*/
|
||||
default void drawGlass(int x, int y, int width, int height, int radius) {
|
||||
drawGlass(getRoundedRectangle(width, height, radius), x, y, width, height);
|
||||
default void drawGlass(int x, int y, int width, int height, int radius, int blur) {
|
||||
drawGlass(getRoundedRectangle(width, height, radius), x, y, width, height, blur);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the blurred game behind the screen where {@code mask}, stretched
|
||||
* over the area, is opaque.
|
||||
* Draws the game behind the screen, blurred by {@code blur}, where
|
||||
* {@code mask}, stretched over the area, is opaque.
|
||||
*/
|
||||
default void drawGlass(IdentifierRef mask, int x, int y, int width, int height) {
|
||||
default void drawGlass(IdentifierRef mask, int x, int y, int width, int height, int blur) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link #drawRoundedRectangle} with a border, frosted with glass blurred
|
||||
* by {@code blur} when the background isn't solid. A blur of 0 leaves it
|
||||
* plain, showing the screen's own background blur.
|
||||
*/
|
||||
default void drawGlassRectangle(int x, int y, int width, int height, int radius, int blur, int thickness,
|
||||
int background, int border) {
|
||||
if (blur > 0 && background >>> 24 < 0xFF) {
|
||||
drawGlass(x, y, width, height, radius, blur);
|
||||
}
|
||||
|
||||
drawRoundedRectangle(x, y, width, height, radius, thickness, background, border);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,11 +46,11 @@ public abstract class SaturnScreen {
|
||||
}
|
||||
|
||||
/**
|
||||
* How much to blur the game behind this screen and its glass right now: the
|
||||
* client's setting, faded in over the screen's first moments.
|
||||
* How much to blur the game behind this screen right now: the client's
|
||||
* setting, faded in over the screen's first moments.
|
||||
*/
|
||||
public int getBlurRadius() {
|
||||
if (start == null) {
|
||||
public int getBackgroundBlur() {
|
||||
if (!blurBackground || start == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -58,14 +58,6 @@ public abstract class SaturnScreen {
|
||||
return Math.round(Config.backgroundBlur.value * Math.min(elapsed / (float) BLUR_FADE_IN, 1f));
|
||||
}
|
||||
|
||||
/**
|
||||
* How much to blur the whole game behind this screen right now, or 0 when it
|
||||
* isn't.
|
||||
*/
|
||||
public int getBackgroundBlur() {
|
||||
return blurBackground ? getBlurRadius() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GUI scale setting this screen follows; the menu scale unless the
|
||||
* screen is another kind.
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.saturnclient.ui.components;
|
||||
import org.saturnclient.client.ServiceClient;
|
||||
import org.saturnclient.common.provider.Providers;
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
import org.saturnclient.config.Config;
|
||||
import org.saturnclient.config.Theme;
|
||||
import org.saturnclient.ui.Element;
|
||||
import org.saturnclient.ui.ElementContext;
|
||||
@@ -36,8 +37,8 @@ public class AccountChip extends Element {
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value, 1, Theme.getPanelBg(),
|
||||
Theme.getBorder());
|
||||
renderScope.drawGlassRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value, Config.widgetBlur.value, 1,
|
||||
Theme.getPanelBg(), Theme.getBorder());
|
||||
|
||||
// The face, then the hat layer over it, from the 64x64 skin
|
||||
IdentifierRef skin = Providers.saturn.getPlayerSkin();
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.saturnclient.ui.components;
|
||||
import java.util.List;
|
||||
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
import org.saturnclient.config.Config;
|
||||
import org.saturnclient.config.Theme;
|
||||
import org.saturnclient.ui.Element;
|
||||
import org.saturnclient.ui.ElementContext;
|
||||
@@ -32,7 +33,8 @@ public class Dock extends Element {
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value + 4, 1, Theme.getPanelBg(),
|
||||
renderScope.drawGlassRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value + 4, Config.widgetBlur.value, 1,
|
||||
Theme.getPanelBg(),
|
||||
Theme.withAlpha(0.1f, Theme.FOREGROUND.value));
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.saturnclient.ui.elements;
|
||||
|
||||
import org.saturnclient.config.Config;
|
||||
import org.saturnclient.config.Theme;
|
||||
import org.saturnclient.ui.Element;
|
||||
import org.saturnclient.ui.ElementContext;
|
||||
@@ -38,7 +39,7 @@ public class Button extends Element {
|
||||
* The button's surface, shared with {@link IconButton}.
|
||||
*/
|
||||
static void drawSurface(RenderScope renderScope, int width, int height, boolean hovered) {
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value, 1,
|
||||
renderScope.drawGlassRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value, Config.widgetBlur.value, 1,
|
||||
hovered ? Theme.PRIMARY.value : Theme.getPanelBg(),
|
||||
Theme.withAlpha(hovered ? 0.25f : 0.1f, Theme.FOREGROUND.value));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.saturnclient.ui.elements;
|
||||
|
||||
import org.saturnclient.config.Config;
|
||||
import org.saturnclient.config.Theme;
|
||||
import org.saturnclient.ui.Element;
|
||||
import org.saturnclient.ui.ElementContext;
|
||||
@@ -17,12 +18,7 @@ public class Panel extends Element {
|
||||
}
|
||||
|
||||
public static void drawBackground(RenderScope renderScope, int width, int height) {
|
||||
// Frosted behind a background that isn't solid
|
||||
if (Theme.getPanelBg() >>> 24 < 0xFF) {
|
||||
renderScope.drawGlass(0, 0, width, height, Theme.BG_RADIUS.value);
|
||||
}
|
||||
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height, Theme.BG_RADIUS.value, 1,
|
||||
renderScope.drawGlassRectangle(0, 0, width, height, Theme.BG_RADIUS.value, Config.menuBlur.value, 1,
|
||||
Theme.getPanelBg(), Theme.getBorder());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +131,8 @@ public class EmoteWheel extends SaturnScreen {
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, ElementContext ctx) {
|
||||
renderScope.drawRoundedRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value, 1,
|
||||
Theme.getPanelBg(), Theme.getBorder());
|
||||
renderScope.drawGlassRectangle(0, 0, width, height, Theme.WIDGET_RADIUS.value, Config.widgetBlur.value,
|
||||
1, Theme.getPanelBg(), Theme.getBorder());
|
||||
|
||||
float titleScale = 0.54f;
|
||||
drawCentered(renderScope, "EMOTES", titleScale, pages > 1 ? 24 : (height - 10) / 2, Theme.getMutedFg());
|
||||
|
||||
Reference in New Issue
Block a user