1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 19:22:56 +08:00

Merge branch 'master' into segmented-slider-paths-3

This commit is contained in:
Dean Herbert 2019-12-10 14:28:20 +09:00 committed by GitHub
commit 5f3d163772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 91 additions and 46 deletions

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Catch.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
InternalChild = new SkinnableSprite("Gameplay/catch/fruit-catcher-idle") InternalChild = new SkinnableSprite("Gameplay/catch/fruit-catcher-idle", confineMode: ConfineMode.ScaleDownToFit)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,

View File

@ -151,7 +151,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
return new MenuItem[] return new MenuItem[]
{ {
new OsuMenuItem($"Delete {"control point".ToQuantity(selectedPoints)}", MenuItemType.Destructive, () => deleteSelected()) new OsuMenuItem($"Delete {"control point".ToQuantity(selectedPoints, selectedPoints > 1 ? ShowQuantityAs.Numeric : ShowQuantityAs.None)}", MenuItemType.Destructive, () => deleteSelected())
}; };
} }
} }

View File

@ -95,6 +95,42 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert("filter count is 1", () => songSelect.FilterCount == 1); AddAssert("filter count is 1", () => songSelect.FilterCount == 1);
} }
[Test]
public void TestNoFilterOnSimpleResume()
{
addRulesetImportStep(0);
addRulesetImportStep(0);
createSongSelect();
AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddStep("return", () => songSelect.MakeCurrent());
AddUntilStep("wait for current", () => songSelect.IsCurrentScreen());
AddAssert("filter count is 1", () => songSelect.FilterCount == 1);
}
[Test]
public void TestFilterOnResumeAfterChange()
{
addRulesetImportStep(0);
addRulesetImportStep(0);
AddStep("change convert setting", () => config.Set(OsuSetting.ShowConvertedBeatmaps, false));
createSongSelect();
AddStep("push child screen", () => Stack.Push(new TestSceneOsuScreenStack.TestScreen("test child")));
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddStep("change convert setting", () => config.Set(OsuSetting.ShowConvertedBeatmaps, true));
AddStep("return", () => songSelect.MakeCurrent());
AddUntilStep("wait for current", () => songSelect.IsCurrentScreen());
AddAssert("filter count is 2", () => songSelect.FilterCount == 2);
}
[Test] [Test]
public void TestAudioResuming() public void TestAudioResuming()
{ {

View File

@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual
AddAssert("Parallax is off", () => stack.ParallaxAmount == 0); AddAssert("Parallax is off", () => stack.ParallaxAmount == 0);
} }
private class TestScreen : ScreenWithBeatmapBackground public class TestScreen : ScreenWithBeatmapBackground
{ {
private readonly string screenText; private readonly string screenText;

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -9,8 +10,8 @@ using osu.Game.Rulesets;
namespace osu.Game.Configuration namespace osu.Game.Configuration
{ {
public abstract class DatabasedConfigManager<T> : ConfigManager<T> public abstract class DatabasedConfigManager<TLookup> : ConfigManager<TLookup>
where T : struct where TLookup : struct, Enum
{ {
private readonly SettingsStore settings; private readonly SettingsStore settings;
@ -53,7 +54,7 @@ namespace osu.Game.Configuration
private readonly List<DatabasedSetting> dirtySettings = new List<DatabasedSetting>(); private readonly List<DatabasedSetting> dirtySettings = new List<DatabasedSetting>();
protected override void AddBindable<TBindable>(T lookup, Bindable<TBindable> bindable) protected override void AddBindable<TBindable>(TLookup lookup, Bindable<TBindable> bindable)
{ {
base.AddBindable(lookup, bindable); base.AddBindable(lookup, bindable);

View File

@ -1,12 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Configuration; using osu.Framework.Configuration;
namespace osu.Game.Configuration namespace osu.Game.Configuration
{ {
public class InMemoryConfigManager<T> : ConfigManager<T> public class InMemoryConfigManager<TLookup> : ConfigManager<TLookup>
where T : struct where TLookup : struct, Enum
{ {
public InMemoryConfigManager() public InMemoryConfigManager()
{ {

View File

@ -24,7 +24,7 @@ namespace osu.Game.Graphics
/// </summary> /// </summary>
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns> /// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
public static TransformSequence<T> FadeAccent<T>(this T accentedDrawable, Color4 newColour, double duration = 0, Easing easing = Easing.None) public static TransformSequence<T> FadeAccent<T>(this T accentedDrawable, Color4 newColour, double duration = 0, Easing easing = Easing.None)
where T : IHasAccentColour where T : class, IHasAccentColour
=> accentedDrawable.TransformTo(nameof(accentedDrawable.AccentColour), newColour, duration, easing); => accentedDrawable.TransformTo(nameof(accentedDrawable.AccentColour), newColour, duration, easing);
/// <summary> /// <summary>

View File

@ -6,12 +6,10 @@ using System;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
public class OsuEnumDropdown<T> : OsuDropdown<T> public class OsuEnumDropdown<T> : OsuDropdown<T>
where T : struct, Enum
{ {
public OsuEnumDropdown() public OsuEnumDropdown()
{ {
if (!typeof(T).IsEnum)
throw new InvalidOperationException("OsuEnumDropdown only supports enums as the generic type argument");
Items = (T[])Enum.GetValues(typeof(T)); Items = (T[])Enum.GetValues(typeof(T));
} }
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osuTK; using osuTK;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -11,6 +12,7 @@ using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.SearchableList namespace osu.Game.Overlays.SearchableList
{ {
public class DisplayStyleControl<T> : Container public class DisplayStyleControl<T> : Container
where T : struct, Enum
{ {
public readonly SlimEnumDropdown<T> Dropdown; public readonly SlimEnumDropdown<T> Dropdown;
public readonly Bindable<PanelDisplayStyle> DisplayStyle = new Bindable<PanelDisplayStyle>(); public readonly Bindable<PanelDisplayStyle> DisplayStyle = new Bindable<PanelDisplayStyle>();

View File

@ -13,7 +13,9 @@ using osu.Framework.Graphics.Shapes;
namespace osu.Game.Overlays.SearchableList namespace osu.Game.Overlays.SearchableList
{ {
public abstract class SearchableListFilterControl<T, U> : Container public abstract class SearchableListFilterControl<TTab, TCategory> : Container
where TTab : struct, Enum
where TCategory : struct, Enum
{ {
private const float padding = 10; private const float padding = 10;
@ -21,12 +23,12 @@ namespace osu.Game.Overlays.SearchableList
private readonly Box tabStrip; private readonly Box tabStrip;
public readonly SearchTextBox Search; public readonly SearchTextBox Search;
public readonly PageTabControl<T> Tabs; public readonly PageTabControl<TTab> Tabs;
public readonly DisplayStyleControl<U> DisplayStyleControl; public readonly DisplayStyleControl<TCategory> DisplayStyleControl;
protected abstract Color4 BackgroundColour { get; } protected abstract Color4 BackgroundColour { get; }
protected abstract T DefaultTab { get; } protected abstract TTab DefaultTab { get; }
protected abstract U DefaultCategory { get; } protected abstract TCategory DefaultCategory { get; }
protected virtual Drawable CreateSupplementaryControls() => null; protected virtual Drawable CreateSupplementaryControls() => null;
/// <summary> /// <summary>
@ -36,9 +38,6 @@ namespace osu.Game.Overlays.SearchableList
protected SearchableListFilterControl() protected SearchableListFilterControl()
{ {
if (!typeof(T).IsEnum)
throw new InvalidOperationException("SearchableListFilterControl's sort tabs only support enums as the generic type argument");
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
var controls = CreateSupplementaryControls(); var controls = CreateSupplementaryControls();
@ -90,7 +89,7 @@ namespace osu.Game.Overlays.SearchableList
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Right = 225 }, Padding = new MarginPadding { Right = 225 },
Child = Tabs = new PageTabControl<T> Child = Tabs = new PageTabControl<TTab>
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
}, },
@ -105,7 +104,7 @@ namespace osu.Game.Overlays.SearchableList
}, },
}, },
}, },
DisplayStyleControl = new DisplayStyleControl<U> DisplayStyleControl = new DisplayStyleControl<TCategory>
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,

View File

@ -14,6 +14,7 @@ using osu.Framework.Graphics.Sprites;
namespace osu.Game.Overlays.SearchableList namespace osu.Game.Overlays.SearchableList
{ {
public abstract class SearchableListHeader<T> : Container public abstract class SearchableListHeader<T> : Container
where T : struct, Enum
{ {
public readonly HeaderTabControl<T> Tabs; public readonly HeaderTabControl<T> Tabs;
@ -24,9 +25,6 @@ namespace osu.Game.Overlays.SearchableList
protected SearchableListHeader() protected SearchableListHeader()
{ {
if (!typeof(T).IsEnum)
throw new InvalidOperationException("BrowseHeader only supports enums as the generic type argument");
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
Height = 90; Height = 90;

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -16,19 +17,22 @@ namespace osu.Game.Overlays.SearchableList
public const float WIDTH_PADDING = 80; public const float WIDTH_PADDING = 80;
} }
public abstract class SearchableListOverlay<T, U, S> : SearchableListOverlay public abstract class SearchableListOverlay<THeader, TTab, TCategory> : SearchableListOverlay
where THeader : struct, Enum
where TTab : struct, Enum
where TCategory : struct, Enum
{ {
private readonly Container scrollContainer; private readonly Container scrollContainer;
protected readonly SearchableListHeader<T> Header; protected readonly SearchableListHeader<THeader> Header;
protected readonly SearchableListFilterControl<U, S> Filter; protected readonly SearchableListFilterControl<TTab, TCategory> Filter;
protected readonly FillFlowContainer ScrollFlow; protected readonly FillFlowContainer ScrollFlow;
protected abstract Color4 BackgroundColour { get; } protected abstract Color4 BackgroundColour { get; }
protected abstract Color4 TrianglesColourLight { get; } protected abstract Color4 TrianglesColourLight { get; }
protected abstract Color4 TrianglesColourDark { get; } protected abstract Color4 TrianglesColourDark { get; }
protected abstract SearchableListHeader<T> CreateHeader(); protected abstract SearchableListHeader<THeader> CreateHeader();
protected abstract SearchableListFilterControl<U, S> CreateFilterControl(); protected abstract SearchableListFilterControl<TTab, TCategory> CreateFilterControl();
protected SearchableListOverlay() protected SearchableListOverlay()
{ {

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -11,6 +12,7 @@ using osuTK;
namespace osu.Game.Overlays.SearchableList namespace osu.Game.Overlays.SearchableList
{ {
public class SlimEnumDropdown<T> : OsuEnumDropdown<T> public class SlimEnumDropdown<T> : OsuEnumDropdown<T>
where T : struct, Enum
{ {
protected override DropdownHeader CreateHeader() => new SlimDropdownHeader(); protected override DropdownHeader CreateHeader() => new SlimDropdownHeader();

View File

@ -1,12 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings namespace osu.Game.Overlays.Settings
{ {
public class SettingsEnumDropdown<T> : SettingsDropdown<T> public class SettingsEnumDropdown<T> : SettingsDropdown<T>
where T : struct, Enum
{ {
protected override OsuDropdown<T> CreateDropdown() => new DropdownControl(); protected override OsuDropdown<T> CreateDropdown() => new DropdownControl();

View File

@ -1,12 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Game.Configuration; using osu.Game.Configuration;
namespace osu.Game.Rulesets.Configuration namespace osu.Game.Rulesets.Configuration
{ {
public abstract class RulesetConfigManager<T> : DatabasedConfigManager<T>, IRulesetConfigManager public abstract class RulesetConfigManager<TLookup> : DatabasedConfigManager<TLookup>, IRulesetConfigManager
where T : struct where TLookup : struct, Enum
{ {
protected RulesetConfigManager(SettingsStore settings, RulesetInfo ruleset, int? variant = null) protected RulesetConfigManager(SettingsStore settings, RulesetInfo ruleset, int? variant = null)
: base(settings, ruleset, variant) : base(settings, ruleset, variant)

View File

@ -44,7 +44,7 @@ namespace osu.Game.Screens.Select
} }
public struct OptionalRange<T> : IEquatable<OptionalRange<T>> public struct OptionalRange<T> : IEquatable<OptionalRange<T>>
where T : struct, IComparable where T : struct
{ {
public bool HasFilter => Max != null || Min != null; public bool HasFilter => Max != null || Min != null;

View File

@ -170,7 +170,7 @@ namespace osu.Game.Screens.Select
} }
private static void updateCriteriaRange<T>(ref FilterCriteria.OptionalRange<T> range, string op, T value) private static void updateCriteriaRange<T>(ref FilterCriteria.OptionalRange<T> range, string op, T value)
where T : struct, IComparable where T : struct
{ {
switch (op) switch (op)
{ {

View File

@ -262,8 +262,10 @@ namespace osu.Game.Screens.Select
protected virtual void ApplyFilterToCarousel(FilterCriteria criteria) protected virtual void ApplyFilterToCarousel(FilterCriteria criteria)
{ {
if (this.IsCurrentScreen()) // if not the current screen, we want to get carousel in a good presentation state before displaying (resume or enter).
Carousel.Filter(criteria); bool shouldDebounce = this.IsCurrentScreen();
Schedule(() => Carousel.Filter(criteria, shouldDebounce));
} }
private DependencyContainer dependencies; private DependencyContainer dependencies;
@ -437,8 +439,6 @@ namespace osu.Game.Screens.Select
{ {
base.OnEntering(last); base.OnEntering(last);
Carousel.Filter(FilterControl.CreateCriteria(), false);
this.FadeInFromZero(250); this.FadeInFromZero(250);
FilterControl.Activate(); FilterControl.Activate();
} }

View File

@ -1,11 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Configuration; using osu.Framework.Configuration;
namespace osu.Game.Skinning namespace osu.Game.Skinning
{ {
public class SkinConfigManager<T> : ConfigManager<T> where T : struct public class SkinConfigManager<TLookup> : ConfigManager<TLookup> where TLookup : struct, Enum
{ {
protected override void PerformLoad() protected override void PerformLoad()
{ {

View File

@ -41,7 +41,7 @@ namespace osu.Game.Storyboards.Drawables
/// </summary> /// </summary>
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns> /// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
public static TransformSequence<T> TransformFlipH<T>(this T flippable, bool newValue, double delay = 0) public static TransformSequence<T> TransformFlipH<T>(this T flippable, bool newValue, double delay = 0)
where T : IFlippable where T : class, IFlippable
=> flippable.TransformTo(flippable.PopulateTransform(new TransformFlipH(), newValue, delay)); => flippable.TransformTo(flippable.PopulateTransform(new TransformFlipH(), newValue, delay));
/// <summary> /// <summary>
@ -49,7 +49,7 @@ namespace osu.Game.Storyboards.Drawables
/// </summary> /// </summary>
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns> /// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
public static TransformSequence<T> TransformFlipV<T>(this T flippable, bool newValue, double delay = 0) public static TransformSequence<T> TransformFlipV<T>(this T flippable, bool newValue, double delay = 0)
where T : IFlippable where T : class, IFlippable
=> flippable.TransformTo(flippable.PopulateTransform(new TransformFlipV(), newValue, delay)); => flippable.TransformTo(flippable.PopulateTransform(new TransformFlipV(), newValue, delay));
} }
} }

View File

@ -12,7 +12,7 @@ namespace osu.Game.Tests.Visual
/// </summary> /// </summary>
public abstract class ScreenTestScene : ManualInputManagerTestScene public abstract class ScreenTestScene : ManualInputManagerTestScene
{ {
private readonly OsuScreenStack stack; protected readonly OsuScreenStack Stack;
private readonly Container content; private readonly Container content;
@ -22,16 +22,16 @@ namespace osu.Game.Tests.Visual
{ {
base.Content.AddRange(new Drawable[] base.Content.AddRange(new Drawable[]
{ {
stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both }, Stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both },
content = new Container { RelativeSizeAxes = Axes.Both } content = new Container { RelativeSizeAxes = Axes.Both }
}); });
} }
protected void LoadScreen(OsuScreen screen) protected void LoadScreen(OsuScreen screen)
{ {
if (stack.CurrentScreen != null) if (Stack.CurrentScreen != null)
stack.Exit(); Stack.Exit();
stack.Push(screen); Stack.Push(screen);
} }
} }
} }