1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 12:32:56 +08:00

Merge branch 'master' into user-profile/decouple-from-api-user

This commit is contained in:
Bartłomiej Dach 2023-01-09 17:47:59 +01:00
commit 0026861bd4
No known key found for this signature in database
65 changed files with 920 additions and 313 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

@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Taiko.Mods
public void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset) public void ApplyToDrawableRuleset(DrawableRuleset<TaikoHitObject> drawableRuleset)
{ {
drawableTaikoRuleset = (DrawableTaikoRuleset)drawableRuleset; drawableTaikoRuleset = (DrawableTaikoRuleset)drawableRuleset;
drawableTaikoRuleset.LockPlayfieldAspect.Value = false; drawableTaikoRuleset.LockPlayfieldMaxAspect.Value = false;
var playfield = (TaikoPlayfield)drawableRuleset.Playfield; var playfield = (TaikoPlayfield)drawableRuleset.Playfield;
playfield.ClassicHitTargetPosition.Value = true; playfield.ClassicHitTargetPosition.Value = true;

View File

@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
public new BindableDouble TimeRange => base.TimeRange; public new BindableDouble TimeRange => base.TimeRange;
public readonly BindableBool LockPlayfieldAspect = new BindableBool(true); public readonly BindableBool LockPlayfieldMaxAspect = new BindableBool(true);
protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping; protected override ScrollVisualisationMethod VisualisationMethod => ScrollVisualisationMethod.Overlapping;
@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Taiko.UI
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TaikoPlayfieldAdjustmentContainer
{ {
LockPlayfieldAspect = { BindTarget = LockPlayfieldAspect } LockPlayfieldMaxAspect = { BindTarget = LockPlayfieldMaxAspect }
}; };
protected override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo); protected override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo);

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

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Taiko.UI
private const float default_relative_height = TaikoPlayfield.DEFAULT_HEIGHT / 768; private const float default_relative_height = TaikoPlayfield.DEFAULT_HEIGHT / 768;
private const float default_aspect = 16f / 9f; private const float default_aspect = 16f / 9f;
public readonly IBindable<bool> LockPlayfieldAspect = new BindableBool(true); public readonly IBindable<bool> LockPlayfieldMaxAspect = new BindableBool(true);
protected override void Update() protected override void Update()
{ {
@ -21,7 +21,12 @@ namespace osu.Game.Rulesets.Taiko.UI
float height = default_relative_height; float height = default_relative_height;
if (LockPlayfieldAspect.Value) // Players coming from stable expect to be able to change the aspect ratio regardless of the window size.
// We originally wanted to limit this more, but there was considerable pushback from the community.
//
// As a middle-ground, the aspect ratio can still be adjusted in the downwards direction but has a maximum limit.
// This is still a bit weird, because readability changes with window size, but it is what it is.
if (LockPlayfieldMaxAspect.Value && Parent.ChildSize.X / Parent.ChildSize.Y > default_aspect)
height *= Math.Clamp(Parent.ChildSize.X / Parent.ChildSize.Y, 0.4f, 4) / default_aspect; height *= Math.Clamp(Parent.ChildSize.X / Parent.ChildSize.Y, 0.4f, 4) / default_aspect;
Height = height; Height = height;

View File

@ -6,6 +6,7 @@
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components.Timelines.Summary; using osu.Game.Screens.Edit.Components.Timelines.Summary;
@ -21,7 +22,13 @@ namespace osu.Game.Tests.Visual.Editing
public TestSceneEditorSummaryTimeline() public TestSceneEditorSummaryTimeline()
{ {
editorBeatmap = new EditorBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)); var beatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
beatmap.ControlPointInfo.Add(100000, new TimingControlPoint { BeatLength = 100 });
beatmap.ControlPointInfo.Add(50000, new DifficultyControlPoint { SliderVelocity = 2 });
beatmap.BeatmapInfo.Bookmarks = new[] { 75000, 125000 };
editorBeatmap = new EditorBeatmap(beatmap);
} }
protected override void LoadComplete() protected override void LoadComplete()

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.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
namespace osu.Game.Tests.Visual.Editing
{
public partial class TestScenePreviewTime : EditorTestScene
{
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
[Test]
public void TestSceneSetPreviewTimingPoint()
{
AddStep("seek to 1000", () => EditorClock.Seek(1000));
AddAssert("time is 1000", () => EditorClock.CurrentTime == 1000);
AddStep("set current time as preview point", () => Editor.SetPreviewPointToCurrentTime());
AddAssert("preview time is 1000", () => EditorBeatmap.PreviewTime.Value == 1000);
}
[Test]
public void TestScenePreviewTimeline()
{
AddStep("set preview time to -1", () => EditorBeatmap.PreviewTime.Value = -1);
AddAssert("preview time line should not show", () => !Editor.ChildrenOfType<PreviewTimePart>().Single().Children.Any());
AddStep("set preview time to 1000", () => EditorBeatmap.PreviewTime.Value = 1000);
AddAssert("preview time line should show", () => Editor.ChildrenOfType<PreviewTimePart>().Single().Children.Single().Alpha == 1);
}
}
}

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

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

@ -0,0 +1,22 @@
// 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 Newtonsoft.Json;
namespace osu.Game.Beatmaps
{
public struct BeatmapSetOnlineNomination
{
[JsonProperty(@"beatmapset_id")]
public int BeatmapsetId { get; set; }
[JsonProperty(@"reset")]
public bool Reset { get; set; }
[JsonProperty(@"rulesets")]
public string[]? Rulesets { get; set; }
[JsonProperty(@"user_id")]
public int UserId { get; set; }
}
}

View File

@ -5,16 +5,19 @@ using System;
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.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Localisation;
namespace osu.Game.Beatmaps.Drawables.Cards namespace osu.Game.Beatmaps.Drawables.Cards
{ {
public abstract partial class BeatmapCard : OsuClickableContainer public abstract partial class BeatmapCard : OsuClickableContainer, IHasContextMenu
{ {
public const float TRANSITION_DURATION = 400; public const float TRANSITION_DURATION = 400;
public const float CORNER_RADIUS = 10; public const float CORNER_RADIUS = 10;
@ -96,5 +99,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards
throw new ArgumentOutOfRangeException(nameof(size), size, @"Unsupported card size"); throw new ArgumentOutOfRangeException(nameof(size), size, @"Unsupported card size");
} }
} }
public MenuItem[] ContextMenuItems => new MenuItem[]
{
new OsuMenuItem(ContextMenuStrings.ViewBeatmap, MenuItemType.Highlighted, Action),
};
} }
} }

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

@ -54,14 +54,14 @@ namespace osu.Game.Database
public void UpdateStorage(string stablePath) => cachedStorage = new StableStorage(stablePath, gameHost as DesktopGameHost); public void UpdateStorage(string stablePath) => cachedStorage = new StableStorage(stablePath, gameHost as DesktopGameHost);
public bool CheckHardLinkAvailability() public bool CheckSongsFolderHardLinkAvailability()
{ {
var stableStorage = GetCurrentStableStorage(); var stableStorage = GetCurrentStableStorage();
if (stableStorage == null || gameHost is not DesktopGameHost desktopGameHost) if (stableStorage == null || gameHost is not DesktopGameHost desktopGameHost)
return false; return false;
string testExistingPath = stableStorage.GetFullPath(string.Empty); string testExistingPath = stableStorage.GetSongStorage().GetFullPath(string.Empty);
string testDestinationPath = desktopGameHost.Storage.GetFullPath(string.Empty); string testDestinationPath = desktopGameHost.Storage.GetFullPath(string.Empty);
return HardLinkHelper.CheckAvailability(testDestinationPath, testExistingPath); return HardLinkHelper.CheckAvailability(testDestinationPath, testExistingPath);

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

@ -0,0 +1,24 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class ContextMenuStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.ContextMenu";
/// <summary>
/// "View profile"
/// </summary>
public static LocalisableString ViewProfile => new TranslatableString(getKey(@"view_profile"), @"View profile");
/// <summary>
/// "View beatmap"
/// </summary>
public static LocalisableString ViewBeatmap => new TranslatableString(getKey(@"view_beatmap"), @"View beatmap");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -259,7 +259,11 @@ namespace osu.Game.Online.API
var friendsReq = new GetFriendsRequest(); var friendsReq = new GetFriendsRequest();
friendsReq.Failure += _ => state.Value = APIState.Failing; friendsReq.Failure += _ => state.Value = APIState.Failing;
friendsReq.Success += res => friends.AddRange(res); friendsReq.Success += res =>
{
friends.Clear();
friends.AddRange(res);
};
if (!handleRequest(friendsReq)) if (!handleRequest(friendsReq))
{ {

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

@ -111,6 +111,12 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"language")] [JsonProperty(@"language")]
public BeatmapSetOnlineLanguage Language { get; set; } public BeatmapSetOnlineLanguage Language { get; set; }
[JsonProperty(@"current_nominations")]
public BeatmapSetOnlineNomination[]? CurrentNominations { get; set; }
[JsonProperty(@"related_users")]
public APIUser[]? RelatedUsers { get; set; }
public string Source { get; set; } = string.Empty; public string Source { get; set; } = string.Empty;
[JsonProperty(@"tags")] [JsonProperty(@"tags")]

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

@ -10,7 +10,6 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; 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.Game.Graphics.Cursor;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
@ -91,79 +90,74 @@ namespace osu.Game.Overlays.BeatmapSet
}, },
}, },
}, },
new OsuContextMenuContainer new Container
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Child = new Container Padding = new MarginPadding
{ {
RelativeSizeAxes = Axes.X, Vertical = BeatmapSetOverlay.Y_PADDING,
AutoSizeAxes = Axes.Y, Left = BeatmapSetOverlay.X_PADDING,
Padding = new MarginPadding Right = BeatmapSetOverlay.X_PADDING + BeatmapSetOverlay.RIGHT_WIDTH,
},
Children = new Drawable[]
{
fadeContent = new FillFlowContainer
{ {
Vertical = BeatmapSetOverlay.Y_PADDING, RelativeSizeAxes = Axes.X,
Left = BeatmapSetOverlay.X_PADDING, AutoSizeAxes = Axes.Y,
Right = BeatmapSetOverlay.X_PADDING + BeatmapSetOverlay.RIGHT_WIDTH, Direction = FillDirection.Vertical,
}, Children = new Drawable[]
Children = new Drawable[]
{
fadeContent = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, new Container
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{ {
new Container RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = Picker = new BeatmapPicker(),
},
title = new MetadataFlowContainer(s =>
{
s.Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true);
})
{
Margin = new MarginPadding { Top = 15 },
},
artist = new MetadataFlowContainer(s =>
{
s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true);
})
{
Margin = new MarginPadding { Bottom = 20 },
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = author = new AuthorInfo(),
},
beatmapAvailability = new BeatmapAvailability(),
new Container
{
RelativeSizeAxes = Axes.X,
Height = buttons_height,
Margin = new MarginPadding { Top = 10 },
Children = new Drawable[]
{ {
RelativeSizeAxes = Axes.X, favouriteButton = new FavouriteButton
AutoSizeAxes = Axes.Y,
Child = Picker = new BeatmapPicker(),
},
title = new MetadataFlowContainer(s =>
{
s.Font = OsuFont.GetFont(size: 30, weight: FontWeight.SemiBold, italics: true);
})
{
Margin = new MarginPadding { Top = 15 },
},
artist = new MetadataFlowContainer(s =>
{
s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Medium, italics: true);
})
{
Margin = new MarginPadding { Bottom = 20 },
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = author = new AuthorInfo(),
},
beatmapAvailability = new BeatmapAvailability(),
new Container
{
RelativeSizeAxes = Axes.X,
Height = buttons_height,
Margin = new MarginPadding { Top = 10 },
Children = new Drawable[]
{ {
favouriteButton = new FavouriteButton BeatmapSet = { BindTarget = BeatmapSet }
{
BeatmapSet = { BindTarget = BeatmapSet }
},
downloadButtonsContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = buttons_height + buttons_spacing },
Spacing = new Vector2(buttons_spacing),
},
}, },
}, downloadButtonsContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = buttons_height + buttons_spacing },
Spacing = new Vector2(buttons_spacing),
},
}
}, },
}, },
} },
}, }
}, },
loading = new LoadingSpinner loading = new LoadingSpinner
{ {

View File

@ -3,14 +3,17 @@
#nullable disable #nullable disable
using System;
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 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 +37,10 @@ namespace osu.Game.Overlays.BeatmapSet
public Info() public Info()
{ {
MetadataSection source, tags, genre, language; MetadataSectionNominators nominators;
MetadataSection source, tags;
MetadataSectionGenre genre;
MetadataSectionLanguage language;
OsuSpriteText notRankedPlaceholder; OsuSpriteText notRankedPlaceholder;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -59,7 +65,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 +82,13 @@ 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), nominators = new MetadataSectionNominators(),
genre = new MetadataSection(MetadataType.Genre) { Width = 0.5f }, source = new MetadataSectionSource(),
language = new MetadataSection(MetadataType.Language) { Width = 0.5f }, genre = new MetadataSectionGenre { Width = 0.5f },
tags = new MetadataSection(MetadataType.Tags), language = new MetadataSectionLanguage { Width = 0.5f },
tags = new MetadataSectionTags(),
}, },
}, },
}, },
@ -118,10 +125,11 @@ namespace osu.Game.Overlays.BeatmapSet
BeatmapSet.ValueChanged += b => BeatmapSet.ValueChanged += b =>
{ {
source.Text = b.NewValue?.Source ?? string.Empty; nominators.Metadata = (b.NewValue?.CurrentNominations ?? Array.Empty<BeatmapSetOnlineNomination>(), b.NewValue?.RelatedUsers ?? Array.Empty<APIUser>());
tags.Text = b.NewValue?.Tags ?? string.Empty; source.Metadata = b.NewValue?.Source ?? string.Empty;
genre.Text = b.NewValue?.Genre.Name ?? string.Empty; tags.Metadata = b.NewValue?.Tags ?? string.Empty;
language.Text = b.NewValue?.Language.Name ?? string.Empty; genre.Metadata = b.NewValue?.Genre ?? new BeatmapSetOnlineGenre { Id = (int)SearchGenre.Unspecified };
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,63 @@
// 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 System.Linq;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.BeatmapSet
{
public partial class MetadataSectionNominators : MetadataSection<(BeatmapSetOnlineNomination[] CurrentNominations, APIUser[] RelatedUsers)>
{
public override (BeatmapSetOnlineNomination[] CurrentNominations, APIUser[] RelatedUsers) Metadata
{
set
{
if (value.CurrentNominations.Length == 0)
{
this.FadeOut(TRANSITION_DURATION);
return;
}
base.Metadata = value;
}
}
public MetadataSectionNominators(Action<(BeatmapSetOnlineNomination[] CurrentNominations, APIUser[] RelatedUsers)>? searchAction = null)
: base(MetadataType.Nominators, searchAction)
{
}
protected override void AddMetadata((BeatmapSetOnlineNomination[] CurrentNominations, APIUser[] RelatedUsers) metadata, LinkFlowContainer loaded)
{
int[] nominatorIds = metadata.CurrentNominations.Select(n => n.UserId).ToArray();
int nominatorsFound = 0;
foreach (int nominatorId in nominatorIds)
{
foreach (var user in metadata.RelatedUsers)
{
if (nominatorId != user.OnlineID) continue;
nominatorsFound++;
loaded.AddUserLink(new APIUser
{
Username = user.Username,
Id = nominatorId,
});
if (nominatorsFound < nominatorIds.Length)
loaded.AddText(CommonStrings.ArrayAndWordsConnector);
break;
}
}
}
}
}

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

@ -23,6 +23,9 @@ namespace osu.Game.Overlays.BeatmapSet
Genre, Genre,
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowInfoLanguage))] [LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowInfoLanguage))]
Language Language,
[LocalisableDescription(typeof(BeatmapsetsStrings), nameof(BeatmapsetsStrings.ShowInfoNominators))]
Nominators,
} }
} }

View File

@ -17,9 +17,11 @@ 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.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Online.API; using osu.Game.Online.API;
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.Resources.Localisation.Web;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -148,11 +150,11 @@ namespace osu.Game.Overlays.Chat
List<MenuItem> items = new List<MenuItem> List<MenuItem> items = new List<MenuItem>
{ {
new OsuMenuItem("View Profile", MenuItemType.Highlighted, openUserProfile) new OsuMenuItem(ContextMenuStrings.ViewProfile, MenuItemType.Highlighted, openUserProfile)
}; };
if (!user.Equals(api.LocalUser.Value)) if (!user.Equals(api.LocalUser.Value))
items.Add(new OsuMenuItem("Start Chat", MenuItemType.Standard, openUserChannel)); items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, openUserChannel));
return items.ToArray(); return items.ToArray();
} }

View File

@ -38,7 +38,7 @@ namespace osu.Game.Overlays.Chat.Listing
private Box hoverBox = null!; private Box hoverBox = null!;
private SpriteIcon checkbox = null!; private SpriteIcon checkbox = null!;
private OsuSpriteText channelText = null!; private OsuSpriteText channelText = null!;
private OsuSpriteText topicText = null!; private OsuTextFlowContainer topicText = null!;
private IBindable<bool> channelJoined = null!; private IBindable<bool> channelJoined = null!;
[Resolved] [Resolved]
@ -65,8 +65,8 @@ namespace osu.Game.Overlays.Chat.Listing
Masking = true; Masking = true;
CornerRadius = 5; CornerRadius = 5;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Content.RelativeSizeAxes = Axes.X;
Height = 20 + (vertical_margin * 2); AutoSizeAxes = Content.AutoSizeAxes = Axes.Y;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -79,14 +79,19 @@ namespace osu.Game.Overlays.Chat.Listing
}, },
new GridContainer new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[] ColumnDimensions = new[]
{ {
new Dimension(GridSizeMode.Absolute, 40), new Dimension(GridSizeMode.Absolute, 40),
new Dimension(GridSizeMode.Absolute, 200), new Dimension(GridSizeMode.Absolute, 200),
new Dimension(GridSizeMode.Absolute, 400), new Dimension(maxSize: 400),
new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize),
new Dimension(), new Dimension(GridSizeMode.Absolute, 50), // enough for any 5 digit user count
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize, minSize: 20 + (vertical_margin * 2)),
}, },
Content = new[] Content = new[]
{ {
@ -108,12 +113,13 @@ namespace osu.Game.Overlays.Chat.Listing
Font = OsuFont.Torus.With(size: text_size, weight: FontWeight.SemiBold), Font = OsuFont.Torus.With(size: text_size, weight: FontWeight.SemiBold),
Margin = new MarginPadding { Bottom = 2 }, Margin = new MarginPadding { Bottom = 2 },
}, },
topicText = new OsuSpriteText topicText = new OsuTextFlowContainer(t => t.Font = OsuFont.Torus.With(size: text_size))
{ {
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Text = Channel.Topic, Text = Channel.Topic,
Font = OsuFont.Torus.With(size: text_size),
Margin = new MarginPadding { Bottom = 2 }, Margin = new MarginPadding { Bottom = 2 },
}, },
new SpriteIcon new SpriteIcon

View File

@ -122,8 +122,8 @@ namespace osu.Game.Overlays.FirstRunSetup
stableLocatorTextBox.Current.Value = storage.GetFullPath(string.Empty); stableLocatorTextBox.Current.Value = storage.GetFullPath(string.Empty);
importButton.Enabled.Value = true; importButton.Enabled.Value = true;
bool available = legacyImportManager.CheckHardLinkAvailability(); bool available = legacyImportManager.CheckSongsFolderHardLinkAvailability();
Logger.Log($"Hard link support is {available}"); Logger.Log($"Hard link support for beatmaps is {available}");
if (available) if (available)
{ {

View File

@ -7,6 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Online; using osu.Game.Online;
@ -38,20 +39,30 @@ namespace osu.Game.Overlays
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false, ScrollbarVisible = false,
Child = new FillFlowContainer Child = new OsuContextMenuContainer
{ {
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical, AutoSizeAxes = Axes.Y,
Children = new Drawable[] Child = new PopoverContainer
{ {
Header.With(h => h.Depth = float.MinValue), RelativeSizeAxes = Axes.X,
content = new PopoverContainer AutoSizeAxes = Axes.Y,
Child = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
Header.With(h => h.Depth = float.MinValue),
content = new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
}
}
} }
} },
} }
}, },
Loading = new LoadingLayer(true) Loading = new LoadingLayer(true)

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

@ -99,6 +99,18 @@ namespace osu.Game.Screens.Backgrounds
} }
} }
/// <summary>
/// Reloads beatmap's background.
/// </summary>
public void RefreshBackground()
{
Schedule(() =>
{
cancellationSource?.Cancel();
LoadComponentAsync(new BeatmapBackground(beatmap), switchBackground, (cancellationSource = new CancellationTokenSource()).Token);
});
}
private void switchBackground(BeatmapBackground b) private void switchBackground(BeatmapBackground b)
{ {
float newDepth = 0; float newDepth = 0;

View File

@ -0,0 +1,41 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Graphics;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{
public partial class PreviewTimePart : TimelinePart
{
private readonly BindableInt previewTime = new BindableInt();
protected override void LoadBeatmap(EditorBeatmap beatmap)
{
base.LoadBeatmap(beatmap);
previewTime.UnbindAll();
previewTime.BindTo(beatmap.PreviewTime);
previewTime.BindValueChanged(t =>
{
Clear();
if (t.NewValue >= 0)
Add(new PreviewTimeVisualisation(t.NewValue));
}, true);
}
private partial class PreviewTimeVisualisation : PointVisualisation
{
public PreviewTimeVisualisation(double time)
: base(time)
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours) => Colour = colours.Green1;
}
}
}

View File

@ -41,6 +41,13 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Height = 0.35f Height = 0.35f
}, },
new PreviewTimePart
{
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
Height = 0.35f
},
new Container new Container
{ {
Name = "centre line", Name = "centre line",

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

@ -322,6 +322,13 @@ namespace osu.Game.Screens.Edit
State = { BindTarget = editorHitMarkers }, State = { BindTarget = editorHitMarkers },
} }
} }
},
new MenuItem("Timing")
{
Items = new MenuItem[]
{
new EditorMenuItem("Set preview point to current time", MenuItemType.Standard, SetPreviewPointToCurrentTime)
}
} }
} }
}, },
@ -801,6 +808,11 @@ namespace osu.Game.Screens.Edit
protected void Redo() => changeHandler?.RestoreState(1); protected void Redo() => changeHandler?.RestoreState(1);
protected void SetPreviewPointToCurrentTime()
{
editorBeatmap.PreviewTime.Value = (int)clock.CurrentTime;
}
private void resetTrack(bool seekToStart = false) private void resetTrack(bool seekToStart = false)
{ {
Beatmap.Value.Track.Stop(); Beatmap.Value.Track.Stop();

View File

@ -86,6 +86,8 @@ namespace osu.Game.Screens.Edit
[Resolved] [Resolved]
private EditorClock editorClock { get; set; } private EditorClock editorClock { get; set; }
public BindableInt PreviewTime { get; }
private readonly IBeatmapProcessor beatmapProcessor; private readonly IBeatmapProcessor beatmapProcessor;
private readonly Dictionary<HitObject, Bindable<double>> startTimeBindables = new Dictionary<HitObject, Bindable<double>>(); private readonly Dictionary<HitObject, Bindable<double>> startTimeBindables = new Dictionary<HitObject, Bindable<double>>();
@ -107,6 +109,14 @@ namespace osu.Game.Screens.Edit
foreach (var obj in HitObjects) foreach (var obj in HitObjects)
trackStartTime(obj); trackStartTime(obj);
PreviewTime = new BindableInt(BeatmapInfo.Metadata.PreviewTime);
PreviewTime.BindValueChanged(s =>
{
BeginChange();
BeatmapInfo.Metadata.PreviewTime = s.NewValue;
EndChange();
});
} }
/// <summary> /// <summary>

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.IO; using System.IO;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -16,25 +14,28 @@ namespace osu.Game.Screens.Edit.Setup
{ {
internal partial class ResourcesSection : SetupSection internal partial class ResourcesSection : SetupSection
{ {
private LabelledFileChooser audioTrackChooser; private LabelledFileChooser audioTrackChooser = null!;
private LabelledFileChooser backgroundChooser; private LabelledFileChooser backgroundChooser = null!;
public override LocalisableString Title => EditorSetupStrings.ResourcesHeader; public override LocalisableString Title => EditorSetupStrings.ResourcesHeader;
[Resolved] [Resolved]
private MusicController music { get; set; } private MusicController music { get; set; } = null!;
[Resolved] [Resolved]
private BeatmapManager beatmaps { get; set; } private BeatmapManager beatmaps { get; set; } = null!;
[Resolved] [Resolved]
private IBindable<WorkingBeatmap> working { get; set; } private IBindable<WorkingBeatmap> working { get; set; } = null!;
[Resolved] [Resolved]
private EditorBeatmap editorBeatmap { get; set; } private EditorBeatmap editorBeatmap { get; set; } = null!;
[Resolved] [Resolved]
private SetupScreenHeader header { get; set; } private Editor? editor { get; set; }
[Resolved]
private SetupScreenHeader header { get; set; } = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
@ -93,6 +94,8 @@ namespace osu.Game.Screens.Edit.Setup
working.Value.Metadata.BackgroundFile = destination.Name; working.Value.Metadata.BackgroundFile = destination.Name;
header.Background.UpdateBackground(); header.Background.UpdateBackground();
editor?.ApplyToBackground(bg => bg.RefreshBackground());
return true; return true;
} }
@ -125,17 +128,17 @@ namespace osu.Game.Screens.Edit.Setup
return true; return true;
} }
private void backgroundChanged(ValueChangedEvent<FileInfo> file) private void backgroundChanged(ValueChangedEvent<FileInfo?> file)
{ {
if (!ChangeBackgroundImage(file.NewValue)) if (file.NewValue == null || !ChangeBackgroundImage(file.NewValue))
backgroundChooser.Current.Value = file.OldValue; backgroundChooser.Current.Value = file.OldValue;
updatePlaceholderText(); updatePlaceholderText();
} }
private void audioTrackChanged(ValueChangedEvent<FileInfo> file) private void audioTrackChanged(ValueChangedEvent<FileInfo?> file)
{ {
if (!ChangeAudioTrack(file.NewValue)) if (file.NewValue == null || !ChangeAudioTrack(file.NewValue))
audioTrackChooser.Current.Value = file.OldValue; audioTrackChooser.Current.Value = file.OldValue;
updatePlaceholderText(); updatePlaceholderText();

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;
@ -150,7 +151,7 @@ namespace osu.Game.Screens.Edit.Timing
if (!displayLocked.Value) if (!displayLocked.Value)
{ {
float trackLength = (float)beatmap.Value.Track.Length; float trackLength = (float)beatmap.Value.Track.Length;
int totalBeatsAvailable = (int)(trackLength / timingPoint.BeatLength); int totalBeatsAvailable = (int)((trackLength - timingPoint.Time) / timingPoint.BeatLength);
Scheduler.AddOnce(showFromBeat, (int)(e.MousePosition.X / DrawWidth * totalBeatsAvailable)); Scheduler.AddOnce(showFromBeat, (int)(e.MousePosition.X / DrawWidth * totalBeatsAvailable));
} }
@ -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

@ -282,7 +282,7 @@ namespace osu.Game.Screens.Menu
if (beatIndex < 0) return; if (beatIndex < 0) return;
if (IsHovered) if (Action != null && IsHovered)
{ {
this.Delay(early_activation).Schedule(() => this.Delay(early_activation).Schedule(() =>
{ {
@ -361,11 +361,11 @@ namespace osu.Game.Screens.Menu
} }
} }
public override bool HandlePositionalInput => base.HandlePositionalInput && Action != null && Alpha > 0.2f; public override bool HandlePositionalInput => base.HandlePositionalInput && Alpha > 0.2f;
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
if (e.Button != MouseButton.Left) return false; if (e.Button != MouseButton.Left) return true;
logoBounceContainer.ScaleTo(0.9f, 1000, Easing.Out); logoBounceContainer.ScaleTo(0.9f, 1000, Easing.Out);
return true; return true;
@ -380,18 +380,21 @@ namespace osu.Game.Screens.Menu
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
if (Action?.Invoke() ?? true)
sampleClick.Play();
flashLayer.ClearTransforms(); flashLayer.ClearTransforms();
flashLayer.Alpha = 0.4f; flashLayer.Alpha = 0.4f;
flashLayer.FadeOut(1500, Easing.OutExpo); flashLayer.FadeOut(1500, Easing.OutExpo);
if (Action?.Invoke() == true)
sampleClick.Play();
return true; return true;
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
logoHoverContainer.ScaleTo(1.1f, 500, Easing.OutElastic); if (Action != null)
logoHoverContainer.ScaleTo(1.1f, 500, Easing.OutElastic);
return true; return true;
} }

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
{ {

View File

@ -100,16 +100,16 @@ namespace osu.Game.Screens.Play.HUD
local.DisplayOrder.Value = long.MaxValue; local.DisplayOrder.Value = long.MaxValue;
} }
protected override bool CheckValidScorePosition(int i) protected override bool CheckValidScorePosition(GameplayLeaderboardScore score, int position)
{ {
// change displayed position to '-' when there are 50 already submitted scores and tracked score is last // change displayed position to '-' when there are 50 already submitted scores and tracked score is last
if (scoreSource.Value != PlayBeatmapDetailArea.TabType.Local) if (score.Tracked && scoreSource.Value != PlayBeatmapDetailArea.TabType.Local)
{ {
if (i == Flow.Count && Flow.Count > GetScoresRequest.MAX_SCORES_PER_REQUEST) if (position == Flow.Count && Flow.Count > GetScoresRequest.MAX_SCORES_PER_REQUEST)
return false; return false;
} }
return base.CheckValidScorePosition(i); return base.CheckValidScorePosition(score, position);
} }
private void updateVisibility() => private void updateVisibility() =>

View File

@ -141,9 +141,9 @@ namespace osu.Game.Screens.Select
LayoutEasing = Easing.OutQuad, LayoutEasing = Easing.OutQuad,
Children = new[] Children = new[]
{ {
description = new MetadataSection(MetadataType.Description, searchOnSongSelect), description = new MetadataSectionDescription(searchOnSongSelect),
source = new MetadataSection(MetadataType.Source, searchOnSongSelect), source = new MetadataSectionSource(searchOnSongSelect),
tags = new MetadataSection(MetadataType.Tags, searchOnSongSelect), tags = new MetadataSectionTags(searchOnSongSelect),
}, },
}, },
}, },
@ -187,9 +187,9 @@ namespace osu.Game.Screens.Select
private void updateStatistics() private void updateStatistics()
{ {
advanced.BeatmapInfo = BeatmapInfo; advanced.BeatmapInfo = BeatmapInfo;
description.Text = BeatmapInfo?.DifficultyName; description.Metadata = BeatmapInfo?.DifficultyName ?? string.Empty;
source.Text = BeatmapInfo?.Metadata.Source; source.Metadata = BeatmapInfo?.Metadata.Source ?? string.Empty;
tags.Text = BeatmapInfo?.Metadata.Tags; tags.Metadata = BeatmapInfo?.Metadata.Tags ?? string.Empty;
// failTimes may have been previously fetched // failTimes may have been previously fetched
if (ratings != null && failTimes != null) if (ratings != null && failTimes != null)

View File

@ -152,14 +152,23 @@ namespace osu.Game.Screens.Select.Leaderboards
else if (filterMods) else if (filterMods)
requestMods = mods.Value; requestMods = mods.Value;
scoreRetrievalRequest = new GetScoresRequest(fetchBeatmapInfo, fetchRuleset, Scope, requestMods); scoreRetrievalRequest?.Cancel();
scoreRetrievalRequest.Success += response => SetScores( var newRequest = new GetScoresRequest(fetchBeatmapInfo, fetchRuleset, Scope, requestMods);
scoreManager.OrderByTotalScore(response.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo))), newRequest.Success += response => Schedule(() =>
response.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo) {
); // Request may have changed since fetch request.
// Can't rely on request cancellation due to Schedule inside SetScores so let's play it safe.
if (!newRequest.Equals(scoreRetrievalRequest))
return;
return scoreRetrievalRequest; SetScores(
scoreManager.OrderByTotalScore(response.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo))),
response.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo)
);
});
return scoreRetrievalRequest = newRequest;
} }
protected override LeaderboardScore CreateDrawableScore(ScoreInfo model, int index) => new LeaderboardScore(model, index, IsOnlineScope) protected override LeaderboardScore CreateDrawableScore(ScoreInfo model, int index) => new LeaderboardScore(model, index, IsOnlineScope)

View File

@ -102,6 +102,8 @@ namespace osu.Game.Tests.Visual
public new void Redo() => base.Redo(); public new void Redo() => base.Redo();
public new void SetPreviewPointToCurrentTime() => base.SetPreviewPointToCurrentTime();
public new bool Save() => base.Save(); public new bool Save() => base.Save();
public new void Cut() => base.Cut(); public new void Cut() => base.Cut();

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.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -14,8 +13,11 @@ using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using JetBrains.Annotations; using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Localisation;
namespace osu.Game.Users namespace osu.Game.Users
{ {
@ -27,11 +29,11 @@ namespace osu.Game.Users
/// Perform an action in addition to showing the user's profile. /// Perform an action in addition to showing the user's profile.
/// This should be used to perform auxiliary tasks and not as a primary action for clicking a user panel (to maintain a consistent UX). /// This should be used to perform auxiliary tasks and not as a primary action for clicking a user panel (to maintain a consistent UX).
/// </summary> /// </summary>
public new Action Action; public new Action? Action;
protected Action ViewProfile { get; private set; } protected Action ViewProfile { get; private set; } = null!;
protected Drawable Background { get; private set; } protected Drawable Background { get; private set; } = null!;
protected UserPanel(APIUser user) protected UserPanel(APIUser user)
: base(HoverSampleSet.Button) : base(HoverSampleSet.Button)
@ -41,14 +43,23 @@ namespace osu.Game.Users
User = user; User = user;
} }
[Resolved(canBeNull: true)] [Resolved]
private UserProfileOverlay profileOverlay { get; set; } private UserProfileOverlay? profileOverlay { get; set; }
[Resolved(canBeNull: true)]
protected OverlayColourProvider ColourProvider { get; private set; }
[Resolved] [Resolved]
protected OsuColour Colours { get; private set; } private IAPIProvider api { get; set; } = null!;
[Resolved]
private ChannelManager? channelManager { get; set; }
[Resolved]
private ChatOverlay? chatOverlay { get; set; }
[Resolved]
protected OverlayColourProvider? ColourProvider { get; private set; }
[Resolved]
protected OsuColour Colours { get; private set; } = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
@ -79,7 +90,6 @@ namespace osu.Game.Users
}; };
} }
[NotNull]
protected abstract Drawable CreateLayout(); protected abstract Drawable CreateLayout();
protected OsuSpriteText CreateUsername() => new OsuSpriteText protected OsuSpriteText CreateUsername() => new OsuSpriteText
@ -89,9 +99,26 @@ namespace osu.Game.Users
Text = User.Username, Text = User.Username,
}; };
public MenuItem[] ContextMenuItems => new MenuItem[] public MenuItem[] ContextMenuItems
{ {
new OsuMenuItem("View Profile", MenuItemType.Highlighted, ViewProfile), get
}; {
List<MenuItem> items = new List<MenuItem>
{
new OsuMenuItem(ContextMenuStrings.ViewProfile, MenuItemType.Highlighted, ViewProfile)
};
if (!User.Equals(api.LocalUser.Value))
{
items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, () =>
{
channelManager?.OpenPrivateChannel(User);
chatOverlay?.Show();
}));
}
return items.ToArray();
}
}
} }
} }