Merge branch 'master' into skin-editor-loc

This commit is contained in:
Dean Herbert 2023-01-17 11:53:08 +09:00 committed by GitHub
commit 1f47def3c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 30 deletions

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
@ -50,7 +48,7 @@ public void Setup() => Schedule(() =>
public void TestBeatmapLink()
{
AddUntilStep("Beatmap overlay displayed", () => Game.ChildrenOfType<BeatmapSetOverlay>().FirstOrDefault()?.State.Value == Visibility.Visible);
AddUntilStep("Beatmap overlay showing content", () => Game.ChildrenOfType<BeatmapPicker>().FirstOrDefault()?.Beatmap.Value.OnlineID == requested_beatmap_id);
AddUntilStep("Beatmap overlay showing content", () => Game.ChildrenOfType<BeatmapPicker>().FirstOrDefault()?.Beatmap.Value?.OnlineID == requested_beatmap_id);
}
}
}

View File

@ -63,6 +63,9 @@ private double lengthInSeconds
set => Length = TimeSpan.FromSeconds(value).TotalMilliseconds;
}
[JsonProperty(@"convert")]
public bool Convert { get; set; }
[JsonProperty(@"count_circles")]
public int CircleCount { get; set; }

View File

@ -125,6 +125,9 @@ public string AuthorString
[JsonProperty(@"beatmaps")]
public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
[JsonProperty(@"converts")]
public APIBeatmap[]? Converts { get; set; }
private BeatmapMetadata metadata => new BeatmapMetadata
{
Title = Title,

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System;
using System.Linq;
using osu.Framework;
@ -38,10 +36,10 @@ public partial class BeatmapPicker : Container
public readonly DifficultiesContainer Difficulties;
public readonly Bindable<APIBeatmap> Beatmap = new Bindable<APIBeatmap>();
private APIBeatmapSet beatmapSet;
public readonly Bindable<APIBeatmap?> Beatmap = new Bindable<APIBeatmap?>();
private APIBeatmapSet? beatmapSet;
public APIBeatmapSet BeatmapSet
public APIBeatmapSet? BeatmapSet
{
get => beatmapSet;
set
@ -142,7 +140,7 @@ public BeatmapPicker()
}
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
@ -168,10 +166,11 @@ private void updateDisplay()
if (BeatmapSet != null)
{
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.Concat(BeatmapSet.Converts ?? Array.Empty<APIBeatmap>())
.Where(b => b.Ruleset.MatchesOnlineID(ruleset.Value))
.OrderBy(b => b.StarRating)
.Select(b => new DifficultySelectorButton(b)
.OrderBy(b => !b.Convert)
.ThenBy(b => b.StarRating)
.Select(b => new DifficultySelectorButton(b, b.Convert ? new RulesetInfo { OnlineID = 0 } : null)
{
State = DifficultySelectorState.NotSelected,
OnHovered = beatmap =>
@ -199,9 +198,9 @@ private void updateDisplay()
updateDifficultyButtons();
}
private void showBeatmap(IBeatmapInfo beatmapInfo)
private void showBeatmap(IBeatmapInfo? beatmapInfo)
{
version.Text = beatmapInfo?.DifficultyName;
version.Text = beatmapInfo?.DifficultyName ?? string.Empty;
}
private void updateDifficultyButtons()
@ -211,7 +210,7 @@ private void updateDifficultyButtons()
public partial class DifficultiesContainer : FillFlowContainer<DifficultySelectorButton>
{
public Action OnLostHover;
public Action? OnLostHover;
protected override void OnHoverLost(HoverLostEvent e)
{
@ -232,9 +231,9 @@ public partial class DifficultySelectorButton : OsuClickableContainer, IStateful
public readonly APIBeatmap Beatmap;
public Action<APIBeatmap> OnHovered;
public Action<APIBeatmap> OnClicked;
public event Action<DifficultySelectorState> StateChanged;
public Action<APIBeatmap>? OnHovered;
public Action<APIBeatmap>? OnClicked;
public event Action<DifficultySelectorState>? StateChanged;
private DifficultySelectorState state;
@ -255,7 +254,7 @@ public DifficultySelectorState State
}
}
public DifficultySelectorButton(APIBeatmap beatmapInfo)
public DifficultySelectorButton(APIBeatmap beatmapInfo, IRulesetInfo? ruleset)
{
Beatmap = beatmapInfo;
Size = new Vector2(size);
@ -274,7 +273,7 @@ public DifficultySelectorButton(APIBeatmap beatmapInfo)
Alpha = 0.5f
}
},
icon = new DifficultyIcon(beatmapInfo)
icon = new DifficultyIcon(beatmapInfo, ruleset)
{
ShowTooltip = false,
Current = { Value = new StarDifficulty(beatmapInfo.StarRating, 0) },

View File

@ -68,11 +68,12 @@ protected override void LoadComplete()
BeatmapSet.BindValueChanged(setInfo =>
{
int beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.MatchesOnlineID(Value)) ?? 0;
int osuBeatmaps = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.OnlineID == 0) ?? 0;
count.Text = beatmapsCount.ToString();
countContainer.FadeTo(beatmapsCount > 0 ? 1 : 0);
Enabled.Value = beatmapsCount > 0;
Enabled.Value = beatmapsCount > 0 || osuBeatmaps > 0;
}, true);
}
}

View File

@ -6,6 +6,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Profile.Header.Components;
using osuTK;
@ -15,6 +16,8 @@ public partial class CentreHeaderContainer : CompositeDrawable
{
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
private LevelBadge levelBadge = null!;
public CentreHeaderContainer()
{
Height = 60;
@ -62,12 +65,11 @@ private void load(OverlayColourProvider colourProvider)
Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN },
Children = new Drawable[]
{
new LevelBadge
levelBadge = new LevelBadge
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Size = new Vector2(40),
User = { BindTarget = User }
Size = new Vector2(40)
},
new Container
{
@ -86,5 +88,17 @@ private void load(OverlayColourProvider colourProvider)
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
User.BindValueChanged(user => updateDisplay(user.NewValue?.User), true);
}
private void updateDisplay(APIUser? user)
{
levelBadge.LevelInfo.Value = user?.Statistics?.Level;
}
}
}

View File

@ -11,14 +11,14 @@
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users;
namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class LevelBadge : CompositeDrawable, IHasTooltip
{
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
public readonly Bindable<UserStatistics.LevelInfo?> LevelInfo = new Bindable<UserStatistics.LevelInfo?>();
public LocalisableString TooltipText { get; private set; }
@ -47,13 +47,18 @@ private void load(OsuColour colours, TextureStore textures)
Font = OsuFont.GetFont(size: 20)
}
};
User.BindValueChanged(user => updateLevel(user.NewValue?.User));
}
private void updateLevel(APIUser? user)
protected override void LoadComplete()
{
string level = user?.Statistics?.Level.Current.ToString() ?? "0";
base.LoadComplete();
LevelInfo.BindValueChanged(level => updateLevel(level.NewValue), true);
}
private void updateLevel(UserStatistics.LevelInfo? levelInfo)
{
string level = levelInfo?.Current.ToString() ?? "0";
levelText.Text = level;
TooltipText = UsersStrings.ShowStatsLevel(level);
}