mirror of
https://github.com/ppy/osu.git
synced 2025-03-18 06:27:18 +08:00
Merge pull request #10082 from EVAST9919/profile-sections-update
Update section headers in ProfileOverlay in line with web
This commit is contained in:
commit
54520faa7e
@ -1,40 +0,0 @@
|
||||
// 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.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Profile.Sections;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneProfileCounterPill : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Red);
|
||||
|
||||
private readonly CounterPill pill;
|
||||
private readonly BindableInt value = new BindableInt();
|
||||
|
||||
public TestSceneProfileCounterPill()
|
||||
{
|
||||
Child = pill = new CounterPill
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current = { BindTarget = value }
|
||||
};
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVisibility()
|
||||
{
|
||||
AddStep("Set value to 0", () => value.Value = 0);
|
||||
AddAssert("Check hidden", () => !pill.IsPresent);
|
||||
AddStep("Set value to 10", () => value.Value = 10);
|
||||
AddAssert("Check visible", () => pill.IsPresent);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
// 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.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Overlays.Profile.Sections;
|
||||
using osu.Framework.Testing;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
public class TestScenePaginatedContainerHeader : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink);
|
||||
|
||||
private PaginatedContainerHeader header;
|
||||
|
||||
[Test]
|
||||
public void TestHiddenCounter()
|
||||
{
|
||||
AddStep("Create header", () => createHeader("Header with hidden counter", CounterVisibilityState.AlwaysHidden));
|
||||
AddAssert("Value is 0", () => header.Current.Value == 0);
|
||||
AddAssert("Counter is hidden", () => header.ChildrenOfType<CounterPill>().First().Alpha == 0);
|
||||
AddStep("Set count 10", () => header.Current.Value = 10);
|
||||
AddAssert("Value is 10", () => header.Current.Value == 10);
|
||||
AddAssert("Counter is hidden", () => header.ChildrenOfType<CounterPill>().First().Alpha == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVisibleCounter()
|
||||
{
|
||||
AddStep("Create header", () => createHeader("Header with visible counter", CounterVisibilityState.AlwaysVisible));
|
||||
AddAssert("Value is 0", () => header.Current.Value == 0);
|
||||
AddAssert("Counter is visible", () => header.ChildrenOfType<CounterPill>().First().Alpha == 1);
|
||||
AddStep("Set count 10", () => header.Current.Value = 10);
|
||||
AddAssert("Value is 10", () => header.Current.Value == 10);
|
||||
AddAssert("Counter is visible", () => header.ChildrenOfType<CounterPill>().First().Alpha == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVisibleWhenZeroCounter()
|
||||
{
|
||||
AddStep("Create header", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenZero));
|
||||
AddAssert("Value is 0", () => header.Current.Value == 0);
|
||||
AddAssert("Counter is visible", () => header.ChildrenOfType<CounterPill>().First().Alpha == 1);
|
||||
AddStep("Set count 10", () => header.Current.Value = 10);
|
||||
AddAssert("Value is 10", () => header.Current.Value == 10);
|
||||
AddAssert("Counter is hidden", () => header.ChildrenOfType<CounterPill>().First().Alpha == 0);
|
||||
AddStep("Set count 0", () => header.Current.Value = 0);
|
||||
AddAssert("Value is 0", () => header.Current.Value == 0);
|
||||
AddAssert("Counter is visible", () => header.ChildrenOfType<CounterPill>().First().Alpha == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInitialVisibility()
|
||||
{
|
||||
AddStep("Create header with 0 value", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenZero, 0));
|
||||
AddAssert("Value is 0", () => header.Current.Value == 0);
|
||||
AddAssert("Counter is visible", () => header.ChildrenOfType<CounterPill>().First().Alpha == 1);
|
||||
|
||||
AddStep("Create header with 1 value", () => createHeader("Header with visible when zero counter", CounterVisibilityState.VisibleWhenZero, 1));
|
||||
AddAssert("Value is 1", () => header.Current.Value == 1);
|
||||
AddAssert("Counter is hidden", () => header.ChildrenOfType<CounterPill>().First().Alpha == 0);
|
||||
}
|
||||
|
||||
private void createHeader(string text, CounterVisibilityState state, int initialValue = 0)
|
||||
{
|
||||
Clear();
|
||||
Add(header = new PaginatedContainerHeader(text, state)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current = { Value = initialValue }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Profile
|
||||
{
|
||||
Horizontal = UserProfileOverlay.CONTENT_X_MARGIN,
|
||||
Top = 15,
|
||||
Bottom = 10,
|
||||
Bottom = 20,
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API;
|
||||
@ -18,16 +19,43 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
||||
private const float panel_padding = 10f;
|
||||
private readonly BeatmapSetType type;
|
||||
|
||||
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.")
|
||||
: base(user, header, missing)
|
||||
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string headerText)
|
||||
: base(user, headerText, "", CounterVisibilityState.AlwaysVisible)
|
||||
{
|
||||
this.type = type;
|
||||
|
||||
ItemsPerPage = 6;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
ItemsContainer.Spacing = new Vector2(panel_padding);
|
||||
}
|
||||
|
||||
protected override int GetCount(User user)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case BeatmapSetType.Favourite:
|
||||
return user.FavouriteBeatmapsetCount;
|
||||
|
||||
case BeatmapSetType.Graveyard:
|
||||
return user.GraveyardBeatmapsetCount;
|
||||
|
||||
case BeatmapSetType.Loved:
|
||||
return user.LovedBeatmapsetCount;
|
||||
|
||||
case BeatmapSetType.RankedAndApproved:
|
||||
return user.RankedAndApprovedBeatmapsetCount;
|
||||
|
||||
case BeatmapSetType.Unranked:
|
||||
return user.UnrankedBeatmapsetCount;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIBeatmapSet>> CreateRequest() =>
|
||||
new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
||||
|
||||
@ -38,15 +66,5 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre,
|
||||
};
|
||||
|
||||
protected override int GetCount(User user) => type switch
|
||||
{
|
||||
BeatmapSetType.Favourite => user.FavouriteBeatmapsetCount,
|
||||
BeatmapSetType.Graveyard => user.GraveyardBeatmapsetCount,
|
||||
BeatmapSetType.Loved => user.LovedBeatmapsetCount,
|
||||
BeatmapSetType.RankedAndApproved => user.RankedAndApprovedBeatmapsetCount,
|
||||
BeatmapSetType.Unranked => user.UnrankedBeatmapsetCount,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
new PaginatedBeatmapContainer(BeatmapSetType.RankedAndApproved, User, "Ranked & Approved Beatmaps"),
|
||||
new PaginatedBeatmapContainer(BeatmapSetType.Loved, User, "Loved Beatmaps"),
|
||||
new PaginatedBeatmapContainer(BeatmapSetType.Unranked, User, "Pending Beatmaps"),
|
||||
new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, "Graveyarded Beatmaps"),
|
||||
new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, "Graveyarded Beatmaps")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public class CounterPill : CircularContainer
|
||||
{
|
||||
private const int duration = 200;
|
||||
|
||||
public readonly BindableInt Current = new BindableInt();
|
||||
|
||||
private OsuSpriteText counter;
|
||||
@ -23,7 +21,6 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Alpha = 0;
|
||||
Masking = true;
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -36,8 +33,8 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold),
|
||||
Margin = new MarginPadding { Horizontal = 10, Bottom = 1 },
|
||||
Font = OsuFont.GetFont(size: 11.2f, weight: FontWeight.Bold),
|
||||
Colour = colourProvider.Foreground1
|
||||
}
|
||||
};
|
||||
@ -51,14 +48,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
|
||||
private void onCurrentChanged(ValueChangedEvent<int> value)
|
||||
{
|
||||
if (value.NewValue == 0)
|
||||
{
|
||||
this.FadeOut(duration, Easing.OutQuint);
|
||||
return;
|
||||
}
|
||||
|
||||
counter.Text = value.NewValue.ToString("N0");
|
||||
this.FadeIn(duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -18,7 +19,11 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
: base(user, "Most Played Beatmaps", "No records. :(")
|
||||
{
|
||||
ItemsPerPage = 5;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
ItemsContainer.Direction = FillDirection.Vertical;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new PaginatedMostPlayedBeatmapContainer(User),
|
||||
new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", "No performance records. :("),
|
||||
new PaginatedScoreContainer(ScoreType.Recent, User, "Recent Plays (24h)", CounterVisibilityState.VisibleWhenZero),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
|
||||
{
|
||||
public class PaginatedKudosuHistoryContainer : PaginatedContainer<APIKudosuHistory>
|
||||
{
|
||||
public PaginatedKudosuHistoryContainer(Bindable<User> user, string header, string missing)
|
||||
: base(user, header, missing)
|
||||
public PaginatedKudosuHistoryContainer(Bindable<User> user)
|
||||
: base(user, missingText: "This user hasn't received any kudosu!")
|
||||
{
|
||||
ItemsPerPage = 5;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new KudosuInfo(User),
|
||||
new PaginatedKudosuHistoryContainer(User, null, @"This user hasn't received any kudosu!"),
|
||||
new PaginatedKudosuHistoryContainer(User),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,6 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public abstract class PaginatedContainer<TModel> : FillFlowContainer
|
||||
{
|
||||
private readonly ShowMoreButton moreButton;
|
||||
private readonly OsuSpriteText missingText;
|
||||
private APIRequest<List<TModel>> retrievalRequest;
|
||||
private CancellationTokenSource loadCancellation;
|
||||
private readonly BindableInt count = new BindableInt();
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
@ -33,41 +27,40 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
protected int ItemsPerPage;
|
||||
|
||||
protected readonly Bindable<User> User = new Bindable<User>();
|
||||
protected readonly FillFlowContainer ItemsContainer;
|
||||
protected FillFlowContainer ItemsContainer;
|
||||
protected RulesetStore Rulesets;
|
||||
|
||||
protected PaginatedContainer(Bindable<User> user, string header, string missing)
|
||||
{
|
||||
User.BindTo(user);
|
||||
private APIRequest<List<TModel>> retrievalRequest;
|
||||
private CancellationTokenSource loadCancellation;
|
||||
|
||||
private readonly string missingText;
|
||||
private ShowMoreButton moreButton;
|
||||
private OsuSpriteText missing;
|
||||
private PaginatedContainerHeader header;
|
||||
|
||||
private readonly string headerText;
|
||||
private readonly CounterVisibilityState counterVisibilityState;
|
||||
|
||||
protected PaginatedContainer(Bindable<User> user, string headerText = "", string missingText = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
|
||||
{
|
||||
this.headerText = headerText;
|
||||
this.missingText = missingText;
|
||||
this.counterVisibilityState = counterVisibilityState;
|
||||
User.BindTo(user);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Direction = FillDirection.Vertical;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
header = new PaginatedContainerHeader(headerText, counterVisibilityState)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5, 0),
|
||||
Margin = new MarginPadding { Top = 10, Bottom = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = header,
|
||||
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
|
||||
},
|
||||
new CounterPill
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Current = { BindTarget = count }
|
||||
}
|
||||
}
|
||||
Alpha = string.IsNullOrEmpty(headerText) ? 0 : 1
|
||||
},
|
||||
ItemsContainer = new FillFlowContainer
|
||||
{
|
||||
@ -83,18 +76,14 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
Margin = new MarginPadding { Top = 10 },
|
||||
Action = showMore,
|
||||
},
|
||||
missingText = new OsuSpriteText
|
||||
missing = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 15),
|
||||
Text = missing,
|
||||
Text = missingText,
|
||||
Alpha = 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets)
|
||||
{
|
||||
Rulesets = rulesets;
|
||||
|
||||
User.ValueChanged += onUserChanged;
|
||||
@ -112,7 +101,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
if (e.NewValue != null)
|
||||
{
|
||||
showMore();
|
||||
count.Value = GetCount(e.NewValue);
|
||||
SetCount(GetCount(e.NewValue));
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,17 +117,22 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
|
||||
protected virtual void UpdateItems(List<TModel> items) => Schedule(() =>
|
||||
{
|
||||
OnItemsReceived(items);
|
||||
|
||||
if (!items.Any() && VisiblePages == 1)
|
||||
{
|
||||
moreButton.Hide();
|
||||
moreButton.IsLoading = false;
|
||||
missingText.Show();
|
||||
|
||||
if (!string.IsNullOrEmpty(missing.Text))
|
||||
missing.Show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LoadComponentsAsync(items.Select(CreateDrawableItem).Where(d => d != null), drawables =>
|
||||
{
|
||||
missingText.Hide();
|
||||
missing.Hide();
|
||||
moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0);
|
||||
moreButton.IsLoading = false;
|
||||
|
||||
@ -148,6 +142,12 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
|
||||
protected virtual int GetCount(User user) => 0;
|
||||
|
||||
protected void SetCount(int value) => header.Current.Value = value;
|
||||
|
||||
protected virtual void OnItemsReceived(List<TModel> items)
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract APIRequest<List<TModel>> CreateRequest();
|
||||
|
||||
protected abstract Drawable CreateDrawableItem(TModel model);
|
||||
|
123
osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs
Normal file
123
osu.Game/Overlays/Profile/Sections/PaginatedContainerHeader.cs
Normal file
@ -0,0 +1,123 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Bindables;
|
||||
using System;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osuTK;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
public class PaginatedContainerHeader : CompositeDrawable, IHasCurrentValue<int>
|
||||
{
|
||||
private readonly BindableWithCurrent<int> current = new BindableWithCurrent<int>();
|
||||
|
||||
public Bindable<int> Current
|
||||
{
|
||||
get => current.Current;
|
||||
set => current.Current = value;
|
||||
}
|
||||
|
||||
private readonly string text;
|
||||
private readonly CounterVisibilityState counterState;
|
||||
|
||||
private CounterPill counterPill;
|
||||
|
||||
public PaginatedContainerHeader(string text, CounterVisibilityState counterState)
|
||||
{
|
||||
this.text = text;
|
||||
this.counterState = counterState;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Padding = new MarginPadding { Vertical = 10 };
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new CircularContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Height = 0.65f,
|
||||
Width = 3,
|
||||
Masking = true,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreRight,
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Highlight1
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = text,
|
||||
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold),
|
||||
},
|
||||
counterPill = new CounterPill
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Current = { BindTarget = current }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
current.BindValueChanged(onCurrentChanged, true);
|
||||
}
|
||||
|
||||
private void onCurrentChanged(ValueChangedEvent<int> countValue)
|
||||
{
|
||||
float alpha;
|
||||
|
||||
switch (counterState)
|
||||
{
|
||||
case CounterVisibilityState.AlwaysHidden:
|
||||
alpha = 0;
|
||||
break;
|
||||
|
||||
case CounterVisibilityState.AlwaysVisible:
|
||||
alpha = 1;
|
||||
break;
|
||||
|
||||
case CounterVisibilityState.VisibleWhenZero:
|
||||
alpha = current.Value == 0 ? 1 : 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException($"{counterState} has an incorrect value.");
|
||||
}
|
||||
|
||||
counterPill.Alpha = alpha;
|
||||
}
|
||||
}
|
||||
|
||||
public enum CounterVisibilityState
|
||||
{
|
||||
AlwaysHidden,
|
||||
AlwaysVisible,
|
||||
VisibleWhenZero
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
{
|
||||
@ -17,25 +18,43 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
{
|
||||
private readonly ScoreType type;
|
||||
|
||||
public PaginatedScoreContainer(ScoreType type, Bindable<User> user, string header, string missing)
|
||||
: base(user, header, missing)
|
||||
public PaginatedScoreContainer(ScoreType type, Bindable<User> user, string headerText, CounterVisibilityState counterVisibilityState, string missingText = "")
|
||||
: base(user, headerText, missingText, counterVisibilityState)
|
||||
{
|
||||
this.type = type;
|
||||
|
||||
ItemsPerPage = 5;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
ItemsContainer.Direction = FillDirection.Vertical;
|
||||
}
|
||||
|
||||
protected override int GetCount(User user)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ScoreType.Firsts:
|
||||
return user.ScoresFirstCount;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnItemsReceived(List<APILegacyScoreInfo> items)
|
||||
{
|
||||
base.OnItemsReceived(items);
|
||||
|
||||
if (type == ScoreType.Recent)
|
||||
SetCount(items.Count);
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APILegacyScoreInfo>> CreateRequest() =>
|
||||
new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
||||
|
||||
protected override int GetCount(User user) => type switch
|
||||
{
|
||||
ScoreType.Firsts => user.ScoresFirstCount,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
protected override Drawable CreateDrawableItem(APILegacyScoreInfo model)
|
||||
{
|
||||
switch (type)
|
||||
|
@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
Children = new[]
|
||||
{
|
||||
new PaginatedScoreContainer(ScoreType.Best, User, "Best Performance", "No performance records. :("),
|
||||
new PaginatedScoreContainer(ScoreType.Firsts, User, "First Place Ranks", "No awesome performance records yet. :("),
|
||||
new PaginatedScoreContainer(ScoreType.Best, User, "Best Performance", CounterVisibilityState.AlwaysHidden, "No performance records. :("),
|
||||
new PaginatedScoreContainer(ScoreType.Firsts, User, "First Place Ranks", CounterVisibilityState.AlwaysVisible)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -9,15 +9,21 @@ using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.API;
|
||||
using System.Collections.Generic;
|
||||
using osuTK;
|
||||
using osu.Framework.Allocation;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
{
|
||||
public class PaginatedRecentActivityContainer : PaginatedContainer<APIRecentActivity>
|
||||
{
|
||||
public PaginatedRecentActivityContainer(Bindable<User> user, string header, string missing)
|
||||
: base(user, header, missing)
|
||||
public PaginatedRecentActivityContainer(Bindable<User> user)
|
||||
: base(user, missingText: "This user hasn't done anything notable recently!")
|
||||
{
|
||||
ItemsPerPage = 10;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
ItemsContainer.Spacing = new Vector2(0, 8);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
Children = new[]
|
||||
{
|
||||
new PaginatedRecentActivityContainer(User, null, @"This user hasn't done anything notable recently!"),
|
||||
new PaginatedRecentActivityContainer(User),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user