Merge master with conflicts resolved

This commit is contained in:
Andrei Zavatski
2020-11-22 02:13:35 +03:00
110 changed files with 2245 additions and 920 deletions

View File

@ -14,7 +14,7 @@ using osuTK;
namespace osu.Game.Overlays.Profile.Sections.Beatmaps
{
public class PaginatedBeatmapContainer : PaginatedContainer<APIBeatmapSet>
public class PaginatedBeatmapContainer : PaginatedProfileSubsection<APIBeatmapSet>
{
private const float panel_padding = 10f;
private readonly BeatmapSetType type;

View File

@ -32,7 +32,13 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
Child = chart = new ProfileLineChart()
};
protected override void OnUserChanged(ValueChangedEvent<User> e)
protected override void LoadComplete()
{
base.LoadComplete();
User.BindValueChanged(onUserChanged, true);
}
private void onUserChanged(ValueChangedEvent<User> e)
{
var values = GetValues(e.NewValue);

View File

@ -13,7 +13,7 @@ using osu.Game.Users;
namespace osu.Game.Overlays.Profile.Sections.Historical
{
public class PaginatedMostPlayedBeatmapContainer : PaginatedContainer<APIUserMostPlayedBeatmap>
public class PaginatedMostPlayedBeatmapContainer : PaginatedProfileSubsection<APIUserMostPlayedBeatmap>
{
public PaginatedMostPlayedBeatmapContainer(Bindable<User> user)
: base(user, "Most Played Beatmaps", "No records. :(", CounterVisibilityState.AlwaysVisible)

View File

@ -11,7 +11,7 @@ using System.Collections.Generic;
namespace osu.Game.Overlays.Profile.Sections.Kudosu
{
public class PaginatedKudosuHistoryContainer : PaginatedContainer<APIKudosuHistory>
public class PaginatedKudosuHistoryContainer : PaginatedProfileSubsection<APIKudosuHistory>
{
public PaginatedKudosuHistoryContainer(Bindable<User> user)
: base(user, missingText: "This user hasn't received any kudosu!")

View File

@ -12,27 +12,35 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics;
namespace osu.Game.Overlays.Profile.Sections
{
public abstract class PaginatedContainer<TModel> : ProfileSubsection
public abstract class PaginatedProfileSubsection<TModel> : ProfileSubsection
{
[Resolved]
private IAPIProvider api { get; set; }
[Resolved]
protected RulesetStore Rulesets { get; private set; }
protected int VisiblePages;
protected int ItemsPerPage;
protected FillFlowContainer ItemsContainer;
protected FillFlowContainer ItemsContainer { get; private set; }
private APIRequest<List<TModel>> retrievalRequest;
private CancellationTokenSource loadCancellation;
private ShowMoreButton moreButton;
private OsuSpriteText missing;
private readonly string missingText;
protected PaginatedContainer(Bindable<User> user, string headerText = "", string missingText = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
: base(user, headerText, missingText, counterVisibilityState)
protected PaginatedProfileSubsection(Bindable<User> user, string headerText = "", string missingText = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
: base(user, headerText, counterVisibilityState)
{
this.missingText = missingText;
}
protected override Drawable CreateContent() => new FillFlowContainer
@ -56,10 +64,22 @@ namespace osu.Game.Overlays.Profile.Sections
Margin = new MarginPadding { Top = 10 },
Action = showMore,
},
missing = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 15),
Text = missingText,
Alpha = 0,
}
}
};
protected override void OnUserChanged(ValueChangedEvent<User> e)
protected override void LoadComplete()
{
base.LoadComplete();
User.BindValueChanged(onUserChanged, true);
}
private void onUserChanged(ValueChangedEvent<User> e)
{
loadCancellation?.Cancel();
retrievalRequest?.Cancel();
@ -93,15 +113,15 @@ namespace osu.Game.Overlays.Profile.Sections
moreButton.Hide();
moreButton.IsLoading = false;
if (!string.IsNullOrEmpty(Missing.Text))
Missing.Show();
if (!string.IsNullOrEmpty(missingText))
missing.Show();
return;
}
LoadComponentsAsync(items.Select(CreateDrawableItem).Where(d => d != null), drawables =>
{
Missing.Hide();
missing.Hide();
moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0);
moreButton.IsLoading = false;
@ -121,8 +141,9 @@ namespace osu.Game.Overlays.Profile.Sections
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
retrievalRequest?.Cancel();
loadCancellation?.Cancel();
base.Dispose(isDisposing);
}
}
}

View File

@ -5,9 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets;
using osu.Game.Users;
using JetBrains.Annotations;
@ -17,26 +14,20 @@ namespace osu.Game.Overlays.Profile.Sections
{
protected readonly Bindable<User> User = new Bindable<User>();
protected RulesetStore Rulesets { get; private set; }
protected OsuSpriteText Missing { get; private set; }
private readonly string headerText;
private readonly string missingText;
private readonly CounterVisibilityState counterVisibilityState;
private ProfileSubsectionHeader header;
protected ProfileSubsection(Bindable<User> user, string headerText = "", string missingText = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
protected ProfileSubsection(Bindable<User> user, string headerText = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
{
this.headerText = headerText;
this.missingText = missingText;
this.counterVisibilityState = counterVisibilityState;
User.BindTo(user);
}
[BackgroundDependencyLoader]
private void load(RulesetStore rulesets)
private void load()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@ -48,31 +39,13 @@ namespace osu.Game.Overlays.Profile.Sections
{
Alpha = string.IsNullOrEmpty(headerText) ? 0 : 1
},
CreateContent(),
Missing = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 15),
Text = missingText,
Alpha = 0,
},
CreateContent()
};
Rulesets = rulesets;
}
protected override void LoadComplete()
{
base.LoadComplete();
User.BindValueChanged(OnUserChanged, true);
}
[NotNull]
protected abstract Drawable CreateContent();
protected virtual void OnUserChanged(ValueChangedEvent<User> e)
{
}
protected void SetCount(int value) => header.Current.Value = value;
}
}

View File

@ -14,7 +14,7 @@ using osu.Framework.Allocation;
namespace osu.Game.Overlays.Profile.Sections.Ranks
{
public class PaginatedScoreContainer : PaginatedContainer<APILegacyScoreInfo>
public class PaginatedScoreContainer : PaginatedProfileSubsection<APILegacyScoreInfo>
{
private readonly ScoreType type;

View File

@ -13,7 +13,7 @@ using osu.Framework.Allocation;
namespace osu.Game.Overlays.Profile.Sections.Recent
{
public class PaginatedRecentActivityContainer : PaginatedContainer<APIRecentActivity>
public class PaginatedRecentActivityContainer : PaginatedProfileSubsection<APIRecentActivity>
{
public PaginatedRecentActivityContainer(Bindable<User> user)
: base(user, missingText: "This user hasn't done anything notable recently!")