Make the background blur adjustable
A "Background blur" setting (0-10, default 5) sets how much the game behind Saturn's screens is blurred. Screens now only say whether to blur, and SaturnScreen.getBackgroundBlur gives the setting's strength, faded in over the screen's first 700 ms. The title menu still doesn't blur. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
package org.saturnclient.ui;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.saturnclient.config.Config;
|
||||
|
||||
public abstract class SaturnScreen {
|
||||
/** How long the background blur takes to fade in, in ms */
|
||||
private static final int BLUR_FADE_IN = 700;
|
||||
|
||||
public static interface ScreenProvider {
|
||||
public void close();
|
||||
|
||||
@@ -22,7 +28,8 @@ public abstract class SaturnScreen {
|
||||
public List<Element> elements = new ArrayList<>();
|
||||
public float backgroundOpacity = 1.0f;
|
||||
public Instant start = null;
|
||||
public int backgroundBlur = 10;
|
||||
/** Whether the game behind this screen is blurred, by the client's background blur setting */
|
||||
public boolean blurBackground = true;
|
||||
|
||||
// Provider
|
||||
public ScreenProvider provider;
|
||||
@@ -31,6 +38,19 @@ public abstract class SaturnScreen {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 getBackgroundBlur() {
|
||||
if (!blurBackground || start == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long elapsed = Duration.between(start, Instant.now()).toMillis();
|
||||
return Math.round(Config.backgroundBlur.value * Math.min(elapsed / (float) BLUR_FADE_IN, 1f));
|
||||
}
|
||||
|
||||
public void init() {
|
||||
elements.clear();
|
||||
width = provider.getWidth();
|
||||
|
||||
Reference in New Issue
Block a user