1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Merge branch 'master' into previewTime

This commit is contained in:
Salman Ahmed 2023-01-07 15:07:09 +03:00 committed by GitHub
commit a65466bdac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
104 changed files with 656 additions and 489 deletions

View File

@ -18,6 +18,36 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
{ {
protected override Ruleset CreatePlayerRuleset() => new CatchRuleset(); protected override Ruleset CreatePlayerRuleset() => new CatchRuleset();
[Test]
public void TestAlwaysHidden()
{
CreateModTest(new ModTestData
{
Mod = new CatchModNoScope
{
HiddenComboCount = { Value = 0 },
},
Autoplay = true,
PassCondition = () => Player.ScoreProcessor.Combo.Value == 2,
Beatmap = new Beatmap
{
HitObjects = new List<HitObject>
{
new Fruit
{
X = CatchPlayfield.CENTER_X * 0.5f,
StartTime = 1000,
},
new Fruit
{
X = CatchPlayfield.CENTER_X * 1.5f,
StartTime = 2000,
}
}
}
});
}
[Test] [Test]
public void TestVisibleDuringBreak() public void TestVisibleDuringBreak()
{ {

View File

@ -26,6 +26,9 @@ namespace osu.Game.Rulesets.Catch.Mods
var catchPlayfield = (CatchPlayfield)playfield; var catchPlayfield = (CatchPlayfield)playfield;
bool shouldAlwaysShowCatcher = IsBreakTime.Value; bool shouldAlwaysShowCatcher = IsBreakTime.Value;
float targetAlpha = shouldAlwaysShowCatcher ? 1 : ComboBasedAlpha; float targetAlpha = shouldAlwaysShowCatcher ? 1 : ComboBasedAlpha;
// AlwaysPresent required for catcher to still act on input when fully hidden.
catchPlayfield.CatcherArea.AlwaysPresent = true;
catchPlayfield.CatcherArea.Alpha = (float)Interpolation.Lerp(catchPlayfield.CatcherArea.Alpha, targetAlpha, Math.Clamp(catchPlayfield.Time.Elapsed / TRANSITION_DURATION, 0, 1)); catchPlayfield.CatcherArea.Alpha = (float)Interpolation.Lerp(catchPlayfield.CatcherArea.Alpha, targetAlpha, Math.Clamp(catchPlayfield.Time.Elapsed / TRANSITION_DURATION, 0, 1));
} }
} }

View File

@ -11,7 +11,6 @@ using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics; using osu.Game.Graphics;
using osuTK; using osuTK;
using osuTK.Input;
namespace osu.Game.Rulesets.Catch.UI namespace osu.Game.Rulesets.Catch.UI
{ {
@ -106,41 +105,17 @@ namespace osu.Game.Rulesets.Catch.UI
return false; return false;
} }
protected override bool OnMouseDown(MouseDownEvent e)
{
return updateAction(e.Button, getTouchCatchActionFromInput(e.ScreenSpaceMousePosition));
}
protected override bool OnTouchDown(TouchDownEvent e) protected override bool OnTouchDown(TouchDownEvent e)
{ {
return updateAction(e.Touch.Source, getTouchCatchActionFromInput(e.ScreenSpaceTouch.Position)); return updateAction(e.Touch.Source, getTouchCatchActionFromInput(e.ScreenSpaceTouch.Position));
} }
protected override bool OnMouseMove(MouseMoveEvent e)
{
Show();
TouchCatchAction? action = getTouchCatchActionFromInput(e.ScreenSpaceMousePosition);
// multiple mouse buttons may be pressed and handling the same action.
foreach (MouseButton button in e.PressedButtons)
updateAction(button, action);
return false;
}
protected override void OnTouchMove(TouchMoveEvent e) protected override void OnTouchMove(TouchMoveEvent e)
{ {
updateAction(e.Touch.Source, getTouchCatchActionFromInput(e.ScreenSpaceTouch.Position)); updateAction(e.Touch.Source, getTouchCatchActionFromInput(e.ScreenSpaceTouch.Position));
base.OnTouchMove(e); base.OnTouchMove(e);
} }
protected override void OnMouseUp(MouseUpEvent e)
{
updateAction(e.Button, null);
base.OnMouseUp(e);
}
protected override void OnTouchUp(TouchUpEvent e) protected override void OnTouchUp(TouchUpEvent e)
{ {
updateAction(e.Touch.Source, null); updateAction(e.Touch.Source, null);

View File

@ -209,18 +209,6 @@ namespace osu.Game.Rulesets.Mania.UI
keyBindingContainer = maniaInputManager?.KeyBindingContainer; keyBindingContainer = maniaInputManager?.KeyBindingContainer;
} }
protected override bool OnMouseDown(MouseDownEvent e)
{
keyBindingContainer?.TriggerPressed(column.Action.Value);
return base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseUpEvent e)
{
keyBindingContainer?.TriggerReleased(column.Action.Value);
base.OnMouseUp(e);
}
protected override bool OnTouchDown(TouchDownEvent e) protected override bool OnTouchDown(TouchDownEvent e)
{ {
keyBindingContainer?.TriggerPressed(column.Action.Value); keyBindingContainer?.TriggerPressed(column.Action.Value);

View File

@ -1,35 +1,64 @@
// 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.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Skinning.Argon namespace osu.Game.Rulesets.Osu.Skinning.Argon
{ {
public partial class ArgonFollowCircle : FollowCircle public partial class ArgonFollowCircle : FollowCircle
{ {
private readonly CircularContainer circleContainer;
private readonly Box circleFill;
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
[Resolved(canBeNull: true)]
private DrawableHitObject? parentObject { get; set; }
public ArgonFollowCircle() public ArgonFollowCircle()
{ {
InternalChild = new CircularContainer InternalChild = circleContainer = new CircularContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true, Masking = true,
BorderThickness = 4, BorderThickness = 4,
BorderColour = ColourInfo.GradientVertical(Colour4.FromHex("FC618F"), Colour4.FromHex("BB1A41")),
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
Child = new Box Child = circleFill = new Box
{ {
Colour = ColourInfo.GradientVertical(Colour4.FromHex("FC618F"), Colour4.FromHex("BB1A41")),
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 0.3f, Alpha = 0.3f,
} }
}; };
} }
[BackgroundDependencyLoader]
private void load()
{
if (parentObject != null)
accentColour.BindTo(parentObject.AccentColour);
}
protected override void LoadComplete()
{
base.LoadComplete();
accentColour.BindValueChanged(colour =>
{
circleContainer.BorderColour = ColourInfo.GradientVertical(colour.NewValue, colour.NewValue.Darken(0.5f));
circleFill.Colour = ColourInfo.GradientVertical(colour.NewValue, colour.NewValue.Darken(0.5f));
}, true);
}
protected override void OnSliderPress() protected override void OnSliderPress()
{ {
const float duration = 300f; const float duration = 300f;

View File

@ -2,6 +2,8 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -21,6 +23,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
private readonly Vector2 defaultIconScale = new Vector2(0.6f, 0.8f); private readonly Vector2 defaultIconScale = new Vector2(0.6f, 0.8f);
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private DrawableHitObject? parentObject { get; set; } private DrawableHitObject? parentObject { get; set; }
@ -37,7 +41,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
{ {
fill = new Box fill = new Box
{ {
Colour = ColourInfo.GradientVertical(Colour4.FromHex("FC618F"), Colour4.FromHex("BB1A41")),
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -53,10 +56,22 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
}; };
} }
[BackgroundDependencyLoader]
private void load()
{
if (parentObject != null)
accentColour.BindTo(parentObject.AccentColour);
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
accentColour.BindValueChanged(colour =>
{
fill.Colour = ColourInfo.GradientVertical(colour.NewValue, colour.NewValue.Darken(0.5f));
}, true);
if (parentObject != null) if (parentObject != null)
{ {
parentObject.ApplyCustomUpdateState += updateStateTransforms; parentObject.ApplyCustomUpdateState += updateStateTransforms;

View File

@ -107,24 +107,6 @@ namespace osu.Game.Rulesets.Taiko.UI
return false; return false;
} }
protected override bool OnMouseDown(MouseDownEvent e)
{
if (!validMouse(e))
return false;
handleDown(e.Button, e.ScreenSpaceMousePosition);
return true;
}
protected override void OnMouseUp(MouseUpEvent e)
{
if (!validMouse(e))
return;
handleUp(e.Button);
base.OnMouseUp(e);
}
protected override bool OnTouchDown(TouchDownEvent e) protected override bool OnTouchDown(TouchDownEvent e)
{ {
handleDown(e.Touch.Source, e.ScreenSpaceTouchDownPosition); handleDown(e.Touch.Source, e.ScreenSpaceTouchDownPosition);

View File

@ -3,6 +3,7 @@
#nullable disable #nullable disable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
@ -46,10 +47,14 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("item removed", () => !playlist.Items.Contains(selectedItem)); AddAssert("item removed", () => !playlist.Items.Contains(selectedItem));
} }
[Test] [TestCase(true)]
public void TestNextItemSelectedAfterDeletion() [TestCase(false)]
public void TestNextItemSelectedAfterDeletion(bool allowSelection)
{ {
createPlaylist(); createPlaylist(p =>
{
p.AllowSelection = allowSelection;
});
moveToItem(0); moveToItem(0);
AddStep("click", () => InputManager.Click(MouseButton.Left)); AddStep("click", () => InputManager.Click(MouseButton.Left));
@ -57,7 +62,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
moveToDeleteButton(0); moveToDeleteButton(0);
AddStep("click delete button", () => InputManager.Click(MouseButton.Left)); AddStep("click delete button", () => InputManager.Click(MouseButton.Left));
AddAssert("item 0 is selected", () => playlist.SelectedItem.Value == playlist.Items[0]); AddAssert("item 0 is " + (allowSelection ? "selected" : "not selected"), () => playlist.SelectedItem.Value == (allowSelection ? playlist.Items[0] : null));
} }
[Test] [Test]
@ -117,7 +122,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset); InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
}); });
private void createPlaylist() private void createPlaylist(Action<TestPlaylist> setupPlaylist = null)
{ {
AddStep("create playlist", () => AddStep("create playlist", () =>
{ {
@ -154,6 +159,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
} }
}); });
} }
setupPlaylist?.Invoke(playlist);
}); });
AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded)); AddUntilStep("wait for items to load", () => playlist.ItemMap.Values.All(i => i.IsLoaded));

View File

@ -54,6 +54,8 @@ namespace osu.Game.Tests.Visual.Online
{ {
overlay.ShowBeatmapSet(new APIBeatmapSet overlay.ShowBeatmapSet(new APIBeatmapSet
{ {
Genre = new BeatmapSetOnlineGenre { Id = 15, Name = "Future genre" },
Language = new BeatmapSetOnlineLanguage { Id = 15, Name = "Future language" },
OnlineID = 1235, OnlineID = 1235,
Title = @"an awesome beatmap", Title = @"an awesome beatmap",
Artist = @"naru narusegawa", Artist = @"naru narusegawa",

View File

@ -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 NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;

View File

@ -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 osu.Game.Overlays.Profile.Sections.Kudosu; using osu.Game.Overlays.Profile.Sections.Kudosu;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;

View File

@ -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 osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Overlays.Profile.Header.Components; using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Rulesets.Catch; using osu.Game.Rulesets.Catch;
@ -24,7 +22,7 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneProfileRulesetSelector() public TestSceneProfileRulesetSelector()
{ {
ProfileRulesetSelector selector; ProfileRulesetSelector selector;
var user = new Bindable<APIUser>(); var user = new Bindable<APIUser?>();
Child = selector = new ProfileRulesetSelector Child = selector = new ProfileRulesetSelector
{ {

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;

View File

@ -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 NUnit.Framework; using NUnit.Framework;
@ -20,7 +18,7 @@ namespace osu.Game.Tests.Visual.Online
[Cached] [Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
private ProfileHeader header; private ProfileHeader header = null!;
[SetUpSteps] [SetUpSteps]
public void SetUpSteps() public void SetUpSteps()

View File

@ -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 NUnit.Framework; using NUnit.Framework;

View File

@ -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 NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -14,7 +12,7 @@ namespace osu.Game.Tests.Visual.Online
[TestFixture] [TestFixture]
public partial class TestSceneUserProfilePreviousUsernames : OsuTestScene public partial class TestSceneUserProfilePreviousUsernames : OsuTestScene
{ {
private PreviousUsernames container; private PreviousUsernames container = null!;
[SetUp] [SetUp]
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
@ -50,7 +48,7 @@ namespace osu.Game.Tests.Visual.Online
AddUntilStep("Is hidden", () => container.Alpha == 0); AddUntilStep("Is hidden", () => container.Alpha == 0);
} }
private static readonly APIUser[] users = private static readonly APIUser?[] users =
{ {
new APIUser { Id = 1, PreviousUsernames = new[] { "username1" } }, new APIUser { Id = 1, PreviousUsernames = new[] { "username1" } },
new APIUser { Id = 2, PreviousUsernames = new[] { "longusername", "longerusername" } }, new APIUser { Id = 2, PreviousUsernames = new[] { "longusername", "longerusername" } },

View File

@ -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.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;

View File

@ -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 NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;

View File

@ -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 NUnit.Framework; using NUnit.Framework;
using osu.Game.Overlays.Profile.Sections; using osu.Game.Overlays.Profile.Sections;
using osu.Framework.Testing; using osu.Framework.Testing;
@ -18,7 +16,7 @@ namespace osu.Game.Tests.Visual.UserInterface
[Cached] [Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink); private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink);
private ProfileSubsectionHeader header; private ProfileSubsectionHeader header = null!;
[Test] [Test]
public void TestHiddenCounter() public void TestHiddenCounter()

View File

@ -55,6 +55,16 @@ namespace osu.Game.Tests.Visual.UserInterface
}; };
}); });
[Test]
public void TestDisplay()
{
AddRepeatStep("toggle expanded state", () =>
{
InputManager.MoveMouseTo(group.ChildrenOfType<IconButton>().Single());
InputManager.Click(MouseButton.Left);
}, 5);
}
[Test] [Test]
public void TestClickExpandButtonMultipleTimes() public void TestClickExpandButtonMultipleTimes()
{ {

View File

@ -138,9 +138,18 @@ namespace osu.Game.Beatmaps.Drawables.Cards
// This avoids depth issues where a hovered (scaled) card to the right of another card would be beneath the card to the left. // This avoids depth issues where a hovered (scaled) card to the right of another card would be beneath the card to the left.
this.ScaleTo(Expanded.Value ? 1.03f : 1, 500, Easing.OutQuint); this.ScaleTo(Expanded.Value ? 1.03f : 1, 500, Easing.OutQuint);
background.FadeTo(Expanded.Value ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); if (Expanded.Value)
dropdownContent.FadeTo(Expanded.Value ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); {
borderContainer.FadeTo(Expanded.Value ? 1 : 0, BeatmapCard.TRANSITION_DURATION, Easing.OutQuint); background.FadeIn(BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
dropdownContent.FadeIn(BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
borderContainer.FadeIn(BeatmapCard.TRANSITION_DURATION, Easing.OutQuint);
}
else
{
background.FadeOut(BeatmapCard.TRANSITION_DURATION / 3f, Easing.OutQuint);
dropdownContent.FadeOut(BeatmapCard.TRANSITION_DURATION / 3f, Easing.OutQuint);
borderContainer.FadeOut(BeatmapCard.TRANSITION_DURATION / 3f, Easing.OutQuint);
}
content.TweenEdgeEffectTo(new EdgeEffectParameters content.TweenEdgeEffectTo(new EdgeEffectParameters
{ {

View File

@ -300,7 +300,7 @@ namespace osu.Game.Beatmaps.Formats
{ {
var comboColour = colours[i]; var comboColour = colours[i];
writer.Write(FormattableString.Invariant($"Combo{i}: ")); writer.Write(FormattableString.Invariant($"Combo{1 + i}: "));
writer.Write(FormattableString.Invariant($"{(byte)(comboColour.R * byte.MaxValue)},")); writer.Write(FormattableString.Invariant($"{(byte)(comboColour.R * byte.MaxValue)},"));
writer.Write(FormattableString.Invariant($"{(byte)(comboColour.G * byte.MaxValue)},")); writer.Write(FormattableString.Invariant($"{(byte)(comboColour.G * byte.MaxValue)},"));
writer.Write(FormattableString.Invariant($"{(byte)(comboColour.B * byte.MaxValue)},")); writer.Write(FormattableString.Invariant($"{(byte)(comboColour.B * byte.MaxValue)},"));

View File

@ -34,8 +34,6 @@ namespace osu.Game.Beatmaps
// TODO: remove once the fallback lookup is not required (and access via `working.BeatmapInfo.Metadata` directly). // TODO: remove once the fallback lookup is not required (and access via `working.BeatmapInfo.Metadata` directly).
public BeatmapMetadata Metadata => BeatmapInfo.Metadata; public BeatmapMetadata Metadata => BeatmapInfo.Metadata;
public Waveform Waveform => waveform.Value;
public Storyboard Storyboard => storyboard.Value; public Storyboard Storyboard => storyboard.Value;
public Texture Background => GetBackground(); // Texture uses ref counting, so we want to return a new instance every usage. public Texture Background => GetBackground(); // Texture uses ref counting, so we want to return a new instance every usage.
@ -48,10 +46,11 @@ namespace osu.Game.Beatmaps
private readonly object beatmapFetchLock = new object(); private readonly object beatmapFetchLock = new object();
private readonly Lazy<Waveform> waveform;
private readonly Lazy<Storyboard> storyboard; private readonly Lazy<Storyboard> storyboard;
private readonly Lazy<ISkin> skin; private readonly Lazy<ISkin> skin;
private Track track; // track is not Lazy as we allow transferring and loading multiple times. private Track track; // track is not Lazy as we allow transferring and loading multiple times.
private Waveform waveform; // waveform is also not Lazy as the track may change.
protected WorkingBeatmap(BeatmapInfo beatmapInfo, AudioManager audioManager) protected WorkingBeatmap(BeatmapInfo beatmapInfo, AudioManager audioManager)
{ {
@ -60,7 +59,6 @@ namespace osu.Game.Beatmaps
BeatmapInfo = beatmapInfo; BeatmapInfo = beatmapInfo;
BeatmapSetInfo = beatmapInfo.BeatmapSet ?? new BeatmapSetInfo(); BeatmapSetInfo = beatmapInfo.BeatmapSet ?? new BeatmapSetInfo();
waveform = new Lazy<Waveform>(GetWaveform);
storyboard = new Lazy<Storyboard>(GetStoryboard); storyboard = new Lazy<Storyboard>(GetStoryboard);
skin = new Lazy<ISkin>(GetSkin); skin = new Lazy<ISkin>(GetSkin);
} }
@ -108,7 +106,16 @@ namespace osu.Game.Beatmaps
public virtual bool TrackLoaded => track != null; public virtual bool TrackLoaded => track != null;
public Track LoadTrack() => track = GetBeatmapTrack() ?? GetVirtualTrack(1000); public Track LoadTrack()
{
track = GetBeatmapTrack() ?? GetVirtualTrack(1000);
// the track may have changed, recycle the current waveform.
waveform?.Dispose();
waveform = null;
return track;
}
public void PrepareTrackForPreview(bool looping, double offsetFromPreviewPoint = 0) public void PrepareTrackForPreview(bool looping, double offsetFromPreviewPoint = 0)
{ {
@ -171,6 +178,12 @@ namespace osu.Game.Beatmaps
#endregion #endregion
#region Waveform
public Waveform Waveform => waveform ??= GetWaveform();
#endregion
#region Beatmap #region Beatmap
public virtual bool BeatmapLoaded => beatmapLoadTask?.IsCompleted ?? false; public virtual bool BeatmapLoaded => beatmapLoadTask?.IsCompleted ?? false;

View File

@ -45,6 +45,9 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)
{ {
if (e.ControlPressed || e.AltPressed || e.SuperPressed || e.ShiftPressed)
return false;
switch (e.Key) switch (e.Key)
{ {
case Key.Up: case Key.Up:

View File

@ -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 osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets; using osu.Game.Rulesets;
@ -11,10 +9,11 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
public class GetScoresRequest : APIRequest<APIScoresCollection> public class GetScoresRequest : APIRequest<APIScoresCollection>, IEquatable<GetScoresRequest>
{ {
public const int MAX_SCORES_PER_REQUEST = 50; public const int MAX_SCORES_PER_REQUEST = 50;
@ -23,7 +22,7 @@ namespace osu.Game.Online.API.Requests
private readonly IRulesetInfo ruleset; private readonly IRulesetInfo ruleset;
private readonly IEnumerable<IMod> mods; private readonly IEnumerable<IMod> mods;
public GetScoresRequest(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset, BeatmapLeaderboardScope scope = BeatmapLeaderboardScope.Global, IEnumerable<IMod> mods = null) public GetScoresRequest(IBeatmapInfo beatmapInfo, IRulesetInfo ruleset, BeatmapLeaderboardScope scope = BeatmapLeaderboardScope.Global, IEnumerable<IMod>? mods = null)
{ {
if (beatmapInfo.OnlineID <= 0) if (beatmapInfo.OnlineID <= 0)
throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(IBeatmapInfo.OnlineID)}."); throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(IBeatmapInfo.OnlineID)}.");
@ -51,5 +50,16 @@ namespace osu.Game.Online.API.Requests
return query.ToString(); return query.ToString();
} }
public bool Equals(GetScoresRequest? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return beatmapInfo.Equals(other.beatmapInfo)
&& scope == other.scope
&& ruleset.Equals(other.ruleset)
&& mods.SequenceEqual(other.mods);
}
} }
} }

View File

@ -341,6 +341,8 @@ namespace osu.Game.Online.Chat
OpenWiki, OpenWiki,
Custom, Custom,
OpenChangelog, OpenChangelog,
FilterBeatmapSetGenre,
FilterBeatmapSetLanguage,
} }
public class Link : IComparable<Link> public class Link : IComparable<Link>

View File

@ -46,6 +46,7 @@ using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapListing;
using osu.Game.Overlays.Music; using osu.Game.Overlays.Music;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using osu.Game.Overlays.Toolbar; using osu.Game.Overlays.Toolbar;
@ -359,6 +360,14 @@ namespace osu.Game
SearchBeatmapSet(argString); SearchBeatmapSet(argString);
break; break;
case LinkAction.FilterBeatmapSetGenre:
FilterBeatmapSetGenre((SearchGenre)link.Argument);
break;
case LinkAction.FilterBeatmapSetLanguage:
FilterBeatmapSetLanguage((SearchLanguage)link.Argument);
break;
case LinkAction.OpenEditorTimestamp: case LinkAction.OpenEditorTimestamp:
case LinkAction.JoinMultiplayerMatch: case LinkAction.JoinMultiplayerMatch:
case LinkAction.Spectate: case LinkAction.Spectate:
@ -463,6 +472,10 @@ namespace osu.Game
/// <param name="query">The query to search for.</param> /// <param name="query">The query to search for.</param>
public void SearchBeatmapSet(string query) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithSearch(query)); public void SearchBeatmapSet(string query) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithSearch(query));
public void FilterBeatmapSetGenre(SearchGenre genre) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithGenreFilter(genre));
public void FilterBeatmapSetLanguage(SearchLanguage language) => waitForReady(() => beatmapListing, _ => beatmapListing.ShowWithLanguageFilter(language));
/// <summary> /// <summary>
/// Show a wiki's page as an overlay /// Show a wiki's page as an overlay
/// </summary> /// </summary>

View File

@ -145,6 +145,12 @@ namespace osu.Game.Overlays.BeatmapListing
public void Search(string query) public void Search(string query)
=> Schedule(() => searchControl.Query.Value = query); => Schedule(() => searchControl.Query.Value = query);
public void FilterGenre(SearchGenre genre)
=> Schedule(() => searchControl.Genre.Value = genre);
public void FilterLanguage(SearchLanguage language)
=> Schedule(() => searchControl.Language.Value = language);
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();

View File

@ -12,6 +12,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; 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.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osuTK; using osuTK;
@ -100,9 +101,30 @@ namespace osu.Game.Overlays.BeatmapListing
protected partial class MultipleSelectionFilterTabItem : FilterTabItem<T> protected partial class MultipleSelectionFilterTabItem : FilterTabItem<T>
{ {
private readonly Box selectedUnderline;
protected override bool HighlightOnHoverWhenActive => true;
public MultipleSelectionFilterTabItem(T value) public MultipleSelectionFilterTabItem(T value)
: base(value) : base(value)
{ {
// This doesn't match any actual design, but should make it easier for the user to understand
// that filters are applied until we settle on a final design.
AddInternal(selectedUnderline = new Box
{
Depth = float.MaxValue,
RelativeSizeAxes = Axes.X,
Height = 1.5f,
Anchor = Anchor.BottomLeft,
Origin = Anchor.CentreLeft,
});
}
protected override void UpdateState()
{
base.UpdateState();
selectedUnderline.FadeTo(Active.Value ? 1 : 0, 200, Easing.OutQuint);
selectedUnderline.FadeColour(IsHovered ? ColourProvider.Content2 : GetStateColour(), 200, Easing.OutQuint);
} }
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.BeatmapListing
public partial class FilterTabItem<T> : TabItem<T> public partial class FilterTabItem<T> : TabItem<T>
{ {
[Resolved] [Resolved]
private OverlayColourProvider colourProvider { get; set; } protected OverlayColourProvider ColourProvider { get; private set; }
private OsuSpriteText text; private OsuSpriteText text;
@ -52,38 +52,42 @@ namespace osu.Game.Overlays.BeatmapListing
{ {
base.LoadComplete(); base.LoadComplete();
updateState(); UpdateState();
FinishTransforms(true); FinishTransforms(true);
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
base.OnHover(e); base.OnHover(e);
updateState(); UpdateState();
return true; return true;
} }
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
base.OnHoverLost(e); base.OnHoverLost(e);
updateState(); UpdateState();
} }
protected override void OnActivated() => updateState(); protected override void OnActivated() => UpdateState();
protected override void OnDeactivated() => updateState(); protected override void OnDeactivated() => UpdateState();
/// <summary> /// <summary>
/// Returns the label text to be used for the supplied <paramref name="value"/>. /// Returns the label text to be used for the supplied <paramref name="value"/>.
/// </summary> /// </summary>
protected virtual LocalisableString LabelFor(T value) => (value as Enum)?.GetLocalisableDescription() ?? value.ToString(); protected virtual LocalisableString LabelFor(T value) => (value as Enum)?.GetLocalisableDescription() ?? value.ToString();
private void updateState() protected virtual bool HighlightOnHoverWhenActive => false;
protected virtual void UpdateState()
{ {
text.FadeColour(IsHovered ? colourProvider.Light1 : GetStateColour(), 200, Easing.OutQuint); bool highlightHover = IsHovered && (!Active.Value || HighlightOnHoverWhenActive);
text.Font = text.Font.With(weight: Active.Value ? FontWeight.SemiBold : FontWeight.Regular);
text.FadeColour(highlightHover ? ColourProvider.Content2 : GetStateColour(), 200, Easing.OutQuint);
text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Regular);
} }
protected virtual Color4 GetStateColour() => Active.Value ? colourProvider.Content1 : colourProvider.Light2; protected virtual Color4 GetStateColour() => Active.Value ? ColourProvider.Content1 : ColourProvider.Light2;
} }
} }

View File

@ -110,6 +110,18 @@ namespace osu.Game.Overlays
ScrollFlow.ScrollToStart(); ScrollFlow.ScrollToStart();
} }
public void ShowWithGenreFilter(SearchGenre genre)
{
ShowWithSearch(string.Empty);
filterControl.FilterGenre(genre);
}
public void ShowWithLanguageFilter(SearchLanguage language)
{
ShowWithSearch(string.Empty);
filterControl.FilterLanguage(language);
}
protected override BeatmapListingHeader CreateHeader() => new BeatmapListingHeader(); protected override BeatmapListingHeader CreateHeader() => new BeatmapListingHeader();
protected override Color4 BackgroundColour => ColourProvider.Background6; protected override Color4 BackgroundColour => ColourProvider.Background6;

View File

@ -8,9 +8,11 @@ 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.Beatmaps;
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.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapListing;
namespace osu.Game.Overlays.BeatmapSet namespace osu.Game.Overlays.BeatmapSet
{ {
@ -34,7 +36,9 @@ namespace osu.Game.Overlays.BeatmapSet
public Info() public Info()
{ {
MetadataSection source, tags, genre, language; MetadataSection source, tags;
MetadataSectionGenre genre;
MetadataSectionLanguage language;
OsuSpriteText notRankedPlaceholder; OsuSpriteText notRankedPlaceholder;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -59,7 +63,7 @@ namespace osu.Game.Overlays.BeatmapSet
Child = new Container Child = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = new MetadataSection(MetadataType.Description), Child = new MetadataSectionDescription(),
}, },
}, },
new Container new Container
@ -76,12 +80,12 @@ namespace osu.Game.Overlays.BeatmapSet
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Full, Direction = FillDirection.Full,
Children = new[] Children = new Drawable[]
{ {
source = new MetadataSection(MetadataType.Source), source = new MetadataSectionSource(),
genre = new MetadataSection(MetadataType.Genre) { Width = 0.5f }, genre = new MetadataSectionGenre { Width = 0.5f },
language = new MetadataSection(MetadataType.Language) { Width = 0.5f }, language = new MetadataSectionLanguage { Width = 0.5f },
tags = new MetadataSection(MetadataType.Tags), tags = new MetadataSectionTags(),
}, },
}, },
}, },
@ -118,10 +122,10 @@ namespace osu.Game.Overlays.BeatmapSet
BeatmapSet.ValueChanged += b => BeatmapSet.ValueChanged += b =>
{ {
source.Text = b.NewValue?.Source ?? string.Empty; source.Metadata = b.NewValue?.Source ?? string.Empty;
tags.Text = b.NewValue?.Tags ?? string.Empty; tags.Metadata = b.NewValue?.Tags ?? string.Empty;
genre.Text = b.NewValue?.Genre.Name ?? string.Empty; genre.Metadata = b.NewValue?.Genre ?? new BeatmapSetOnlineGenre { Id = (int)SearchGenre.Unspecified };
language.Text = b.NewValue?.Language.Name ?? string.Empty; language.Metadata = b.NewValue?.Language ?? new BeatmapSetOnlineLanguage { Id = (int)SearchLanguage.Unspecified };
bool setHasLeaderboard = b.NewValue?.Status > 0; bool setHasLeaderboard = b.NewValue?.Status > 0;
successRate.Alpha = setHasLeaderboard ? 1 : 0; successRate.Alpha = setHasLeaderboard ? 1 : 0;
notRankedPlaceholder.Alpha = setHasLeaderboard ? 0 : 1; notRankedPlaceholder.Alpha = setHasLeaderboard ? 0 : 1;

View File

@ -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 osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -11,26 +9,45 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Chat;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Overlays.BeatmapSet namespace osu.Game.Overlays.BeatmapSet
{ {
public partial class MetadataSection : Container public abstract partial class MetadataSection : MetadataSection<string>
{
public override string Metadata
{
set
{
if (string.IsNullOrEmpty(value))
{
this.FadeOut(TRANSITION_DURATION);
return;
}
base.Metadata = value;
}
}
protected MetadataSection(MetadataType type, Action<string>? searchAction = null)
: base(type, searchAction)
{
}
}
public abstract partial class MetadataSection<T> : Container
{ {
private readonly FillFlowContainer textContainer; private readonly FillFlowContainer textContainer;
private readonly MetadataType type; private TextFlowContainer? textFlow;
private TextFlowContainer textFlow;
private readonly Action<string> searchAction; protected readonly Action<T>? SearchAction;
private const float transition_duration = 250; protected const float TRANSITION_DURATION = 250;
public MetadataSection(MetadataType type, Action<string> searchAction = null) protected MetadataSection(MetadataType type, Action<T>? searchAction = null)
{ {
this.type = type; SearchAction = searchAction;
this.searchAction = searchAction;
Alpha = 0; Alpha = 0;
@ -53,7 +70,7 @@ namespace osu.Game.Overlays.BeatmapSet
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Child = new OsuSpriteText Child = new OsuSpriteText
{ {
Text = this.type.GetLocalisableDescription(), Text = type.GetLocalisableDescription(),
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14), Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 14),
}, },
}, },
@ -61,23 +78,23 @@ namespace osu.Game.Overlays.BeatmapSet
}; };
} }
public string Text public virtual T Metadata
{ {
set set
{ {
if (string.IsNullOrEmpty(value)) if (value == null)
{ {
this.FadeOut(transition_duration); this.FadeOut(TRANSITION_DURATION);
return; return;
} }
this.FadeIn(transition_duration); this.FadeIn(TRANSITION_DURATION);
setTextAsync(value); setTextFlowAsync(value);
} }
} }
private void setTextAsync(string text) private void setTextFlowAsync(T metadata)
{ {
LoadComponentAsync(new LinkFlowContainer(s => s.Font = s.Font.With(size: 14)) LoadComponentAsync(new LinkFlowContainer(s => s.Font = s.Font.With(size: 14))
{ {
@ -88,44 +105,15 @@ namespace osu.Game.Overlays.BeatmapSet
{ {
textFlow?.Expire(); textFlow?.Expire();
switch (type) AddMetadata(metadata, loaded);
{
case MetadataType.Tags:
string[] tags = text.Split(" ");
for (int i = 0; i <= tags.Length - 1; i++)
{
string tag = tags[i];
if (searchAction != null)
loaded.AddLink(tag, () => searchAction(tag));
else
loaded.AddLink(tag, LinkAction.SearchBeatmapSet, tag);
if (i != tags.Length - 1)
loaded.AddText(" ");
}
break;
case MetadataType.Source:
if (searchAction != null)
loaded.AddLink(text, () => searchAction(text));
else
loaded.AddLink(text, LinkAction.SearchBeatmapSet, text);
break;
default:
loaded.AddText(text);
break;
}
textContainer.Add(textFlow = loaded); textContainer.Add(textFlow = loaded);
// fade in if we haven't yet. // fade in if we haven't yet.
textContainer.FadeIn(transition_duration); textContainer.FadeIn(TRANSITION_DURATION);
}); });
} }
protected abstract void AddMetadata(T metadata, LinkFlowContainer loaded);
} }
} }

View File

@ -0,0 +1,21 @@
// 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 System;
using osu.Game.Graphics.Containers;
namespace osu.Game.Overlays.BeatmapSet
{
public partial class MetadataSectionDescription : MetadataSection
{
public MetadataSectionDescription(Action<string>? searchAction = null)
: base(MetadataType.Description, searchAction)
{
}
protected override void AddMetadata(string metadata, LinkFlowContainer loaded)
{
loaded.AddText(metadata);
}
}
}

View File

@ -0,0 +1,30 @@
// 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 System;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Chat;
using osu.Game.Overlays.BeatmapListing;
namespace osu.Game.Overlays.BeatmapSet
{
public partial class MetadataSectionGenre : MetadataSection<BeatmapSetOnlineGenre>
{
public MetadataSectionGenre(Action<BeatmapSetOnlineGenre>? searchAction = null)
: base(MetadataType.Genre, searchAction)
{
}
protected override void AddMetadata(BeatmapSetOnlineGenre metadata, LinkFlowContainer loaded)
{
var genre = (SearchGenre)metadata.Id;
if (Enum.IsDefined(genre))
loaded.AddLink(genre.GetLocalisableDescription(), LinkAction.FilterBeatmapSetGenre, genre);
else
loaded.AddText(metadata.Name);
}
}
}

View File

@ -0,0 +1,30 @@
// 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 System;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Chat;
using osu.Game.Overlays.BeatmapListing;
namespace osu.Game.Overlays.BeatmapSet
{
public partial class MetadataSectionLanguage : MetadataSection<BeatmapSetOnlineLanguage>
{
public MetadataSectionLanguage(Action<BeatmapSetOnlineLanguage>? searchAction = null)
: base(MetadataType.Language, searchAction)
{
}
protected override void AddMetadata(BeatmapSetOnlineLanguage metadata, LinkFlowContainer loaded)
{
var language = (SearchLanguage)metadata.Id;
if (Enum.IsDefined(language))
loaded.AddLink(language.GetLocalisableDescription(), LinkAction.FilterBeatmapSetLanguage, language);
else
loaded.AddText(metadata.Name);
}
}
}

View File

@ -0,0 +1,25 @@
// 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 System;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Chat;
namespace osu.Game.Overlays.BeatmapSet
{
public partial class MetadataSectionSource : MetadataSection
{
public MetadataSectionSource(Action<string>? searchAction = null)
: base(MetadataType.Source, searchAction)
{
}
protected override void AddMetadata(string metadata, LinkFlowContainer loaded)
{
if (SearchAction != null)
loaded.AddLink(metadata, () => SearchAction(metadata));
else
loaded.AddLink(metadata, LinkAction.SearchBeatmapSet, metadata);
}
}
}

View File

@ -0,0 +1,35 @@
// 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 System;
using osu.Game.Graphics.Containers;
using osu.Game.Online.Chat;
namespace osu.Game.Overlays.BeatmapSet
{
public partial class MetadataSectionTags : MetadataSection
{
public MetadataSectionTags(Action<string>? searchAction = null)
: base(MetadataType.Tags, searchAction)
{
}
protected override void AddMetadata(string metadata, LinkFlowContainer loaded)
{
string[] tags = metadata.Split(" ");
for (int i = 0; i <= tags.Length - 1; i++)
{
string tag = tags[i];
if (SearchAction != null)
loaded.AddLink(tag, () => SearchAction(tag));
else
loaded.AddLink(tag, LinkAction.SearchBeatmapSet, tag);
if (i != tags.Length - 1)
loaded.AddText(" ");
}
}
}
}

View File

@ -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 Humanizer; using Humanizer;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -25,15 +23,15 @@ namespace osu.Game.Overlays.Profile.Header
{ {
public partial class BottomHeaderContainer : CompositeDrawable public partial class BottomHeaderContainer : CompositeDrawable
{ {
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
private LinkFlowContainer topLinkContainer; private LinkFlowContainer topLinkContainer = null!;
private LinkFlowContainer bottomLinkContainer; private LinkFlowContainer bottomLinkContainer = null!;
private Color4 iconColour; private Color4 iconColour;
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; } = null!;
public BottomHeaderContainer() public BottomHeaderContainer()
{ {
@ -78,7 +76,7 @@ namespace osu.Game.Overlays.Profile.Header
User.BindValueChanged(user => updateDisplay(user.NewValue)); User.BindValueChanged(user => updateDisplay(user.NewValue));
} }
private void updateDisplay(APIUser user) private void updateDisplay(APIUser? user)
{ {
topLinkContainer.Clear(); topLinkContainer.Clear();
bottomLinkContainer.Clear(); bottomLinkContainer.Clear();
@ -164,7 +162,7 @@ namespace osu.Game.Overlays.Profile.Header
private void addSpacer(OsuTextFlowContainer textFlow) => textFlow.AddArbitraryDrawable(new Container { Width = 15 }); private void addSpacer(OsuTextFlowContainer textFlow) => textFlow.AddArbitraryDrawable(new Container { Width = 15 });
private bool tryAddInfo(IconUsage icon, string content, string link = null) private bool tryAddInfo(IconUsage icon, string content, string? link = null)
{ {
if (string.IsNullOrEmpty(content)) return false; if (string.IsNullOrEmpty(content)) return false;

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
@ -20,10 +18,10 @@ namespace osu.Game.Overlays.Profile.Header
public partial class CentreHeaderContainer : CompositeDrawable public partial class CentreHeaderContainer : CompositeDrawable
{ {
public readonly BindableBool DetailsVisible = new BindableBool(true); public readonly BindableBool DetailsVisible = new BindableBool(true);
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
private OverlinedInfoContainer hiddenDetailGlobal; private OverlinedInfoContainer hiddenDetailGlobal = null!;
private OverlinedInfoContainer hiddenDetailCountry; private OverlinedInfoContainer hiddenDetailCountry = null!;
public CentreHeaderContainer() public CentreHeaderContainer()
{ {
@ -146,7 +144,7 @@ namespace osu.Game.Overlays.Profile.Header
User.BindValueChanged(user => updateDisplay(user.NewValue)); User.BindValueChanged(user => updateDisplay(user.NewValue));
} }
private void updateDisplay(APIUser user) private void updateDisplay(APIUser? user)
{ {
hiddenDetailGlobal.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; hiddenDetailGlobal.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
hiddenDetailCountry.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-"; hiddenDetailCountry.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
@ -23,9 +21,9 @@ namespace osu.Game.Overlays.Profile.Header.Components
public override LocalisableString TooltipText => DetailsVisible.Value ? CommonStrings.ButtonsCollapse : CommonStrings.ButtonsExpand; public override LocalisableString TooltipText => DetailsVisible.Value ? CommonStrings.ButtonsCollapse : CommonStrings.ButtonsExpand;
private SpriteIcon icon; private SpriteIcon icon = null!;
private Sample sampleOpen; private Sample? sampleOpen;
private Sample sampleClose; private Sample? sampleClose;
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds(); protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds();

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -14,7 +12,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
public partial class FollowersButton : ProfileHeaderStatisticsButton public partial class FollowersButton : ProfileHeaderStatisticsButton
{ {
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public override LocalisableString TooltipText => FriendsStrings.ButtonsDisabled; public override LocalisableString TooltipText => FriendsStrings.ButtonsDisabled;

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -20,11 +18,11 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
public partial class LevelBadge : CompositeDrawable, IHasTooltip public partial class LevelBadge : CompositeDrawable, IHasTooltip
{ {
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public LocalisableString TooltipText { get; private set; } public LocalisableString TooltipText { get; private set; }
private OsuSpriteText levelText; private OsuSpriteText levelText = null!;
public LevelBadge() public LevelBadge()
{ {
@ -53,10 +51,11 @@ namespace osu.Game.Overlays.Profile.Header.Components
User.BindValueChanged(user => updateLevel(user.NewValue)); User.BindValueChanged(user => updateLevel(user.NewValue));
} }
private void updateLevel(APIUser user) private void updateLevel(APIUser? user)
{ {
levelText.Text = user?.Statistics?.Level.Current.ToString() ?? "0"; string level = user?.Statistics?.Level.Current.ToString() ?? "0";
TooltipText = UsersStrings.ShowStatsLevel(user?.Statistics?.Level.Current.ToString()); levelText.Text = level;
TooltipText = UsersStrings.ShowStatsLevel(level);
} }
} }
} }

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
@ -21,12 +19,12 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
public partial class LevelProgressBar : CompositeDrawable, IHasTooltip public partial class LevelProgressBar : CompositeDrawable, IHasTooltip
{ {
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public LocalisableString TooltipText { get; } public LocalisableString TooltipText { get; }
private Bar levelProgressBar; private Bar levelProgressBar = null!;
private OsuSpriteText levelProgressText; private OsuSpriteText levelProgressText = null!;
public LevelProgressBar() public LevelProgressBar()
{ {
@ -61,7 +59,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
User.BindValueChanged(user => updateProgress(user.NewValue)); User.BindValueChanged(user => updateProgress(user.NewValue));
} }
private void updateProgress(APIUser user) private void updateProgress(APIUser? user)
{ {
levelProgressBar.Length = user?.Statistics?.Level.Progress / 100f ?? 0; levelProgressBar.Length = user?.Statistics?.Level.Progress / 100f ?? 0;
levelProgressText.Text = user?.Statistics?.Level.Progress.ToLocalisableString("0'%'") ?? default; levelProgressText.Text = user?.Statistics?.Level.Progress.ToLocalisableString("0'%'") ?? default;

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -14,7 +12,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
public partial class MappingSubscribersButton : ProfileHeaderStatisticsButton public partial class MappingSubscribersButton : ProfileHeaderStatisticsButton
{ {
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public override LocalisableString TooltipText => FollowsStrings.MappingFollowers; public override LocalisableString TooltipText => FollowsStrings.MappingFollowers;

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -18,21 +16,21 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
public partial class MessageUserButton : ProfileHeaderButton public partial class MessageUserButton : ProfileHeaderButton
{ {
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public override LocalisableString TooltipText => UsersStrings.CardSendMessage; public override LocalisableString TooltipText => UsersStrings.CardSendMessage;
[Resolved(CanBeNull = true)] [Resolved]
private ChannelManager channelManager { get; set; } private ChannelManager? channelManager { get; set; }
[Resolved(CanBeNull = true)]
private UserProfileOverlay userOverlay { get; set; }
[Resolved(CanBeNull = true)]
private ChatOverlay chatOverlay { get; set; }
[Resolved] [Resolved]
private IAPIProvider apiProvider { get; set; } private UserProfileOverlay? userOverlay { get; set; }
[Resolved]
private ChatOverlay? chatOverlay { get; set; }
[Resolved]
private IAPIProvider apiProvider { get; set; } = null!;
public MessageUserButton() public MessageUserButton()
{ {
@ -56,7 +54,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
chatOverlay?.Show(); chatOverlay?.Show();
}; };
User.ValueChanged += e => Content.Alpha = !e.NewValue.PMFriendsOnly && apiProvider.LocalUser.Value.Id != e.NewValue.Id ? 1 : 0; User.ValueChanged += e => Content.Alpha = e.NewValue != null && !e.NewValue.PMFriendsOnly && apiProvider.LocalUser.Value.Id != e.NewValue.Id ? 1 : 0;
} }
} }
} }

View File

@ -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 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;

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -16,11 +14,11 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
public partial class OverlinedTotalPlayTime : CompositeDrawable, IHasTooltip public partial class OverlinedTotalPlayTime : CompositeDrawable, IHasTooltip
{ {
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public LocalisableString TooltipText { get; set; } public LocalisableString TooltipText { get; set; }
private OverlinedInfoContainer info; private OverlinedInfoContainer info = null!;
public OverlinedTotalPlayTime() public OverlinedTotalPlayTime()
{ {
@ -41,7 +39,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
User.BindValueChanged(updateTime, true); User.BindValueChanged(updateTime, true);
} }
private void updateTime(ValueChangedEvent<APIUser> user) private void updateTime(ValueChangedEvent<APIUser?> user)
{ {
TooltipText = (user.NewValue?.Statistics?.PlayTime ?? 0) / 3600 + " hours"; TooltipText = (user.NewValue?.Statistics?.PlayTime ?? 0) / 3600 + " hours";
info.Content = formatTime(user.NewValue?.Statistics?.PlayTime); info.Content = formatTime(user.NewValue?.Statistics?.PlayTime);

View File

@ -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.Allocation; using osu.Framework.Allocation;
@ -27,7 +25,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
private const int width = 310; private const int width = 310;
private const int move_offset = 15; private const int move_offset = 15;
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
private readonly TextFlowContainer text; private readonly TextFlowContainer text;
private readonly Box background; private readonly Box background;
@ -109,11 +107,11 @@ namespace osu.Game.Overlays.Profile.Header.Components
User.BindValueChanged(onUserChanged, true); User.BindValueChanged(onUserChanged, true);
} }
private void onUserChanged(ValueChangedEvent<APIUser> user) private void onUserChanged(ValueChangedEvent<APIUser?> user)
{ {
text.Text = string.Empty; text.Text = string.Empty;
string[] usernames = user.NewValue?.PreviousUsernames; string[]? usernames = user.NewValue?.PreviousUsernames;
if (usernames?.Any() ?? false) if (usernames?.Any() ?? false)
{ {
@ -149,7 +147,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
private partial class HoverIconContainer : Container private partial class HoverIconContainer : Container
{ {
public Action ActivateHover; public Action? ActivateHover;
public HoverIconContainer() public HoverIconContainer()
{ {

View File

@ -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.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;

View File

@ -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 osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;

View File

@ -1,9 +1,8 @@
// 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 osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets; using osu.Game.Rulesets;
@ -12,12 +11,12 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
public partial class ProfileRulesetSelector : OverlayRulesetSelector public partial class ProfileRulesetSelector : OverlayRulesetSelector
{ {
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
User.BindValueChanged(u => SetDefaultRuleset(Rulesets.GetRuleset(u.NewValue?.PlayMode ?? "osu")), true); User.BindValueChanged(u => SetDefaultRuleset(Rulesets.GetRuleset(u.NewValue?.PlayMode ?? "osu").AsNonNull()), true);
} }
public void SetDefaultRuleset(RulesetInfo ruleset) public void SetDefaultRuleset(RulesetInfo ruleset)

View File

@ -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 osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;

View File

@ -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.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -21,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
{ {
private const int ranked_days = 88; private const int ranked_days = 88;
public readonly Bindable<UserStatistics> Statistics = new Bindable<UserStatistics>(); public readonly Bindable<UserStatistics?> Statistics = new Bindable<UserStatistics?>();
private readonly OsuSpriteText placeholder; private readonly OsuSpriteText placeholder;
@ -42,11 +40,11 @@ namespace osu.Game.Overlays.Profile.Header.Components
Statistics.BindValueChanged(statistics => updateStatistics(statistics.NewValue), true); Statistics.BindValueChanged(statistics => updateStatistics(statistics.NewValue), true);
} }
private void updateStatistics(UserStatistics statistics) private void updateStatistics(UserStatistics? statistics)
{ {
// checking both IsRanked and RankHistory is required. // checking both IsRanked and RankHistory is required.
// see https://github.com/ppy/osu-web/blob/154ceafba0f35a1dd935df53ec98ae2ea5615f9f/resources/assets/lib/profile-page/rank-chart.tsx#L46 // see https://github.com/ppy/osu-web/blob/154ceafba0f35a1dd935df53ec98ae2ea5615f9f/resources/assets/lib/profile-page/rank-chart.tsx#L46
int[] userRanks = statistics?.IsRanked == true ? statistics.RankHistory?.Data : null; int[]? userRanks = statistics?.IsRanked == true ? statistics.RankHistory?.Data : null;
Data = userRanks?.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray(); Data = userRanks?.Select((x, index) => new KeyValuePair<int, int>(index, x)).Where(x => x.Value != 0).ToArray();
} }

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -82,10 +80,10 @@ namespace osu.Game.Overlays.Profile.Header.Components
} }
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; } = null!;
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader]
private void load(OsuGame game) private void load(OsuGame? game)
{ {
background.Colour = colours.Pink; background.Colour = colours.Pink;

View File

@ -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.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -25,14 +23,14 @@ namespace osu.Game.Overlays.Profile.Header
public partial class DetailHeaderContainer : CompositeDrawable public partial class DetailHeaderContainer : CompositeDrawable
{ {
private readonly Dictionary<ScoreRank, ScoreRankInfo> scoreRankInfos = new Dictionary<ScoreRank, ScoreRankInfo>(); private readonly Dictionary<ScoreRank, ScoreRankInfo> scoreRankInfos = new Dictionary<ScoreRank, ScoreRankInfo>();
private OverlinedInfoContainer medalInfo; private OverlinedInfoContainer medalInfo = null!;
private OverlinedInfoContainer ppInfo; private OverlinedInfoContainer ppInfo = null!;
private OverlinedInfoContainer detailGlobalRank; private OverlinedInfoContainer detailGlobalRank = null!;
private OverlinedInfoContainer detailCountryRank; private OverlinedInfoContainer detailCountryRank = null!;
private FillFlowContainer fillFlow; private FillFlowContainer? fillFlow;
private RankGraph rankGraph; private RankGraph rankGraph = null!;
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
private bool expanded = true; private bool expanded = true;
@ -173,7 +171,7 @@ namespace osu.Game.Overlays.Profile.Header
}; };
} }
private void updateDisplay(APIUser user) private void updateDisplay(APIUser? user)
{ {
medalInfo.Content = user?.Achievements?.Length.ToString() ?? "0"; medalInfo.Content = user?.Achievements?.Length.ToString() ?? "0";
ppInfo.Content = user?.Statistics?.PP?.ToLocalisableString("#,##0") ?? (LocalisableString)"0"; ppInfo.Content = user?.Statistics?.PP?.ToLocalisableString("#,##0") ?? (LocalisableString)"0";

View File

@ -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.Threading; using System.Threading;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -20,9 +18,9 @@ namespace osu.Game.Overlays.Profile.Header
{ {
public partial class MedalHeaderContainer : CompositeDrawable public partial class MedalHeaderContainer : CompositeDrawable
{ {
private FillFlowContainer badgeFlowContainer; private FillFlowContainer badgeFlowContainer = null!;
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider)
@ -66,16 +64,16 @@ namespace osu.Game.Overlays.Profile.Header
}; };
} }
private CancellationTokenSource cancellationTokenSource; private CancellationTokenSource? cancellationTokenSource;
private void updateDisplay(APIUser user) private void updateDisplay(APIUser? user)
{ {
cancellationTokenSource?.Cancel(); cancellationTokenSource?.Cancel();
cancellationTokenSource = new CancellationTokenSource(); cancellationTokenSource = new CancellationTokenSource();
badgeFlowContainer.Clear(); badgeFlowContainer.Clear();
var badges = user.Badges; var badges = user?.Badges;
if (badges?.Length > 0) if (badges?.Length > 0)
{ {

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
@ -29,19 +27,19 @@ namespace osu.Game.Overlays.Profile.Header
{ {
private const float avatar_size = 110; private const float avatar_size = 110;
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; } = null!;
private SupporterIcon supporterTag; private SupporterIcon supporterTag = null!;
private UpdateableAvatar avatar; private UpdateableAvatar avatar = null!;
private OsuSpriteText usernameText; private OsuSpriteText usernameText = null!;
private ExternalLinkButton openUserExternally; private ExternalLinkButton openUserExternally = null!;
private OsuSpriteText titleText; private OsuSpriteText titleText = null!;
private UpdateableFlag userFlag; private UpdateableFlag userFlag = null!;
private OsuSpriteText userCountryText; private OsuSpriteText userCountryText = null!;
private FillFlowContainer userStats; private FillFlowContainer userStats = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider)
@ -176,7 +174,7 @@ namespace osu.Game.Overlays.Profile.Header
User.BindValueChanged(user => updateUser(user.NewValue)); User.BindValueChanged(user => updateUser(user.NewValue));
} }
private void updateUser(APIUser user) private void updateUser(APIUser? user)
{ {
avatar.User = user; avatar.User = user;
usernameText.Text = user?.Username ?? string.Empty; usernameText.Text = user?.Username ?? string.Empty;

View File

@ -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.Diagnostics; using System.Diagnostics;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -20,9 +18,9 @@ namespace osu.Game.Overlays.Profile
{ {
public partial class ProfileHeader : TabControlOverlayHeader<LocalisableString> public partial class ProfileHeader : TabControlOverlayHeader<LocalisableString>
{ {
private UserCoverBackground coverContainer; private UserCoverBackground coverContainer = null!;
public Bindable<APIUser> User = new Bindable<APIUser>(); public Bindable<APIUser?> User = new Bindable<APIUser?>();
private CentreHeaderContainer centreHeaderContainer; private CentreHeaderContainer centreHeaderContainer;
private DetailHeaderContainer detailHeaderContainer; private DetailHeaderContainer detailHeaderContainer;
@ -102,7 +100,7 @@ namespace osu.Game.Overlays.Profile
protected override OverlayTitle CreateTitle() => new ProfileHeaderTitle(); protected override OverlayTitle CreateTitle() => new ProfileHeaderTitle();
private void updateDisplay(APIUser user) => coverContainer.User = user; private void updateDisplay(APIUser? user) => coverContainer.User = user;
private partial class ProfileHeaderTitle : OverlayTitle private partial class ProfileHeaderTitle : OverlayTitle
{ {

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -31,7 +29,7 @@ namespace osu.Game.Overlays.Profile
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
public readonly Bindable<APIUser> User = new Bindable<APIUser>(); public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
protected ProfileSection() protected ProfileSection()
{ {

View File

@ -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 osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -25,8 +23,8 @@ namespace osu.Game.Overlays.Profile.Sections
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
} }
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader]
private void load(BeatmapSetOverlay beatmapSetOverlay) private void load(BeatmapSetOverlay? beatmapSetOverlay)
{ {
Action = () => Action = () =>
{ {

View File

@ -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.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -24,7 +22,7 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
protected override int InitialItemsCount => type == BeatmapSetType.Graveyard ? 2 : 6; protected override int InitialItemsCount => type == BeatmapSetType.Graveyard ? 2 : 6;
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<APIUser> user, LocalisableString headerText) public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<APIUser?> user, LocalisableString headerText)
: base(user, headerText) : base(user, headerText)
{ {
this.type = type; this.type = type;
@ -66,10 +64,10 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
} }
} }
protected override APIRequest<List<APIBeatmapSet>> CreateRequest(PaginationParameters pagination) => protected override APIRequest<List<APIBeatmapSet>> CreateRequest(APIUser user, PaginationParameters pagination) =>
new GetUserBeatmapsRequest(User.Value.Id, type, pagination); new GetUserBeatmapsRequest(user.Id, type, pagination);
protected override Drawable CreateDrawableItem(APIBeatmapSet model) => model.OnlineID > 0 protected override Drawable? CreateDrawableItem(APIBeatmapSet model) => model.OnlineID > 0
? new BeatmapCardNormal(model) ? new BeatmapCardNormal(model)
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,

View File

@ -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 osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Profile.Sections.Beatmaps; using osu.Game.Overlays.Profile.Sections.Beatmaps;

View File

@ -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 osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -18,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections
{ {
public readonly BindableInt Current = new BindableInt(); public readonly BindableInt Current = new BindableInt();
private OsuSpriteText counter; private OsuSpriteText counter = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider)

View File

@ -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.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -15,14 +13,14 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{ {
public abstract partial class ChartProfileSubsection : ProfileSubsection public abstract partial class ChartProfileSubsection : ProfileSubsection
{ {
private ProfileLineChart chart; private ProfileLineChart chart = null!;
/// <summary> /// <summary>
/// Text describing the value being plotted on the graph, which will be displayed as a prefix to the value in the history graph tooltip. /// Text describing the value being plotted on the graph, which will be displayed as a prefix to the value in the history graph tooltip.
/// </summary> /// </summary>
protected abstract LocalisableString GraphCounterName { get; } protected abstract LocalisableString GraphCounterName { get; }
protected ChartProfileSubsection(Bindable<APIUser> user, LocalisableString headerText) protected ChartProfileSubsection(Bindable<APIUser?> user, LocalisableString headerText)
: base(user, headerText) : base(user, headerText)
{ {
} }
@ -46,7 +44,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
User.BindValueChanged(onUserChanged, true); User.BindValueChanged(onUserChanged, true);
} }
private void onUserChanged(ValueChangedEvent<APIUser> e) private void onUserChanged(ValueChangedEvent<APIUser?> e)
{ {
var values = GetValues(e.NewValue); var values = GetValues(e.NewValue);
@ -86,6 +84,6 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
return filledHistoryEntries.ToArray(); return filledHistoryEntries.ToArray();
} }
protected abstract APIUserHistoryCount[] GetValues(APIUser user); protected abstract APIUserHistoryCount[]? GetValues(APIUser? user);
} }
} }

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;

View File

@ -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.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -18,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{ {
public partial class PaginatedMostPlayedBeatmapContainer : PaginatedProfileSubsection<APIUserMostPlayedBeatmap> public partial class PaginatedMostPlayedBeatmapContainer : PaginatedProfileSubsection<APIUserMostPlayedBeatmap>
{ {
public PaginatedMostPlayedBeatmapContainer(Bindable<APIUser> user) public PaginatedMostPlayedBeatmapContainer(Bindable<APIUser?> user)
: base(user, UsersStrings.ShowExtraHistoricalMostPlayedTitle) : base(user, UsersStrings.ShowExtraHistoricalMostPlayedTitle)
{ {
} }
@ -31,8 +29,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
protected override int GetCount(APIUser user) => user.BeatmapPlayCountsCount; protected override int GetCount(APIUser user) => user.BeatmapPlayCountsCount;
protected override APIRequest<List<APIUserMostPlayedBeatmap>> CreateRequest(PaginationParameters pagination) => protected override APIRequest<List<APIUserMostPlayedBeatmap>> CreateRequest(APIUser user, PaginationParameters pagination) =>
new GetUserMostPlayedBeatmapsRequest(User.Value.Id, pagination); new GetUserMostPlayedBeatmapsRequest(user.Id, pagination);
protected override Drawable CreateDrawableItem(APIUserMostPlayedBeatmap mostPlayed) => protected override Drawable CreateDrawableItem(APIUserMostPlayedBeatmap mostPlayed) =>
new DrawableMostPlayedBeatmap(mostPlayed); new DrawableMostPlayedBeatmap(mostPlayed);

View File

@ -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 osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -14,11 +12,11 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{ {
protected override LocalisableString GraphCounterName => UsersStrings.ShowExtraHistoricalMonthlyPlaycountsCountLabel; protected override LocalisableString GraphCounterName => UsersStrings.ShowExtraHistoricalMonthlyPlaycountsCountLabel;
public PlayHistorySubsection(Bindable<APIUser> user) public PlayHistorySubsection(Bindable<APIUser?> user)
: base(user, UsersStrings.ShowExtraHistoricalMonthlyPlaycountsTitle) : base(user, UsersStrings.ShowExtraHistoricalMonthlyPlaycountsTitle)
{ {
} }
protected override APIUserHistoryCount[] GetValues(APIUser user) => user?.MonthlyPlayCounts; protected override APIUserHistoryCount[]? GetValues(APIUser? user) => user?.MonthlyPlayCounts;
} }
} }

View File

@ -1,11 +1,8 @@
// 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 osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using JetBrains.Annotations;
using System; using System;
using System.Linq; using System.Linq;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
@ -22,9 +19,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{ {
public partial class ProfileLineChart : CompositeDrawable public partial class ProfileLineChart : CompositeDrawable
{ {
private APIUserHistoryCount[] values; private APIUserHistoryCount[] values = Array.Empty<APIUserHistoryCount>();
[NotNull]
public APIUserHistoryCount[] Values public APIUserHistoryCount[] Values
{ {
get => values; get => values;

View File

@ -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 osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -14,11 +12,11 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{ {
protected override LocalisableString GraphCounterName => UsersStrings.ShowExtraHistoricalReplaysWatchedCountsCountLabel; protected override LocalisableString GraphCounterName => UsersStrings.ShowExtraHistoricalReplaysWatchedCountsCountLabel;
public ReplaysSubsection(Bindable<APIUser> user) public ReplaysSubsection(Bindable<APIUser?> user)
: base(user, UsersStrings.ShowExtraHistoricalReplaysWatchedCountsTitle) : base(user, UsersStrings.ShowExtraHistoricalReplaysWatchedCountsTitle)
{ {
} }
protected override APIUserHistoryCount[] GetValues(APIUser user) => user?.ReplaysWatchedCounts; protected override APIUserHistoryCount[]? GetValues(APIUser? user) => user?.ReplaysWatchedCounts;
} }
} }

View File

@ -1,12 +1,9 @@
// 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.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -17,8 +14,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{ {
private readonly LocalisableString tooltipCounterName; private readonly LocalisableString tooltipCounterName;
[CanBeNull] public APIUserHistoryCount[]? Values
public APIUserHistoryCount[] Values
{ {
set => Data = value?.Select(v => new KeyValuePair<DateTime, long>(v.Date, v.Count)).ToArray(); set => Data = value?.Select(v => new KeyValuePair<DateTime, long>(v.Date, v.Count)).ToArray();
} }

View File

@ -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 osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -20,7 +18,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
private const int height = 25; private const int height = 25;
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; } = null!;
private readonly APIKudosuHistory historyItem; private readonly APIKudosuHistory historyItem;
private readonly LinkFlowContainer linkFlowContainer; private readonly LinkFlowContainer linkFlowContainer;

View File

@ -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 osu.Framework.Bindables; using osu.Framework.Bindables;
using osuTK; using osuTK;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -22,9 +20,9 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
{ {
public partial class KudosuInfo : Container public partial class KudosuInfo : Container
{ {
private readonly Bindable<APIUser> user = new Bindable<APIUser>(); private readonly Bindable<APIUser?> user = new Bindable<APIUser?>();
public KudosuInfo(Bindable<APIUser> user) public KudosuInfo(Bindable<APIUser?> user)
{ {
this.user.BindTo(user); this.user.BindTo(user);
CountSection total; CountSection total;

View File

@ -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 osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -16,13 +14,13 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
{ {
public partial class PaginatedKudosuHistoryContainer : PaginatedProfileSubsection<APIKudosuHistory> public partial class PaginatedKudosuHistoryContainer : PaginatedProfileSubsection<APIKudosuHistory>
{ {
public PaginatedKudosuHistoryContainer(Bindable<APIUser> user) public PaginatedKudosuHistoryContainer(Bindable<APIUser?> user)
: base(user, missingText: UsersStrings.ShowExtraKudosuEntryEmpty) : base(user, missingText: UsersStrings.ShowExtraKudosuEntryEmpty)
{ {
} }
protected override APIRequest<List<APIKudosuHistory>> CreateRequest(PaginationParameters pagination) protected override APIRequest<List<APIKudosuHistory>> CreateRequest(APIUser user, PaginationParameters pagination)
=> new GetUserKudosuHistoryRequest(User.Value.Id, pagination); => new GetUserKudosuHistoryRequest(user.Id, pagination);
protected override Drawable CreateDrawableItem(APIKudosuHistory item) => new DrawableKudosuHistoryItem(item); protected override Drawable CreateDrawableItem(APIKudosuHistory item) => new DrawableKudosuHistoryItem(item);
} }

View File

@ -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 osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Overlays.Profile.Sections.Kudosu; using osu.Game.Overlays.Profile.Sections.Kudosu;
using osu.Framework.Localisation; using osu.Framework.Localisation;

View File

@ -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 osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;

View File

@ -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.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -35,20 +33,20 @@ namespace osu.Game.Overlays.Profile.Sections
protected virtual int InitialItemsCount => 5; protected virtual int InitialItemsCount => 5;
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; } = null!;
protected PaginationParameters? CurrentPage { get; private set; } protected PaginationParameters? CurrentPage { get; private set; }
protected ReverseChildIDFillFlowContainer<Drawable> ItemsContainer { get; private set; } protected ReverseChildIDFillFlowContainer<Drawable> ItemsContainer { get; private set; } = null!;
private APIRequest<List<TModel>> retrievalRequest; private APIRequest<List<TModel>>? retrievalRequest;
private CancellationTokenSource loadCancellation; private CancellationTokenSource? loadCancellation;
private ShowMoreButton moreButton; private ShowMoreButton moreButton = null!;
private OsuSpriteText missing; private OsuSpriteText missing = null!;
private readonly LocalisableString? missingText; private readonly LocalisableString? missingText;
protected PaginatedProfileSubsection(Bindable<APIUser> user, LocalisableString? headerText = null, LocalisableString? missingText = null) protected PaginatedProfileSubsection(Bindable<APIUser?> user, LocalisableString? headerText = null, LocalisableString? missingText = null)
: base(user, headerText, CounterVisibilityState.AlwaysVisible) : base(user, headerText, CounterVisibilityState.AlwaysVisible)
{ {
this.missingText = missingText; this.missingText = missingText;
@ -94,7 +92,7 @@ namespace osu.Game.Overlays.Profile.Sections
User.BindValueChanged(onUserChanged, true); User.BindValueChanged(onUserChanged, true);
} }
private void onUserChanged(ValueChangedEvent<APIUser> e) private void onUserChanged(ValueChangedEvent<APIUser?> e)
{ {
loadCancellation?.Cancel(); loadCancellation?.Cancel();
retrievalRequest?.Cancel(); retrievalRequest?.Cancel();
@ -111,17 +109,20 @@ namespace osu.Game.Overlays.Profile.Sections
private void showMore() private void showMore()
{ {
if (User.Value == null)
return;
loadCancellation = new CancellationTokenSource(); loadCancellation = new CancellationTokenSource();
CurrentPage = CurrentPage?.TakeNext(ItemsPerPage) ?? new PaginationParameters(InitialItemsCount); CurrentPage = CurrentPage?.TakeNext(ItemsPerPage) ?? new PaginationParameters(InitialItemsCount);
retrievalRequest = CreateRequest(CurrentPage.Value); retrievalRequest = CreateRequest(User.Value, CurrentPage.Value);
retrievalRequest.Success += UpdateItems; retrievalRequest.Success += items => UpdateItems(items, loadCancellation);
api.Queue(retrievalRequest); api.Queue(retrievalRequest);
} }
protected virtual void UpdateItems(List<TModel> items) => Schedule(() => protected virtual void UpdateItems(List<TModel> items, CancellationTokenSource cancellationTokenSource) => Schedule(() =>
{ {
OnItemsReceived(items); OnItemsReceived(items);
@ -136,7 +137,7 @@ namespace osu.Game.Overlays.Profile.Sections
return; return;
} }
LoadComponentsAsync(items.Select(CreateDrawableItem).Where(d => d != null), drawables => LoadComponentsAsync(items.Select(CreateDrawableItem).Where(d => d != null).Cast<Drawable>(), drawables =>
{ {
missing.Hide(); missing.Hide();
@ -144,7 +145,7 @@ namespace osu.Game.Overlays.Profile.Sections
moreButton.IsLoading = false; moreButton.IsLoading = false;
ItemsContainer.AddRange(drawables); ItemsContainer.AddRange(drawables);
}, loadCancellation.Token); }, cancellationTokenSource.Token);
}); });
protected virtual int GetCount(APIUser user) => 0; protected virtual int GetCount(APIUser user) => 0;
@ -153,9 +154,9 @@ namespace osu.Game.Overlays.Profile.Sections
{ {
} }
protected abstract APIRequest<List<TModel>> CreateRequest(PaginationParameters pagination); protected abstract APIRequest<List<TModel>> CreateRequest(APIUser user, PaginationParameters pagination);
protected abstract Drawable CreateDrawableItem(TModel model); protected abstract Drawable? CreateDrawableItem(TModel model);
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;

View File

@ -1,13 +1,10 @@
// 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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using JetBrains.Annotations;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -15,14 +12,14 @@ namespace osu.Game.Overlays.Profile.Sections
{ {
public abstract partial class ProfileSubsection : FillFlowContainer public abstract partial class ProfileSubsection : FillFlowContainer
{ {
protected readonly Bindable<APIUser> User = new Bindable<APIUser>(); protected readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
private readonly LocalisableString headerText; private readonly LocalisableString headerText;
private readonly CounterVisibilityState counterVisibilityState; private readonly CounterVisibilityState counterVisibilityState;
private ProfileSubsectionHeader header; private ProfileSubsectionHeader header = null!;
protected ProfileSubsection(Bindable<APIUser> user, LocalisableString? headerText = null, CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden) protected ProfileSubsection(Bindable<APIUser?> user, LocalisableString? headerText = null, CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
{ {
this.headerText = headerText ?? string.Empty; this.headerText = headerText ?? string.Empty;
this.counterVisibilityState = counterVisibilityState; this.counterVisibilityState = counterVisibilityState;
@ -46,7 +43,6 @@ namespace osu.Game.Overlays.Profile.Sections
}; };
} }
[NotNull]
protected abstract Drawable CreateContent(); protected abstract Drawable CreateContent();
protected void SetCount(int value) => header.Current.Value = value; protected void SetCount(int value) => header.Current.Value = value;

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -30,7 +28,7 @@ namespace osu.Game.Overlays.Profile.Sections
private readonly LocalisableString text; private readonly LocalisableString text;
private readonly CounterVisibilityState counterState; private readonly CounterVisibilityState counterState;
private CounterPill counterPill; private CounterPill counterPill = null!;
public ProfileSubsectionHeader(LocalisableString text, CounterVisibilityState counterState) public ProfileSubsectionHeader(LocalisableString text, CounterVisibilityState counterState)
{ {

View File

@ -1,12 +1,10 @@
// 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 JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
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;
@ -34,10 +32,10 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
protected readonly SoloScoreInfo Score; protected readonly SoloScoreInfo Score;
[Resolved] [Resolved]
private OsuColour colours { get; set; } private OsuColour colours { get; set; } = null!;
[Resolved] [Resolved]
private OverlayColourProvider colourProvider { get; set; } private OverlayColourProvider colourProvider { get; set; } = null!;
public DrawableProfileScore(SoloScoreInfo score) public DrawableProfileScore(SoloScoreInfo score)
{ {
@ -84,7 +82,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Spacing = new Vector2(0, 2), Spacing = new Vector2(0, 2),
Children = new Drawable[] Children = new Drawable[]
{ {
new ScoreBeatmapMetadataContainer(Score.Beatmap), new ScoreBeatmapMetadataContainer(Score.Beatmap.AsNonNull()),
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
@ -94,7 +92,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{ {
new OsuSpriteText new OsuSpriteText
{ {
Text = $"{Score.Beatmap?.DifficultyName}", Text = $"{Score.Beatmap.AsNonNull().DifficultyName}",
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular), Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
Colour = colours.Yellow Colour = colours.Yellow
}, },
@ -199,7 +197,6 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
}); });
} }
[NotNull]
protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy(); protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy();
protected Drawable CreateDrawableAccuracy() => new Container protected Drawable CreateDrawableAccuracy() => new Container

View File

@ -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 osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;

View File

@ -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 osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using System; using System;
@ -21,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{ {
private readonly ScoreType type; private readonly ScoreType type;
public PaginatedScoreContainer(ScoreType type, Bindable<APIUser> user, LocalisableString headerText) public PaginatedScoreContainer(ScoreType type, Bindable<APIUser?> user, LocalisableString headerText)
: base(user, headerText) : base(user, headerText)
{ {
this.type = type; this.type = type;
@ -62,8 +60,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
base.OnItemsReceived(items); base.OnItemsReceived(items);
} }
protected override APIRequest<List<SoloScoreInfo>> CreateRequest(PaginationParameters pagination) => protected override APIRequest<List<SoloScoreInfo>> CreateRequest(APIUser user, PaginationParameters pagination) =>
new GetUserScoresRequest(User.Value.Id, type, pagination); new GetUserScoresRequest(user.Id, type, pagination);
private int drawableItemIndex; private int drawableItemIndex;

View File

@ -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 osu.Game.Overlays.Profile.Sections.Ranks; using osu.Game.Overlays.Profile.Sections.Ranks;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Framework.Localisation; using osu.Framework.Localisation;

View File

@ -1,10 +1,9 @@
// 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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -24,14 +23,14 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
private const int font_size = 14; private const int font_size = 14;
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; } = null!;
[Resolved] [Resolved]
private IRulesetStore rulesets { get; set; } private IRulesetStore rulesets { get; set; } = null!;
private readonly APIRecentActivity activity; private readonly APIRecentActivity activity;
private LinkFlowContainer content; private LinkFlowContainer content = null!;
public DrawableRecentActivity(APIRecentActivity activity) public DrawableRecentActivity(APIRecentActivity activity)
{ {
@ -216,15 +215,15 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
rulesets.AvailableRulesets.FirstOrDefault(r => r.ShortName == activity.Mode)?.Name ?? activity.Mode; rulesets.AvailableRulesets.FirstOrDefault(r => r.ShortName == activity.Mode)?.Name ?? activity.Mode;
private void addUserLink() private void addUserLink()
=> content.AddLink(activity.User?.Username, LinkAction.OpenUserProfile, getLinkArgument(activity.User?.Url), creationParameters: t => t.Font = getLinkFont(FontWeight.Bold)); => content.AddLink(activity.User.AsNonNull().Username, LinkAction.OpenUserProfile, getLinkArgument(activity.User.AsNonNull().Url), creationParameters: t => t.Font = getLinkFont(FontWeight.Bold));
private void addBeatmapLink() private void addBeatmapLink()
=> content.AddLink(activity.Beatmap?.Title, LinkAction.OpenBeatmap, getLinkArgument(activity.Beatmap?.Url), creationParameters: t => t.Font = getLinkFont()); => content.AddLink(activity.Beatmap.AsNonNull().Title, LinkAction.OpenBeatmap, getLinkArgument(activity.Beatmap.AsNonNull().Url), creationParameters: t => t.Font = getLinkFont());
private void addBeatmapsetLink() private void addBeatmapsetLink()
=> content.AddLink(activity.Beatmapset?.Title, LinkAction.OpenBeatmapSet, getLinkArgument(activity.Beatmapset?.Url), creationParameters: t => t.Font = getLinkFont()); => content.AddLink(activity.Beatmapset.AsNonNull().Title, LinkAction.OpenBeatmapSet, getLinkArgument(activity.Beatmapset.AsNonNull().Url), creationParameters: t => t.Font = getLinkFont());
private string getLinkArgument(string url) => MessageFormatter.GetLinkDetails($"{api.WebsiteRootUrl}{url}").Argument.ToString(); private string getLinkArgument(string url) => MessageFormatter.GetLinkDetails($"{api.WebsiteRootUrl}{url}").Argument.ToString().AsNonNull();
private FontUsage getLinkFont(FontWeight fontWeight = FontWeight.Regular) private FontUsage getLinkFont(FontWeight fontWeight = FontWeight.Regular)
=> OsuFont.GetFont(size: font_size, weight: fontWeight, italics: true); => OsuFont.GetFont(size: font_size, weight: fontWeight, italics: true);

View File

@ -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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;

View File

@ -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 osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -18,7 +16,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
{ {
public partial class PaginatedRecentActivityContainer : PaginatedProfileSubsection<APIRecentActivity> public partial class PaginatedRecentActivityContainer : PaginatedProfileSubsection<APIRecentActivity>
{ {
public PaginatedRecentActivityContainer(Bindable<APIUser> user) public PaginatedRecentActivityContainer(Bindable<APIUser?> user)
: base(user, missingText: EventsStrings.Empty) : base(user, missingText: EventsStrings.Empty)
{ {
} }
@ -29,8 +27,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
ItemsContainer.Spacing = new Vector2(0, 8); ItemsContainer.Spacing = new Vector2(0, 8);
} }
protected override APIRequest<List<APIRecentActivity>> CreateRequest(PaginationParameters pagination) => protected override APIRequest<List<APIRecentActivity>> CreateRequest(APIUser user, PaginationParameters pagination) =>
new GetUserRecentActivitiesRequest(User.Value.Id, pagination); new GetUserRecentActivitiesRequest(user.Id, pagination);
protected override Drawable CreateDrawableItem(APIRecentActivity model) => new DrawableRecentActivity(model); protected override Drawable CreateDrawableItem(APIRecentActivity model) => new DrawableRecentActivity(model);
} }

View File

@ -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 osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Overlays.Profile.Sections.Recent; using osu.Game.Overlays.Profile.Sections.Recent;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;

View File

@ -1,12 +1,9 @@
// 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.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -26,12 +23,12 @@ namespace osu.Game.Overlays.Profile
/// </summary> /// </summary>
/// <typeparam name="TKey">Type of data to be used for X-axis of the graph.</typeparam> /// <typeparam name="TKey">Type of data to be used for X-axis of the graph.</typeparam>
/// <typeparam name="TValue">Type of data to be used for Y-axis of the graph.</typeparam> /// <typeparam name="TValue">Type of data to be used for Y-axis of the graph.</typeparam>
public abstract partial class UserGraph<TKey, TValue> : Container, IHasCustomTooltip<UserGraphTooltipContent> public abstract partial class UserGraph<TKey, TValue> : Container, IHasCustomTooltip<UserGraphTooltipContent?>
{ {
protected const float FADE_DURATION = 150; protected const float FADE_DURATION = 150;
private readonly UserLineGraph graph; private readonly UserLineGraph graph;
private KeyValuePair<TKey, TValue>[] data; private KeyValuePair<TKey, TValue>[]? data;
private int hoveredIndex = -1; private int hoveredIndex = -1;
protected UserGraph() protected UserGraph()
@ -83,8 +80,7 @@ namespace osu.Game.Overlays.Profile
/// <summary> /// <summary>
/// Set of values which will be used to create a graph. /// Set of values which will be used to create a graph.
/// </summary> /// </summary>
[CanBeNull] protected KeyValuePair<TKey, TValue>[]? Data
protected KeyValuePair<TKey, TValue>[] Data
{ {
set set
{ {
@ -120,9 +116,9 @@ namespace osu.Game.Overlays.Profile
protected virtual void ShowGraph() => graph.FadeIn(FADE_DURATION, Easing.Out); protected virtual void ShowGraph() => graph.FadeIn(FADE_DURATION, Easing.Out);
protected virtual void HideGraph() => graph.FadeOut(FADE_DURATION, Easing.Out); protected virtual void HideGraph() => graph.FadeOut(FADE_DURATION, Easing.Out);
public ITooltip<UserGraphTooltipContent> GetCustomTooltip() => new UserGraphTooltip(); public ITooltip<UserGraphTooltipContent?> GetCustomTooltip() => new UserGraphTooltip();
public UserGraphTooltipContent TooltipContent public UserGraphTooltipContent? TooltipContent
{ {
get get
{ {
@ -143,7 +139,7 @@ namespace osu.Game.Overlays.Profile
private readonly Box ballBg; private readonly Box ballBg;
private readonly Box line; private readonly Box line;
public Action<int> OnBallMove; public Action<int>? OnBallMove;
public UserLineGraph() public UserLineGraph()
{ {
@ -191,7 +187,7 @@ namespace osu.Game.Overlays.Profile
Vector2 position = calculateBallPosition(index); Vector2 position = calculateBallPosition(index);
movingBall.MoveToY(position.Y, duration, Easing.OutQuint); movingBall.MoveToY(position.Y, duration, Easing.OutQuint);
bar.MoveToX(position.X, duration, Easing.OutQuint); bar.MoveToX(position.X, duration, Easing.OutQuint);
OnBallMove.Invoke(index); OnBallMove?.Invoke(index);
} }
public void ShowBar() => bar.FadeIn(FADE_DURATION); public void ShowBar() => bar.FadeIn(FADE_DURATION);
@ -207,7 +203,7 @@ namespace osu.Game.Overlays.Profile
} }
} }
private partial class UserGraphTooltip : VisibilityContainer, ITooltip<UserGraphTooltipContent> private partial class UserGraphTooltip : VisibilityContainer, ITooltip<UserGraphTooltipContent?>
{ {
protected readonly OsuSpriteText Label, Counter, BottomText; protected readonly OsuSpriteText Label, Counter, BottomText;
private readonly Box background; private readonly Box background;
@ -267,8 +263,11 @@ namespace osu.Game.Overlays.Profile
background.Colour = colours.Gray1; background.Colour = colours.Gray1;
} }
public void SetContent(UserGraphTooltipContent content) public void SetContent(UserGraphTooltipContent? content)
{ {
if (content == null)
return;
Label.Text = content.Name; Label.Text = content.Name;
Counter.Text = content.Count; Counter.Text = content.Count;
BottomText.Text = content.Time; BottomText.Text = content.Time;

View File

@ -126,7 +126,8 @@ namespace osu.Game.Overlays
{ {
base.LoadComplete(); base.LoadComplete();
Expanded.BindValueChanged(updateExpandedState, true); Expanded.BindValueChanged(_ => updateExpandedState(true));
updateExpandedState(false);
this.Delay(600).Schedule(updateFadeState); this.Delay(600).Schedule(updateFadeState);
} }
@ -161,21 +162,25 @@ namespace osu.Game.Overlays
return base.OnInvalidate(invalidation, source); return base.OnInvalidate(invalidation, source);
} }
private void updateExpandedState(ValueChangedEvent<bool> expanded) private void updateExpandedState(bool animate)
{ {
// clearing transforms is necessary to avoid a previous height transform // clearing transforms is necessary to avoid a previous height transform
// potentially continuing to get processed while content has changed to autosize. // potentially continuing to get processed while content has changed to autosize.
content.ClearTransforms(); content.ClearTransforms();
if (expanded.NewValue) if (Expanded.Value)
{
content.AutoSizeAxes = Axes.Y; content.AutoSizeAxes = Axes.Y;
content.AutoSizeDuration = animate ? transition_duration : 0;
content.AutoSizeEasing = Easing.OutQuint;
}
else else
{ {
content.AutoSizeAxes = Axes.None; content.AutoSizeAxes = Axes.None;
content.ResizeHeightTo(0, transition_duration, Easing.OutQuint); content.ResizeHeightTo(0, animate ? transition_duration : 0, Easing.OutQuint);
} }
headerContent.FadeColour(expanded.NewValue ? Color4.White : OsuColour.Gray(0.5f), 200, Easing.OutQuint); headerContent.FadeColour(Expanded.Value ? Color4.White : OsuColour.Gray(0.5f), 200, Easing.OutQuint);
} }
private void updateFadeState() private void updateFadeState()

View File

@ -1,9 +1,8 @@
// 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.Diagnostics;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -24,11 +23,11 @@ namespace osu.Game.Overlays
{ {
public partial class UserProfileOverlay : FullscreenOverlay<ProfileHeader> public partial class UserProfileOverlay : FullscreenOverlay<ProfileHeader>
{ {
private ProfileSection lastSection; private ProfileSection? lastSection;
private ProfileSection[] sections; private ProfileSection[]? sections;
private GetUserRequest userReq; private GetUserRequest? userReq;
private ProfileSectionsContainer sectionsContainer; private ProfileSectionsContainer? sectionsContainer;
private ProfileSectionTabControl tabs; private ProfileSectionTabControl? tabs;
public const float CONTENT_X_MARGIN = 70; public const float CONTENT_X_MARGIN = 70;
@ -133,6 +132,8 @@ namespace osu.Game.Overlays
private void userLoadComplete(APIUser user) private void userLoadComplete(APIUser user)
{ {
Debug.Assert(sections != null && sectionsContainer != null && tabs != null);
Header.User.Value = user; Header.User.Value = user;
if (user.ProfileOrder != null) if (user.ProfileOrder != null)

View File

@ -5,6 +5,7 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -35,8 +36,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
public readonly Bindable<bool> TicksVisible = new Bindable<bool>(); public readonly Bindable<bool> TicksVisible = new Bindable<bool>();
public readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
[Resolved] [Resolved]
private EditorClock editorClock { get; set; } private EditorClock editorClock { get; set; }
@ -92,6 +91,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private double trackLengthForZoom; private double trackLengthForZoom;
private readonly IBindable<Track> track = new Bindable<Track>();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours, OsuConfigManager config) private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours, OsuConfigManager config)
{ {
@ -139,11 +140,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
waveformOpacity = config.GetBindable<float>(OsuSetting.EditorWaveformOpacity); waveformOpacity = config.GetBindable<float>(OsuSetting.EditorWaveformOpacity);
Beatmap.BindTo(beatmap); track.BindTo(editorClock.Track);
Beatmap.BindValueChanged(b => track.BindValueChanged(_ => waveform.Waveform = beatmap.Value.Waveform, true);
{
waveform.Waveform = b.NewValue.Waveform;
}, true);
Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom); Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
} }

View File

@ -88,7 +88,7 @@ namespace osu.Game.Screens.Edit.Timing
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
}, },
new WaveformComparisonDisplay(), new WaveformComparisonDisplay()
} }
}, },
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Audio; using osu.Framework.Graphics.Audio;
@ -294,13 +295,18 @@ namespace osu.Game.Screens.Edit.Timing
[Resolved] [Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!; private OverlayColourProvider colourProvider { get; set; } = null!;
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; } = null!;
private readonly IBindable<Track> track = new Bindable<Track>();
public WaveformRow(bool isMainRow) public WaveformRow(bool isMainRow)
{ {
this.isMainRow = isMainRow; this.isMainRow = isMainRow;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IBindable<WorkingBeatmap> beatmap) private void load(EditorClock clock)
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
@ -330,6 +336,13 @@ namespace osu.Game.Screens.Edit.Timing
Colour = colourProvider.Content2 Colour = colourProvider.Content2
} }
}; };
track.BindTo(clock.Track);
}
protected override void LoadComplete()
{
track.ValueChanged += _ => waveformGraph.Waveform = beatmap.Value.Waveform;
} }
public int BeatIndex { set => beatIndexText.Text = value.ToString(); } public int BeatIndex { set => beatIndexText.Text = value.ToString(); }

View File

@ -156,6 +156,8 @@ namespace osu.Game.Screens.OnlinePlay
protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new FillFlowContainer<RearrangeableListItem<PlaylistItem>> protected override FillFlowContainer<RearrangeableListItem<PlaylistItem>> CreateListFillFlowContainer() => new FillFlowContainer<RearrangeableListItem<PlaylistItem>>
{ {
LayoutDuration = 200,
LayoutEasing = Easing.OutQuint,
Spacing = new Vector2(0, 2) Spacing = new Vector2(0, 2)
}; };

View File

@ -24,7 +24,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
Items.Remove(item); Items.Remove(item);
SelectedItem.Value = nextItem ?? Items.LastOrDefault(); if (AllowSelection && SelectedItem.Value == item)
SelectedItem.Value = nextItem ?? Items.LastOrDefault();
}; };
} }
} }

View File

@ -171,13 +171,13 @@ namespace osu.Game.Screens.Play.HUD
for (int i = 0; i < Flow.Count; i++) for (int i = 0; i < Flow.Count; i++)
{ {
Flow.SetLayoutPosition(orderedByScore[i], i); Flow.SetLayoutPosition(orderedByScore[i], i);
orderedByScore[i].ScorePosition = CheckValidScorePosition(i + 1) ? i + 1 : null; orderedByScore[i].ScorePosition = CheckValidScorePosition(orderedByScore[i], i + 1) ? i + 1 : null;
} }
sorting.Validate(); sorting.Validate();
} }
protected virtual bool CheckValidScorePosition(int i) => true; protected virtual bool CheckValidScorePosition(GameplayLeaderboardScore score, int position) => true;
private partial class InputDisabledScrollContainer : OsuScrollContainer private partial class InputDisabledScrollContainer : OsuScrollContainer
{ {

Some files were not shown because too many files have changed in this diff Show More