mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Merge branch 'master' into skin-editor-loc
This commit is contained in:
commit
1f47def3c4
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -50,7 +48,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
public void TestBeatmapLink()
|
public void TestBeatmapLink()
|
||||||
{
|
{
|
||||||
AddUntilStep("Beatmap overlay displayed", () => Game.ChildrenOfType<BeatmapSetOverlay>().FirstOrDefault()?.State.Value == Visibility.Visible);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,9 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
set => Length = TimeSpan.FromSeconds(value).TotalMilliseconds;
|
set => Length = TimeSpan.FromSeconds(value).TotalMilliseconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonProperty(@"convert")]
|
||||||
|
public bool Convert { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"count_circles")]
|
[JsonProperty(@"count_circles")]
|
||||||
public int CircleCount { get; set; }
|
public int CircleCount { get; set; }
|
||||||
|
|
||||||
|
@ -125,6 +125,9 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonProperty(@"beatmaps")]
|
[JsonProperty(@"beatmaps")]
|
||||||
public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
|
public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
|
||||||
|
|
||||||
|
[JsonProperty(@"converts")]
|
||||||
|
public APIBeatmap[]? Converts { get; set; }
|
||||||
|
|
||||||
private BeatmapMetadata metadata => new BeatmapMetadata
|
private BeatmapMetadata metadata => new BeatmapMetadata
|
||||||
{
|
{
|
||||||
Title = Title,
|
Title = Title,
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
@ -38,10 +36,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
public readonly DifficultiesContainer Difficulties;
|
public readonly DifficultiesContainer Difficulties;
|
||||||
|
|
||||||
public readonly Bindable<APIBeatmap> Beatmap = new Bindable<APIBeatmap>();
|
public readonly Bindable<APIBeatmap?> Beatmap = new Bindable<APIBeatmap?>();
|
||||||
private APIBeatmapSet beatmapSet;
|
private APIBeatmapSet? beatmapSet;
|
||||||
|
|
||||||
public APIBeatmapSet BeatmapSet
|
public APIBeatmapSet? BeatmapSet
|
||||||
{
|
{
|
||||||
get => beatmapSet;
|
get => beatmapSet;
|
||||||
set
|
set
|
||||||
@ -142,7 +140,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
@ -168,10 +166,11 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
if (BeatmapSet != null)
|
if (BeatmapSet != null)
|
||||||
{
|
{
|
||||||
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps
|
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.Concat(BeatmapSet.Converts ?? Array.Empty<APIBeatmap>())
|
||||||
.Where(b => b.Ruleset.MatchesOnlineID(ruleset.Value))
|
.Where(b => b.Ruleset.MatchesOnlineID(ruleset.Value))
|
||||||
.OrderBy(b => b.StarRating)
|
.OrderBy(b => !b.Convert)
|
||||||
.Select(b => new DifficultySelectorButton(b)
|
.ThenBy(b => b.StarRating)
|
||||||
|
.Select(b => new DifficultySelectorButton(b, b.Convert ? new RulesetInfo { OnlineID = 0 } : null)
|
||||||
{
|
{
|
||||||
State = DifficultySelectorState.NotSelected,
|
State = DifficultySelectorState.NotSelected,
|
||||||
OnHovered = beatmap =>
|
OnHovered = beatmap =>
|
||||||
@ -199,9 +198,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
updateDifficultyButtons();
|
updateDifficultyButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showBeatmap(IBeatmapInfo beatmapInfo)
|
private void showBeatmap(IBeatmapInfo? beatmapInfo)
|
||||||
{
|
{
|
||||||
version.Text = beatmapInfo?.DifficultyName;
|
version.Text = beatmapInfo?.DifficultyName ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDifficultyButtons()
|
private void updateDifficultyButtons()
|
||||||
@ -211,7 +210,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
public partial class DifficultiesContainer : FillFlowContainer<DifficultySelectorButton>
|
public partial class DifficultiesContainer : FillFlowContainer<DifficultySelectorButton>
|
||||||
{
|
{
|
||||||
public Action OnLostHover;
|
public Action? OnLostHover;
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
@ -232,9 +231,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
public readonly APIBeatmap Beatmap;
|
public readonly APIBeatmap Beatmap;
|
||||||
|
|
||||||
public Action<APIBeatmap> OnHovered;
|
public Action<APIBeatmap>? OnHovered;
|
||||||
public Action<APIBeatmap> OnClicked;
|
public Action<APIBeatmap>? OnClicked;
|
||||||
public event Action<DifficultySelectorState> StateChanged;
|
public event Action<DifficultySelectorState>? StateChanged;
|
||||||
|
|
||||||
private DifficultySelectorState state;
|
private DifficultySelectorState state;
|
||||||
|
|
||||||
@ -255,7 +254,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DifficultySelectorButton(APIBeatmap beatmapInfo)
|
public DifficultySelectorButton(APIBeatmap beatmapInfo, IRulesetInfo? ruleset)
|
||||||
{
|
{
|
||||||
Beatmap = beatmapInfo;
|
Beatmap = beatmapInfo;
|
||||||
Size = new Vector2(size);
|
Size = new Vector2(size);
|
||||||
@ -274,7 +273,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
Alpha = 0.5f
|
Alpha = 0.5f
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon = new DifficultyIcon(beatmapInfo)
|
icon = new DifficultyIcon(beatmapInfo, ruleset)
|
||||||
{
|
{
|
||||||
ShowTooltip = false,
|
ShowTooltip = false,
|
||||||
Current = { Value = new StarDifficulty(beatmapInfo.StarRating, 0) },
|
Current = { Value = new StarDifficulty(beatmapInfo.StarRating, 0) },
|
||||||
|
@ -68,11 +68,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
BeatmapSet.BindValueChanged(setInfo =>
|
BeatmapSet.BindValueChanged(setInfo =>
|
||||||
{
|
{
|
||||||
int beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.MatchesOnlineID(Value)) ?? 0;
|
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();
|
count.Text = beatmapsCount.ToString();
|
||||||
countContainer.FadeTo(beatmapsCount > 0 ? 1 : 0);
|
countContainer.FadeTo(beatmapsCount > 0 ? 1 : 0);
|
||||||
|
|
||||||
Enabled.Value = beatmapsCount > 0;
|
Enabled.Value = beatmapsCount > 0 || osuBeatmaps > 0;
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Overlays.Profile.Header.Components;
|
using osu.Game.Overlays.Profile.Header.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -15,6 +16,8 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
{
|
{
|
||||||
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
|
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
|
||||||
|
|
||||||
|
private LevelBadge levelBadge = null!;
|
||||||
|
|
||||||
public CentreHeaderContainer()
|
public CentreHeaderContainer()
|
||||||
{
|
{
|
||||||
Height = 60;
|
Height = 60;
|
||||||
@ -62,12 +65,11 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN },
|
Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new LevelBadge
|
levelBadge = new LevelBadge
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Size = new Vector2(40),
|
Size = new Vector2(40)
|
||||||
User = { BindTarget = User }
|
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -86,5 +88,17 @@ namespace osu.Game.Overlays.Profile.Header
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,14 @@ using osu.Framework.Graphics.Textures;
|
|||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header.Components
|
namespace osu.Game.Overlays.Profile.Header.Components
|
||||||
{
|
{
|
||||||
public partial class LevelBadge : CompositeDrawable, IHasTooltip
|
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; }
|
public LocalisableString TooltipText { get; private set; }
|
||||||
|
|
||||||
@ -47,13 +47,18 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
Font = OsuFont.GetFont(size: 20)
|
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;
|
levelText.Text = level;
|
||||||
TooltipText = UsersStrings.ShowStatsLevel(level);
|
TooltipText = UsersStrings.ShowStatsLevel(level);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user