Merge remote-tracking branch 'upstream/master' into hide-useless-beatmap-info

This commit is contained in:
Dean Herbert
2017-12-26 20:18:53 +09:00
131 changed files with 10325 additions and 795 deletions

View File

@ -75,7 +75,8 @@ namespace osu.Game.Screens.Select
scrollableContent.Clear(false);
itemsCache.Invalidate();
scrollPositionCache.Invalidate();
BeatmapSetsChanged?.Invoke();
Schedule(() => BeatmapSetsChanged?.Invoke());
}));
}
}
@ -142,7 +143,6 @@ namespace osu.Game.Screens.Select
if (newSet == null)
{
itemsCache.Invalidate();
SelectNext();
return;
}
@ -155,6 +155,7 @@ namespace osu.Game.Screens.Select
select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == selectedBeatmap?.Beatmap.ID) ?? newSet);
itemsCache.Invalidate();
Schedule(() => BeatmapSetsChanged?.Invoke());
});
}
@ -181,6 +182,9 @@ namespace osu.Game.Screens.Select
/// <param name="skipDifficulties">Whether to skip individual difficulties and only increment over full groups.</param>
public void SelectNext(int direction = 1, bool skipDifficulties = true)
{
if (!Items.Any())
return;
int originalIndex = Items.IndexOf(selectedBeatmap?.Drawables.First());
int currentIndex = originalIndex;
@ -509,7 +513,7 @@ namespace osu.Game.Screens.Select
currentY += DrawHeight / 2;
scrollableContent.Height = currentY;
if (selectedBeatmapSet != null && selectedBeatmapSet.State.Value != CarouselItemState.Selected)
if (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected)
{
selectedBeatmapSet = null;
SelectionChanged?.Invoke(null);

View File

@ -17,6 +17,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Extensions.Color4Extensions;
using osu.Game.Screens.Select.Details;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
namespace osu.Game.Screens.Select
{
@ -334,7 +335,7 @@ namespace osu.Game.Screens.Select
TextSize = 14,
},
},
textFlow = new TextFlowContainer
textFlow = new OsuTextFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@ -359,7 +360,7 @@ namespace osu.Game.Screens.Select
private void setTextAsync(string text)
{
LoadComponentAsync(new TextFlowContainer(s => s.TextSize = 14)
LoadComponentAsync(new OsuTextFlowContainer(s => s.TextSize = 14)
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,

View File

@ -69,6 +69,8 @@ namespace osu.Game.Screens.Select
Depth = Info?.Depth + 1 ?? 0,
}, newInfo =>
{
State = beatmap == null ? Visibility.Hidden : Visibility.Visible;
// ensure we ourselves are visible if not already.
if (!IsPresent)
State = Visibility.Visible;

View File

@ -75,7 +75,7 @@ namespace osu.Game.Screens.Select
{
Children = new Drawable[]
{
new Box
Background = new Box
{
Colour = Color4.Black,
Alpha = 0.8f,
@ -167,6 +167,8 @@ namespace osu.Game.Screens.Select
private Bindable<bool> showConverted;
public readonly Box Background;
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuColour colours, OsuGame osu, OsuConfigManager config)
{

View File

@ -0,0 +1,33 @@
// 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 osu.Game.Graphics;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Screens.Select
{
public class ImportFromStablePopup : PopupDialog
{
public ImportFromStablePopup(Action importFromStable)
{
HeaderText = @"You have no beatmaps!";
BodyText = "An existing copy of osu! was found, though.\nWould you like to import your beatmaps?";
Icon = FontAwesome.fa_trash_o;
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = @"Yes please!",
Action = importFromStable
},
new PopupDialogCancelButton
{
Text = @"No, I'd like to start from scratch",
},
};
}
}
}

View File

@ -19,17 +19,14 @@ using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using System.Linq;
using osu.Framework.Configuration;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Framework.Logging;
using osu.Game.Rulesets;
using osu.Framework.Input;
namespace osu.Game.Screens.Select.Leaderboards
{
public class Leaderboard : Container
{
private const double fade_duration = 200;
private const double fade_duration = 300;
private readonly ScrollContainer scrollContainer;
private readonly Container placeholderContainer;
@ -51,7 +48,7 @@ namespace osu.Game.Screens.Select.Leaderboards
{
scores = value;
scrollFlow?.FadeOut(fade_duration).Expire();
scrollFlow?.FadeOut(fade_duration, Easing.OutQuint).Expire();
scrollFlow = null;
loading.Hide();
@ -90,6 +87,7 @@ namespace osu.Game.Screens.Select.Leaderboards
}
private LeaderboardScope scope;
public LeaderboardScope Scope
{
get { return scope; }
@ -103,6 +101,7 @@ namespace osu.Game.Screens.Select.Leaderboards
}
private PlaceholderState placeholderState;
protected PlaceholderState PlaceholderState
{
get { return placeholderState; }
@ -118,19 +117,18 @@ namespace osu.Game.Screens.Select.Leaderboards
OnRetry = updateScores,
});
break;
case PlaceholderState.Unavailable:
replacePlaceholder(new MessagePlaceholder(@"Leaderboards are not available for this beatmap!"));
break;
case PlaceholderState.NoScores:
replacePlaceholder(new MessagePlaceholder(@"No records yet!"));
break;
case PlaceholderState.NotLoggedIn:
replacePlaceholder(new MessagePlaceholder(@"Please login to view online leaderboards!"));
break;
case PlaceholderState.NotSupporter:
replacePlaceholder(new MessagePlaceholder(@"Please invest in a supporter tag to view this leaderboard!"));
break;
default:
replacePlaceholder(null);
break;
@ -150,18 +148,13 @@ namespace osu.Game.Screens.Select.Leaderboards
loading = new LoadingAnimation(),
placeholderContainer = new Container
{
Alpha = 0,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both
},
};
}
private APIAccess api;
private BeatmapInfo beatmap;
private OsuGame osuGame;
private ScheduledDelegate pendingBeatmapSwitch;
@ -229,15 +222,15 @@ namespace osu.Game.Screens.Select.Leaderboards
return;
}
if (api?.IsLoggedIn != true)
if (Beatmap?.OnlineBeatmapID == null)
{
PlaceholderState = PlaceholderState.NotLoggedIn;
PlaceholderState = PlaceholderState.Unavailable;
return;
}
if (Beatmap?.OnlineBeatmapID == null)
if (api?.IsLoggedIn != true)
{
PlaceholderState = PlaceholderState.NetworkFailure;
PlaceholderState = PlaceholderState.NotLoggedIn;
return;
}
@ -272,23 +265,22 @@ namespace osu.Game.Screens.Select.Leaderboards
private void replacePlaceholder(Placeholder placeholder)
{
if (placeholder == null)
{
placeholderContainer.FadeOutFromOne(fade_duration, Easing.OutQuint);
placeholderContainer.Clear(true);
var existingPlaceholder = placeholderContainer.Children.LastOrDefault() as Placeholder;
if (placeholder != null && placeholder.Equals(existingPlaceholder))
return;
}
var existingPlaceholder = placeholderContainer.Children.FirstOrDefault() as Placeholder;
existingPlaceholder?.FadeOut(150, Easing.OutQuint).Expire();
if (placeholder.Equals(existingPlaceholder))
if (placeholder == null)
return;
Scores = null;
placeholderContainer.Clear(true);
placeholderContainer.Child = placeholder;
placeholderContainer.FadeInFromZero(fade_duration, Easing.OutQuint);
placeholderContainer.Add(placeholder);
placeholder.ScaleTo(0.8f).Then().ScaleTo(1, fade_duration * 3, Easing.OutQuint);
placeholder.FadeInFromZero(fade_duration, Easing.OutQuint);
}
protected override void Update()
@ -319,101 +311,6 @@ namespace osu.Game.Screens.Select.Leaderboards
}
}
}
private abstract class Placeholder : FillFlowContainer, IEquatable<Placeholder>
{
public virtual bool Equals(Placeholder other) => GetType() == other?.GetType();
}
private class MessagePlaceholder : Placeholder
{
private readonly string message;
public MessagePlaceholder(string message)
{
Direction = FillDirection.Horizontal;
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
new SpriteIcon
{
Icon = FontAwesome.fa_exclamation_circle,
Size = new Vector2(26),
Margin = new MarginPadding { Right = 10 },
},
new OsuSpriteText
{
Text = this.message = message,
TextSize = 22,
},
};
}
public override bool Equals(Placeholder other) => (other as MessagePlaceholder)?.message == message;
}
private class RetrievalFailurePlaceholder : Placeholder
{
public Action OnRetry;
public RetrievalFailurePlaceholder()
{
Direction = FillDirection.Horizontal;
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
new RetryButton
{
Action = () => OnRetry?.Invoke(),
Margin = new MarginPadding { Right = 10 },
},
new OsuSpriteText
{
Anchor = Anchor.TopLeft,
Text = @"Couldn't retrieve scores!",
TextSize = 22,
},
};
}
private class RetryButton : OsuHoverContainer
{
private readonly SpriteIcon icon;
public Action Action;
public RetryButton()
{
Height = 26;
Width = 26;
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),
Shadow = true,
},
};
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
icon.ScaleTo(0.8f, 4000, Easing.OutQuint);
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
icon.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args);
}
}
}
}
public enum LeaderboardScope
@ -429,6 +326,7 @@ namespace osu.Game.Screens.Select.Leaderboards
Successful,
Retrieving,
NetworkFailure,
Unavailable,
NoScores,
NotLoggedIn,
NotSupporter,

View File

@ -0,0 +1,38 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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
{
public class MessagePlaceholder : Placeholder
{
private readonly string message;
public MessagePlaceholder(string message)
{
Direction = FillDirection.Horizontal;
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
new SpriteIcon
{
Icon = FontAwesome.fa_exclamation_circle,
Size = new Vector2(26),
Margin = new MarginPadding { Right = 10 },
},
new OsuSpriteText
{
Text = this.message = message,
TextSize = 22,
},
};
}
public override bool Equals(Placeholder other) => (other as MessagePlaceholder)?.message == message;
}
}

View File

@ -0,0 +1,20 @@
// 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Screens.Select.Leaderboards
{
public abstract class Placeholder : FillFlowContainer, IEquatable<Placeholder>
{
protected Placeholder()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
public virtual bool Equals(Placeholder other) => GetType() == other?.GetType();
}
}

View File

@ -0,0 +1,77 @@
// 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 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
{
public class RetrievalFailurePlaceholder : Placeholder
{
public Action OnRetry;
public RetrievalFailurePlaceholder()
{
Direction = FillDirection.Horizontal;
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
new RetryButton
{
Action = () => OnRetry?.Invoke(),
Margin = new MarginPadding { Right = 10 },
},
new OsuSpriteText
{
Anchor = Anchor.TopLeft,
Text = @"Couldn't retrieve scores!",
TextSize = 22,
},
};
}
public class RetryButton : OsuHoverContainer
{
private readonly SpriteIcon icon;
public Action Action;
public RetryButton()
{
Height = 26;
Width = 26;
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),
Shadow = true,
},
};
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{
icon.ScaleTo(0.8f, 4000, Easing.OutQuint);
return base.OnMouseDown(state, args);
}
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{
icon.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(state, args);
}
}
}
}

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Play;
@ -45,8 +46,8 @@ namespace osu.Game.Screens.Select
private SampleChannel sampleConfirm;
[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio)
[BackgroundDependencyLoader(true)]
private void load(OsuColour colours, AudioManager audio, BeatmapManager beatmaps, DialogOverlay dialogOverlay)
{
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
@ -59,6 +60,16 @@ namespace osu.Game.Screens.Select
ValidForResume = false;
Push(new Editor());
}, Key.Number3);
if (dialogOverlay != null)
{
Schedule(() =>
{
// if we have no beatmaps but osu-stable is found, let's prompt the user to import.
if (!beatmaps.GetAllUsableBeatmapSets().Any() && beatmaps.StableInstallationAvailable)
dialogOverlay.Push(new ImportFromStablePopup(() => beatmaps.ImportFromStable()));
});
}
}
protected override void UpdateBeatmap(WorkingBeatmap beatmap)

View File

@ -55,7 +55,7 @@ namespace osu.Game.Screens.Select
protected Container LeftContent;
private readonly BeatmapCarousel carousel;
protected readonly BeatmapCarousel Carousel;
private readonly BeatmapInfoWedge beatmapInfoWedge;
private DialogOverlay dialogOverlay;
private BeatmapManager beatmaps;
@ -103,21 +103,41 @@ namespace osu.Game.Screens.Select
Right = left_area_padding * 2,
}
},
carousel = new BeatmapCarousel
new Container
{
RelativeSizeAxes = Axes.Y,
Size = new Vector2(carousel_width, 1),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
SelectionChanged = carouselSelectionChanged,
BeatmapSetsChanged = carouselBeatmapsLoaded,
},
FilterControl = new FilterControl
{
RelativeSizeAxes = Axes.X,
Height = filter_height,
FilterChanged = c => carousel.Filter(c),
Exit = Exit,
RelativeSizeAxes = Axes.Both,
Masking = true,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 2, //avoid horizontal masking so the panels don't clip when screen stack is pushed.
Child = new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 0.5f,
Children = new Drawable[]
{
Carousel = new BeatmapCarousel
{
Masking = false,
RelativeSizeAxes = Axes.Y,
Size = new Vector2(carousel_width, 1),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
SelectionChanged = carouselSelectionChanged,
BeatmapSetsChanged = carouselBeatmapsLoaded,
},
FilterControl = new FilterControl
{
RelativeSizeAxes = Axes.X,
Height = filter_height,
FilterChanged = c => Carousel.Filter(c),
Background = { Width = 2 },
Exit = Exit,
},
}
},
},
beatmapInfoWedge = new BeatmapInfoWedge
{
@ -129,7 +149,7 @@ namespace osu.Game.Screens.Select
Right = left_area_padding,
},
},
new ResetScrollContainer(() => carousel.ScrollToSelected())
new ResetScrollContainer(() => Carousel.ScrollToSelected())
{
RelativeSizeAxes = Axes.Y,
Width = 250,
@ -189,15 +209,15 @@ namespace osu.Game.Screens.Select
initialAddSetsTask = new CancellationTokenSource();
carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets();
Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSets();
Beatmap.DisabledChanged += disabled => carousel.AllowSelection = !disabled;
Beatmap.DisabledChanged += disabled => Carousel.AllowSelection = !disabled;
Beatmap.TriggerChange();
Beatmap.ValueChanged += b =>
{
if (IsCurrentScreen)
carousel.SelectBeatmap(b?.BeatmapInfo);
Carousel.SelectBeatmap(b?.BeatmapInfo);
};
}
@ -211,9 +231,9 @@ namespace osu.Game.Screens.Select
{
// if we have a pending filter operation, we want to run it now.
// it could change selection (ie. if the ruleset has been changed).
carousel.FlushPendingFilterOperations();
Carousel.FlushPendingFilterOperations();
carousel.SelectBeatmap(beatmap);
Carousel.SelectBeatmap(beatmap);
if (selectionChangedDebounce?.Completed == false)
{
@ -281,9 +301,9 @@ namespace osu.Game.Screens.Select
private void triggerRandom()
{
if (GetContainingInputManager().CurrentState.Keyboard.ShiftPressed)
carousel.SelectPreviousRandom();
Carousel.SelectPreviousRandom();
else
carousel.SelectNextRandom();
Carousel.SelectNextRandom();
}
protected override void OnEntering(Screen last)
@ -398,7 +418,6 @@ namespace osu.Game.Screens.Select
backgroundModeBeatmap.FadeTo(1, 250);
}
beatmapInfoWedge.State = Visibility.Visible;
beatmapInfoWedge.UpdateBeatmap(beatmap);
}
@ -416,17 +435,17 @@ namespace osu.Game.Screens.Select
}
}
private void onBeatmapSetAdded(BeatmapSetInfo s) => carousel.UpdateBeatmapSet(s);
private void onBeatmapSetRemoved(BeatmapSetInfo s) => carousel.RemoveBeatmapSet(s);
private void onBeatmapRestored(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void onBeatmapHidden(BeatmapInfo b) => carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s);
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void carouselBeatmapsLoaded()
{
if (Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false)
Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo);
else
carousel.SelectNextRandom();
Carousel.SelectNextRandom();
}
private void delete(BeatmapSetInfo beatmap)