mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 09:02:55 +08:00
Merge pull request #1121 from peppy/settings-transition-fixes
Visually improve settings transitions and back button
This commit is contained in:
commit
4ad99a2464
@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Catch
|
||||
public class CatchInputManager : DatabasedKeyBindingInputManager<CatchAction>
|
||||
{
|
||||
public CatchInputManager(RulesetInfo ruleset)
|
||||
: base(ruleset, simultaneousMode: SimultaneousBindingMode.Unique)
|
||||
: base(ruleset, 0, SimultaneousBindingMode.Unique)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
{
|
||||
public class OsuInputManager : DatabasedKeyBindingInputManager<OsuAction>
|
||||
{
|
||||
public OsuInputManager(RulesetInfo ruleset) : base(ruleset, simultaneousMode: SimultaneousBindingMode.Unique)
|
||||
public OsuInputManager(RulesetInfo ruleset) : base(ruleset, 0, SimultaneousBindingMode.Unique)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Input.Bindings;
|
||||
@ -17,7 +18,7 @@ namespace osu.Game.Input.Bindings
|
||||
{
|
||||
private readonly RulesetInfo ruleset;
|
||||
|
||||
private readonly int variant;
|
||||
private readonly int? variant;
|
||||
|
||||
private KeyBindingStore store;
|
||||
|
||||
@ -29,11 +30,14 @@ namespace osu.Game.Input.Bindings
|
||||
/// <param name="ruleset">A reference to identify the current <see cref="Ruleset"/>. Used to lookup mappings. Null for global mappings.</param>
|
||||
/// <param name="variant">An optional variant for the specified <see cref="Ruleset"/>. Used when a ruleset has more than one possible keyboard layouts.</param>
|
||||
/// <param name="simultaneousMode">Specify how to deal with multiple matches of <see cref="KeyCombination"/>s and <see cref="T"/>s.</param>
|
||||
protected DatabasedKeyBindingInputManager(RulesetInfo ruleset = null, int variant = 0, SimultaneousBindingMode simultaneousMode = SimultaneousBindingMode.None)
|
||||
protected DatabasedKeyBindingInputManager(RulesetInfo ruleset = null, int? variant = null, SimultaneousBindingMode simultaneousMode = SimultaneousBindingMode.None)
|
||||
: base(simultaneousMode)
|
||||
{
|
||||
this.ruleset = ruleset;
|
||||
this.variant = variant;
|
||||
|
||||
if (ruleset != null && variant == null)
|
||||
throw new InvalidOperationException($"{nameof(variant)} can not be null when a non-null {nameof(ruleset)} is provided.");
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -182,7 +182,11 @@ namespace osu.Game
|
||||
LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add);
|
||||
LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add);
|
||||
LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add);
|
||||
LoadComponentAsync(settings = new MainSettings { Depth = -1 }, overlayContent.Add);
|
||||
LoadComponentAsync(settings = new MainSettings
|
||||
{
|
||||
GetToolbarHeight = () => ToolbarOffset,
|
||||
Depth = -1
|
||||
}, overlayContent.Add);
|
||||
LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add);
|
||||
LoadComponentAsync(musicController = new MusicController
|
||||
{
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Overlays.Settings.Sections;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -40,27 +41,35 @@ namespace osu.Game.Overlays
|
||||
public MainSettings()
|
||||
: base(true)
|
||||
{
|
||||
keyBindingOverlay = new KeyBindingOverlay { Depth = 1 };
|
||||
keyBindingOverlay = new KeyBindingOverlay
|
||||
{
|
||||
Depth = 1,
|
||||
Anchor = Anchor.TopRight,
|
||||
};
|
||||
keyBindingOverlay.StateChanged += keyBindingOverlay_StateChanged;
|
||||
}
|
||||
|
||||
public override bool AcceptsFocus => keyBindingOverlay.State != Visibility.Visible;
|
||||
|
||||
private const float hidden_width = 120;
|
||||
|
||||
private void keyBindingOverlay_StateChanged(VisibilityContainer container, Visibility visibility)
|
||||
{
|
||||
const float hidden_width = 120;
|
||||
|
||||
switch (visibility)
|
||||
{
|
||||
case Visibility.Visible:
|
||||
Background.FadeTo(0.9f, 500, Easing.OutQuint);
|
||||
SectionsContainer.FadeOut(100);
|
||||
ContentContainer.MoveToX(hidden_width - ContentContainer.DrawWidth, 500, Easing.OutQuint);
|
||||
Background.FadeTo(0.9f, 300, Easing.OutQuint);
|
||||
Sidebar?.FadeColour(Color4.DarkGray, 300, Easing.OutQuint);
|
||||
|
||||
SectionsContainer.FadeOut(300, Easing.OutQuint);
|
||||
ContentContainer.MoveToX(hidden_width - WIDTH, 500, Easing.OutQuint);
|
||||
|
||||
backButton.Delay(100).FadeIn(100);
|
||||
break;
|
||||
case Visibility.Hidden:
|
||||
Background.FadeTo(0.6f, 500, Easing.OutQuint);
|
||||
Sidebar?.FadeColour(Color4.White, 300, Easing.OutQuint);
|
||||
|
||||
SectionsContainer.FadeIn(500, Easing.OutQuint);
|
||||
ContentContainer.MoveToX(0, 500, Easing.OutQuint);
|
||||
|
||||
@ -69,39 +78,26 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
keyBindingOverlay.State = Visibility.Hidden;
|
||||
}
|
||||
protected override float ExpandedPosition => keyBindingOverlay.State == Visibility.Visible ? hidden_width - WIDTH : base.ExpandedPosition;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddInternal(keyBindingOverlay);
|
||||
AddInternal(backButton = new BackButton
|
||||
ContentContainer.Add(keyBindingOverlay);
|
||||
|
||||
ContentContainer.Add(backButton = new BackButton
|
||||
{
|
||||
Alpha = 0,
|
||||
Height = 150,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Width = hidden_width,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Action = () => keyBindingOverlay.Hide()
|
||||
});
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
keyBindingOverlay.Margin = new MarginPadding { Left = ContentContainer.Margin.Left + ContentContainer.DrawWidth + ContentContainer.X };
|
||||
|
||||
backButton.Margin = new MarginPadding { Left = ContentContainer.Margin.Left };
|
||||
backButton.Width = ContentContainer.DrawWidth + ContentContainer.X;
|
||||
}
|
||||
|
||||
private class BackButton : OsuClickableContainer
|
||||
{
|
||||
private FillFlowContainer flow;
|
||||
private AspectContainer aspect;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -116,29 +112,22 @@ namespace osu.Game.Overlays
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
flow = new FillFlowContainer
|
||||
new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Y = 0.4f,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new SpriteIcon { Size = new Vector2(15), Shadow = true, Icon = FontAwesome.fa_chevron_left },
|
||||
new SpriteIcon { Size = new Vector2(15), Shadow = true, Icon = FontAwesome.fa_chevron_left },
|
||||
new SpriteIcon { Size = new Vector2(15), Shadow = true, Icon = FontAwesome.fa_chevron_left },
|
||||
}
|
||||
Y = -15,
|
||||
Size = new Vector2(15),
|
||||
Shadow = true,
|
||||
Icon = FontAwesome.fa_chevron_left
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
RelativePositionAxes = Axes.Y,
|
||||
Y = 0.7f,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Y = 15,
|
||||
TextSize = 12,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Origin = Anchor.Centre,
|
||||
Text = @"back",
|
||||
},
|
||||
}
|
||||
@ -146,18 +135,6 @@ namespace osu.Game.Overlays
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
flow.TransformSpacingTo(new Vector2(5), 500, Easing.OutQuint);
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
flow.TransformSpacingTo(new Vector2(0), 500, Easing.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
aspect.ScaleTo(0.75f, 2000, Easing.OutQuint);
|
||||
@ -171,4 +148,4 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
@ -25,7 +26,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
public const float SIDEBAR_WIDTH = Sidebar.DEFAULT_WIDTH;
|
||||
|
||||
private const float width = 400;
|
||||
protected const float WIDTH = 400;
|
||||
|
||||
private const float sidebar_padding = 10;
|
||||
|
||||
@ -33,14 +34,17 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected override Container<Drawable> Content => ContentContainer;
|
||||
|
||||
private Sidebar sidebar;
|
||||
protected Sidebar Sidebar;
|
||||
private SidebarButton selectedSidebarButton;
|
||||
|
||||
protected SettingsSectionsContainer SectionsContainer;
|
||||
|
||||
private SearchTextBox searchTextBox;
|
||||
|
||||
private Func<float> getToolbarHeight;
|
||||
/// <summary>
|
||||
/// Provide a source for the toolbar height.
|
||||
/// </summary>
|
||||
public Func<float> GetToolbarHeight;
|
||||
|
||||
private readonly bool showSidebar;
|
||||
|
||||
@ -55,17 +59,20 @@ namespace osu.Game.Overlays
|
||||
|
||||
protected virtual IEnumerable<SettingsSection> CreateSections() => null;
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuGame game)
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = ContentContainer = new Container
|
||||
{
|
||||
Width = width,
|
||||
Width = WIDTH,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Background = new Box
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Scale = new Vector2(2, 1), // over-extend to the left for transitions
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.6f,
|
||||
@ -94,20 +101,18 @@ namespace osu.Game.Overlays
|
||||
|
||||
if (showSidebar)
|
||||
{
|
||||
AddInternal(sidebar = new Sidebar { Width = SIDEBAR_WIDTH });
|
||||
AddInternal(Sidebar = new Sidebar { Width = SIDEBAR_WIDTH });
|
||||
|
||||
SectionsContainer.SelectedSection.ValueChanged += section =>
|
||||
{
|
||||
selectedSidebarButton.Selected = false;
|
||||
selectedSidebarButton = sidebar.Children.Single(b => b.Section == section);
|
||||
selectedSidebarButton = Sidebar.Children.Single(b => b.Section == section);
|
||||
selectedSidebarButton.Selected = true;
|
||||
};
|
||||
}
|
||||
|
||||
searchTextBox.Current.ValueChanged += newValue => SectionsContainer.SearchContainer.SearchTerm = newValue;
|
||||
|
||||
getToolbarHeight = () => game?.ToolbarOffset ?? 0;
|
||||
|
||||
CreateSections()?.ForEach(AddSection);
|
||||
}
|
||||
|
||||
@ -115,7 +120,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
SectionsContainer.Add(section);
|
||||
|
||||
if (sidebar != null)
|
||||
if (Sidebar != null)
|
||||
{
|
||||
var button = new SidebarButton
|
||||
{
|
||||
@ -123,15 +128,15 @@ namespace osu.Game.Overlays
|
||||
Action = s =>
|
||||
{
|
||||
SectionsContainer.ScrollTo(s);
|
||||
sidebar.State = ExpandedState.Contracted;
|
||||
Sidebar.State = ExpandedState.Contracted;
|
||||
},
|
||||
};
|
||||
|
||||
sidebar.Add(button);
|
||||
Sidebar.Add(button);
|
||||
|
||||
if (selectedSidebarButton == null)
|
||||
{
|
||||
selectedSidebarButton = sidebar.Children.First();
|
||||
selectedSidebarButton = Sidebar.Children.First();
|
||||
selectedSidebarButton.Selected = true;
|
||||
}
|
||||
}
|
||||
@ -145,20 +150,24 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
base.PopIn();
|
||||
|
||||
ContentContainer.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
sidebar?.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
this.FadeTo(1, TRANSITION_LENGTH / 2);
|
||||
ContentContainer.MoveToX(ExpandedPosition, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
|
||||
Sidebar?.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
this.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
|
||||
searchTextBox.HoldFocus = true;
|
||||
}
|
||||
|
||||
protected virtual float ExpandedPosition => 0;
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
base.PopOut();
|
||||
|
||||
ContentContainer.MoveToX(-width, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
sidebar?.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
this.FadeTo(0, TRANSITION_LENGTH / 2);
|
||||
ContentContainer.MoveToX(-WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
|
||||
Sidebar?.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||
|
||||
searchTextBox.HoldFocus = false;
|
||||
if (searchTextBox.HasFocus)
|
||||
@ -179,8 +188,8 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
ContentContainer.Margin = new MarginPadding { Left = sidebar?.DrawWidth ?? 0 };
|
||||
ContentContainer.Padding = new MarginPadding { Top = getToolbarHeight() };
|
||||
ContentContainer.Margin = new MarginPadding { Left = Sidebar?.DrawWidth ?? 0 };
|
||||
ContentContainer.Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
|
||||
}
|
||||
|
||||
protected class SettingsSectionsContainer : SectionsContainer<SettingsSection>
|
||||
|
Loading…
Reference in New Issue
Block a user