1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:52:55 +08:00

add feature to adjust ScalingContainer background dim

This commit is contained in:
cdwcgt 2023-03-28 22:24:05 +09:00
parent 5c82d1f777
commit 46ede27869
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2
3 changed files with 29 additions and 2 deletions

View File

@ -157,6 +157,7 @@ namespace osu.Game.Configuration
SetDefault(OsuSetting.Scaling, ScalingMode.Off);
SetDefault(OsuSetting.SafeAreaConsiderations, true);
SetDefault(OsuSetting.ScalingMenuBackgroundDim, 0.9f, 0.5f, 1f);
SetDefault(OsuSetting.ScalingSizeX, 0.8f, 0.2f, 1f);
SetDefault(OsuSetting.ScalingSizeY, 0.8f, 0.2f, 1f);
@ -364,6 +365,7 @@ namespace osu.Game.Configuration
ScalingPositionY,
ScalingSizeX,
ScalingSizeY,
ScalingMenuBackgroundDim,
UIScale,
IntroSequence,
NotifyOnUsernameMentioned,

View File

@ -46,6 +46,8 @@ namespace osu.Game.Graphics.Containers
private BackgroundScreenStack backgroundStack;
private Bindable<float> scalingMenuBackgroundDim;
private RectangleF? customRect;
private bool customRectIsRelativePosition;
@ -138,6 +140,9 @@ namespace osu.Game.Graphics.Containers
safeAreaPadding = safeArea.SafeAreaPadding.GetBoundCopy();
safeAreaPadding.BindValueChanged(_ => Scheduler.AddOnce(updateSize));
scalingMenuBackgroundDim = config.GetBindable<float>(OsuSetting.ScalingMenuBackgroundDim);
scalingMenuBackgroundDim.ValueChanged += _ => Scheduler.AddOnce(updateSize);
}
protected override void LoadComplete()
@ -148,7 +153,9 @@ namespace osu.Game.Graphics.Containers
sizableContainer.FinishTransforms();
}
private bool requiresBackgroundVisible => (scalingMode.Value == ScalingMode.Everything || scalingMode.Value == ScalingMode.ExcludeOverlays) && (sizeX.Value != 1 || sizeY.Value != 1);
private bool requiresBackgroundVisible => (scalingMode.Value == ScalingMode.Everything || scalingMode.Value == ScalingMode.ExcludeOverlays)
&& (sizeX.Value != 1 || sizeY.Value != 1)
&& scalingMenuBackgroundDim.Value != 1f;
private void updateSize()
{
@ -161,7 +168,6 @@ namespace osu.Game.Graphics.Containers
{
AddInternal(backgroundStack = new BackgroundScreenStack
{
Colour = OsuColour.Gray(0.1f),
Alpha = 0,
Depth = float.MaxValue
});
@ -170,6 +176,7 @@ namespace osu.Game.Graphics.Containers
}
backgroundStack.FadeIn(TRANSITION_DURATION);
backgroundStack.FadeColour(OsuColour.Gray(1.0f - scalingMenuBackgroundDim.Value), 800, Easing.OutQuint);
}
else
backgroundStack?.FadeOut(TRANSITION_DURATION);

View File

@ -30,6 +30,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
protected override LocalisableString Header => GraphicsSettingsStrings.LayoutHeader;
private FillFlowContainer<SettingsSlider<float>> scalingSettings = null!;
private SettingsSlider<float> dimSlider = null!;
private readonly Bindable<Display> currentDisplay = new Bindable<Display>();
private readonly IBindableList<WindowMode> windowModes = new BindableList<WindowMode>();
@ -58,6 +59,8 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
private Bindable<float> scalingSizeX = null!;
private Bindable<float> scalingSizeY = null!;
private Bindable<float> scalingBackgroundDim = null!;
private const int transition_duration = 400;
[BackgroundDependencyLoader]
@ -71,6 +74,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
scalingSizeY = osuConfig.GetBindable<float>(OsuSetting.ScalingSizeY);
scalingPositionX = osuConfig.GetBindable<float>(OsuSetting.ScalingPositionX);
scalingPositionY = osuConfig.GetBindable<float>(OsuSetting.ScalingPositionY);
scalingBackgroundDim = osuConfig.GetBindable<float>(OsuSetting.ScalingMenuBackgroundDim);
if (window != null)
{
@ -162,6 +166,13 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
dimSlider = new SettingsSlider<float>
{
LabelText = GameplaySettingsStrings.BackgroundDim,
Current = scalingBackgroundDim,
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
}
},
};
@ -219,6 +230,13 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
scalingSettings.AutoSizeAxes = scalingMode.Value != ScalingMode.Off ? Axes.Y : Axes.None;
scalingSettings.ForEach(s =>
{
if (s == dimSlider)
{
s.TransferValueOnCommit = false;
s.CanBeShown.Value = scalingMode.Value == ScalingMode.Everything || scalingMode.Value == ScalingMode.ExcludeOverlays;
return;
}
s.TransferValueOnCommit = scalingMode.Value == ScalingMode.Everything;
s.CanBeShown.Value = scalingMode.Value != ScalingMode.Off;
});