mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Improve overall usability of scale adjust screen
This commit is contained in:
parent
c27831145c
commit
1490502d4c
@ -79,12 +79,12 @@ namespace osu.Game.Graphics.Containers
|
||||
};
|
||||
}
|
||||
|
||||
private class ScalingDrawSizePreservingFillContainer : DrawSizePreservingFillContainer
|
||||
public class ScalingDrawSizePreservingFillContainer : DrawSizePreservingFillContainer
|
||||
{
|
||||
private readonly bool applyUIScale;
|
||||
private Bindable<float> uiScale;
|
||||
|
||||
private float currentScale = 1;
|
||||
protected float CurrentScale { get; private set; } = 1;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
@ -99,14 +99,14 @@ namespace osu.Game.Graphics.Containers
|
||||
if (applyUIScale)
|
||||
{
|
||||
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()
|
||||
{
|
||||
Scale = new Vector2(currentScale);
|
||||
Size = new Vector2(1 / currentScale);
|
||||
Scale = new Vector2(CurrentScale);
|
||||
Size = new Vector2(1 / CurrentScale);
|
||||
|
||||
base.Update();
|
||||
}
|
||||
|
@ -2,17 +2,23 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Select;
|
||||
@ -27,77 +33,113 @@ namespace osu.Game.Overlays.FirstRunSetup
|
||||
private OsuConfigManager osuConfig { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(RulesetStore rulesets, BeatmapManager beatmaps)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
Content.Children = new Drawable[]
|
||||
{
|
||||
new GridContainer
|
||||
new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 24))
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
RowDimensions = new[]
|
||||
Text = FirstRunSetupOverlayStrings.UIScaleDescription,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y
|
||||
},
|
||||
new SettingsSlider<float, UIScaleSlider>
|
||||
{
|
||||
LabelText = GraphicsSettingsStrings.UIScaling,
|
||||
Current = osuConfig.GetBindable<float>(OsuSetting.UIScale),
|
||||
KeyboardStep = 0.01f,
|
||||
},
|
||||
new InverseScalingDrawSizePreservingFillContainer
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Size = new Vector2(960, 960 / 16f * 9 / 2),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension()
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
new GridContainer
|
||||
{
|
||||
new FillFlowContainer
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Content = new[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(20),
|
||||
Children = new Drawable[]
|
||||
new Drawable[]
|
||||
{
|
||||
new OsuTextFlowContainer(cp => cp.Font = OsuFont.Default.With(size: 24))
|
||||
{
|
||||
Text = FirstRunSetupOverlayStrings.UIScaleDescription,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y
|
||||
},
|
||||
new SettingsSlider<float, UIScaleSlider>
|
||||
{
|
||||
LabelText = GraphicsSettingsStrings.UIScaling,
|
||||
Current = osuConfig.GetBindable<float>(OsuSetting.UIScale),
|
||||
KeyboardStep = 0.01f,
|
||||
},
|
||||
}
|
||||
new SampleScreenContainer(new PinnedMainMenu()),
|
||||
new SampleScreenContainer(new PlaySongSelect()),
|
||||
},
|
||||
// TODO: add more screens here in the future (gameplay / results)
|
||||
// requires a bit more consideration to isolate their behaviour from the "parent" game.
|
||||
}
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
new SampleScreenContainer(new MainMenu()),
|
||||
new SampleScreenContainer(new PlaySongSelect()),
|
||||
},
|
||||
new Drawable[]
|
||||
{
|
||||
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
|
||||
{
|
||||
// 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 HandleNonPositionalInput => false;
|
||||
public override bool PropagatePositionalInputSubTree => 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)
|
||||
{
|
||||
OsuScreenStack stack;
|
||||
@ -105,6 +147,8 @@ namespace osu.Game.Overlays.FirstRunSetup
|
||||
|
||||
OsuLogo logo;
|
||||
|
||||
Padding = new MarginPadding(5);
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new DependencyProvidingContainer
|
||||
@ -120,7 +164,7 @@ namespace osu.Game.Overlays.FirstRunSetup
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ScalingContainer(ScalingMode.Off)
|
||||
new ScalingContainer.ScalingDrawSizePreservingFillContainer(true)
|
||||
{
|
||||
Masking = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -137,10 +181,5 @@ namespace osu.Game.Overlays.FirstRunSetup
|
||||
stack.Push(screen);
|
||||
}
|
||||
}
|
||||
|
||||
private class UIScaleSlider : OsuSliderBar<float>
|
||||
{
|
||||
public override LocalisableString TooltipText => base.TooltipText + "x";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user