1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +08:00

Merge branch 'master' into allocs-off-the-charts

This commit is contained in:
Bartłomiej Dach 2024-01-09 14:11:00 +01:00
commit 8110c995dd
No known key found for this signature in database
28 changed files with 360 additions and 81 deletions

View File

@ -0,0 +1,51 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Osu.Tests.Editor
{
/// <summary>
/// This test covers autoplay working correctly in the editor on fast streams.
/// Might seem like a weird test, but frame stability being toggled can cause autoplay to operation incorrectly.
/// This is clearly a bug with the autoplay algorithm, but is worked around at an editor level for now.
/// </summary>
public partial class TestSceneEditorAutoplayFastStreams : EditorTestScene
{
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var testBeatmap = new TestBeatmap(ruleset, false);
testBeatmap.HitObjects.AddRange(new[]
{
new HitCircle { StartTime = 500 },
new HitCircle { StartTime = 530 },
new HitCircle { StartTime = 560 },
new HitCircle { StartTime = 590 },
new HitCircle { StartTime = 620 },
});
return testBeatmap;
}
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
[Test]
public void TestAllHit()
{
AddStep("start playback", () => EditorClock.Start());
AddUntilStep("wait for all hit", () =>
{
DrawableHitCircle[] hitCircles = Editor.ChildrenOfType<DrawableHitCircle>().OrderBy(s => s.HitObject.StartTime).ToArray();
return hitCircles.Length == 5 && hitCircles.All(h => h.IsHit);
});
}
}
}

View File

@ -46,10 +46,12 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
moveMouseToObject(() => slider);
AddStep("seek after end", () => EditorClock.Seek(750));
AddUntilStep("wait for seek", () => !EditorClock.IsSeeking);
AddStep("left click", () => InputManager.Click(MouseButton.Left));
AddAssert("slider not selected", () => EditorBeatmap.SelectedHitObjects.Count == 0);
AddStep("seek to visible", () => EditorClock.Seek(650));
AddUntilStep("wait for seek", () => !EditorClock.IsSeeking);
AddStep("left click", () => InputManager.Click(MouseButton.Left));
AddUntilStep("slider selected", () => EditorBeatmap.SelectedHitObjects.Single() == slider);
}

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -182,9 +183,63 @@ namespace osu.Game.Tests.Database
AddAssert("Score version not upgraded", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreVersion), () => Is.EqualTo(30000002));
}
[Test]
public void TestCustomRulesetScoreNotSubjectToUpgrades([Values] bool available)
{
RulesetInfo rulesetInfo = null!;
ScoreInfo scoreInfo = null!;
TestBackgroundDataStoreProcessor processor = null!;
AddStep("Add unavailable ruleset", () => Realm.Write(r => r.Add(rulesetInfo = new RulesetInfo
{
ShortName = Guid.NewGuid().ToString(),
Available = available
})));
AddStep("Add score for unavailable ruleset", () => Realm.Write(r => r.Add(scoreInfo = new ScoreInfo(
ruleset: rulesetInfo,
beatmap: r.All<BeatmapInfo>().First())
{
TotalScoreVersion = 30000001
})));
AddStep("Run background processor", () => Add(processor = new TestBackgroundDataStoreProcessor()));
AddUntilStep("Wait for completion", () => processor.Completed);
AddAssert("Score not marked as failed", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.BackgroundReprocessingFailed), () => Is.False);
AddAssert("Score version not upgraded", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreVersion), () => Is.EqualTo(30000001));
}
[Test]
public void TestNonLegacyScoreNotSubjectToUpgrades()
{
ScoreInfo scoreInfo = null!;
TestBackgroundDataStoreProcessor processor = null!;
AddStep("Add score which requires upgrade (and has beatmap)", () =>
{
Realm.Write(r =>
{
r.Add(scoreInfo = new ScoreInfo(ruleset: r.All<RulesetInfo>().First(), beatmap: r.All<BeatmapInfo>().First())
{
TotalScoreVersion = 30000005,
LegacyTotalScore = 123456,
});
});
});
AddStep("Run background processor", () => Add(processor = new TestBackgroundDataStoreProcessor()));
AddUntilStep("Wait for completion", () => processor.Completed);
AddAssert("Score not marked as failed", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.BackgroundReprocessingFailed), () => Is.False);
AddAssert("Score version not upgraded", () => Realm.Run(r => r.Find<ScoreInfo>(scoreInfo.ID)!.TotalScoreVersion), () => Is.EqualTo(30000005));
}
public partial class TestBackgroundDataStoreProcessor : BackgroundDataStoreProcessor
{
protected override int TimeToSleepDuringGameplay => 10;
public bool Completed => ProcessingTask.IsCompleted;
}
}
}

View File

@ -0,0 +1,39 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Game.Input.Bindings;
using osu.Game.Screens.Menu;
namespace osu.Game.Tests.Visual.Menus
{
public partial class TestSceneIntroMusicActionHandling : OsuGameTestScene
{
private GlobalActionContainer globalActionContainer => Game.ChildrenOfType<GlobalActionContainer>().First();
public override void SetUpSteps()
{
CreateNewGame();
// we do not want to progress to main menu immediately, hence the override and lack of `ConfirmAtMainMenu()` call here.
}
[Test]
public void TestPauseDuringIntro()
{
AddUntilStep("Wait for music", () => Game?.MusicController.IsPlaying == true);
// Check that pause doesn't work during intro sequence.
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
AddAssert("Still playing before menu", () => Game?.MusicController.IsPlaying == true);
AddUntilStep("Wait for main menu", () => Game?.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
// Check that toggling after intro still works.
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
AddUntilStep("Music paused", () => Game?.MusicController.IsPlaying == false && Game?.MusicController.UserPauseRequested == true);
AddStep("Toggle playback", () => globalActionContainer.TriggerPressed(GlobalAction.MusicPlay));
AddUntilStep("Music resumed", () => Game?.MusicController.IsPlaying == true && Game?.MusicController.UserPauseRequested == false);
}
}
}

View File

@ -799,11 +799,7 @@ namespace osu.Game.Tests.Visual.Navigation
});
});
AddStep("attempt exit", () =>
{
for (int i = 0; i < 2; ++i)
Game.ScreenStack.CurrentScreen.Exit();
});
AddRepeatStep("attempt force exit", () => Game.ScreenStack.CurrentScreen.Exit(), 2);
AddUntilStep("stopped at exit confirm", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is ConfirmExitDialog);
}
@ -942,6 +938,35 @@ namespace osu.Game.Tests.Visual.Navigation
AddUntilStep("touch device mod still active", () => Game.SelectedMods.Value, () => Has.One.InstanceOf<ModTouchDevice>());
}
[Test]
public void TestExitSongSelectAndImmediatelyClickLogo()
{
Screens.Select.SongSelect songSelect = null;
PushAndConfirm(() => songSelect = new TestPlaySongSelect());
AddUntilStep("wait for song select", () => songSelect.BeatmapSetsLoaded);
AddStep("import beatmap", () => BeatmapImportHelper.LoadQuickOszIntoOsu(Game).WaitSafely());
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
AddStep("press escape and then click logo immediately", () =>
{
InputManager.Key(Key.Escape);
clickLogoWhenNotCurrent();
});
void clickLogoWhenNotCurrent()
{
if (songSelect.IsCurrentScreen())
Scheduler.AddOnce(clickLogoWhenNotCurrent);
else
{
InputManager.MoveMouseTo(Game.ChildrenOfType<OsuLogo>().Single());
InputManager.Click(MouseButton.Left);
}
}
}
private Func<Player> playToResults()
{
var player = playToCompletion();

View File

@ -24,8 +24,8 @@ namespace osu.Game.Tests.Visual.Online
[Cached]
private readonly Bindable<APIWikiPage> wikiPageData = new Bindable<APIWikiPage>(new APIWikiPage
{
Title = "Main Page",
Path = "Main_Page",
Title = "Main page",
Path = WikiOverlay.INDEX_PATH,
});
private TestHeader header;

View File

@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual.Online
};
}
// From https://osu.ppy.sh/api/v2/wiki/en/Main_Page
// From https://osu.ppy.sh/api/v2/wiki/en/Main_page
private const string main_page_markdown =
"---\nlayout: main_page\n---\n\n<!-- Do not add any empty lines inside this div. -->\n\n<div class=\"wiki-main-page__blurb\">\nWelcome to the osu! wiki, a project containing a wide range of osu! related information.\n</div>\n\n<div class=\"wiki-main-page__panels\">\n<div class=\"wiki-main-page-panel wiki-main-page-panel--full\">\n\n# Getting started\n\n[Welcome](/wiki/Welcome) • [Installation](/wiki/Installation) • [Registration](/wiki/Registration) • [Help Centre](/wiki/Help_Centre) • [FAQ](/wiki/FAQ)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# Game client\n\n[Interface](/wiki/Interface) • [Options](/wiki/Options) • [Visual settings](/wiki/Visual_Settings) • [Shortcut key reference](/wiki/Shortcut_key_reference) • [Configuration file](/wiki/osu!_Program_Files/User_Configuration_File) • [Program files](/wiki/osu!_Program_Files)\n\n[File formats](/wiki/osu!_File_Formats): [.osz](/wiki/osu!_File_Formats/Osz_(file_format)) • [.osk](/wiki/osu!_File_Formats/Osk_(file_format)) • [.osr](/wiki/osu!_File_Formats/Osr_(file_format)) • [.osu](/wiki/osu!_File_Formats/Osu_(file_format)) • [.osb](/wiki/osu!_File_Formats/Osb_(file_format)) • [.db](/wiki/osu!_File_Formats/Db_(file_format))\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# Gameplay\n\n[Game modes](/wiki/Game_mode): [osu!](/wiki/Game_mode/osu!) • [osu!taiko](/wiki/Game_mode/osu!taiko) • [osu!catch](/wiki/Game_mode/osu!catch) • [osu!mania](/wiki/Game_mode/osu!mania)\n\n[Beatmap](/wiki/Beatmap) • [Hit object](/wiki/Hit_object) • [Mods](/wiki/Game_modifier) • [Score](/wiki/Score) • [Replay](/wiki/Replay) • [Multi](/wiki/Multi)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# [Beatmap editor](/wiki/Beatmap_Editor)\n\nSections: [Compose](/wiki/Beatmap_Editor/Compose) • [Design](/wiki/Beatmap_Editor/Design) • [Timing](/wiki/Beatmap_Editor/Timing) • [Song setup](/wiki/Beatmap_Editor/Song_Setup)\n\nComponents: [AiMod](/wiki/Beatmap_Editor/AiMod) • [Beat snap divisor](/wiki/Beatmap_Editor/Beat_Snap_Divisor) • [Distance snap](/wiki/Beatmap_Editor/Distance_Snap) • [Menu](/wiki/Beatmap_Editor/Menu) • [SB load](/wiki/Beatmap_Editor/SB_Load) • [Timelines](/wiki/Beatmap_Editor/Timelines)\n\n[Beatmapping](/wiki/Beatmapping) • [Difficulty](/wiki/Beatmap/Difficulty) • [Mapping techniques](/wiki/Mapping_Techniques) • [Storyboarding](/wiki/Storyboarding)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# Beatmap submission and ranking\n\n[Submission](/wiki/Submission) • [Modding](/wiki/Modding) • [Ranking procedure](/wiki/Beatmap_ranking_procedure) • [Mappers' Guild](/wiki/Mappers_Guild) • [Project Loved](/wiki/Project_Loved)\n\n[Ranking criteria](/wiki/Ranking_Criteria): [osu!](/wiki/Ranking_Criteria/osu!) • [osu!taiko](/wiki/Ranking_Criteria/osu!taiko) • [osu!catch](/wiki/Ranking_Criteria/osu!catch) • [osu!mania](/wiki/Ranking_Criteria/osu!mania)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# Community\n\n[Tournaments](/wiki/Tournaments) • [Skinning](/wiki/Skinning) • [Projects](/wiki/Projects) • [Guides](/wiki/Guides) • [osu!dev Discord server](/wiki/osu!dev_Discord_server) • [How you can help](/wiki/How_You_Can_Help!) • [Glossary](/wiki/Glossary)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# People\n\n[The Team](/wiki/People/The_Team): [Developers](/wiki/People/The_Team/Developers) • [Global Moderation Team](/wiki/People/The_Team/Global_Moderation_Team) • [Support Team](/wiki/People/The_Team/Support_Team) • [Nomination Assessment Team](/wiki/People/The_Team/Nomination_Assessment_Team) • [Beatmap Nominators](/wiki/People/The_Team/Beatmap_Nominators) • [osu! Alumni](/wiki/People/The_Team/osu!_Alumni) • [Project Loved Team](/wiki/People/The_Team/Project_Loved_Team)\n\nOrganisations: [osu! UCI](/wiki/Organisations/osu!_UCI)\n\n[Community Contributors](/wiki/People/Community_Contributors) • [Users with unique titles](/wiki/People/Users_with_unique_titles)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# For developers\n\n[API](/wiki/osu!api) • [Bot account](/wiki/Bot_account) • [Brand identity guidelines](/wiki/Brand_identity_guidelines)\n\n</div>\n<div class=\"wiki-main-page-panel\">\n\n# About the wiki\n\n[Sitemap](/wiki/Sitemap) • [Contribution guide](/wiki/osu!_wiki_Contribution_Guide) • [Article styling criteria](/wiki/Article_Styling_Criteria) • [News styling criteria](/wiki/News_Styling_Criteria)\n\n</div>\n</div>\n";
}

View File

@ -69,8 +69,8 @@ namespace osu.Game.Tests.Visual.Online
{
AddStep("set current path", () => markdownContainer.CurrentPath = $"{API.WebsiteRootUrl}/wiki/Article_styling_criteria/");
AddStep("set '/wiki/Main_Page''", () => markdownContainer.Text = "[wiki main page](/wiki/Main_Page)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/Main_Page");
AddStep("set '/wiki/Main_page''", () => markdownContainer.Text = "[wiki main page](/wiki/Main_page)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/Main_page");
AddStep("set '../FAQ''", () => markdownContainer.Text = "[FAQ](../FAQ)");
AddAssert("check url", () => markdownContainer.Link.Url == $"{API.WebsiteRootUrl}/wiki/FAQ");

View File

@ -107,12 +107,12 @@ namespace osu.Game.Tests.Visual.Online
};
});
// From https://osu.ppy.sh/api/v2/wiki/en/Main_Page
// From https://osu.ppy.sh/api/v2/wiki/en/Main_page
private APIWikiPage responseMainPage => new APIWikiPage
{
Title = "Main Page",
Layout = "main_page",
Path = "Main_Page",
Title = "Main page",
Layout = WikiOverlay.INDEX_PATH.ToLowerInvariant(), // custom classes are always lower snake.
Path = WikiOverlay.INDEX_PATH,
Locale = "en",
Subtitle = null,
Markdown =

View File

@ -13,6 +13,7 @@ using osu.Framework.Graphics;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
@ -28,6 +29,8 @@ namespace osu.Game
/// </summary>
public partial class BackgroundDataStoreProcessor : Component
{
protected Task ProcessingTask { get; private set; } = null!;
[Resolved]
private RulesetStore rulesetStore { get; set; } = null!;
@ -61,7 +64,7 @@ namespace osu.Game
{
base.LoadComplete();
Task.Factory.StartNew(() =>
ProcessingTask = Task.Factory.StartNew(() =>
{
Logger.Log("Beginning background data store processing..");
@ -314,10 +317,17 @@ namespace osu.Game
{
Logger.Log("Querying for scores that need total score conversion...");
HashSet<Guid> scoreIds = realmAccess.Run(r => new HashSet<Guid>(r.All<ScoreInfo>()
.Where(s => !s.BackgroundReprocessingFailed && s.BeatmapInfo != null
&& s.TotalScoreVersion < LegacyScoreEncoder.LATEST_VERSION)
.AsEnumerable().Select(s => s.ID)));
HashSet<Guid> scoreIds = realmAccess.Run(r => new HashSet<Guid>(
r.All<ScoreInfo>()
.Where(s => !s.BackgroundReprocessingFailed
&& s.BeatmapInfo != null
&& s.IsLegacyScore
&& s.TotalScoreVersion < LegacyScoreEncoder.LATEST_VERSION)
.AsEnumerable()
// must be done after materialisation, as realm doesn't want to support
// nested property predicates
.Where(s => s.Ruleset.IsLegacyRuleset())
.Select(s => s.ID)));
Logger.Log($"Found {scoreIds.Count} scores which require total score conversion.");

View File

@ -2,8 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using osu.Framework.Extensions;
using osu.Framework.IO.Stores;
using osu.Framework.Logging;
@ -98,15 +98,11 @@ namespace osu.Game.Database
// can potentially be run asynchronously, although we will need to consider operation order for disk deletion vs realm removal.
realm.Write(r =>
{
// TODO: consider using a realm native query to avoid iterating all files (https://github.com/realm/realm-dotnet/issues/2659#issuecomment-927823707)
var files = r.All<RealmFile>().ToList();
foreach (var file in files)
foreach (var file in r.All<RealmFile>().Filter(@$"{nameof(RealmFile.Usages)}.@count = 0"))
{
totalFiles++;
if (file.BacklinksCount > 0)
continue;
Debug.Assert(file.BacklinksCount == 0);
try
{

View File

@ -311,13 +311,22 @@ namespace osu.Game.Database
long maximumLegacyBonusScore = attributes.BonusScore;
double legacyAccScore = maximumLegacyAccuracyScore * score.Accuracy;
// We can not separate the ComboScore from the BonusScore, so we keep the bonus in the ratio.
// Note that `maximumLegacyComboScore + maximumLegacyBonusScore` can actually be 0
// when playing a beatmap with no bonus objects, with mods that have a 0.0x multiplier on stable (relax/autopilot).
// In such cases, just assume 0.
double comboProportion = maximumLegacyComboScore + maximumLegacyBonusScore > 0
? Math.Max((double)score.LegacyTotalScore - legacyAccScore, 0) / (maximumLegacyComboScore + maximumLegacyBonusScore)
: 0;
double comboProportion;
if (maximumLegacyComboScore + maximumLegacyBonusScore > 0)
{
// We can not separate the ComboScore from the BonusScore, so we keep the bonus in the ratio.
comboProportion = Math.Max((double)score.LegacyTotalScore - legacyAccScore, 0) / (maximumLegacyComboScore + maximumLegacyBonusScore);
}
else
{
// Two possible causes:
// the beatmap has no bonus objects *AND*
// either the active mods have a zero mod multiplier, in which case assume 0,
// or the *beatmap* has a zero `difficultyPeppyStars` (or just no combo-giving objects), in which case assume 1.
comboProportion = legacyModMultiplier == 0 ? 0 : 1;
}
// We assume the bonus proportion only makes up the rest of the score that exceeds maximumLegacyBaseScore.
long maximumLegacyBaseScore = maximumLegacyAccuracyScore + maximumLegacyComboScore;

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Game.IO;
using Realms;
@ -11,5 +12,8 @@ namespace osu.Game.Models
{
[PrimaryKey]
public string Hash { get; set; } = string.Empty;
[Backlink(nameof(RealmNamedFileUsage.File))]
public IQueryable<RealmNamedFileUsage> Usages { get; } = null!;
}
}

View File

@ -152,6 +152,15 @@ namespace osu.Game.Online.Leaderboards
/// </summary>
public void RefetchScores() => Scheduler.AddOnce(refetchScores);
/// <summary>
/// Clear all scores from the display.
/// </summary>
public void ClearScores()
{
cancelPendingWork();
SetScores(null);
}
/// <summary>
/// Call when a retrieval or display failure happened to show a relevant message to the user.
/// </summary>
@ -220,9 +229,7 @@ namespace osu.Game.Online.Leaderboards
{
Debug.Assert(ThreadSafety.IsUpdateThread);
cancelPendingWork();
SetScores(null);
ClearScores();
setState(LeaderboardState.Retrieving);
currentFetchCancellationSource = new CancellationTokenSource();

View File

@ -32,7 +32,7 @@ namespace osu.Game.Overlays.Dialog
private readonly Vector2 ringMinifiedSize = new Vector2(20f);
private readonly Box flashLayer;
private Sample flashSample = null!;
private Sample? flashSample;
private readonly Container content;
private readonly Container ring;
@ -267,7 +267,7 @@ namespace osu.Game.Overlays.Dialog
flashLayer.FadeInFromZero(80, Easing.OutQuint)
.Then()
.FadeOutFromOne(1500, Easing.OutQuint);
flashSample.Play();
flashSample?.Play();
}
protected override bool OnKeyDown(KeyDownEvent e)

View File

@ -17,8 +17,6 @@ namespace osu.Game.Overlays.Wiki
{
public partial class WikiHeader : BreadcrumbControlOverlayHeader
{
private const string index_path = "Main_page";
public static LocalisableString IndexPageString => LayoutStrings.HeaderHelpIndex;
public readonly Bindable<APIWikiPage> WikiPageData = new Bindable<APIWikiPage>();
@ -45,7 +43,7 @@ namespace osu.Game.Overlays.Wiki
TabControl.AddItem(IndexPageString);
if (e.NewValue.Path == index_path)
if (e.NewValue.Path == WikiOverlay.INDEX_PATH)
{
Current.Value = IndexPageString;
return;

View File

@ -19,11 +19,11 @@ namespace osu.Game.Overlays
{
public partial class WikiOverlay : OnlineOverlay<WikiHeader>
{
private const string index_path = "Main_page";
public const string INDEX_PATH = @"Main_page";
public string CurrentPath => path.Value;
private readonly Bindable<string> path = new Bindable<string>(index_path);
private readonly Bindable<string> path = new Bindable<string>(INDEX_PATH);
private readonly Bindable<APIWikiPage> wikiData = new Bindable<APIWikiPage>();
@ -43,7 +43,7 @@ namespace osu.Game.Overlays
{
}
public void ShowPage(string pagePath = index_path)
public void ShowPage(string pagePath = INDEX_PATH)
{
path.Value = pagePath.Trim('/');
Show();
@ -137,7 +137,7 @@ namespace osu.Game.Overlays
wikiData.Value = response;
path.Value = response.Path;
if (response.Layout == index_path)
if (response.Layout.Equals(INDEX_PATH, StringComparison.OrdinalIgnoreCase))
{
LoadDisplay(new WikiMainPage
{
@ -161,7 +161,7 @@ namespace osu.Game.Overlays
path.Value = "error";
LoadDisplay(articlePage = new WikiArticlePage($@"{api.WebsiteRootUrl}/wiki/",
$"Something went wrong when trying to fetch page \"{originalPath}\".\n\n[Return to the main page](Main_page)."));
$"Something went wrong when trying to fetch page \"{originalPath}\".\n\n[Return to the main page]({INDEX_PATH})."));
}
private void showParentPage()

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
@ -26,6 +27,9 @@ namespace osu.Game.Rulesets.Edit
[Resolved]
private EditorBeatmap beatmap { get; set; } = null!;
[Resolved]
private EditorClock editorClock { get; set; } = null!;
public DrawableEditorRulesetWrapper(DrawableRuleset<TObject> drawableRuleset)
{
this.drawableRuleset = drawableRuleset;
@ -38,7 +42,6 @@ namespace osu.Game.Rulesets.Edit
[BackgroundDependencyLoader]
private void load()
{
drawableRuleset.FrameStablePlayback = false;
Playfield.DisplayJudgements.Value = false;
}
@ -65,6 +68,22 @@ namespace osu.Game.Rulesets.Edit
Scheduler.AddOnce(regenerateAutoplay);
}
protected override void Update()
{
base.Update();
// Whenever possible, we want to stay in frame stability playback.
// Without doing so, we run into bugs with some gameplay elements not behaving as expected.
//
// Note that this is not using EditorClock.IsSeeking as that would exit frame stability
// on all seeks. The intention here is to retain frame stability for small seeks.
//
// I still think no gameplay elements should require frame stability in the first place, but maybe that ship has sailed already..
bool shouldBypassFrameStability = Math.Abs(drawableRuleset.FrameStableClock.CurrentTime - editorClock.CurrentTime) > 1000;
drawableRuleset.FrameStablePlayback = !shouldBypassFrameStability;
}
private void regenerateAutoplay()
{
var autoplayMod = drawableRuleset.Mods.OfType<ModAutoplay>().Single();

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Mods
public override IconUsage? Icon => OsuIcon.ModCinema;
public override LocalisableString Description => "Watch the video without visual distractions.";
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(ModAutoplay), typeof(ModNoFail) }).ToArray();
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(ModAutoplay), typeof(ModNoFail), typeof(ModFailCondition) }).ToArray();
public void ApplyToHUD(HUDOverlay overlay)
{

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mods
{
public abstract class ModFailCondition : Mod, IApplicableToHealthProcessor, IApplicableFailOverride
{
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail) };
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModCinema) };
[SettingSource("Restart on fail", "Automatically restarts when failed.")]
public BindableBool Restart { get; } = new BindableBool();

View File

@ -95,6 +95,8 @@ namespace osu.Game.Screens.Menu
Colour = Color4.Black
};
public override bool? AllowGlobalTrackControl => false;
protected IntroScreen([CanBeNull] Func<MainMenu> createNextScreen = null)
{
this.createNextScreen = createNextScreen;

View File

@ -5,6 +5,7 @@
using System;
using System.Diagnostics;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -25,6 +26,7 @@ using osu.Game.Input.Bindings;
using osu.Game.IO;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Overlays.Dialog;
using osu.Game.Overlays.SkinEditor;
using osu.Game.Rulesets;
using osu.Game.Screens.Backgrounds;
@ -49,6 +51,8 @@ namespace osu.Game.Screens.Menu
public override bool AllowExternalScreenChange => true;
public override bool? AllowGlobalTrackControl => true;
private Screen songSelect;
private MenuSideFlashes sideFlashes;
@ -390,7 +394,12 @@ namespace osu.Game.Screens.Menu
if (requiresConfirmation)
{
if (dialogOverlay.CurrentDialog is ConfirmExitDialog exitDialog)
exitDialog.PerformOkAction();
{
if (exitDialog.Buttons.OfType<PopupDialogOkButton>().FirstOrDefault() != null)
exitDialog.PerformOkAction();
else
exitDialog.Flash();
}
else
{
dialogOverlay.Push(new ConfirmExitDialog(() =>

View File

@ -37,7 +37,6 @@ namespace osu.Game.Screens.Ranking.Statistics
RelativeSizeAxes = Axes.X,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Width = 0.5f,
StatisticsUpdate = { BindTarget = StatisticsUpdate }
})).ToArray();
}

View File

@ -96,18 +96,19 @@ namespace osu.Game.Screens.Select
/// <summary>
/// Extend the range to retain already loaded pooled drawables.
/// </summary>
private const float distance_offscreen_before_unload = 1024;
private const float distance_offscreen_before_unload = 2048;
/// <summary>
/// Extend the range to update positions / retrieve pooled drawables outside of visible range.
/// </summary>
private const float distance_offscreen_to_preload = 512; // todo: adjust this appropriately once we can make set panel contents load while off-screen.
private const float distance_offscreen_to_preload = 768;
/// <summary>
/// Whether carousel items have completed asynchronously loaded.
/// </summary>
public bool BeatmapSetsLoaded { get; private set; }
[Cached]
protected readonly CarouselScrollContainer Scroll;
private readonly NoResultsPlaceholder noResultsPlaceholder;
@ -1251,7 +1252,7 @@ namespace osu.Game.Screens.Select
}
}
protected partial class CarouselScrollContainer : UserTrackingScrollContainer<DrawableCarouselItem>
public partial class CarouselScrollContainer : UserTrackingScrollContainer<DrawableCarouselItem>
{
private bool rightMouseScrollBlocked;

View File

@ -5,11 +5,14 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
@ -46,6 +49,8 @@ namespace osu.Game.Screens.Select.Carousel
private MenuItem[]? mainMenuItems;
private double timeSinceUnpool;
[Resolved]
private BeatmapManager manager { get; set; } = null!;
@ -54,6 +59,7 @@ namespace osu.Game.Screens.Select.Carousel
base.FreeAfterUse();
Item = null;
timeSinceUnpool = 0;
ClearTransforms();
}
@ -92,13 +98,21 @@ namespace osu.Game.Screens.Select.Carousel
// algorithm for this is taken from ScrollContainer.
// while it doesn't necessarily need to match 1:1, as we are emulating scroll in some cases this feels most correct.
Y = (float)Interpolation.Lerp(targetY, Y, Math.Exp(-0.01 * Time.Elapsed));
loadContentIfRequired();
}
private CancellationTokenSource? loadCancellation;
protected override void UpdateItem()
{
loadCancellation?.Cancel();
loadCancellation = null;
base.UpdateItem();
Content.Clear();
Header.Clear();
beatmapContainer = null;
beatmapsLoadTask = null;
@ -107,32 +121,8 @@ namespace osu.Game.Screens.Select.Carousel
return;
beatmapSet = ((CarouselBeatmapSet)Item).BeatmapSet;
DelayedLoadWrapper background;
DelayedLoadWrapper mainFlow;
Header.Children = new Drawable[]
{
// Choice of background image matches BSS implementation (always uses the lowest `beatmap_id` from the set).
background = new DelayedLoadWrapper(() => new SetPanelBackground(manager.GetWorkingBeatmap(beatmapSet.Beatmaps.MinBy(b => b.OnlineID)))
{
RelativeSizeAxes = Axes.Both,
}, 200)
{
RelativeSizeAxes = Axes.Both
},
mainFlow = new DelayedLoadWrapper(() => new SetPanelContent((CarouselBeatmapSet)Item), 50)
{
RelativeSizeAxes = Axes.Both
},
};
background.DelayedLoadComplete += fadeContentIn;
mainFlow.DelayedLoadComplete += fadeContentIn;
}
private void fadeContentIn(Drawable d) => d.FadeInFromZero(150);
protected override void Deselected()
{
base.Deselected();
@ -190,6 +180,56 @@ namespace osu.Game.Screens.Select.Carousel
}
}
[Resolved]
private BeatmapCarousel.CarouselScrollContainer scrollContainer { get; set; } = null!;
private void loadContentIfRequired()
{
Quad containingSsdq = scrollContainer.ScreenSpaceDrawQuad;
// Using DelayedLoadWrappers would only allow us to load content when on screen, but we want to preload while off-screen
// to provide a better user experience.
// This is tracking time that this drawable is updating since the last pool.
// This is intended to provide a debounce so very fast scrolls (from one end to the other of the carousel)
// don't cause huge overheads.
//
// We increase the delay based on distance from centre, so the beatmaps the user is currently looking at load first.
float timeUpdatingBeforeLoad = 50 + Math.Abs(containingSsdq.Centre.Y - ScreenSpaceDrawQuad.Centre.Y) / containingSsdq.Height * 100;
Debug.Assert(Item != null);
// A load is already in progress if the cancellation token is non-null.
if (loadCancellation != null)
return;
timeSinceUnpool += Time.Elapsed;
// We only trigger a load after this set has been in an updating state for a set amount of time.
if (timeSinceUnpool <= timeUpdatingBeforeLoad)
return;
loadCancellation = new CancellationTokenSource();
LoadComponentsAsync(new CompositeDrawable[]
{
// Choice of background image matches BSS implementation (always uses the lowest `beatmap_id` from the set).
new SetPanelBackground(manager.GetWorkingBeatmap(beatmapSet.Beatmaps.MinBy(b => b.OnlineID)))
{
RelativeSizeAxes = Axes.Both,
},
new SetPanelContent((CarouselBeatmapSet)Item)
{
Depth = float.MinValue,
RelativeSizeAxes = Axes.Both,
}
}, drawables =>
{
Header.AddRange(drawables);
drawables.ForEach(d => d.FadeInFromZero(150));
}, loadCancellation.Token);
}
private void updateBeatmapYPositions()
{
if (beatmapContainer == null)

View File

@ -146,6 +146,14 @@ namespace osu.Game.Screens.Select
}
}
public override void OnSuspending(ScreenTransitionEvent e)
{
// Scores will be refreshed on arriving at this screen.
// Clear them to avoid animation overload on returning to song select.
playBeatmapDetailArea.Leaderboard.ClearScores();
base.OnSuspending(e);
}
public override void OnResuming(ScreenTransitionEvent e)
{
base.OnResuming(e);

View File

@ -660,7 +660,8 @@ namespace osu.Game.Screens.Select
logo.Action = () =>
{
FinaliseSelection();
if (this.IsCurrentScreen())
FinaliseSelection();
return false;
};
}

View File

@ -58,6 +58,12 @@ namespace osu.Game.Tests.Visual
[SetUpSteps]
public virtual void SetUpSteps()
{
CreateNewGame();
ConfirmAtMainMenu();
}
protected void CreateNewGame()
{
AddStep("Create new game instance", () =>
{
@ -71,8 +77,6 @@ namespace osu.Game.Tests.Visual
AddUntilStep("Wait for load", () => Game.IsLoaded);
AddUntilStep("Wait for intro", () => Game.ScreenStack.CurrentScreen is IntroScreen);
ConfirmAtMainMenu();
}
[TearDownSteps]