1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 15:23:11 +08:00

Merge branch 'master' into fix-spinner-ignoring-actions

This commit is contained in:
Shane Woolcock 2017-08-18 16:25:26 +09:30
commit f951120775
14 changed files with 106 additions and 93 deletions

View File

@ -10,16 +10,20 @@ using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using OpenTK; using OpenTK;
using osu.Game.Rulesets.Osu;
using osu.Framework.Allocation;
using osu.Game.Rulesets;
namespace osu.Desktop.Tests.Visual namespace osu.Desktop.Tests.Visual
{ {
internal class TestCaseHitObjects : OsuTestCase internal class TestCaseHitObjects : OsuTestCase
{ {
private readonly FramedClock framedClock; private FramedClock framedClock;
private bool auto; private bool auto;
public TestCaseHitObjects() [BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
{ {
var rateAdjustClock = new StopwatchClock(true); var rateAdjustClock = new StopwatchClock(true);
framedClock = new FramedClock(rateAdjustClock); framedClock = new FramedClock(rateAdjustClock);
@ -39,7 +43,7 @@ namespace osu.Desktop.Tests.Visual
Clock = framedClock, Clock = framedClock,
Children = new[] Children = new[]
{ {
playfieldContainer = new Container { RelativeSizeAxes = Axes.Both }, playfieldContainer = new OsuInputManager(rulesets.GetRuleset(0)) { RelativeSizeAxes = Axes.Both },
approachContainer = new Container { RelativeSizeAxes = Axes.Both } approachContainer = new Container { RelativeSizeAxes = Axes.Both }
} }
}; };
@ -49,8 +53,8 @@ namespace osu.Desktop.Tests.Visual
private HitObjectType mode = HitObjectType.Slider; private HitObjectType mode = HitObjectType.Slider;
private readonly Container playfieldContainer; private Container playfieldContainer;
private readonly Container approachContainer; private Container approachContainer;
private void loadHitobjects(HitObjectType mode) private void loadHitobjects(HitObjectType mode)
{ {

View File

@ -10,7 +10,7 @@ namespace osu.Game.Rulesets.Catch
public class CatchInputManager : DatabasedKeyBindingInputManager<CatchAction> public class CatchInputManager : DatabasedKeyBindingInputManager<CatchAction>
{ {
public CatchInputManager(RulesetInfo ruleset) public CatchInputManager(RulesetInfo ruleset)
: base(ruleset, simultaneousMode: SimultaneousBindingMode.Unique) : base(ruleset, 0, SimultaneousBindingMode.Unique)
{ {
} }
} }

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Osu
{ {
public class OsuInputManager : DatabasedKeyBindingInputManager<OsuAction> public class OsuInputManager : DatabasedKeyBindingInputManager<OsuAction>
{ {
public OsuInputManager(RulesetInfo ruleset) : base(ruleset, simultaneousMode: SimultaneousBindingMode.Unique) public OsuInputManager(RulesetInfo ruleset) : base(ruleset, 0, SimultaneousBindingMode.Unique)
{ {
} }

View File

@ -331,6 +331,7 @@ namespace osu.Game.Beatmaps.Formats
if (speedMultiplier != difficultyPoint.SpeedMultiplier) if (speedMultiplier != difficultyPoint.SpeedMultiplier)
{ {
beatmap.ControlPointInfo.DifficultyPoints.RemoveAll(x => x.Time == time);
beatmap.ControlPointInfo.DifficultyPoints.Add(new DifficultyControlPoint beatmap.ControlPointInfo.DifficultyPoints.Add(new DifficultyControlPoint
{ {
Time = time, Time = time,

View File

@ -7,6 +7,7 @@ using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
@ -16,7 +17,7 @@ using osu.Game.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public class OsuButton : Button public class OsuButton : Button, IFilterable
{ {
private Box hover; private Box hover;
@ -108,5 +109,15 @@ namespace osu.Game.Graphics.UserInterface
Content.ScaleTo(1, 1000, Easing.OutElastic); Content.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args); return base.OnMouseUp(state, args);
} }
public string[] FilterTerms => new[] { Text };
public bool MatchingFilter
{
set
{
this.FadeTo(value ? 1 : 0);
}
}
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
@ -34,6 +35,9 @@ namespace osu.Game.Input.Bindings
{ {
this.ruleset = ruleset; this.ruleset = ruleset;
this.variant = variant; 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] [BackgroundDependencyLoader]

View File

@ -182,7 +182,11 @@ namespace osu.Game
LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add);
LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add);
LoadComponentAsync(chat = new ChatOverlay { 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(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add);
LoadComponentAsync(musicController = new MusicController LoadComponentAsync(musicController = new MusicController
{ {

View File

@ -13,6 +13,7 @@ using osu.Game.Overlays.Settings;
using osu.Game.Overlays.Settings.Sections; using osu.Game.Overlays.Settings.Sections;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using OpenTK; using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
@ -40,27 +41,35 @@ namespace osu.Game.Overlays
public MainSettings() public MainSettings()
: base(true) : base(true)
{ {
keyBindingOverlay = new KeyBindingOverlay { Depth = 1 }; keyBindingOverlay = new KeyBindingOverlay
{
Depth = 1,
Anchor = Anchor.TopRight,
};
keyBindingOverlay.StateChanged += keyBindingOverlay_StateChanged; keyBindingOverlay.StateChanged += keyBindingOverlay_StateChanged;
} }
public override bool AcceptsFocus => keyBindingOverlay.State != Visibility.Visible; public override bool AcceptsFocus => keyBindingOverlay.State != Visibility.Visible;
private const float hidden_width = 120;
private void keyBindingOverlay_StateChanged(VisibilityContainer container, Visibility visibility) private void keyBindingOverlay_StateChanged(VisibilityContainer container, Visibility visibility)
{ {
const float hidden_width = 120;
switch (visibility) switch (visibility)
{ {
case Visibility.Visible: case Visibility.Visible:
Background.FadeTo(0.9f, 500, Easing.OutQuint); Background.FadeTo(0.9f, 300, Easing.OutQuint);
SectionsContainer.FadeOut(100); Sidebar?.FadeColour(Color4.DarkGray, 300, Easing.OutQuint);
ContentContainer.MoveToX(hidden_width - ContentContainer.DrawWidth, 500, Easing.OutQuint);
SectionsContainer.FadeOut(300, Easing.OutQuint);
ContentContainer.MoveToX(hidden_width - WIDTH, 500, Easing.OutQuint);
backButton.Delay(100).FadeIn(100); backButton.Delay(100).FadeIn(100);
break; break;
case Visibility.Hidden: case Visibility.Hidden:
Background.FadeTo(0.6f, 500, Easing.OutQuint); Background.FadeTo(0.6f, 500, Easing.OutQuint);
Sidebar?.FadeColour(Color4.White, 300, Easing.OutQuint);
SectionsContainer.FadeIn(500, Easing.OutQuint); SectionsContainer.FadeIn(500, Easing.OutQuint);
ContentContainer.MoveToX(0, 500, Easing.OutQuint); ContentContainer.MoveToX(0, 500, Easing.OutQuint);
@ -69,39 +78,26 @@ namespace osu.Game.Overlays
} }
} }
protected override void PopOut() protected override float ExpandedPosition => keyBindingOverlay.State == Visibility.Visible ? hidden_width - WIDTH : base.ExpandedPosition;
{
base.PopOut();
keyBindingOverlay.State = Visibility.Hidden;
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
AddInternal(keyBindingOverlay); ContentContainer.Add(keyBindingOverlay);
AddInternal(backButton = new BackButton
ContentContainer.Add(backButton = new BackButton
{ {
Alpha = 0, Alpha = 0,
Height = 150, Width = hidden_width,
Anchor = Anchor.CentreLeft, RelativeSizeAxes = Axes.Y,
Origin = Anchor.CentreLeft, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Action = () => keyBindingOverlay.Hide() 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 class BackButton : OsuClickableContainer
{ {
private FillFlowContainer flow;
private AspectContainer aspect; private AspectContainer aspect;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -116,29 +112,22 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Children = new Drawable[] Children = new Drawable[]
{ {
flow = new FillFlowContainer new SpriteIcon
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.Centre,
RelativePositionAxes = Axes.Y,
Y = 0.4f,
AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Direction = FillDirection.Horizontal, Y = -15,
Children = new[] Size = new Vector2(15),
{ Shadow = true,
new SpriteIcon { Size = new Vector2(15), Shadow = true, Icon = FontAwesome.fa_chevron_left }, 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 },
}
}, },
new OsuSpriteText new OsuSpriteText
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.Centre,
RelativePositionAxes = Axes.Y, Origin = Anchor.Centre,
Y = 0.7f, Y = 15,
TextSize = 12, TextSize = 12,
Font = @"Exo2.0-Bold", Font = @"Exo2.0-Bold",
Origin = Anchor.Centre,
Text = @"back", 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) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{ {
aspect.ScaleTo(0.75f, 2000, Easing.OutQuint); aspect.ScaleTo(0.75f, 2000, Easing.OutQuint);

View File

@ -258,7 +258,10 @@ namespace osu.Game.Overlays
Type = EdgeEffectType.Glow, Type = EdgeEffectType.Glow,
Radius = 8, Radius = 8,
}; };
}
protected override void LoadComplete()
{
updateGlow(); updateGlow();
FinishTransforms(true); FinishTransforms(true);
} }

View File

@ -171,7 +171,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
break; break;
} }
if (form != null) GetContainingInputManager().ChangeFocus(form); if (form != null) GetContainingInputManager()?.ChangeFocus(form);
} }
public override bool AcceptsFocus => true; public override bool AcceptsFocus => true;

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
@ -25,7 +26,7 @@ namespace osu.Game.Overlays
public const float SIDEBAR_WIDTH = Sidebar.DEFAULT_WIDTH; public const float SIDEBAR_WIDTH = Sidebar.DEFAULT_WIDTH;
private const float width = 400; protected const float WIDTH = 400;
private const float sidebar_padding = 10; private const float sidebar_padding = 10;
@ -33,14 +34,17 @@ namespace osu.Game.Overlays
protected override Container<Drawable> Content => ContentContainer; protected override Container<Drawable> Content => ContentContainer;
private Sidebar sidebar; protected Sidebar Sidebar;
private SidebarButton selectedSidebarButton; private SidebarButton selectedSidebarButton;
protected SettingsSectionsContainer SectionsContainer; protected SettingsSectionsContainer SectionsContainer;
private SearchTextBox searchTextBox; private SearchTextBox searchTextBox;
private Func<float> getToolbarHeight; /// <summary>
/// Provide a source for the toolbar height.
/// </summary>
public Func<float> GetToolbarHeight;
private readonly bool showSidebar; private readonly bool showSidebar;
@ -55,17 +59,20 @@ namespace osu.Game.Overlays
protected virtual IEnumerable<SettingsSection> CreateSections() => null; protected virtual IEnumerable<SettingsSection> CreateSections() => null;
[BackgroundDependencyLoader(permitNulls: true)] [BackgroundDependencyLoader]
private void load(OsuGame game) private void load()
{ {
InternalChild = ContentContainer = new Container InternalChild = ContentContainer = new Container
{ {
Width = width, Width = WIDTH,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Children = new Drawable[] Children = new Drawable[]
{ {
Background = new Box Background = new Box
{ {
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Scale = new Vector2(2, 1), // over-extend to the left for transitions
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Black, Colour = Color4.Black,
Alpha = 0.6f, Alpha = 0.6f,
@ -94,20 +101,18 @@ namespace osu.Game.Overlays
if (showSidebar) if (showSidebar)
{ {
AddInternal(sidebar = new Sidebar { Width = SIDEBAR_WIDTH }); AddInternal(Sidebar = new Sidebar { Width = SIDEBAR_WIDTH });
SectionsContainer.SelectedSection.ValueChanged += section => SectionsContainer.SelectedSection.ValueChanged += section =>
{ {
selectedSidebarButton.Selected = false; selectedSidebarButton.Selected = false;
selectedSidebarButton = sidebar.Children.Single(b => b.Section == section); selectedSidebarButton = Sidebar.Children.Single(b => b.Section == section);
selectedSidebarButton.Selected = true; selectedSidebarButton.Selected = true;
}; };
} }
searchTextBox.Current.ValueChanged += newValue => SectionsContainer.SearchContainer.SearchTerm = newValue; searchTextBox.Current.ValueChanged += newValue => SectionsContainer.SearchContainer.SearchTerm = newValue;
getToolbarHeight = () => game?.ToolbarOffset ?? 0;
CreateSections()?.ForEach(AddSection); CreateSections()?.ForEach(AddSection);
} }
@ -115,7 +120,7 @@ namespace osu.Game.Overlays
{ {
SectionsContainer.Add(section); SectionsContainer.Add(section);
if (sidebar != null) if (Sidebar != null)
{ {
var button = new SidebarButton var button = new SidebarButton
{ {
@ -123,15 +128,15 @@ namespace osu.Game.Overlays
Action = s => Action = s =>
{ {
SectionsContainer.ScrollTo(s); SectionsContainer.ScrollTo(s);
sidebar.State = ExpandedState.Contracted; Sidebar.State = ExpandedState.Contracted;
}, },
}; };
sidebar.Add(button); Sidebar.Add(button);
if (selectedSidebarButton == null) if (selectedSidebarButton == null)
{ {
selectedSidebarButton = sidebar.Children.First(); selectedSidebarButton = Sidebar.Children.First();
selectedSidebarButton.Selected = true; selectedSidebarButton.Selected = true;
} }
} }
@ -145,20 +150,24 @@ namespace osu.Game.Overlays
{ {
base.PopIn(); base.PopIn();
ContentContainer.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint); ContentContainer.MoveToX(ExpandedPosition, TRANSITION_LENGTH, Easing.OutQuint);
sidebar?.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(1, TRANSITION_LENGTH / 2); Sidebar?.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
searchTextBox.HoldFocus = true; searchTextBox.HoldFocus = true;
} }
protected virtual float ExpandedPosition => 0;
protected override void PopOut() protected override void PopOut()
{ {
base.PopOut(); base.PopOut();
ContentContainer.MoveToX(-width, TRANSITION_LENGTH, Easing.OutQuint); ContentContainer.MoveToX(-WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
sidebar?.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(0, TRANSITION_LENGTH / 2); Sidebar?.MoveToX(-SIDEBAR_WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
searchTextBox.HoldFocus = false; searchTextBox.HoldFocus = false;
if (searchTextBox.HasFocus) if (searchTextBox.HasFocus)
@ -179,8 +188,8 @@ namespace osu.Game.Overlays
{ {
base.UpdateAfterChildren(); base.UpdateAfterChildren();
ContentContainer.Margin = new MarginPadding { Left = sidebar?.DrawWidth ?? 0 }; ContentContainer.Margin = new MarginPadding { Left = Sidebar?.DrawWidth ?? 0 };
ContentContainer.Padding = new MarginPadding { Top = getToolbarHeight() }; ContentContainer.Padding = new MarginPadding { Top = GetToolbarHeight?.Invoke() ?? 0 };
} }
protected class SettingsSectionsContainer : SectionsContainer<SettingsSection> protected class SettingsSectionsContainer : SectionsContainer<SettingsSection>

View File

@ -58,8 +58,8 @@ namespace osu.Game.Overlays.Toolbar
AutoSizeAxes = Axes.X, AutoSizeAxes = Axes.X,
Children = new Drawable[] Children = new Drawable[]
{ {
new ToolbarSocialButton(),
new ToolbarChatButton(), new ToolbarChatButton(),
new ToolbarSocialButton(),
new ToolbarMusicButton(), new ToolbarMusicButton(),
new ToolbarButton new ToolbarButton
{ {

View File

@ -6,7 +6,7 @@ using SQLite.Net.Attributes;
namespace osu.Game.Rulesets namespace osu.Game.Rulesets
{ {
public class RulesetInfo public class RulesetInfo : IEquatable<RulesetInfo>
{ {
[PrimaryKey, AutoIncrement] [PrimaryKey, AutoIncrement]
public int? ID { get; set; } public int? ID { get; set; }
@ -21,5 +21,7 @@ namespace osu.Game.Rulesets
public bool Available { get; set; } public bool Available { get; set; }
public virtual Ruleset CreateInstance() => (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo), this); public virtual Ruleset CreateInstance() => (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo), this);
public bool Equals(RulesetInfo other) => other != null && ID == other.ID && Available == other.Available && Name == other.Name && InstantiationInfo == other.InstantiationInfo;
} }
} }

View File

@ -253,8 +253,6 @@ namespace osu.Game.Screens.Select
} }
else else
{ {
Ruleset.Value = beatmap.Ruleset;
if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID)
sampleChangeDifficulty.Play(); sampleChangeDifficulty.Play();
else else