Merge remote-tracking branch 'upstream/master' into rearrangeable-playlist

This commit is contained in:
Dean Herbert
2020-02-06 17:40:28 +09:00
65 changed files with 936 additions and 901 deletions

View File

@ -36,7 +36,11 @@ namespace osu.Game.Rulesets.Catch.Objects
} }
} }
public double EndTime => StartTime + Duration; public double EndTime
{
get => StartTime + Duration;
set => Duration = value - StartTime;
}
public double Duration { get; set; } public double Duration { get; set; }
} }

View File

@ -110,7 +110,11 @@ namespace osu.Game.Rulesets.Catch.Objects
} }
} }
public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity; public double EndTime
{
get => StartTime + this.SpanCount() * Path.Distance / Velocity;
set => throw new System.NotSupportedException($"Adjust via {nameof(RepeatCount)} instead"); // can be implemented if/when needed.
}
public float EndX => X + this.CurvePositionAt(1).X / CatchPlayfield.BASE_WIDTH; public float EndX => X + this.CurvePositionAt(1).X / CatchPlayfield.BASE_WIDTH;

View File

@ -15,7 +15,11 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary> /// </summary>
public class HoldNote : ManiaHitObject, IHasEndTime public class HoldNote : ManiaHitObject, IHasEndTime
{ {
public double EndTime => StartTime + Duration; public double EndTime
{
get => StartTime + Duration;
set => Duration = value - StartTime;
}
private double duration; private double duration;

View File

@ -18,7 +18,12 @@ namespace osu.Game.Rulesets.Osu.Objects
{ {
public class Slider : OsuHitObject, IHasCurve public class Slider : OsuHitObject, IHasCurve
{ {
public double EndTime => StartTime + this.SpanCount() * Path.Distance / Velocity; public double EndTime
{
get => StartTime + this.SpanCount() * Path.Distance / Velocity;
set => throw new System.NotSupportedException($"Adjust via {nameof(RepeatCount)} instead"); // can be implemented if/when needed.
}
public double Duration => EndTime - StartTime; public double Duration => EndTime - StartTime;
private readonly Cached<Vector2> endPositionCache = new Cached<Vector2>(); private readonly Cached<Vector2> endPositionCache = new Cached<Vector2>();
@ -81,7 +86,7 @@ namespace osu.Game.Rulesets.Osu.Objects
set set
{ {
repeatCount = value; repeatCount = value;
endPositionCache.Invalidate(); updateNestedPositions();
} }
} }

View File

@ -18,7 +18,11 @@ namespace osu.Game.Rulesets.Taiko.Objects
/// </summary> /// </summary>
private const float base_distance = 100; private const float base_distance = 100;
public double EndTime => StartTime + Duration; public double EndTime
{
get => StartTime + Duration;
set => Duration = value - StartTime;
}
public double Duration { get; set; } public double Duration { get; set; }

View File

@ -11,7 +11,11 @@ namespace osu.Game.Rulesets.Taiko.Objects
{ {
public class Swell : TaikoHitObject, IHasEndTime public class Swell : TaikoHitObject, IHasEndTime
{ {
public double EndTime => StartTime + Duration; public double EndTime
{
get => StartTime + Duration;
set => Duration = value - StartTime;
}
public double Duration { get; set; } public double Duration { get; set; }

View File

@ -3,6 +3,8 @@
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
@ -23,15 +25,31 @@ namespace osu.Game.Tests.Editor
[Cached(typeof(IBeatSnapProvider))] [Cached(typeof(IBeatSnapProvider))]
private readonly EditorBeatmap editorBeatmap; private readonly EditorBeatmap editorBeatmap;
protected override Container<Drawable> Content { get; }
public TestSceneHitObjectComposerDistanceSnapping() public TestSceneHitObjectComposerDistanceSnapping()
{ {
editorBeatmap = new EditorBeatmap(new OsuBeatmap(), BeatDivisor); base.Content.Add(new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
editorBeatmap = new EditorBeatmap(new OsuBeatmap()),
Content = new Container
{
RelativeSizeAxes = Axes.Both,
}
},
});
} }
[SetUp] [SetUp]
public void Setup() => Schedule(() => public void Setup() => Schedule(() =>
{ {
Child = composer = new TestHitObjectComposer(); Children = new Drawable[]
{
composer = new TestHitObjectComposer()
};
BeatDivisor.Value = 1; BeatDivisor.Value = 1;

View File

@ -1,6 +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.
using System;
using System.Collections.Generic;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Screens.Edit.Compose.Components.Timeline; using osu.Game.Screens.Edit.Compose.Components.Timeline;
@ -10,6 +12,17 @@ namespace osu.Game.Tests.Visual.Editor
[TestFixture] [TestFixture]
public class TestSceneTimelineBlueprintContainer : TimelineTestScene public class TestSceneTimelineBlueprintContainer : TimelineTestScene
{ {
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(TimelineHitObjectBlueprint),
};
public override Drawable CreateTestComponent() => new TimelineBlueprintContainer(); public override Drawable CreateTestComponent() => new TimelineBlueprintContainer();
protected override void LoadComplete()
{
base.LoadComplete();
Clock.Seek(10000);
}
} }
} }

View File

@ -27,7 +27,12 @@ namespace osu.Game.Tests.Visual.Editor
}; };
[Cached(typeof(EditorBeatmap))] [Cached(typeof(EditorBeatmap))]
private readonly EditorBeatmap editorBeatmap = new EditorBeatmap(new OsuBeatmap()); private readonly EditorBeatmap editorBeatmap;
public TestSceneTimingScreen()
{
editorBeatmap = new EditorBeatmap(new OsuBeatmap());
}
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()

View File

@ -13,7 +13,6 @@ using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline; using osu.Game.Screens.Edit.Compose.Components.Timeline;
using osuTK; using osuTK;
@ -38,13 +37,16 @@ namespace osu.Game.Tests.Visual.Editor
{ {
Beatmap.Value = new WaveformTestBeatmap(audio); Beatmap.Value = new WaveformTestBeatmap(audio);
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap, BeatDivisor); var playable = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
var editorBeatmap = new EditorBeatmap(playable);
Dependencies.Cache(editorBeatmap); Dependencies.Cache(editorBeatmap);
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap); Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
AddRange(new Drawable[] AddRange(new Drawable[]
{ {
editorBeatmap,
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,

View File

@ -4,11 +4,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NUnit.Framework;
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.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.Multiplayer; using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Catch;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Multi; using osu.Game.Screens.Multi;
using osu.Game.Screens.Multi.Lounge.Components; using osu.Game.Screens.Multi.Lounge.Components;
using osu.Game.Users; using osu.Game.Users;
@ -27,11 +32,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
[Cached(Type = typeof(IRoomManager))] [Cached(Type = typeof(IRoomManager))]
private TestRoomManager roomManager = new TestRoomManager(); private TestRoomManager roomManager = new TestRoomManager();
private RoomsContainer container;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
RoomsContainer container;
Child = container = new RoomsContainer Child = container = new RoomsContainer
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
@ -39,24 +44,21 @@ namespace osu.Game.Tests.Visual.Multiplayer
Width = 0.5f, Width = 0.5f,
JoinRequested = joinRequested JoinRequested = joinRequested
}; };
}
public override void SetUpSteps()
{
base.SetUpSteps();
AddStep("clear rooms", () => roomManager.Rooms.Clear()); AddStep("clear rooms", () => roomManager.Rooms.Clear());
AddStep("add rooms", () =>
{
for (int i = 0; i < 3; i++)
{
roomManager.Rooms.Add(new Room
{
RoomID = { Value = i },
Name = { Value = $"Room {i}" },
Host = { Value = new User { Username = "Host" } },
EndDate = { Value = DateTimeOffset.Now + TimeSpan.FromSeconds(10) }
});
} }
});
AddAssert("has 2 rooms", () => container.Rooms.Count == 3); [Test]
public void TestBasicListChanges()
{
addRooms(3);
AddAssert("has 3 rooms", () => container.Rooms.Count == 3);
AddStep("remove first room", () => roomManager.Rooms.Remove(roomManager.Rooms.FirstOrDefault())); AddStep("remove first room", () => roomManager.Rooms.Remove(roomManager.Rooms.FirstOrDefault()));
AddAssert("has 2 rooms", () => container.Rooms.Count == 2); AddAssert("has 2 rooms", () => container.Rooms.Count == 2);
AddAssert("first room removed", () => container.Rooms.All(r => r.Room.RoomID.Value != 0)); AddAssert("first room removed", () => container.Rooms.All(r => r.Room.RoomID.Value != 0));
@ -68,6 +70,70 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddAssert("first room joined", () => roomManager.Rooms.First().Status.Value is JoinedRoomStatus); AddAssert("first room joined", () => roomManager.Rooms.First().Status.Value is JoinedRoomStatus);
} }
[Test]
public void TestStringFiltering()
{
addRooms(4);
AddUntilStep("4 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 4);
AddStep("filter one room", () => container.Filter(new FilterCriteria { SearchString = "1" }));
AddUntilStep("1 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 1);
AddStep("remove filter", () => container.Filter(null));
AddUntilStep("4 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 4);
}
[Test]
public void TestRulesetFiltering()
{
addRooms(2, new OsuRuleset().RulesetInfo);
addRooms(3, new CatchRuleset().RulesetInfo);
AddUntilStep("5 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 5);
AddStep("filter osu! rooms", () => container.Filter(new FilterCriteria { Ruleset = new OsuRuleset().RulesetInfo }));
AddUntilStep("2 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 2);
AddStep("filter catch rooms", () => container.Filter(new FilterCriteria { Ruleset = new CatchRuleset().RulesetInfo }));
AddUntilStep("3 rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 3);
}
private void addRooms(int count, RulesetInfo ruleset = null)
{
AddStep("add rooms", () =>
{
for (int i = 0; i < count; i++)
{
var room = new Room
{
RoomID = { Value = i },
Name = { Value = $"Room {i}" },
Host = { Value = new User { Username = "Host" } },
EndDate = { Value = DateTimeOffset.Now + TimeSpan.FromSeconds(10) }
};
if (ruleset != null)
{
room.Playlist.Add(new PlaylistItem
{
Ruleset = ruleset,
Beatmap = new BeatmapInfo
{
Metadata = new BeatmapMetadata()
}
});
}
roomManager.Rooms.Add(room);
}
});
}
private void joinRequested(Room room) => room.Status.Value = new JoinedRoomStatus(); private void joinRequested(Room room) => room.Status.Value = new JoinedRoomStatus();
private class TestRoomManager : IRoomManager private class TestRoomManager : IRoomManager

View File

@ -11,6 +11,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Framework.Allocation;
namespace osu.Game.Tests.Visual.Online namespace osu.Game.Tests.Visual.Online
{ {
@ -22,6 +24,9 @@ namespace osu.Game.Tests.Visual.Online
typeof(CountryPill) typeof(CountryPill)
}; };
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
public TestSceneRankingsCountryFilter() public TestSceneRankingsCountryFilter()
{ {
var countryBindable = new Bindable<Country>(); var countryBindable = new Bindable<Country>();

View File

@ -1,66 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays.Rankings;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsDismissableFlag : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(DismissableFlag),
};
public TestSceneRankingsDismissableFlag()
{
DismissableFlag flag;
SpriteText text;
var countryA = new Country
{
FlagName = "BY",
FullName = "Belarus"
};
var countryB = new Country
{
FlagName = "US",
FullName = "United States"
};
AddRange(new Drawable[]
{
flag = new DismissableFlag
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(30, 20),
Country = countryA,
},
text = new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "Invoked",
Font = OsuFont.GetFont(size: 30),
Alpha = 0,
}
});
flag.Action += () => text.FadeIn().Then().FadeOut(1000, Easing.OutQuint);
AddStep("Trigger click", () => flag.Click());
AddStep("Change to country 2", () => flag.Country = countryB);
AddStep("Change to country 1", () => flag.Country = countryA);
}
}
}

View File

@ -3,8 +3,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Game.Overlays;
using osu.Game.Overlays.Rankings; using osu.Game.Overlays.Rankings;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Users; using osu.Game.Users;
@ -15,24 +16,23 @@ namespace osu.Game.Tests.Visual.Online
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
typeof(DismissableFlag), typeof(RankingsOverlayHeader),
typeof(HeaderTitle), typeof(CountryFilter),
typeof(RankingsRulesetSelector), typeof(CountryPill)
typeof(RankingsScopeSelector),
typeof(RankingsHeader),
}; };
[Cached]
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Green);
public TestSceneRankingsHeader() public TestSceneRankingsHeader()
{ {
var countryBindable = new Bindable<Country>(); var countryBindable = new Bindable<Country>();
var ruleset = new Bindable<RulesetInfo>(); var ruleset = new Bindable<RulesetInfo>();
var scope = new Bindable<RankingsScope>(); var scope = new Bindable<RankingsScope>();
Add(new RankingsHeader Add(new RankingsOverlayHeader
{ {
Anchor = Anchor.Centre, Current = { BindTarget = scope },
Origin = Anchor.Centre,
Scope = { BindTarget = scope },
Country = { BindTarget = countryBindable }, Country = { BindTarget = countryBindable },
Ruleset = { BindTarget = ruleset }, Ruleset = { BindTarget = ruleset },
Spotlights = new[] Spotlights = new[]

View File

@ -1,55 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Overlays.Rankings;
using osu.Game.Users;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsHeaderTitle : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(DismissableFlag),
typeof(HeaderTitle),
};
public TestSceneRankingsHeaderTitle()
{
var countryBindable = new Bindable<Country>();
var scope = new Bindable<RankingsScope>();
Add(new HeaderTitle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Country = { BindTarget = countryBindable },
Scope = { BindTarget = scope },
});
var countryA = new Country
{
FlagName = "BY",
FullName = "Belarus"
};
var countryB = new Country
{
FlagName = "US",
FullName = "United States"
};
AddStep("Set country 1", () => countryBindable.Value = countryA);
AddStep("Set country 2", () => countryBindable.Value = countryB);
AddStep("Set null country", () => countryBindable.Value = null);
AddStep("Set scope to Performance", () => scope.Value = RankingsScope.Performance);
AddStep("Set scope to Spotlights", () => scope.Value = RankingsScope.Spotlights);
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
AddStep("Set scope to Country", () => scope.Value = RankingsScope.Country);
}
}
}

View File

@ -25,7 +25,8 @@ namespace osu.Game.Tests.Visual.Online
typeof(TableRowBackground), typeof(TableRowBackground),
typeof(UserBasedTable), typeof(UserBasedTable),
typeof(RankingsTable<>), typeof(RankingsTable<>),
typeof(RankingsOverlay) typeof(RankingsOverlay),
typeof(RankingsOverlayHeader)
}; };
[Cached] [Cached]

View File

@ -1,41 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Game.Overlays.Rankings;
using osu.Framework.Graphics;
using osu.Game.Rulesets;
using osu.Framework.Bindables;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.Catch;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsRulesetSelector : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(RankingsRulesetSelector),
};
public TestSceneRankingsRulesetSelector()
{
var current = new Bindable<RulesetInfo>();
Add(new RankingsRulesetSelector
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Current = { BindTarget = current }
});
AddStep("Select osu!", () => current.Value = new OsuRuleset().RulesetInfo);
AddStep("Select mania", () => current.Value = new ManiaRuleset().RulesetInfo);
AddStep("Select taiko", () => current.Value = new TaikoRuleset().RulesetInfo);
AddStep("Select catch", () => current.Value = new CatchRuleset().RulesetInfo);
}
}
}

View File

@ -1,54 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Allocation;
using osu.Game.Graphics;
using osu.Game.Overlays.Rankings;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneRankingsScopeSelector : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(RankingsScopeSelector),
};
private readonly Box background;
public TestSceneRankingsScopeSelector()
{
var scope = new Bindable<RankingsScope>();
AddRange(new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both
},
new RankingsScopeSelector
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Current = scope,
}
});
AddStep(@"Select country", () => scope.Value = RankingsScope.Country);
AddStep(@"Select performance", () => scope.Value = RankingsScope.Performance);
AddStep(@"Select score", () => scope.Value = RankingsScope.Score);
AddStep(@"Select spotlights", () => scope.Value = RankingsScope.Spotlights);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
background.Colour = colours.GreySeafoam;
}
}
}

View File

@ -16,6 +16,7 @@ using osu.Game.Rulesets.Mania;
using osu.Game.Rulesets.Taiko; using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.Catch; using osu.Game.Rulesets.Catch;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.Online namespace osu.Game.Tests.Visual.Online
{ {
@ -36,6 +37,9 @@ namespace osu.Game.Tests.Visual.Online
[Resolved] [Resolved]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; }
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
private readonly BasicScrollContainer scrollFlow; private readonly BasicScrollContainer scrollFlow;
private readonly DimmedLoadingLayer loading; private readonly DimmedLoadingLayer loading;
private CancellationTokenSource cancellationToken; private CancellationTokenSource cancellationToken;
@ -64,6 +68,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Mania scores", () => createScoreTable(new ManiaRuleset().RulesetInfo)); AddStep("Mania scores", () => createScoreTable(new ManiaRuleset().RulesetInfo));
AddStep("Taiko country scores", () => createCountryTable(new TaikoRuleset().RulesetInfo)); AddStep("Taiko country scores", () => createCountryTable(new TaikoRuleset().RulesetInfo));
AddStep("Catch US performance page 10", () => createPerformanceTable(new CatchRuleset().RulesetInfo, "US", 10)); AddStep("Catch US performance page 10", () => createPerformanceTable(new CatchRuleset().RulesetInfo, "US", 10));
AddStep("Osu spotlight table (chart 271)", () => createSpotlightTable(new OsuRuleset().RulesetInfo, 271));
} }
private void createCountryTable(RulesetInfo ruleset, int page = 1) private void createCountryTable(RulesetInfo ruleset, int page = 1)
@ -108,6 +113,20 @@ namespace osu.Game.Tests.Visual.Online
api.Queue(request); api.Queue(request);
} }
private void createSpotlightTable(RulesetInfo ruleset, int spotlight)
{
onLoadStarted();
request = new GetSpotlightRankingsRequest(ruleset, spotlight);
((GetSpotlightRankingsRequest)request).Success += rankings => Schedule(() =>
{
var table = new ScoresTable(1, rankings.Users);
loadTable(table);
});
api.Queue(request);
}
private void onLoadStarted() private void onLoadStarted()
{ {
loading.Show(); loading.Show();

View File

@ -3,11 +3,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
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.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapSet.Scores; using osu.Game.Overlays.BeatmapSet.Scores;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring; using osu.Game.Scoring;
@ -27,6 +29,9 @@ namespace osu.Game.Tests.Visual.Online
typeof(ScoreTableRowBackground), typeof(ScoreTableRowBackground),
}; };
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
public TestSceneScoresContainer() public TestSceneScoresContainer()
{ {
TestScoresContainer scoresContainer; TestScoresContainer scoresContainer;

View File

@ -11,6 +11,8 @@ using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
using osu.Game.Rulesets.Catch;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
namespace osu.Game.Tests namespace osu.Game.Tests
@ -20,11 +22,18 @@ namespace osu.Game.Tests
/// </summary> /// </summary>
public class WaveformTestBeatmap : WorkingBeatmap public class WaveformTestBeatmap : WorkingBeatmap
{ {
private readonly Beatmap beatmap;
private readonly ITrackStore trackStore; private readonly ITrackStore trackStore;
public WaveformTestBeatmap(AudioManager audioManager) public WaveformTestBeatmap(AudioManager audioManager)
: base(new BeatmapInfo(), audioManager) : this(audioManager, new WaveformBeatmap())
{ {
}
public WaveformTestBeatmap(AudioManager audioManager, Beatmap beatmap)
: base(beatmap.BeatmapInfo, audioManager)
{
this.beatmap = beatmap;
trackStore = audioManager.GetTrackStore(getZipReader()); trackStore = audioManager.GetTrackStore(getZipReader());
} }
@ -34,11 +43,11 @@ namespace osu.Game.Tests
trackStore?.Dispose(); trackStore?.Dispose();
} }
private Stream getStream() => TestResources.GetTestBeatmapStream(); private static Stream getStream() => TestResources.GetTestBeatmapStream();
private ZipArchiveReader getZipReader() => new ZipArchiveReader(getStream()); private static ZipArchiveReader getZipReader() => new ZipArchiveReader(getStream());
protected override IBeatmap GetBeatmap() => createTestBeatmap(); protected override IBeatmap GetBeatmap() => beatmap;
protected override Texture GetBackground() => null; protected override Texture GetBackground() => null;
@ -57,10 +66,16 @@ namespace osu.Game.Tests
} }
} }
private Beatmap createTestBeatmap() private class WaveformBeatmap : TestBeatmap
{
public WaveformBeatmap()
: base(new CatchRuleset().RulesetInfo)
{
}
protected override Beatmap CreateBeatmap()
{ {
using (var reader = getZipReader()) using (var reader = getZipReader())
{
using (var beatmapStream = reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu")))) using (var beatmapStream = reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu"))))
using (var beatmapReader = new LineBufferedReader(beatmapStream)) using (var beatmapReader = new LineBufferedReader(beatmapStream))
return Decoder.GetDecoder<Beatmap>(beatmapReader).Decode(beatmapReader); return Decoder.GetDecoder<Beatmap>(beatmapReader).Decode(beatmapReader);

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 osu.Framework.IO.Network;
using osu.Game.Rulesets;
namespace osu.Game.Online.API.Requests
{
public class GetSpotlightRankingsRequest : GetRankingsRequest<GetSpotlightRankingsResponse>
{
private readonly int spotlight;
public GetSpotlightRankingsRequest(RulesetInfo ruleset, int spotlight)
: base(ruleset, 1)
{
this.spotlight = spotlight;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.AddParameter("spotlight", spotlight.ToString());
return req;
}
protected override string TargetPostfix() => "charts";
}
}

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 System.Collections.Generic;
using Newtonsoft.Json;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Users;
namespace osu.Game.Online.API.Requests
{
public class GetSpotlightRankingsResponse
{
[JsonProperty("ranking")]
public List<UserStatistics> Users;
[JsonProperty("spotlight")]
public APISpotlight Spotlight;
[JsonProperty("beatmapsets")]
public List<APIBeatmapSet> BeatmapSets;
}
}

View File

@ -24,6 +24,7 @@ namespace osu.Game.Overlays.BeatmapSet
private const float spacing = 20; private const float spacing = 20;
private readonly Box successRateBackground; private readonly Box successRateBackground;
private readonly Box background;
private readonly SuccessRate successRate; private readonly SuccessRate successRate;
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>(); public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
@ -50,10 +51,9 @@ namespace osu.Game.Overlays.BeatmapSet
Children = new Drawable[] Children = new Drawable[]
{ {
new Box background = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both
Colour = Color4.White,
}, },
new Container new Container
{ {
@ -126,14 +126,14 @@ namespace osu.Game.Overlays.BeatmapSet
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
successRateBackground.Colour = colours.GrayE; successRateBackground.Colour = colourProvider.Background4;
background.Colour = colourProvider.Background5;
} }
private class MetadataSection : FillFlowContainer private class MetadataSection : FillFlowContainer
{ {
private readonly OsuSpriteText header;
private readonly TextFlowContainer textFlow; private readonly TextFlowContainer textFlow;
public string Text public string Text
@ -148,7 +148,7 @@ namespace osu.Game.Overlays.BeatmapSet
this.FadeIn(transition_duration); this.FadeIn(transition_duration);
textFlow.Clear(); textFlow.Clear();
textFlow.AddText(value, s => s.Font = s.Font.With(size: 14)); textFlow.AddText(value, s => s.Font = s.Font.With(size: 12));
} }
} }
@ -160,11 +160,10 @@ namespace osu.Game.Overlays.BeatmapSet
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
header = new OsuSpriteText new OsuSpriteText
{ {
Text = title, Text = title,
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold), Font = OsuFont.GetFont(size: 14, weight: FontWeight.Black),
Shadow = false,
Margin = new MarginPadding { Top = 20 }, Margin = new MarginPadding { Top = 20 },
}, },
textFlow = new OsuTextFlowContainer textFlow = new OsuTextFlowContainer
@ -174,12 +173,6 @@ namespace osu.Game.Overlays.BeatmapSet
}, },
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
header.Colour = textFlow.Colour = colours.Gray5;
}
} }
} }
} }

View File

@ -7,8 +7,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Scoring; using osu.Game.Scoring;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -17,11 +15,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
public class DrawableTopScore : CompositeDrawable public class DrawableTopScore : CompositeDrawable
{ {
private const float fade_duration = 100;
private Color4 backgroundIdleColour;
private Color4 backgroundHoveredColour;
private readonly Box background; private readonly Box background;
public DrawableTopScore(ScoreInfo score, int position = 1) public DrawableTopScore(ScoreInfo score, int position = 1)
@ -30,7 +23,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
Masking = true; Masking = true;
CornerRadius = 10; CornerRadius = 5;
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
{ {
Type = EdgeEffectType.Shadow, Type = EdgeEffectType.Shadow,
@ -49,7 +42,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(10), Padding = new MarginPadding
{
Vertical = 10,
Left = 10,
Right = 25,
},
Children = new Drawable[] Children = new Drawable[]
{ {
new AutoSizingGrid new AutoSizingGrid
@ -84,24 +82,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
backgroundIdleColour = colours.Gray3; background.Colour = colourProvider.Background4;
backgroundHoveredColour = colours.Gray4;
background.Colour = backgroundIdleColour;
}
protected override bool OnHover(HoverEvent e)
{
background.FadeColour(backgroundHoveredColour, fade_duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
background.FadeColour(backgroundIdleColour, fade_duration, Easing.OutQuint);
base.OnHoverLost(e);
} }
private class AutoSizingGrid : GridContainer private class AutoSizingGrid : GridContainer

View File

@ -23,7 +23,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
private const float horizontal_inset = 20; private const float horizontal_inset = 20;
private const float row_height = 25; private const float row_height = 25;
private const int text_size = 14; private const int text_size = 12;
private readonly FillFlowContainer backgroundFlow; private readonly FillFlowContainer backgroundFlow;
@ -190,7 +190,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
public HeaderText(string text) public HeaderText(string text)
{ {
Text = text.ToUpper(); Text = text.ToUpper();
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black); Font = OsuFont.GetFont(size: 10, weight: FontWeight.Bold);
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
Colour = colourProvider.Foreground1;
} }
} }
} }

View File

@ -48,18 +48,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours, IAPIProvider api) private void load(OsuColour colours, OverlayColourProvider colourProvider, IAPIProvider api)
{ {
var isOwnScore = api.LocalUser.Value.Id == score.UserID; var isOwnScore = api.LocalUser.Value.Id == score.UserID;
if (isOwnScore) if (isOwnScore)
background.Colour = colours.GreenDarker; background.Colour = colours.GreenDarker;
else if (index % 2 == 0) else if (index % 2 == 0)
background.Colour = colours.Gray3; background.Colour = colourProvider.Background4;
else else
background.Alpha = 0; background.Alpha = 0;
hoveredBackground.Colour = isOwnScore ? colours.GreenDark : colours.Gray4; hoveredBackground.Colour = isOwnScore ? colours.GreenDark : colourProvider.Background3;
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)

View File

@ -5,7 +5,6 @@ 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.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osuTK; using osuTK;
using System.Linq; using System.Linq;
@ -179,9 +178,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
background.Colour = colours.Gray2; background.Colour = colourProvider.Background5;
user.BindTo(api.LocalUser); user.BindTo(api.LocalUser);
} }

View File

@ -23,9 +23,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
public class TopScoreStatisticsSection : CompositeDrawable public class TopScoreStatisticsSection : CompositeDrawable
{ {
private const float margin = 10; private const float margin = 10;
private const float top_columns_min_width = 64;
private const float bottom_columns_min_width = 45;
private readonly FontUsage smallFont = OsuFont.GetFont(size: 20); private readonly FontUsage smallFont = OsuFont.GetFont(size: 16);
private readonly FontUsage largeFont = OsuFont.GetFont(size: 25); private readonly FontUsage largeFont = OsuFont.GetFont(size: 22);
private readonly TextColumn totalScoreColumn; private readonly TextColumn totalScoreColumn;
private readonly TextColumn accuracyColumn; private readonly TextColumn accuracyColumn;
@ -44,9 +46,24 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Spacing = new Vector2(10, 0), Direction = FillDirection.Vertical,
Spacing = new Vector2(10, 8),
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(margin, 0),
Children = new Drawable[]
{
totalScoreColumn = new TextColumn("total score", largeFont, top_columns_min_width),
accuracyColumn = new TextColumn("accuracy", largeFont, top_columns_min_width),
maxComboColumn = new TextColumn("max combo", largeFont, top_columns_min_width)
}
},
new FillFlowContainer new FillFlowContainer
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
@ -62,24 +79,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(margin, 0), Spacing = new Vector2(margin, 0),
}, },
ppColumn = new TextColumn("pp", smallFont), ppColumn = new TextColumn("pp", smallFont, bottom_columns_min_width),
modsColumn = new ModsInfoColumn(), modsColumn = new ModsInfoColumn(),
} }
}, },
new FillFlowContainer
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(margin, 0),
Children = new Drawable[]
{
totalScoreColumn = new TextColumn("total score", largeFont),
accuracyColumn = new TextColumn("accuracy", largeFont),
maxComboColumn = new TextColumn("max combo", largeFont)
}
},
} }
}; };
} }
@ -96,12 +99,14 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
maxComboColumn.Text = $@"{value.MaxCombo:N0}x"; maxComboColumn.Text = $@"{value.MaxCombo:N0}x";
ppColumn.Text = $@"{value.PP:N0}"; ppColumn.Text = $@"{value.PP:N0}";
statisticsColumns.ChildrenEnumerable = value.Statistics.Select(kvp => createStatisticsColumn(kvp.Key, kvp.Value)); statisticsColumns.ChildrenEnumerable = value.Statistics
.OrderByDescending(pair => pair.Key)
.Select(kvp => createStatisticsColumn(kvp.Key, kvp.Value));
modsColumn.Mods = value.Mods; modsColumn.Mods = value.Mods;
} }
} }
private TextColumn createStatisticsColumn(HitResult hitResult, int count) => new TextColumn(hitResult.GetDescription(), smallFont) private TextColumn createStatisticsColumn(HitResult hitResult, int count) => new TextColumn(hitResult.GetDescription(), smallFont, bottom_columns_min_width)
{ {
Text = count.ToString() Text = count.ToString()
}; };
@ -109,8 +114,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
private class InfoColumn : CompositeDrawable private class InfoColumn : CompositeDrawable
{ {
private readonly Box separator; private readonly Box separator;
private readonly OsuSpriteText text;
public InfoColumn(string title, Drawable content) public InfoColumn(string title, Drawable content, float? minWidth = null)
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
@ -118,18 +124,20 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 2), Spacing = new Vector2(0, 1),
Children = new[] Children = new[]
{ {
new OsuSpriteText text = new OsuSpriteText
{ {
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Black), Font = OsuFont.GetFont(size: 10, weight: FontWeight.Bold),
Text = title.ToUpper() Text = title.ToUpper()
}, },
separator = new Box separator = new Box
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = minWidth == null ? Axes.X : Axes.None,
Height = 2 Width = minWidth ?? 1f,
Height = 2,
Margin = new MarginPadding { Top = 2 }
}, },
content content
} }
@ -137,9 +145,10 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
separator.Colour = colours.Gray5; text.Colour = colourProvider.Foreground1;
separator.Colour = colourProvider.Background3;
} }
} }
@ -147,13 +156,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
private readonly SpriteText text; private readonly SpriteText text;
public TextColumn(string title, FontUsage font) public TextColumn(string title, FontUsage font, float? minWidth = null)
: this(title, new OsuSpriteText { Font = font }) : this(title, new OsuSpriteText { Font = font }, minWidth)
{ {
} }
private TextColumn(string title, SpriteText text) private TextColumn(string title, SpriteText text, float? minWidth = null)
: base(title, text) : base(title, text, minWidth)
{ {
this.text = text; this.text = text;
} }
@ -189,15 +198,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
set set
{ {
modsContainer.Clear(); modsContainer.Clear();
modsContainer.Children = value.Select(mod => new ModIcon(mod)
foreach (Mod mod in value)
{
modsContainer.Add(new ModIcon(mod)
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Scale = new Vector2(0.3f), Scale = new Vector2(0.25f),
}); }).ToList();
}
} }
} }
} }

View File

@ -1,7 +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.
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -51,13 +50,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Bold, italics: true) Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold)
}, },
rank = new UpdateableRank(ScoreRank.D) rank = new UpdateableRank(ScoreRank.D)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(40), Size = new Vector2(28),
FillMode = FillMode.Fit, FillMode = FillMode.Fit,
}, },
} }
@ -66,7 +65,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(80), Size = new Vector2(70),
Masking = true, Masking = true,
CornerRadius = 5, CornerRadius = 5,
EdgeEffect = new EdgeEffectParameters EdgeEffect = new EdgeEffectParameters
@ -87,7 +86,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
Spacing = new Vector2(0, 3), Spacing = new Vector2(0, 3),
Children = new Drawable[] Children = new Drawable[]
{ {
usernameText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold, italics: true)) usernameText = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true))
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
@ -97,13 +96,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Bold) Font = OsuFont.GetFont(size: 10, weight: FontWeight.Bold)
}, },
flag = new UpdateableFlag flag = new UpdateableFlag
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
Size = new Vector2(20, 13), Size = new Vector2(19, 13),
ShowPlaceholderOnNull = false, ShowPlaceholderOnNull = false,
}, },
} }
@ -112,12 +111,6 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
rankText.Colour = colours.Yellow;
}
public int ScorePosition public int ScorePosition
{ {
set => rankText.Text = $"#{value}"; set => rankText.Text = $"#{value}";

View File

@ -17,7 +17,7 @@ namespace osu.Game.Overlays.BeatmapSet
protected readonly FailRetryGraph Graph; protected readonly FailRetryGraph Graph;
private readonly FillFlowContainer header; private readonly FillFlowContainer header;
private readonly OsuSpriteText successRateLabel, successPercent, graphLabel; private readonly OsuSpriteText successPercent;
private readonly Bar successRate; private readonly Bar successRate;
private readonly Container percentContainer; private readonly Container percentContainer;
@ -60,7 +60,7 @@ namespace osu.Game.Overlays.BeatmapSet
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
successRateLabel = new OsuSpriteText new OsuSpriteText
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
@ -85,7 +85,7 @@ namespace osu.Game.Overlays.BeatmapSet
Font = OsuFont.GetFont(size: 13), Font = OsuFont.GetFont(size: 13),
}, },
}, },
graphLabel = new OsuSpriteText new OsuSpriteText
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
@ -107,7 +107,6 @@ namespace osu.Game.Overlays.BeatmapSet
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
successRateLabel.Colour = successPercent.Colour = graphLabel.Colour = colours.Gray5;
successRate.AccentColour = colours.Green; successRate.AccentColour = colours.Green;
successRate.BackgroundColour = colours.GrayD; successRate.BackgroundColour = colours.GrayD;

View File

@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
using osu.Game.Overlays.BeatmapSet; using osu.Game.Overlays.BeatmapSet;
@ -33,6 +32,8 @@ namespace osu.Game.Overlays
// receive input outside our bounds so we can trigger a close event on ourselves. // receive input outside our bounds so we can trigger a close event on ourselves.
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
private readonly Box background;
public BeatmapSetOverlay() public BeatmapSetOverlay()
: base(OverlayColourScheme.Blue) : base(OverlayColourScheme.Blue)
{ {
@ -41,10 +42,9 @@ namespace osu.Game.Overlays
Children = new Drawable[] Children = new Drawable[]
{ {
new Box background = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both
Colour = OsuColour.Gray(0.2f)
}, },
scroll = new OsuScrollContainer scroll = new OsuScrollContainer
{ {
@ -55,10 +55,20 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
Children = new Drawable[]
{
new ReverseChildIDFillFlowContainer<Drawable>
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
Header = new Header(), Header = new Header(),
info = new Info(), info = new Info()
}
},
new ScoresContainer new ScoresContainer
{ {
Beatmap = { BindTarget = Header.Picker.Beatmap } Beatmap = { BindTarget = Header.Picker.Beatmap }
@ -83,6 +93,8 @@ namespace osu.Game.Overlays
private void load(RulesetStore rulesets) private void load(RulesetStore rulesets)
{ {
this.rulesets = rulesets; this.rulesets = rulesets;
background.Colour = ColourProvider.Background6;
} }
protected override void PopOutComplete() protected override void PopOutComplete()

View File

@ -76,9 +76,9 @@ namespace osu.Game.Overlays.Rankings
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
background.Colour = colours.GreySeafoam; background.Colour = colourProvider.Dark3;
} }
protected override void LoadComplete() protected override void LoadComplete()

View File

@ -100,9 +100,9 @@ namespace osu.Game.Overlays.Rankings
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
background.Colour = colours.GreySeafoamDarker; background.Colour = colourProvider.Background5;
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -154,9 +154,9 @@ namespace osu.Game.Overlays.Rankings
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
IdleColour = colours.GreySeafoamLighter; IdleColour = colourProvider.Light2;
HoverColour = Color4.White; HoverColour = Color4.White;
} }
} }

View File

@ -1,55 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Users.Drawables;
using osuTK.Graphics;
using osuTK;
using osu.Framework.Input.Events;
using System;
namespace osu.Game.Overlays.Rankings
{
public class DismissableFlag : UpdateableFlag
{
private const int duration = 200;
public Action Action;
private readonly SpriteIcon hoverIcon;
public DismissableFlag()
{
AddInternal(hoverIcon = new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Depth = -1,
Alpha = 0,
Size = new Vector2(10),
Icon = FontAwesome.Solid.Times,
});
}
protected override bool OnHover(HoverEvent e)
{
hoverIcon.FadeIn(duration, Easing.OutQuint);
this.FadeColour(Color4.Gray, duration, Easing.OutQuint);
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
hoverIcon.FadeOut(duration, Easing.OutQuint);
this.FadeColour(Color4.White, duration, Easing.OutQuint);
}
protected override bool OnClick(ClickEvent e)
{
Action?.Invoke();
return true;
}
}
}

View File

@ -1,91 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Users;
using osu.Framework.Graphics;
using osuTK;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Rankings
{
public class HeaderTitle : CompositeDrawable
{
private const int spacing = 10;
private const int flag_margin = 5;
private const int text_size = 40;
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
public readonly Bindable<Country> Country = new Bindable<Country>();
private readonly SpriteText scopeText;
private readonly DismissableFlag flag;
public HeaderTitle()
{
AutoSizeAxes = Axes.Both;
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(spacing, 0),
Children = new Drawable[]
{
flag = new DismissableFlag
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Margin = new MarginPadding { Bottom = flag_margin },
Size = new Vector2(30, 20),
},
scopeText = new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Light)
},
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Light),
Text = @"Ranking"
}
}
};
flag.Action += () => Country.Value = null;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
scopeText.Colour = colours.Lime;
}
protected override void LoadComplete()
{
Scope.BindValueChanged(onScopeChanged, true);
Country.BindValueChanged(onCountryChanged, true);
base.LoadComplete();
}
private void onScopeChanged(ValueChangedEvent<RankingsScope> scope) => scopeText.Text = scope.NewValue.ToString();
private void onCountryChanged(ValueChangedEvent<Country> country)
{
if (country.NewValue == null)
{
flag.Hide();
return;
}
flag.Country = country.NewValue;
flag.Show();
}
}
}

View File

@ -1,129 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Rulesets;
using osu.Game.Users;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osuTK;
using osu.Game.Graphics.UserInterface;
using System.Collections.Generic;
namespace osu.Game.Overlays.Rankings
{
public class RankingsHeader : CompositeDrawable
{
private const int content_height = 250;
public IEnumerable<Spotlight> Spotlights
{
get => dropdown.Items;
set => dropdown.Items = value;
}
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
public readonly Bindable<Country> Country = new Bindable<Country>();
public readonly Bindable<Spotlight> Spotlight = new Bindable<Spotlight>();
private readonly OsuDropdown<Spotlight> dropdown;
public RankingsHeader()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddInternal(new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new RankingsRulesetSelector
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Current = Ruleset
},
new Container
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Height = content_height,
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Child = new HeaderBackground(),
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
Children = new Drawable[]
{
new RankingsScopeSelector
{
Margin = new MarginPadding { Top = 10 },
Current = Scope
},
new HeaderTitle
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 10 },
Scope = { BindTarget = Scope },
Country = { BindTarget = Country },
},
dropdown = new OsuDropdown<Spotlight>
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Width = 0.8f,
Current = Spotlight,
}
}
},
}
}
}
});
}
protected override void LoadComplete()
{
Scope.BindValueChanged(onScopeChanged, true);
base.LoadComplete();
}
private void onScopeChanged(ValueChangedEvent<RankingsScope> scope) =>
dropdown.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint);
private class HeaderBackground : Sprite
{
public HeaderBackground()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fill;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(@"Headers/rankings");
}
}
}
}

View File

@ -0,0 +1,135 @@
// 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.Graphics;
using osu.Framework.Bindables;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Users;
using System.Collections.Generic;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Allocation;
namespace osu.Game.Overlays.Rankings
{
public class RankingsOverlayHeader : TabControlOverlayHeader<RankingsScope>
{
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
public readonly Bindable<Spotlight> Spotlight = new Bindable<Spotlight>();
public readonly Bindable<Country> Country = new Bindable<Country>();
public IEnumerable<Spotlight> Spotlights
{
get => spotlightsContainer.Spotlights;
set => spotlightsContainer.Spotlights = value;
}
protected override ScreenTitle CreateTitle() => new RankingsTitle
{
Scope = { BindTarget = Current }
};
protected override Drawable CreateTitleContent() => new OverlayRulesetSelector
{
Current = Ruleset
};
private SpotlightsContainer spotlightsContainer;
protected override Drawable CreateContent() => new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new CountryFilter
{
Current = Country
},
spotlightsContainer = new SpotlightsContainer
{
Spotlight = { BindTarget = Spotlight }
}
}
};
protected override void LoadComplete()
{
Current.BindValueChanged(onCurrentChanged, true);
base.LoadComplete();
}
private void onCurrentChanged(ValueChangedEvent<RankingsScope> scope) =>
spotlightsContainer.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint);
private class RankingsTitle : ScreenTitle
{
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
public RankingsTitle()
{
Title = "ranking";
}
protected override void LoadComplete()
{
base.LoadComplete();
Scope.BindValueChanged(scope => Section = scope.NewValue.ToString().ToLowerInvariant(), true);
}
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/rankings");
}
private class SpotlightsContainer : CompositeDrawable
{
public readonly Bindable<Spotlight> Spotlight = new Bindable<Spotlight>();
public IEnumerable<Spotlight> Spotlights
{
get => dropdown.Items;
set => dropdown.Items = value;
}
private readonly OsuDropdown<Spotlight> dropdown;
private readonly Box background;
public SpotlightsContainer()
{
Height = 100;
RelativeSizeAxes = Axes.X;
InternalChildren = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
},
dropdown = new OsuDropdown<Spotlight>
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Width = 0.8f,
Current = Spotlight,
Y = 20,
}
};
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
background.Colour = colourProvider.Dark3;
}
}
}
public enum RankingsScope
{
Performance,
Spotlights,
Score,
Country
}
}

View File

@ -1,56 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osuTK;
using System.Linq;
namespace osu.Game.Overlays.Rankings
{
public class RankingsRulesetSelector : PageTabControl<RulesetInfo>
{
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new RankingsTabItem(value);
protected override Dropdown<RulesetInfo> CreateDropdown() => null;
public RankingsRulesetSelector()
{
AutoSizeAxes = Axes.X;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, RulesetStore rulesets)
{
foreach (var r in rulesets.AvailableRulesets)
AddItem(r);
AccentColour = colours.Lime;
SelectTab(TabContainer.FirstOrDefault());
}
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(20, 0),
};
private class RankingsTabItem : PageTabItem
{
public RankingsTabItem(RulesetInfo value)
: base(value)
{
}
protected override string CreateText() => $"{Value.Name}";
}
}
}

View File

@ -1,26 +0,0 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Graphics.UserInterface;
using osu.Framework.Allocation;
using osuTK.Graphics;
namespace osu.Game.Overlays.Rankings
{
public class RankingsScopeSelector : GradientLineTabControl<RankingsScope>
{
[BackgroundDependencyLoader]
private void load()
{
AccentColour = LineColour = Color4.Black;
}
}
public enum RankingsScope
{
Performance,
Spotlights,
Score,
Country
}
}

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Rankings.Tables
{ {
public abstract class RankingsTable<TModel> : TableContainer public abstract class RankingsTable<TModel> : TableContainer
{ {
protected const int TEXT_SIZE = 14; protected const int TEXT_SIZE = 12;
private const float horizontal_inset = 20; private const float horizontal_inset = 20;
private const float row_height = 25; private const float row_height = 25;
private const int items_per_page = 50; private const int items_per_page = 50;
@ -60,7 +60,7 @@ namespace osu.Game.Overlays.Rankings.Tables
private static TableColumn[] mainHeaders => new[] private static TableColumn[] mainHeaders => new[]
{ {
new TableColumn(string.Empty, Anchor.Centre, new Dimension(GridSizeMode.Absolute, 50)), // place new TableColumn(string.Empty, Anchor.Centre, new Dimension(GridSizeMode.Absolute, 40)), // place
new TableColumn(string.Empty, Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed)), // flag and username (country name) new TableColumn(string.Empty, Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed)), // flag and username (country name)
}; };
@ -77,7 +77,7 @@ namespace osu.Game.Overlays.Rankings.Tables
private OsuSpriteText createIndexDrawable(int index) => new OsuSpriteText private OsuSpriteText createIndexDrawable(int index) => new OsuSpriteText
{ {
Text = $"#{index + 1}", Text = $"#{index + 1}",
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold) Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.SemiBold)
}; };
private FillFlowContainer createMainContent(TModel item) => new FillFlowContainer private FillFlowContainer createMainContent(TModel item) => new FillFlowContainer
@ -112,10 +112,10 @@ namespace osu.Game.Overlays.Rankings.Tables
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
if (Text != highlighted) if (Text != highlighted)
Colour = colours.GreySeafoamLighter; Colour = colourProvider.Foreground1;
} }
} }
@ -131,9 +131,9 @@ namespace osu.Game.Overlays.Rankings.Tables
protected class ColoredRowText : RowText protected class ColoredRowText : RowText
{ {
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
Colour = colours.GreySeafoamLighter; Colour = colourProvider.Foreground1;
} }
} }
} }

View File

@ -6,7 +6,6 @@ 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.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Overlays.Rankings.Tables namespace osu.Game.Overlays.Rankings.Tables
@ -35,10 +34,10 @@ namespace osu.Game.Overlays.Rankings.Tables
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OverlayColourProvider colourProvider)
{ {
background.Colour = idleColour = colours.GreySeafoam; background.Colour = idleColour = colourProvider.Background4;
hoverColour = colours.GreySeafoamLight; hoverColour = colourProvider.Background3;
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)

View File

@ -8,6 +8,7 @@ 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.Users; using osu.Game.Users;
using osu.Game.Scoring;
namespace osu.Game.Overlays.Rankings.Tables namespace osu.Game.Overlays.Rankings.Tables
{ {
@ -44,9 +45,9 @@ namespace osu.Game.Overlays.Rankings.Tables
new ColoredRowText { Text = $@"{item.PlayCount:N0}", }, new ColoredRowText { Text = $@"{item.PlayCount:N0}", },
}.Concat(CreateUniqueContent(item)).Concat(new[] }.Concat(CreateUniqueContent(item)).Concat(new[]
{ {
new ColoredRowText { Text = $@"{item.GradesCount.SS + item.GradesCount.SSPlus:N0}", }, new ColoredRowText { Text = $@"{item.GradesCount[ScoreRank.XH] + item.GradesCount[ScoreRank.X]:N0}", },
new ColoredRowText { Text = $@"{item.GradesCount.S + item.GradesCount.SPlus:N0}", }, new ColoredRowText { Text = $@"{item.GradesCount[ScoreRank.SH] + item.GradesCount[ScoreRank.S]:N0}", },
new ColoredRowText { Text = $@"{item.GradesCount.A:N0}", } new ColoredRowText { Text = $@"{item.GradesCount[ScoreRank.A]:N0}", }
}).ToArray(); }).ToArray();
protected abstract TableColumn[] CreateUniqueHeaders(); protected abstract TableColumn[] CreateUniqueHeaders();

View File

@ -6,7 +6,6 @@ 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.Graphics;
using osu.Game.Overlays.Rankings; using osu.Game.Overlays.Rankings;
using osu.Game.Users; using osu.Game.Users;
using osu.Game.Rulesets; using osu.Game.Rulesets;
@ -27,6 +26,7 @@ namespace osu.Game.Overlays
private readonly BasicScrollContainer scrollFlow; private readonly BasicScrollContainer scrollFlow;
private readonly Container tableContainer; private readonly Container tableContainer;
private readonly DimmedLoadingLayer loading; private readonly DimmedLoadingLayer loading;
private readonly Box background;
private APIRequest lastRequest; private APIRequest lastRequest;
private CancellationTokenSource cancellationToken; private CancellationTokenSource cancellationToken;
@ -39,10 +39,9 @@ namespace osu.Game.Overlays
{ {
Children = new Drawable[] Children = new Drawable[]
{ {
new Box background = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both
Colour = OsuColour.Gray(0.1f),
}, },
scrollFlow = new BasicScrollContainer scrollFlow = new BasicScrollContainer
{ {
@ -55,12 +54,13 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
new RankingsHeader new RankingsOverlayHeader
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Depth = -float.MaxValue,
Country = { BindTarget = Country }, Country = { BindTarget = Country },
Scope = { BindTarget = Scope }, Current = { BindTarget = Scope },
Ruleset = { BindTarget = ruleset } Ruleset = { BindTarget = ruleset }
}, },
new Container new Container
@ -86,6 +86,12 @@ namespace osu.Game.Overlays
}; };
} }
[BackgroundDependencyLoader]
private void load()
{
background.Colour = ColourProvider.Background5;
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
Country.BindValueChanged(_ => Country.BindValueChanged(_ =>

View File

@ -47,7 +47,7 @@ namespace osu.Game.Overlays
TabControl = CreateTabControl().With(control => TabControl = CreateTabControl().With(control =>
{ {
control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }; control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN };
control.Current = current; control.Current = Current;
}) })
} }
}); });

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Threading;
using osu.Framework.Timing; using osu.Framework.Timing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -50,8 +49,6 @@ namespace osu.Game.Rulesets.Edit
[Resolved] [Resolved]
private IBeatSnapProvider beatSnapProvider { get; set; } private IBeatSnapProvider beatSnapProvider { get; set; }
private IBeatmapProcessor beatmapProcessor;
private DrawableEditRulesetWrapper<TObject> drawableRulesetWrapper; private DrawableEditRulesetWrapper<TObject> drawableRulesetWrapper;
private ComposeBlueprintContainer blueprintContainer; private ComposeBlueprintContainer blueprintContainer;
private Container distanceSnapGridContainer; private Container distanceSnapGridContainer;
@ -71,8 +68,6 @@ namespace osu.Game.Rulesets.Edit
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IFrameBasedClock framedClock) private void load(IFrameBasedClock framedClock)
{ {
beatmapProcessor = Ruleset.CreateBeatmapProcessor(EditorBeatmap.PlayableBeatmap);
EditorBeatmap.HitObjectAdded += addHitObject; EditorBeatmap.HitObjectAdded += addHitObject;
EditorBeatmap.HitObjectRemoved += removeHitObject; EditorBeatmap.HitObjectRemoved += removeHitObject;
EditorBeatmap.StartTimeChanged += UpdateHitObject; EditorBeatmap.StartTimeChanged += UpdateHitObject;
@ -240,19 +235,6 @@ namespace osu.Game.Rulesets.Edit
lastGridUpdateTime = EditorClock.CurrentTime; lastGridUpdateTime = EditorClock.CurrentTime;
} }
private ScheduledDelegate scheduledUpdate;
public override void UpdateHitObject(HitObject hitObject)
{
scheduledUpdate?.Cancel();
scheduledUpdate = Schedule(() =>
{
beatmapProcessor?.PreProcess();
hitObject?.ApplyDefaults(EditorBeatmap.ControlPointInfo, EditorBeatmap.BeatmapInfo.BaseDifficulty);
beatmapProcessor?.PostProcess();
});
}
private void addHitObject(HitObject hitObject) => UpdateHitObject(hitObject); private void addHitObject(HitObject hitObject) => UpdateHitObject(hitObject);
private void removeHitObject(HitObject hitObject) => UpdateHitObject(null); private void removeHitObject(HitObject hitObject) => UpdateHitObject(null);
@ -309,6 +291,8 @@ namespace osu.Game.Rulesets.Edit
public override float GetSnappedDistanceFromDistance(double referenceTime, float distance) public override float GetSnappedDistanceFromDistance(double referenceTime, float distance)
=> DurationToDistance(referenceTime, beatSnapProvider.SnapTime(DistanceToDuration(referenceTime, distance), referenceTime)); => DurationToDistance(referenceTime, beatSnapProvider.SnapTime(DistanceToDuration(referenceTime, distance), referenceTime));
public override void UpdateHitObject(HitObject hitObject) => EditorBeatmap.UpdateHitObject(hitObject);
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);

View File

@ -26,7 +26,12 @@ namespace osu.Game.Rulesets.Objects.Legacy
public List<IList<HitSampleInfo>> NodeSamples { get; set; } public List<IList<HitSampleInfo>> NodeSamples { get; set; }
public int RepeatCount { get; set; } public int RepeatCount { get; set; }
public double EndTime => StartTime + this.SpanCount() * Distance / Velocity; public double EndTime
{
get => StartTime + this.SpanCount() * Distance / Velocity;
set => throw new System.NotSupportedException($"Adjust via {nameof(RepeatCount)} instead"); // can be implemented if/when needed.
}
public double Duration => EndTime - StartTime; public double Duration => EndTime - StartTime;
public double Velocity = 1; public double Velocity = 1;

View File

@ -1,6 +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.
using Newtonsoft.Json;
namespace osu.Game.Rulesets.Objects.Types namespace osu.Game.Rulesets.Objects.Types
{ {
/// <summary> /// <summary>
@ -11,7 +13,8 @@ namespace osu.Game.Rulesets.Objects.Types
/// <summary> /// <summary>
/// The time at which the HitObject ends. /// The time at which the HitObject ends.
/// </summary> /// </summary>
double EndTime { get; } [JsonIgnore]
double EndTime { get; set; }
/// <summary> /// <summary>
/// The duration of the HitObject. /// The duration of the HitObject.

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Objects.Types
/// <summary> /// <summary>
/// The amount of times the HitObject repeats. /// The amount of times the HitObject repeats.
/// </summary> /// </summary>
int RepeatCount { get; } int RepeatCount { get; set; }
/// <summary> /// <summary>
/// The samples to be played when each node of the <see cref="IHasRepeats"/> is hit.<br /> /// The samples to be played when each node of the <see cref="IHasRepeats"/> is hit.<br />

View File

@ -179,11 +179,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
[Resolved] [Resolved]
private IBeatSnapProvider beatSnapProvider { get; set; } private IBeatSnapProvider beatSnapProvider { get; set; }
public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time) public double GetTimeFromScreenSpacePosition(Vector2 position)
{ => getTimeFromPosition(Content.ToLocalSpace(position));
var targetTime = (position.X / Content.DrawWidth) * track.Length;
return (position, beatSnapProvider.SnapTime(targetTime)); public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time) =>
} (position, beatSnapProvider.SnapTime(getTimeFromPosition(position)));
private double getTimeFromPosition(Vector2 localPosition) =>
(localPosition.X / Content.DrawWidth) * track.Length;
public float GetBeatSnapDistanceAt(double referenceTime) => throw new NotImplementedException(); public float GetBeatSnapDistanceAt(double referenceTime) => throw new NotImplementedException();

View File

@ -49,20 +49,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
protected override void OnDrag(DragEvent e) protected override void OnDrag(DragEvent e)
{ {
if (timeline != null) handleScrollViaDrag(e);
{
var timelineQuad = timeline.ScreenSpaceDrawQuad;
var mouseX = e.ScreenSpaceMousePosition.X;
// scroll if in a drag and dragging outside visible extents
if (mouseX > timelineQuad.TopRight.X)
timeline.ScrollBy((float)((mouseX - timelineQuad.TopRight.X) / 10 * Clock.ElapsedFrameTime));
else if (mouseX < timelineQuad.TopLeft.X)
timeline.ScrollBy((float)((mouseX - timelineQuad.TopLeft.X) / 10 * Clock.ElapsedFrameTime));
}
base.OnDrag(e); base.OnDrag(e);
lastDragEvent = e;
} }
protected override void OnDragEnd(DragEndEvent e) protected override void OnDragEnd(DragEndEvent e)
@ -74,7 +63,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
protected override void Update() protected override void Update()
{ {
// trigger every frame so drags continue to update selection while playback is scrolling the timeline. // trigger every frame so drags continue to update selection while playback is scrolling the timeline.
if (IsDragged) if (lastDragEvent != null)
OnDrag(lastDragEvent); OnDrag(lastDragEvent);
base.Update(); base.Update();
@ -82,10 +71,33 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
protected override SelectionHandler CreateSelectionHandler() => new TimelineSelectionHandler(); protected override SelectionHandler CreateSelectionHandler() => new TimelineSelectionHandler();
protected override SelectionBlueprint CreateBlueprintFor(HitObject hitObject) => new TimelineHitObjectBlueprint(hitObject); protected override SelectionBlueprint CreateBlueprintFor(HitObject hitObject) => new TimelineHitObjectBlueprint(hitObject)
{
OnDragHandled = handleScrollViaDrag
};
protected override DragBox CreateDragBox(Action<RectangleF> performSelect) => new TimelineDragBox(performSelect); protected override DragBox CreateDragBox(Action<RectangleF> performSelect) => new TimelineDragBox(performSelect);
private void handleScrollViaDrag(DragEvent e)
{
lastDragEvent = e;
if (lastDragEvent == null)
return;
if (timeline != null)
{
var timelineQuad = timeline.ScreenSpaceDrawQuad;
var mouseX = e.ScreenSpaceMousePosition.X;
// scroll if in a drag and dragging outside visible extents
if (mouseX > timelineQuad.TopRight.X)
timeline.ScrollBy((float)((mouseX - timelineQuad.TopRight.X) / 10 * Clock.ElapsedFrameTime));
else if (mouseX < timelineQuad.TopLeft.X)
timeline.ScrollBy((float)((mouseX - timelineQuad.TopLeft.X) / 10 * Clock.ElapsedFrameTime));
}
}
internal class TimelineSelectionHandler : SelectionHandler internal class TimelineSelectionHandler : SelectionHandler
{ {
// for now we always allow movement. snapping is provided by the Timeline's "distance" snap implementation // for now we always allow movement. snapping is provided by the Timeline's "distance" snap implementation

View File

@ -1,12 +1,18 @@
// 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 System;
using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
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.Effects;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
@ -19,17 +25,21 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{ {
private readonly Circle circle; private readonly Circle circle;
private readonly Container extensionBar;
[UsedImplicitly] [UsedImplicitly]
private readonly Bindable<double> startTime; private readonly Bindable<double> startTime;
public const float THICKNESS = 3; public Action<DragEvent> OnDragHandled;
private readonly DragBar dragBar;
private readonly List<Container> shadowComponents = new List<Container>();
private const float thickness = 5;
private const float shadow_radius = 5;
private const float circle_size = 16; private const float circle_size = 16;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) || circle.ReceivePositionalInputAt(screenSpacePos);
public TimelineHitObjectBlueprint(HitObject hitObject) public TimelineHitObjectBlueprint(HitObject hitObject)
: base(hitObject) : base(hitObject)
{ {
@ -44,26 +54,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
if (hitObject is IHasEndTime) circle = new Circle
{
AddInternal(extensionBar = new Container
{
CornerRadius = 2,
Masking = true,
Size = new Vector2(1, THICKNESS),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativePositionAxes = Axes.X,
RelativeSizeAxes = Axes.X,
Colour = Color4.Black,
Child = new Box
{
RelativeSizeAxes = Axes.Both,
}
});
}
AddInternal(circle = new Circle
{ {
Size = new Vector2(circle_size), Size = new Vector2(circle_size),
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
@ -71,9 +62,65 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
RelativePositionAxes = Axes.X, RelativePositionAxes = Axes.X,
AlwaysPresent = true, AlwaysPresent = true,
Colour = Color4.White, Colour = Color4.White,
BorderColour = Color4.Black, EdgeEffect = new EdgeEffectParameters
BorderThickness = THICKNESS, {
Type = EdgeEffectType.Shadow,
Radius = shadow_radius,
Colour = Color4.Black
},
};
shadowComponents.Add(circle);
if (hitObject is IHasEndTime)
{
DragBar dragBarUnderlay;
Container extensionBar;
AddRangeInternal(new Drawable[]
{
extensionBar = new Container
{
Masking = true,
Size = new Vector2(1, thickness),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativePositionAxes = Axes.X,
RelativeSizeAxes = Axes.X,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Radius = shadow_radius,
Colour = Color4.Black
},
Child = new Box
{
RelativeSizeAxes = Axes.Both,
}
},
circle,
// only used for drawing the shadow
dragBarUnderlay = new DragBar(null),
// cover up the shadow on the join
new Box
{
Height = thickness,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.X,
},
dragBar = new DragBar(hitObject) { OnDragHandled = e => OnDragHandled?.Invoke(e) },
}); });
shadowComponents.Add(dragBarUnderlay);
shadowComponents.Add(extensionBar);
}
else
{
AddInternal(circle);
}
updateShadows();
} }
protected override void Update() protected override void Update()
@ -84,18 +131,46 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
Width = (float)(HitObject.GetEndTime() - HitObject.StartTime); Width = (float)(HitObject.GetEndTime() - HitObject.StartTime);
} }
protected override bool ShouldBeConsideredForInput(Drawable child) => true;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
base.ReceivePositionalInputAt(screenSpacePos) ||
circle.ReceivePositionalInputAt(screenSpacePos) ||
dragBar?.ReceivePositionalInputAt(screenSpacePos) == true;
protected override void OnSelected() protected override void OnSelected()
{ {
circle.BorderColour = Color4.Orange; updateShadows();
if (extensionBar != null) }
extensionBar.Colour = Color4.Orange;
private void updateShadows()
{
foreach (var s in shadowComponents)
{
if (State == SelectionState.Selected)
{
s.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Radius = shadow_radius / 2,
Colour = Color4.Orange,
};
}
else
{
s.EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Radius = shadow_radius,
Colour = State == SelectionState.Selected ? Color4.Orange : Color4.Black
};
}
}
} }
protected override void OnDeselected() protected override void OnDeselected()
{ {
circle.BorderColour = Color4.Black; updateShadows();
if (extensionBar != null)
extensionBar.Colour = Color4.Black;
} }
public override Quad SelectionQuad public override Quad SelectionQuad
@ -103,14 +178,130 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
get get
{ {
// correctly include the circle in the selection quad region, as it is usually outside the blueprint itself. // correctly include the circle in the selection quad region, as it is usually outside the blueprint itself.
var circleQuad = circle.ScreenSpaceDrawQuad; var leftQuad = circle.ScreenSpaceDrawQuad;
var actualQuad = ScreenSpaceDrawQuad; var rightQuad = dragBar?.ScreenSpaceDrawQuad ?? ScreenSpaceDrawQuad;
return new Quad(circleQuad.TopLeft, Vector2.ComponentMax(actualQuad.TopRight, circleQuad.TopRight), return new Quad(leftQuad.TopLeft, Vector2.ComponentMax(rightQuad.TopRight, leftQuad.TopRight),
circleQuad.BottomLeft, Vector2.ComponentMax(actualQuad.BottomRight, circleQuad.BottomRight)); leftQuad.BottomLeft, Vector2.ComponentMax(rightQuad.BottomRight, leftQuad.BottomRight));
} }
} }
public override Vector2 SelectionPoint => ScreenSpaceDrawQuad.TopLeft; public override Vector2 SelectionPoint => ScreenSpaceDrawQuad.TopLeft;
public class DragBar : Container
{
private readonly HitObject hitObject;
[Resolved]
private Timeline timeline { get; set; }
public Action<DragEvent> OnDragHandled;
public override bool HandlePositionalInput => hitObject != null;
public DragBar(HitObject hitObject)
{
this.hitObject = hitObject;
CornerRadius = 2;
Masking = true;
Size = new Vector2(5, 1);
Anchor = Anchor.CentreRight;
Origin = Anchor.Centre;
RelativePositionAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
InternalChildren = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
}
};
}
protected override bool OnHover(HoverEvent e)
{
updateState();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
updateState();
base.OnHoverLost(e);
}
private bool hasMouseDown;
protected override bool OnMouseDown(MouseDownEvent e)
{
hasMouseDown = true;
updateState();
return true;
}
protected override void OnMouseUp(MouseUpEvent e)
{
hasMouseDown = false;
updateState();
base.OnMouseUp(e);
}
private void updateState()
{
Colour = IsHovered || hasMouseDown ? Color4.OrangeRed : Color4.White;
}
protected override bool OnDragStart(DragStartEvent e) => true;
[Resolved]
private EditorBeatmap beatmap { get; set; }
[Resolved]
private IBeatSnapProvider beatSnapProvider { get; set; }
protected override void OnDrag(DragEvent e)
{
base.OnDrag(e);
OnDragHandled?.Invoke(e);
var time = timeline.GetTimeFromScreenSpacePosition(e.ScreenSpaceMousePosition);
switch (hitObject)
{
case IHasRepeats repeatHitObject:
// find the number of repeats which can fit in the requested time.
var lengthOfOneRepeat = repeatHitObject.Duration / (repeatHitObject.RepeatCount + 1);
var proposedCount = Math.Max(0, (int)((time - hitObject.StartTime) / lengthOfOneRepeat) - 1);
if (proposedCount == repeatHitObject.RepeatCount)
return;
repeatHitObject.RepeatCount = proposedCount;
break;
case IHasEndTime endTimeHitObject:
var snappedTime = Math.Max(hitObject.StartTime, beatSnapProvider.SnapTime(time));
if (endTimeHitObject.EndTime == snappedTime)
return;
endTimeHitObject.EndTime = snappedTime;
break;
}
beatmap.UpdateHitObject(hitObject);
}
protected override void OnDragEnd(DragEndEvent e)
{
base.OnDragEnd(e);
OnDragHandled?.Invoke(null);
}
}
} }
} }

View File

@ -80,15 +80,15 @@ namespace osu.Game.Screens.Edit
clock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false }; clock = new EditorClock(Beatmap.Value, beatDivisor) { IsCoupled = false };
clock.ChangeSource(sourceClock); clock.ChangeSource(sourceClock);
playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
editorBeatmap = new EditorBeatmap(playableBeatmap, beatDivisor);
dependencies.CacheAs<IFrameBasedClock>(clock); dependencies.CacheAs<IFrameBasedClock>(clock);
dependencies.CacheAs<IAdjustableClock>(clock); dependencies.CacheAs<IAdjustableClock>(clock);
// todo: remove caching of this and consume via editorBeatmap? // todo: remove caching of this and consume via editorBeatmap?
dependencies.Cache(beatDivisor); dependencies.Cache(beatDivisor);
playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap));
dependencies.CacheAs(editorBeatmap); dependencies.CacheAs(editorBeatmap);
EditorMenuBar menuBar; EditorMenuBar menuBar;
@ -104,7 +104,7 @@ namespace osu.Game.Screens.Edit
fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit)); fileMenuItems.Add(new EditorMenuItem("Exit", MenuItemType.Standard, this.Exit));
InternalChild = new OsuContextMenuContainer AddInternal(new OsuContextMenuContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new[] Children = new[]
@ -189,7 +189,7 @@ namespace osu.Game.Screens.Edit
} }
}, },
} }
}; });
menuBar.Mode.ValueChanged += onModeChanged; menuBar.Mode.ValueChanged += onModeChanged;

View File

@ -4,7 +4,10 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Threading;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
@ -13,7 +16,7 @@ using osu.Game.Rulesets.Objects;
namespace osu.Game.Screens.Edit namespace osu.Game.Screens.Edit
{ {
public class EditorBeatmap : IBeatmap, IBeatSnapProvider public class EditorBeatmap : Component, IBeatmap, IBeatSnapProvider
{ {
/// <summary> /// <summary>
/// Invoked when a <see cref="HitObject"/> is added to this <see cref="EditorBeatmap"/>. /// Invoked when a <see cref="HitObject"/> is added to this <see cref="EditorBeatmap"/>.
@ -34,19 +37,40 @@ namespace osu.Game.Screens.Edit
public readonly IBeatmap PlayableBeatmap; public readonly IBeatmap PlayableBeatmap;
private readonly BindableBeatDivisor beatDivisor; [Resolved]
private BindableBeatDivisor beatDivisor { get; set; }
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>>();
public EditorBeatmap(IBeatmap playableBeatmap, BindableBeatDivisor beatDivisor = null) public EditorBeatmap(IBeatmap playableBeatmap)
{ {
PlayableBeatmap = playableBeatmap; PlayableBeatmap = playableBeatmap;
this.beatDivisor = beatDivisor;
beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateBeatmapProcessor(PlayableBeatmap);
foreach (var obj in HitObjects) foreach (var obj in HitObjects)
trackStartTime(obj); trackStartTime(obj);
} }
private ScheduledDelegate scheduledUpdate;
/// <summary>
/// Updates a <see cref="HitObject"/>, invoking <see cref="HitObject.ApplyDefaults"/> and re-processing the beatmap.
/// </summary>
/// <param name="hitObject">The <see cref="HitObject"/> to update.</param>
public void UpdateHitObject(HitObject hitObject)
{
scheduledUpdate?.Cancel();
scheduledUpdate = Scheduler.AddDelayed(() =>
{
beatmapProcessor?.PreProcess();
hitObject?.ApplyDefaults(ControlPointInfo, BeatmapInfo.BaseDifficulty);
beatmapProcessor?.PostProcess();
}, 0);
}
public BeatmapInfo BeatmapInfo public BeatmapInfo BeatmapInfo
{ {
get => PlayableBeatmap.BeatmapInfo; get => PlayableBeatmap.BeatmapInfo;

View File

@ -75,8 +75,13 @@ namespace osu.Game.Screens.Multi.Lounge.Components
{ {
matchingFilter = value; matchingFilter = value;
if (IsLoaded) if (!IsLoaded)
this.FadeTo(MatchingFilter ? 1 : 0, 200); return;
if (matchingFilter)
this.FadeIn(200);
else
Hide();
} }
} }

View File

@ -7,6 +7,7 @@ using osu.Framework.Bindables;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Overlays.SearchableList; using osu.Game.Overlays.SearchableList;
using osu.Game.Rulesets;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Screens.Multi.Lounge.Components namespace osu.Game.Screens.Multi.Lounge.Components
@ -22,6 +23,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private Bindable<FilterCriteria> filter { get; set; } private Bindable<FilterCriteria> filter { get; set; }
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
public FilterControl() public FilterControl()
{ {
DisplayStyleControl.Hide(); DisplayStyleControl.Hide();
@ -38,6 +42,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
{ {
base.LoadComplete(); base.LoadComplete();
ruleset.BindValueChanged(_ => updateFilter());
Search.Current.BindValueChanged(_ => scheduleUpdateFilter()); Search.Current.BindValueChanged(_ => scheduleUpdateFilter());
Tabs.Current.BindValueChanged(_ => updateFilter(), true); Tabs.Current.BindValueChanged(_ => updateFilter(), true);
} }
@ -58,7 +63,8 @@ namespace osu.Game.Screens.Multi.Lounge.Components
{ {
SearchString = Search.Current.Value ?? string.Empty, SearchString = Search.Current.Value ?? string.Empty,
PrimaryFilter = Tabs.Current.Value, PrimaryFilter = Tabs.Current.Value,
SecondaryFilter = DisplayStyleControl.Dropdown.Current.Value SecondaryFilter = DisplayStyleControl.Dropdown.Current.Value,
Ruleset = ruleset.Value
}; };
} }
} }

View File

@ -1,6 +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.
using osu.Game.Rulesets;
namespace osu.Game.Screens.Multi.Lounge.Components namespace osu.Game.Screens.Multi.Lounge.Components
{ {
public class FilterCriteria public class FilterCriteria
@ -8,5 +10,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
public string SearchString; public string SearchString;
public PrimaryFilter PrimaryFilter; public PrimaryFilter PrimaryFilter;
public SecondaryFilter SecondaryFilter; public SecondaryFilter SecondaryFilter;
public RulesetInfo Ruleset;
} }
} }

View File

@ -47,22 +47,15 @@ namespace osu.Game.Screens.Multi.Lounge.Components
}; };
} }
[BackgroundDependencyLoader]
private void load()
{
rooms.BindTo(roomManager.Rooms);
rooms.ItemsAdded += addRooms;
rooms.ItemsRemoved += removeRooms;
roomManager.RoomsUpdated += updateSorting;
addRooms(rooms);
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
filter?.BindValueChanged(f => Filter(f.NewValue), true); rooms.ItemsAdded += addRooms;
rooms.ItemsRemoved += removeRooms;
roomManager.RoomsUpdated += updateSorting;
rooms.BindTo(roomManager.Rooms);
filter?.BindValueChanged(criteria => Filter(criteria.NewValue));
} }
public void Filter(FilterCriteria criteria) public void Filter(FilterCriteria criteria)
@ -74,6 +67,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components
else else
{ {
bool matchingFilter = true; bool matchingFilter = true;
matchingFilter &= r.Room.Playlist.Count == 0 || r.Room.Playlist.Any(i => i.Ruleset.Equals(criteria.Ruleset));
if (!string.IsNullOrEmpty(criteria.SearchString))
matchingFilter &= r.FilterTerms.Any(term => term.IndexOf(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase) >= 0); matchingFilter &= r.FilterTerms.Any(term => term.IndexOf(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase) >= 0);
switch (criteria.SecondaryFilter) switch (criteria.SecondaryFilter)
@ -94,8 +91,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
foreach (var r in rooms) foreach (var r in rooms)
roomFlow.Add(new DrawableRoom(r) { Action = () => selectRoom(r) }); roomFlow.Add(new DrawableRoom(r) { Action = () => selectRoom(r) });
if (filter != null) Filter(filter?.Value);
Filter(filter.Value);
} }
private void removeRooms(IEnumerable<Room> rooms) private void removeRooms(IEnumerable<Room> rooms)

View File

@ -91,6 +91,22 @@ namespace osu.Game.Screens.Multi.Lounge
public override void OnEntering(IScreen last) public override void OnEntering(IScreen last)
{ {
base.OnEntering(last); base.OnEntering(last);
onReturning();
}
public override void OnResuming(IScreen last)
{
base.OnResuming(last);
if (currentRoom.Value?.RoomID.Value == null)
currentRoom.Value = new Room();
onReturning();
}
private void onReturning()
{
Filter.Search.HoldFocus = true; Filter.Search.HoldFocus = true;
} }
@ -106,14 +122,6 @@ namespace osu.Game.Screens.Multi.Lounge
Filter.Search.HoldFocus = false; Filter.Search.HoldFocus = false;
} }
public override void OnResuming(IScreen last)
{
base.OnResuming(last);
if (currentRoom.Value?.RoomID.Value == null)
currentRoom.Value = new Room();
}
private void joinRequested(Room room) private void joinRequested(Room room)
{ {
processingOverlay.Show(); processingOverlay.Show();

View File

@ -32,6 +32,8 @@ namespace osu.Game.Screens.Multi
{ {
public override bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.CursorVisible ?? true; public override bool CursorVisible => (screenStack.CurrentScreen as IMultiplayerSubScreen)?.CursorVisible ?? true;
// this is required due to PlayerLoader eventually being pushed to the main stack
// while leases may be taken out by a subscreen.
public override bool DisallowExternalBeatmapRulesetChanges => true; public override bool DisallowExternalBeatmapRulesetChanges => true;
private readonly MultiplayerWaveContainer waves; private readonly MultiplayerWaveContainer waves;
@ -96,7 +98,7 @@ namespace osu.Game.Screens.Multi
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = Header.HEIGHT }, Padding = new MarginPadding { Top = Header.HEIGHT },
Child = screenStack = new OsuScreenStack { RelativeSizeAxes = Axes.Both } Child = screenStack = new MultiplayerSubScreenStack { RelativeSizeAxes = Axes.Both }
}, },
new Header(screenStack), new Header(screenStack),
createButton = new HeaderButton createButton = new HeaderButton
@ -277,11 +279,7 @@ namespace osu.Game.Screens.Multi
private void updateTrack(ValueChangedEvent<WorkingBeatmap> _ = null) private void updateTrack(ValueChangedEvent<WorkingBeatmap> _ = null)
{ {
bool isMatch = screenStack.CurrentScreen is MatchSubScreen; if (screenStack.CurrentScreen is MatchSubScreen)
Beatmap.Disabled = isMatch;
if (isMatch)
{ {
var track = Beatmap.Value?.Track; var track = Beatmap.Value?.Track;

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.Screens;
namespace osu.Game.Screens.Multi
{
public class MultiplayerSubScreenStack : OsuScreenStack
{
protected override void ScreenChanged(IScreen prev, IScreen next)
{
base.ScreenChanged(prev, next);
// because this is a screen stack within a screen stack, let's manually handle disabled changes to simplify things.
var osuScreen = ((OsuScreen)next);
bool disallowChanges = osuScreen.DisallowExternalBeatmapRulesetChanges;
osuScreen.Beatmap.Disabled = disallowChanges;
osuScreen.Ruleset.Disabled = disallowChanges;
osuScreen.Mods.Disabled = disallowChanges;
}
}
}

View File

@ -26,7 +26,7 @@ namespace osu.Game.Screens
}; };
ScreenPushed += screenPushed; ScreenPushed += screenPushed;
ScreenExited += screenExited; ScreenExited += ScreenChanged;
} }
private void screenPushed(IScreen prev, IScreen next) private void screenPushed(IScreen prev, IScreen next)
@ -42,10 +42,10 @@ namespace osu.Game.Screens
// create dependencies synchronously to ensure leases are in a sane state. // create dependencies synchronously to ensure leases are in a sane state.
((OsuScreen)next).CreateLeasedDependencies((prev as OsuScreen)?.Dependencies ?? Dependencies); ((OsuScreen)next).CreateLeasedDependencies((prev as OsuScreen)?.Dependencies ?? Dependencies);
setParallax(next); ScreenChanged(prev, next);
} }
private void screenExited(IScreen prev, IScreen next) protected virtual void ScreenChanged(IScreen prev, IScreen next)
{ {
setParallax(next); setParallax(next);
} }

View File

@ -65,20 +65,7 @@ namespace osu.Game.Screens.Select
Mods.Value = CurrentItem.Value.RequiredMods?.ToArray() ?? Array.Empty<Mod>(); Mods.Value = CurrentItem.Value.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
} }
Beatmap.Disabled = true;
Ruleset.Disabled = true;
Mods.Disabled = true;
return false; return false;
} }
public override void OnEntering(IScreen last)
{
base.OnEntering(last);
Beatmap.Disabled = false;
Ruleset.Disabled = false;
Mods.Disabled = false;
}
} }
} }

View File

@ -15,7 +15,7 @@ namespace osu.Game.Tests.Beatmaps
{ {
public TestBeatmap(RulesetInfo ruleset) public TestBeatmap(RulesetInfo ruleset)
{ {
var baseBeatmap = createTestBeatmap(); var baseBeatmap = CreateBeatmap();
BeatmapInfo = baseBeatmap.BeatmapInfo; BeatmapInfo = baseBeatmap.BeatmapInfo;
ControlPointInfo = baseBeatmap.ControlPointInfo; ControlPointInfo = baseBeatmap.ControlPointInfo;
@ -37,6 +37,8 @@ namespace osu.Game.Tests.Beatmaps
}; };
} }
protected virtual Beatmap CreateBeatmap() => createTestBeatmap();
private static Beatmap createTestBeatmap() private static Beatmap createTestBeatmap()
{ {
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(test_beatmap_data))) using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(test_beatmap_data)))

View File

@ -30,7 +30,7 @@ namespace osu.Game.Users
public decimal? PP; public decimal? PP;
[JsonProperty(@"pp_rank")] // the API sometimes only returns this value in condensed user responses [JsonProperty(@"pp_rank")] // the API sometimes only returns this value in condensed user responses
private int rank private int? rank
{ {
set => Ranks.Global = value; set => Ranks.Global = value;
} }
@ -71,13 +71,13 @@ namespace osu.Game.Users
public struct Grades public struct Grades
{ {
[JsonProperty(@"ssh")] [JsonProperty(@"ssh")]
public int SSPlus; public int? SSPlus;
[JsonProperty(@"ss")] [JsonProperty(@"ss")]
public int SS; public int SS;
[JsonProperty(@"sh")] [JsonProperty(@"sh")]
public int SPlus; public int? SPlus;
[JsonProperty(@"s")] [JsonProperty(@"s")]
public int S; public int S;
@ -92,13 +92,13 @@ namespace osu.Game.Users
switch (rank) switch (rank)
{ {
case ScoreRank.XH: case ScoreRank.XH:
return SSPlus; return SSPlus ?? 0;
case ScoreRank.X: case ScoreRank.X:
return SS; return SS;
case ScoreRank.SH: case ScoreRank.SH:
return SPlus; return SPlus ?? 0;
case ScoreRank.S: case ScoreRank.S:
return S; return S;