1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 07:22:55 +08:00

Improve overall usability of scale adjust screen

This commit is contained in:
Dean Herbert 2022-04-19 16:37:38 +09:00
parent c27831145c
commit 1490502d4c
2 changed files with 101 additions and 62 deletions

View File

@ -79,12 +79,12 @@ namespace osu.Game.Graphics.Containers
}; };
} }
private class ScalingDrawSizePreservingFillContainer : DrawSizePreservingFillContainer public class ScalingDrawSizePreservingFillContainer : DrawSizePreservingFillContainer
{ {
private readonly bool applyUIScale; private readonly bool applyUIScale;
private Bindable<float> uiScale; private Bindable<float> uiScale;
private float currentScale = 1; protected float CurrentScale { get; private set; } = 1;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
@ -99,14 +99,14 @@ namespace osu.Game.Graphics.Containers
if (applyUIScale) if (applyUIScale)
{ {
uiScale = osuConfig.GetBindable<float>(OsuSetting.UIScale); uiScale = osuConfig.GetBindable<float>(OsuSetting.UIScale);
uiScale.BindValueChanged(args => this.TransformTo(nameof(currentScale), args.NewValue, duration, Easing.OutQuart), true); uiScale.BindValueChanged(args => this.TransformTo(nameof(CurrentScale), args.NewValue, duration, Easing.OutQuart), true);
} }
} }
protected override void Update() protected override void Update()
{ {
Scale = new Vector2(currentScale); Scale = new Vector2(CurrentScale);
Size = new Vector2(1 / currentScale); Size = new Vector2(1 / CurrentScale);
base.Update(); base.Update();
} }

View File

@ -2,17 +2,23 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Overlays.Settings; using osu.Game.Overlays.Settings;
using osu.Game.Rulesets;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
@ -27,29 +33,9 @@ namespace osu.Game.Overlays.FirstRunSetup
private OsuConfigManager osuConfig { get; set; } private OsuConfigManager osuConfig { get; set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(RulesetStore rulesets, BeatmapManager beatmaps)
{ {
InternalChildren = new Drawable[] Content.Children = new Drawable[]
{
new GridContainer
{
RelativeSizeAxes = Axes.Both,
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension()
},
Content = new[]
{
new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(20),
Children = new Drawable[]
{ {
new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 24)) new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 24))
{ {
@ -63,10 +49,13 @@ namespace osu.Game.Overlays.FirstRunSetup
Current = osuConfig.GetBindable<float>(OsuSetting.UIScale), Current = osuConfig.GetBindable<float>(OsuSetting.UIScale),
KeyboardStep = 0.01f, KeyboardStep = 0.01f,
}, },
} new InverseScalingDrawSizePreservingFillContainer
} {
}, Anchor = Anchor.TopCentre,
new Drawable[] Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.None,
Size = new Vector2(960, 960 / 16f * 9 / 2),
Children = new Drawable[]
{ {
new GridContainer new GridContainer
{ {
@ -75,29 +64,82 @@ namespace osu.Game.Overlays.FirstRunSetup
{ {
new Drawable[] new Drawable[]
{ {
new SampleScreenContainer(new MainMenu()), new SampleScreenContainer(new PinnedMainMenu()),
new SampleScreenContainer(new PlaySongSelect()), new SampleScreenContainer(new PlaySongSelect()),
}, },
new Drawable[] // TODO: add more screens here in the future (gameplay / results)
{ // requires a bit more consideration to isolate their behaviour from the "parent" game.
new SampleScreenContainer(new MainMenu()),
new SampleScreenContainer(new MainMenu()),
} }
} }
} }
},
}
} }
}; };
} }
private class InverseScalingDrawSizePreservingFillContainer : ScalingContainer.ScalingDrawSizePreservingFillContainer
{
private Vector2 initialSize;
public InverseScalingDrawSizePreservingFillContainer()
: base(true)
{
}
protected override void LoadComplete()
{
base.LoadComplete();
initialSize = Size;
}
protected override void Update()
{
Size = initialSize / CurrentScale;
}
}
private class PinnedMainMenu : MainMenu
{
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
Buttons.ReturnToTopOnIdle = false;
Buttons.State = ButtonSystemState.TopLevel;
}
}
private class UIScaleSlider : OsuSliderBar<float>
{
public override LocalisableString TooltipText => base.TooltipText + "x";
}
private class SampleScreenContainer : CompositeDrawable private class SampleScreenContainer : CompositeDrawable
{ {
// Minimal isolation from main game.
[Cached]
[Cached(typeof(IBindable<RulesetInfo>))]
protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
[Cached]
[Cached(typeof(IBindable<WorkingBeatmap>))]
protected Bindable<WorkingBeatmap> Beatmap { get; private set; } = new Bindable<WorkingBeatmap>();
public override bool HandlePositionalInput => false; public override bool HandlePositionalInput => false;
public override bool HandleNonPositionalInput => false; public override bool HandleNonPositionalInput => false;
public override bool PropagatePositionalInputSubTree => false; public override bool PropagatePositionalInputSubTree => false;
public override bool PropagateNonPositionalInputSubTree => false; public override bool PropagateNonPositionalInputSubTree => false;
[BackgroundDependencyLoader]
private void load(AudioManager audio, TextureStore textures, RulesetStore rulesets)
{
Beatmap.Value = new DummyWorkingBeatmap(audio, textures);
Beatmap.Value.LoadTrack();
Ruleset.Value = rulesets.AvailableRulesets.First();
}
public SampleScreenContainer(Screen screen) public SampleScreenContainer(Screen screen)
{ {
OsuScreenStack stack; OsuScreenStack stack;
@ -105,6 +147,8 @@ namespace osu.Game.Overlays.FirstRunSetup
OsuLogo logo; OsuLogo logo;
Padding = new MarginPadding(5);
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new DependencyProvidingContainer new DependencyProvidingContainer
@ -120,7 +164,7 @@ namespace osu.Game.Overlays.FirstRunSetup
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
new ScalingContainer(ScalingMode.Off) new ScalingContainer.ScalingDrawSizePreservingFillContainer(true)
{ {
Masking = true, Masking = true,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -137,10 +181,5 @@ namespace osu.Game.Overlays.FirstRunSetup
stack.Push(screen); stack.Push(screen);
} }
} }
private class UIScaleSlider : OsuSliderBar<float>
{
public override LocalisableString TooltipText => base.TooltipText + "x";
}
} }
} }