mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:20:04 +08:00
Merge branch 'master' into beatmap-bar
This commit is contained in:
commit
7d02cbafed
@ -65,7 +65,7 @@ namespace osu.Game.Tests.Database
|
||||
private class TestLegacyBeatmapImporter : LegacyBeatmapImporter
|
||||
{
|
||||
public TestLegacyBeatmapImporter()
|
||||
: base(null)
|
||||
: base(null!)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Screens.Select;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
@ -26,6 +27,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private readonly BindableList<ScoreInfo> scores = new BindableList<ScoreInfo>();
|
||||
|
||||
private readonly Bindable<bool> configVisibility = new Bindable<bool>();
|
||||
private readonly Bindable<PlayBeatmapDetailArea.TabType> beatmapTabType = new Bindable<PlayBeatmapDetailArea.TabType>();
|
||||
|
||||
private SoloGameplayLeaderboard leaderboard = null!;
|
||||
|
||||
@ -33,6 +35,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility);
|
||||
config.BindWith(OsuSetting.BeatmapDetailTab, beatmapTabType);
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
@ -70,6 +73,25 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
AddStep("toggle expanded", () => leaderboard.Expanded.Value = !leaderboard.Expanded.Value);
|
||||
}
|
||||
|
||||
[TestCase(PlayBeatmapDetailArea.TabType.Local, 51)]
|
||||
[TestCase(PlayBeatmapDetailArea.TabType.Global, null)]
|
||||
[TestCase(PlayBeatmapDetailArea.TabType.Country, null)]
|
||||
[TestCase(PlayBeatmapDetailArea.TabType.Friends, null)]
|
||||
public void TestTrackedScorePosition(PlayBeatmapDetailArea.TabType tabType, int? expectedOverflowIndex)
|
||||
{
|
||||
AddStep($"change TabType to {tabType}", () => beatmapTabType.Value = tabType);
|
||||
AddUntilStep("tracked player is #50", () => leaderboard.TrackedScore?.ScorePosition, () => Is.EqualTo(50));
|
||||
|
||||
AddStep("add one more score", () => scores.Add(new ScoreInfo { User = new APIUser { Username = "New player 1" }, TotalScore = RNG.Next(600000, 1000000) }));
|
||||
|
||||
AddUntilStep("wait for sort", () => leaderboard.ChildrenOfType<GameplayLeaderboardScore>().First().ScorePosition != null);
|
||||
|
||||
if (expectedOverflowIndex == null)
|
||||
AddUntilStep("tracked player has null position", () => leaderboard.TrackedScore?.ScorePosition, () => Is.Null);
|
||||
else
|
||||
AddUntilStep($"tracked player is #{expectedOverflowIndex}", () => leaderboard.TrackedScore?.ScorePosition, () => Is.EqualTo(expectedOverflowIndex));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVisibility()
|
||||
{
|
||||
@ -95,7 +117,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
new ScoreInfo { User = new APIUser { Username = @"spaceman_atlas" }, TotalScore = RNG.Next(500000, 1000000) },
|
||||
new ScoreInfo { User = new APIUser { Username = @"frenzibyte" }, TotalScore = RNG.Next(500000, 1000000) },
|
||||
new ScoreInfo { User = new APIUser { Username = @"Susko3" }, TotalScore = RNG.Next(500000, 1000000) },
|
||||
}.Concat(Enumerable.Range(0, 50).Select(i => new ScoreInfo { User = new APIUser { Username = $"User {i + 1}" }, TotalScore = 1000000 - i * 10000 })).ToList();
|
||||
}.Concat(Enumerable.Range(0, 44).Select(i => new ScoreInfo { User = new APIUser { Username = $"User {i + 1}" }, TotalScore = 1000000 - i * 10000 })).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
@ -85,6 +86,19 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
AddAssert("did perform", () => actionPerformed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPerformEnsuresScreenIsLoaded()
|
||||
{
|
||||
TestLoadBlockingScreen screen = null;
|
||||
|
||||
AddStep("push blocking screen", () => Game.ScreenStack.Push(screen = new TestLoadBlockingScreen()));
|
||||
AddStep("perform", () => Game.PerformFromScreen(_ => actionPerformed = true, new[] { typeof(TestLoadBlockingScreen) }));
|
||||
AddAssert("action not performed", () => !actionPerformed);
|
||||
|
||||
AddStep("allow load", () => screen.LoadEvent.Set());
|
||||
AddUntilStep("action performed", () => actionPerformed);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOverlaysAlwaysClosed()
|
||||
{
|
||||
@ -270,5 +284,16 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
return base.OnExiting(e);
|
||||
}
|
||||
}
|
||||
|
||||
public class TestLoadBlockingScreen : OsuScreen
|
||||
{
|
||||
public readonly ManualResetEventSlim LoadEvent = new ManualResetEventSlim();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
LoadEvent.Wait(10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,14 @@ using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Select;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
@ -55,6 +57,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
presentAndConfirm(firstImport);
|
||||
|
||||
var secondImport = importBeatmap(3);
|
||||
confirmBeatmapInSongSelect(secondImport);
|
||||
presentAndConfirm(secondImport);
|
||||
|
||||
// Test presenting same beatmap more than once
|
||||
@ -74,6 +77,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
presentAndConfirm(firstImport);
|
||||
|
||||
var secondImport = importBeatmap(3, new ManiaRuleset().RulesetInfo);
|
||||
confirmBeatmapInSongSelect(secondImport);
|
||||
presentAndConfirm(secondImport);
|
||||
|
||||
presentSecondDifficultyAndConfirm(firstImport, 1);
|
||||
@ -134,13 +138,22 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
return () => imported;
|
||||
}
|
||||
|
||||
private void confirmBeatmapInSongSelect(Func<BeatmapSetInfo> getImport)
|
||||
{
|
||||
AddUntilStep("beatmap in song select", () =>
|
||||
{
|
||||
var songSelect = (Screens.Select.SongSelect)Game.ScreenStack.CurrentScreen;
|
||||
return songSelect.ChildrenOfType<BeatmapCarousel>().Single().BeatmapSets.Any(b => b.MatchesOnlineID(getImport()));
|
||||
});
|
||||
}
|
||||
|
||||
private void presentAndConfirm(Func<BeatmapSetInfo> getImport)
|
||||
{
|
||||
AddStep("present beatmap", () => Game.PresentBeatmap(getImport()));
|
||||
|
||||
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect);
|
||||
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapSetInfo.MatchesOnlineID(getImport()));
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.Equals(getImport().Beatmaps.First().Ruleset));
|
||||
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect songSelect && songSelect.IsLoaded);
|
||||
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapSetInfo.OnlineID, () => Is.EqualTo(getImport().OnlineID));
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value, () => Is.EqualTo(getImport().Beatmaps.First().Ruleset));
|
||||
}
|
||||
|
||||
private void presentSecondDifficultyAndConfirm(Func<BeatmapSetInfo> getImport, int importedID)
|
||||
@ -148,9 +161,9 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
Predicate<BeatmapInfo> pred = b => b.OnlineID == importedID * 2048;
|
||||
AddStep("present difficulty", () => Game.PresentBeatmap(getImport(), pred));
|
||||
|
||||
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect);
|
||||
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapInfo.OnlineID == importedID * 2048);
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.Equals(getImport().Beatmaps.First().Ruleset));
|
||||
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect songSelect && songSelect.IsLoaded);
|
||||
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapInfo.OnlineID, () => Is.EqualTo(importedID * 2048));
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value, () => Is.EqualTo(getImport().Beatmaps.First().Ruleset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.IO;
|
||||
@ -22,22 +22,42 @@ namespace osu.Game.Database
|
||||
{
|
||||
// make sure the directory exists
|
||||
if (!storage.ExistsDirectory(string.Empty))
|
||||
yield break;
|
||||
return Array.Empty<string>();
|
||||
|
||||
foreach (string directory in storage.GetDirectories(string.Empty))
|
||||
List<string> paths = new List<string>();
|
||||
|
||||
try
|
||||
{
|
||||
var directoryStorage = storage.GetStorageForDirectory(directory);
|
||||
|
||||
if (!directoryStorage.GetFiles(string.Empty).ExcludeSystemFileNames().Any())
|
||||
foreach (string directory in storage.GetDirectories(string.Empty))
|
||||
{
|
||||
// if a directory doesn't contain files, attempt looking for beatmaps inside of that directory.
|
||||
// this is a special behaviour in stable for beatmaps only, see https://github.com/ppy/osu/issues/18615.
|
||||
foreach (string subDirectory in GetStableImportPaths(directoryStorage))
|
||||
yield return subDirectory;
|
||||
var directoryStorage = storage.GetStorageForDirectory(directory);
|
||||
|
||||
try
|
||||
{
|
||||
if (!directoryStorage.GetFiles(string.Empty).ExcludeSystemFileNames().Any())
|
||||
{
|
||||
// if a directory doesn't contain files, attempt looking for beatmaps inside of that directory.
|
||||
// this is a special behaviour in stable for beatmaps only, see https://github.com/ppy/osu/issues/18615.
|
||||
foreach (string subDirectory in GetStableImportPaths(directoryStorage))
|
||||
paths.Add(subDirectory);
|
||||
}
|
||||
else
|
||||
paths.Add(storage.GetFullPath(directory));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Catch any errors when enumerating files
|
||||
Logger.Log($"Error when enumerating files in {directoryStorage.GetFullPath(string.Empty)}: {e}");
|
||||
}
|
||||
}
|
||||
else
|
||||
yield return storage.GetFullPath(directory);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Catch any errors when enumerating directories
|
||||
Logger.Log($"Error when enumerating directories in {storage.GetFullPath(string.Empty)}: {e}");
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
public LegacyBeatmapImporter(IModelImporter<BeatmapSetInfo> importer)
|
||||
|
@ -16,6 +16,8 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetScoresRequest : APIRequest<APIScoresCollection>
|
||||
{
|
||||
public const int MAX_SCORES_PER_REQUEST = 50;
|
||||
|
||||
private readonly IBeatmapInfo beatmapInfo;
|
||||
private readonly BeatmapLeaderboardScope scope;
|
||||
private readonly IRulesetInfo ruleset;
|
||||
|
@ -89,6 +89,10 @@ namespace osu.Game
|
||||
// check if we are already at a valid target screen.
|
||||
if (validScreens.Any(t => t.IsAssignableFrom(type)))
|
||||
{
|
||||
if (!((Drawable)current).IsLoaded)
|
||||
// wait until screen is loaded before invoking action.
|
||||
return true;
|
||||
|
||||
finalAction(current);
|
||||
Cancel();
|
||||
return true;
|
||||
|
@ -270,7 +270,7 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
IsSeeking &= Transforms.Any();
|
||||
|
||||
if (track.Value?.IsRunning != true)
|
||||
if (!IsRunning)
|
||||
{
|
||||
// seeking in the editor can happen while the track isn't running.
|
||||
// in this case we always want to expose ourselves as seeking (to avoid sample playback).
|
||||
|
@ -171,12 +171,14 @@ namespace osu.Game.Screens.Play.HUD
|
||||
for (int i = 0; i < Flow.Count; i++)
|
||||
{
|
||||
Flow.SetLayoutPosition(orderedByScore[i], i);
|
||||
orderedByScore[i].ScorePosition = i + 1;
|
||||
orderedByScore[i].ScorePosition = CheckValidScorePosition(i + 1) ? i + 1 : null;
|
||||
}
|
||||
|
||||
sorting.Validate();
|
||||
}
|
||||
|
||||
protected virtual bool CheckValidScorePosition(int i) => true;
|
||||
|
||||
private class InputDisabledScrollContainer : OsuScrollContainer
|
||||
{
|
||||
public InputDisabledScrollContainer()
|
||||
|
@ -62,20 +62,22 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private int? scorePosition;
|
||||
|
||||
private bool scorePositionIsSet;
|
||||
|
||||
public int? ScorePosition
|
||||
{
|
||||
get => scorePosition;
|
||||
set
|
||||
{
|
||||
if (value == scorePosition)
|
||||
// We always want to run once, as the incoming value may be null and require a visual update to "-".
|
||||
if (value == scorePosition && scorePositionIsSet)
|
||||
return;
|
||||
|
||||
scorePosition = value;
|
||||
|
||||
if (scorePosition.HasValue)
|
||||
positionText.Text = $"#{scorePosition.Value.FormatRank()}";
|
||||
positionText.Text = scorePosition.HasValue ? $"#{scorePosition.Value.FormatRank()}" : "-";
|
||||
scorePositionIsSet = true;
|
||||
|
||||
positionText.FadeTo(scorePosition.HasValue ? 1 : 0);
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,10 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
@ -18,6 +20,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
private const int duration = 100;
|
||||
|
||||
private readonly Bindable<bool> configVisibility = new Bindable<bool>();
|
||||
|
||||
private readonly Bindable<PlayBeatmapDetailArea.TabType> scoreSource = new Bindable<PlayBeatmapDetailArea.TabType>();
|
||||
|
||||
private readonly IUser trackingUser;
|
||||
|
||||
public readonly IBindableList<ScoreInfo> Scores = new BindableList<ScoreInfo>();
|
||||
@ -46,11 +51,13 @@ namespace osu.Game.Screens.Play.HUD
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
config.BindWith(OsuSetting.GameplayLeaderboard, configVisibility);
|
||||
config.BindWith(OsuSetting.BeatmapDetailTab, scoreSource);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Scores.BindCollectionChanged((_, _) => Scheduler.AddOnce(showScores), true);
|
||||
|
||||
// Alpha will be updated via `updateVisibility` below.
|
||||
@ -93,6 +100,18 @@ namespace osu.Game.Screens.Play.HUD
|
||||
local.DisplayOrder.Value = long.MaxValue;
|
||||
}
|
||||
|
||||
protected override bool CheckValidScorePosition(int i)
|
||||
{
|
||||
// change displayed position to '-' when there are 50 already submitted scores and tracked score is last
|
||||
if (scoreSource.Value != PlayBeatmapDetailArea.TabType.Local)
|
||||
{
|
||||
if (i == Flow.Count && Flow.Count > GetScoresRequest.MAX_SCORES_PER_REQUEST)
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.CheckValidScorePosition(i);
|
||||
}
|
||||
|
||||
private void updateVisibility() =>
|
||||
this.FadeTo(AlwaysVisible.Value || configVisibility.Value ? 1 : 0, duration);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user