Merge remote-tracking branch 'origin/master' into non-null-ruleset

# Conflicts:
#	osu.Game/Screens/Select/FilterControl.cs
This commit is contained in:
smoogipoo
2018-07-02 15:05:34 +09:00
117 changed files with 3735 additions and 1701 deletions

View File

@ -64,7 +64,7 @@ namespace osu.Game.Screens.Select
Sort = sort,
SearchText = searchTextBox.Text,
AllowConvertedBeatmaps = showConverted,
Ruleset = ruleset
Ruleset = ruleset.Value
};
public Action Exit;
@ -166,14 +166,14 @@ namespace osu.Game.Screens.Select
searchTextBox.HoldFocus = true;
}
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private Bindable<bool> showConverted;
public readonly Box Background;
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuColour colours, Bindable<RulesetInfo> parentRuleset, OsuConfigManager config)
private void load(OsuColour colours, IBindable<RulesetInfo> parentRuleset, OsuConfigManager config)
{
sortTabs.AccentColour = colours.GreenLight;
@ -181,8 +181,7 @@ namespace osu.Game.Screens.Select
showConverted.ValueChanged += val => updateCriteria();
ruleset.BindTo(parentRuleset);
ruleset.ValueChanged += val => updateCriteria();
ruleset.TriggerChange();
ruleset.BindValueChanged(val => updateCriteria(), true);
}
private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria());

View File

@ -32,7 +32,7 @@ namespace osu.Game.Screens.Select.Leaderboards
private FillFlowContainer<LeaderboardScore> scrollFlow;
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
public Action<Score> ScoreSelected;
@ -146,7 +146,7 @@ namespace osu.Game.Screens.Select.Leaderboards
replacePlaceholder(new MessagePlaceholder(@"Please sign in to view online leaderboards!"));
break;
case PlaceholderState.NotSupporter:
replacePlaceholder(new MessagePlaceholder(@"Please invest in a supporter tag to view this leaderboard!"));
replacePlaceholder(new MessagePlaceholder(@"Please invest in an osu!supporter tag to view this leaderboard!"));
break;
default:
replacePlaceholder(null);
@ -193,7 +193,7 @@ namespace osu.Game.Screens.Select.Leaderboards
}
[BackgroundDependencyLoader(permitNulls: true)]
private void load(APIAccess api, Bindable<RulesetInfo> parentRuleset)
private void load(APIAccess api, IBindable<RulesetInfo> parentRuleset)
{
this.api = api;
@ -332,23 +332,4 @@ namespace osu.Game.Screens.Select.Leaderboards
}
}
}
public enum LeaderboardScope
{
Local,
Country,
Global,
Friend,
}
public enum PlaceholderState
{
Successful,
Retrieving,
NetworkFailure,
Unavailable,
NoScores,
NotLoggedIn,
NotSupporter,
}
}

View File

@ -0,0 +1,13 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Screens.Select.Leaderboards
{
public enum LeaderboardScope
{
Local,
Country,
Global,
Friend,
}
}

View File

@ -2,10 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using OpenTK;
namespace osu.Game.Screens.Select.Leaderboards
{
@ -15,22 +12,13 @@ namespace osu.Game.Screens.Select.Leaderboards
public MessagePlaceholder(string message)
{
Direction = FillDirection.Horizontal;
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
AddIcon(FontAwesome.fa_exclamation_circle, cp =>
{
new SpriteIcon
{
Icon = FontAwesome.fa_exclamation_circle,
Size = new Vector2(26),
Margin = new MarginPadding { Right = 10 },
},
new OsuSpriteText
{
Text = this.message = message,
TextSize = 22,
},
};
cp.TextSize = TEXT_SIZE;
cp.Padding = new MarginPadding { Right = 10 };
});
AddText(this.message = message);
}
public override bool Equals(Placeholder other) => (other as MessagePlaceholder)?.message == message;

View File

@ -3,16 +3,27 @@
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
namespace osu.Game.Screens.Select.Leaderboards
{
public abstract class Placeholder : FillFlowContainer, IEquatable<Placeholder>
public abstract class Placeholder : OsuTextFlowContainer, IEquatable<Placeholder>
{
protected const float TEXT_SIZE = 22;
public override bool HandleMouseInput => true;
protected Placeholder()
: base(cp => cp.TextSize = TEXT_SIZE)
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
TextAnchor = Anchor.TopCentre;
Padding = new MarginPadding(20);
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
}
public virtual bool Equals(Placeholder other) => GetType() == other?.GetType();

View File

@ -0,0 +1,16 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Screens.Select.Leaderboards
{
public enum PlaceholderState
{
Successful,
Retrieving,
NetworkFailure,
Unavailable,
NoScores,
NotLoggedIn,
NotSupporter,
}
}

View File

@ -3,11 +3,9 @@
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using OpenTK;
namespace osu.Game.Screens.Select.Leaderboards
@ -18,22 +16,13 @@ namespace osu.Game.Screens.Select.Leaderboards
public RetrievalFailurePlaceholder()
{
Direction = FillDirection.Horizontal;
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
AddArbitraryDrawable(new RetryButton
{
new RetryButton
{
Action = () => OnRetry?.Invoke(),
Margin = new MarginPadding { Right = 10 },
},
new OsuSpriteText
{
Anchor = Anchor.TopLeft,
Text = @"Couldn't retrieve scores!",
TextSize = 22,
},
};
Action = () => OnRetry?.Invoke(),
Padding = new MarginPadding { Right = 10 }
});
AddText(@"Couldn't retrieve scores!");
}
public class RetryButton : OsuHoverContainer
@ -44,18 +33,16 @@ namespace osu.Game.Screens.Select.Leaderboards
public RetryButton()
{
Height = 26;
Width = 26;
AutoSizeAxes = Axes.Both;
Child = new OsuClickableContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Action = () => Action?.Invoke(),
Child = icon = new SpriteIcon
{
Icon = FontAwesome.fa_refresh,
Size = new Vector2(26),
Size = new Vector2(TEXT_SIZE),
Shadow = true,
},
};

View File

@ -127,7 +127,7 @@ namespace osu.Game.Screens.Select
Size = new Vector2(carousel_width, 1),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
SelectionChanged = carouselSelectionChanged,
SelectionChanged = updateSelectedBeatmap,
BeatmapSetsChanged = carouselBeatmapsLoaded,
},
FilterControl = new FilterControl
@ -180,12 +180,14 @@ namespace osu.Game.Screens.Select
}
}
[BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours)
{
dependencies.CacheAs(this);
dependencies.CacheAs(Ruleset);
dependencies.CacheAs<IBindable<RulesetInfo>>(Ruleset);
base.Ruleset.ValueChanged += r => updateSelectedBeatmap(beatmapNoDebounce);
if (Footer != null)
{
@ -253,9 +255,6 @@ namespace osu.Game.Screens.Select
private ScheduledDelegate selectionChangedDebounce;
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
private BeatmapInfo beatmapNoDebounce;
private void workingBeatmapChanged(WorkingBeatmap beatmap)
{
if (beatmap is DummyWorkingBeatmap) return;
@ -269,11 +268,17 @@ namespace osu.Game.Screens.Select
}
}
// We need to keep track of the last selected beatmap ignoring debounce to play the correct selection sounds.
private BeatmapInfo beatmapNoDebounce;
private RulesetInfo rulesetNoDebounce;
/// <summary>
/// selection has been changed as the result of interaction with the carousel.
/// selection has been changed as the result of a user interaction.
/// </summary>
private void carouselSelectionChanged(BeatmapInfo beatmap)
private void updateSelectedBeatmap(BeatmapInfo beatmap)
{
var ruleset = base.Ruleset.Value;
void performLoad()
{
// We may be arriving here due to another component changing the bindable Beatmap.
@ -283,19 +288,21 @@ namespace osu.Game.Screens.Select
bool preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID;
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value);
Ruleset.Value = base.Ruleset.Value;
ensurePlayingSelected(preview);
}
Ruleset.Value = ruleset;
UpdateBeatmap(Beatmap.Value);
}
if (beatmap?.Equals(beatmapNoDebounce) == true)
if (beatmap?.Equals(beatmapNoDebounce) == true && ruleset?.Equals(rulesetNoDebounce) == true)
return;
selectionChangedDebounce?.Cancel();
beatmapNoDebounce = beatmap;
rulesetNoDebounce = ruleset;
if (beatmap == null)
performLoad();
@ -464,7 +471,7 @@ namespace osu.Game.Screens.Select
{
// in the case random selection failed, we want to trigger selectionChanged
// to show the dummy beatmap (we have nothing else to display).
carouselSelectionChanged(null);
updateSelectedBeatmap(null);
}
}