mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 11:33:22 +08:00
Add preview for gameplay region
This commit is contained in:
parent
9c7830d83b
commit
3a10dd47d5
@ -23,7 +23,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
private Bindable<float> posX;
|
private Bindable<float> posX;
|
||||||
private Bindable<float> posY;
|
private Bindable<float> posY;
|
||||||
|
|
||||||
private readonly ScalingMode targetMode;
|
private readonly ScalingMode? targetMode;
|
||||||
|
|
||||||
private Bindable<ScalingMode> scalingMode;
|
private Bindable<ScalingMode> scalingMode;
|
||||||
|
|
||||||
@ -37,8 +37,8 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new instance.
|
/// Create a new instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="targetMode">The mode which this container should be handling.</param>
|
/// <param name="targetMode">The mode which this container should be handling. Handles all modes if null.</param>
|
||||||
public ScalingContainer(ScalingMode targetMode)
|
public ScalingContainer(ScalingMode? targetMode = null)
|
||||||
{
|
{
|
||||||
this.targetMode = targetMode;
|
this.targetMode = targetMode;
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
@ -47,6 +47,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RelativePositionAxes = Axes.Both,
|
RelativePositionAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
CornerRadius = 10,
|
CornerRadius = 10,
|
||||||
Child = content = new DrawSizePreservingFillContainer()
|
Child = content = new DrawSizePreservingFillContainer()
|
||||||
};
|
};
|
||||||
@ -76,7 +77,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
updateSize();
|
updateSize();
|
||||||
content.FinishTransforms();
|
sizableContainer.FinishTransforms();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool requiresBackgroundVisible => (scalingMode == ScalingMode.Everything || scalingMode == ScalingMode.ExcludeOverlays) && (sizeX.Value != 1 || sizeY.Value != 1);
|
private bool requiresBackgroundVisible => (scalingMode == ScalingMode.Everything || scalingMode == ScalingMode.ExcludeOverlays) && (sizeX.Value != 1 || sizeY.Value != 1);
|
||||||
@ -106,10 +107,10 @@ namespace osu.Game.Graphics.Containers
|
|||||||
backgroundLayer?.FadeOut(500);
|
backgroundLayer?.FadeOut(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool letterbox = scalingMode.Value == targetMode;
|
bool scaling = targetMode == null || scalingMode.Value == targetMode;
|
||||||
|
|
||||||
var targetSize = letterbox ? new Vector2(sizeX, sizeY) : Vector2.One;
|
var targetSize = scaling ? new Vector2(sizeX, sizeY) : Vector2.One;
|
||||||
var targetPosition = letterbox ? new Vector2(posX, posY) * (Vector2.One - targetSize) : Vector2.Zero;
|
var targetPosition = scaling ? new Vector2(posX, posY) * (Vector2.One - targetSize) : Vector2.Zero;
|
||||||
bool requiresMasking = targetSize != Vector2.One;
|
bool requiresMasking = targetSize != Vector2.One;
|
||||||
|
|
||||||
if (requiresMasking)
|
if (requiresMasking)
|
||||||
|
@ -9,9 +9,12 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osuTK.Graphics;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||||
@ -151,15 +154,32 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
|||||||
configBindable.BindValueChanged(v => delayed.Value = v, true);
|
configBindable.BindValueChanged(v => delayed.Value = v, true);
|
||||||
delayed.ValueChanged += v =>
|
delayed.ValueChanged += v =>
|
||||||
{
|
{
|
||||||
if (scalingMode == ScalingMode.Everything)
|
switch (scalingMode.Value)
|
||||||
|
{
|
||||||
|
case ScalingMode.Everything:
|
||||||
applyWithDelay(() => configBindable.Value = v);
|
applyWithDelay(() => configBindable.Value = v);
|
||||||
else
|
return;
|
||||||
|
case ScalingMode.Gameplay:
|
||||||
|
showPreview();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
configBindable.Value = v;
|
configBindable.Value = v;
|
||||||
};
|
};
|
||||||
|
|
||||||
return delayed;
|
return delayed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Drawable preview;
|
||||||
|
private void showPreview()
|
||||||
|
{
|
||||||
|
if (preview?.IsAlive != true)
|
||||||
|
game.Add(preview = new ScalingPreview());
|
||||||
|
|
||||||
|
preview.FadeOutFromOne(1500);
|
||||||
|
preview.Expire();
|
||||||
|
}
|
||||||
|
|
||||||
private ScheduledDelegate delayedApplication;
|
private ScheduledDelegate delayedApplication;
|
||||||
|
|
||||||
private void applyWithDelay(Action func, bool firstRun = true)
|
private void applyWithDelay(Action func, bool firstRun = true)
|
||||||
@ -191,6 +211,19 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
|||||||
return resolutions;
|
return resolutions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ScalingPreview : ScalingContainer
|
||||||
|
{
|
||||||
|
public ScalingPreview()
|
||||||
|
{
|
||||||
|
Child = new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.White,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0.5f,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class ResolutionSettingsDropdown : SettingsDropdown<Size>
|
private class ResolutionSettingsDropdown : SettingsDropdown<Size>
|
||||||
{
|
{
|
||||||
protected override OsuDropdown<Size> CreateDropdown() => new ResolutionDropdownControl { Items = Items };
|
protected override OsuDropdown<Size> CreateDropdown() => new ResolutionDropdownControl { Items = Items };
|
||||||
|
Loading…
Reference in New Issue
Block a user