1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 07:32:55 +08:00

Add ui scaling setup screen, kind of

This commit is contained in:
Dean Herbert 2022-04-06 18:11:32 +09:00
parent ae07b2b512
commit c2df3465b2
3 changed files with 94 additions and 10 deletions

View File

@ -0,0 +1,87 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays.Settings;
using osu.Game.Screens;
using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.Select;
using osuTK;
namespace osu.Game.Overlays.FirstRunSetup
{
public class ScreenSetupUIScale : FirstRunSetupScreen
{
[Resolved]
private OsuConfigManager osuConfig { get; set; }
[BackgroundDependencyLoader]
private void load()
{
OsuScreenStack stack;
Content.Children = new Drawable[]
{
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(20),
Children = new Drawable[]
{
new OsuTextFlowContainer
{
Text = "The osu! user interface size can be adjusted to your liking.",
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
},
new SettingsSlider<float, UIScaleSlider>
{
LabelText = GraphicsSettingsStrings.UIScaling,
TransferValueOnCommit = true,
Current = osuConfig.GetBindable<float>(OsuSetting.UIScale),
KeyboardStep = 0.01f,
},
new DrawSizePreservingFillContainer
{
Masking = true,
RelativeSizeAxes = Axes.X,
Height = 300,
Child = stack = new OsuScreenStack()
}
}
},
new PurpleTriangleButton
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X,
Margin = new MarginPadding(10),
Text = "Finish",
Action = () => Overlay.Hide()
}
};
stack.Push(new PlaySongSelect());
}
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
Overlay.MoveDisplayTo(new Vector2(0.5f));
Overlay.ResizeDisplayTo(new Vector2(0.8f));
}
private class UIScaleSlider : OsuSliderBar<float>
{
public override LocalisableString TooltipText => base.TooltipText + "x";
}
}
}

View File

@ -4,7 +4,6 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Utils;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Screens.OnlinePlay.Match.Components; using osu.Game.Screens.OnlinePlay.Match.Components;
using osuTK; using osuTK;
@ -38,7 +37,7 @@ namespace osu.Game.Overlays.FirstRunSetup
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Margin = new MarginPadding(10), Margin = new MarginPadding(10),
Text = "Get started", Text = "Get started",
Action = () => this.Push(new ScreenWelcome()), Action = () => this.Push(new ScreenSetupUIScale()),
} }
}; };
} }
@ -46,13 +45,7 @@ namespace osu.Game.Overlays.FirstRunSetup
public override void OnEntering(IScreen last) public override void OnEntering(IScreen last)
{ {
base.OnEntering(last); base.OnEntering(last);
Overlay.MoveDisplayTo(new Vector2(RNG.NextSingle(), RNG.NextSingle())); Overlay.MoveDisplayTo(new Vector2(0.5f));
}
public override void OnResuming(IScreen last)
{
base.OnResuming(last);
Overlay.MoveDisplayTo(new Vector2(RNG.NextSingle(), RNG.NextSingle()));
} }
} }
} }

View File

@ -57,7 +57,8 @@ namespace osu.Game.Overlays
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativePositionAxes = Axes.Both, RelativePositionAxes = Axes.Both,
Size = new Vector2(400, 300), RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f),
Position = new Vector2(0.5f), Position = new Vector2(0.5f),
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
{ {
@ -130,5 +131,8 @@ namespace osu.Game.Overlays
public void MoveDisplayTo(Vector2 position) => public void MoveDisplayTo(Vector2 position) =>
currentDisplayContainer.MoveTo(position, 1000, Easing.OutElasticQuarter); currentDisplayContainer.MoveTo(position, 1000, Easing.OutElasticQuarter);
public void ResizeDisplayTo(Vector2 scale) =>
currentDisplayContainer.ScaleTo(scale, 1000, Easing.OutElasticQuarter);
} }
} }