From 32b5a736c8b38e34817e5438f9d6ed927d9da27b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 11 Nov 2021 14:00:09 +0100 Subject: [PATCH 01/11] Add preview gameplay button to bottom editor bar --- .../Editing/TestSceneEditorTestGameplay.cs | 13 +++++++ .../Timelines/Summary/TestGameplayButton.cs | 34 +++++++++++++++++++ osu.Game/Screens/Edit/Editor.cs | 13 ++++++- osu.Game/Screens/Edit/EditorRoundedScreen.cs | 5 +-- osu.Game/Screens/Edit/EditorScreen.cs | 6 ---- 5 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs create mode 100644 osu.Game/Screens/Edit/Components/Timelines/Summary/TestGameplayButton.cs diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs new file mode 100644 index 0000000000..a2e210d92f --- /dev/null +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs @@ -0,0 +1,13 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Rulesets; +using osu.Game.Rulesets.Osu; + +namespace osu.Game.Tests.Visual.Editing +{ + public class TestSceneEditorTestGameplay : EditorTestScene + { + protected override Ruleset CreateEditorRuleset() => new OsuRuleset(); + } +} diff --git a/osu.Game/Screens/Edit/Components/Timelines/Summary/TestGameplayButton.cs b/osu.Game/Screens/Edit/Components/Timelines/Summary/TestGameplayButton.cs new file mode 100644 index 0000000000..0d7a4ad057 --- /dev/null +++ b/osu.Game/Screens/Edit/Components/Timelines/Summary/TestGameplayButton.cs @@ -0,0 +1,34 @@ +// Copyright (c) ppy Pty Ltd . 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.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Overlays; + +namespace osu.Game.Screens.Edit.Components.Timelines.Summary +{ + public class TestGameplayButton : OsuButton + { + protected override SpriteText CreateText() => new OsuSpriteText + { + Depth = -1, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Font = OsuFont.TorusAlternate.With(weight: FontWeight.Light, size: 24), + Shadow = false + }; + + [BackgroundDependencyLoader] + private void load(OsuColour colours, OverlayColourProvider colourProvider) + { + BackgroundColour = colours.Orange1; + SpriteText.Colour = colourProvider.Background6; + + Text = "Test!"; + } + } +} diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 0ca7038580..ef9cce4bf7 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -36,6 +36,7 @@ using osu.Game.Screens.Edit.Timing; using osu.Game.Screens.Edit.Verify; using osu.Game.Screens.Play; using osu.Game.Users; +using osuTK; using osuTK.Graphics; using osuTK.Input; @@ -106,6 +107,9 @@ namespace osu.Game.Screens.Edit [Cached] public readonly EditorClipboard Clipboard = new EditorClipboard(); + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + public Editor(EditorLoader loader = null) { this.loader = loader; @@ -262,7 +266,8 @@ namespace osu.Game.Screens.Edit { new Dimension(GridSizeMode.Absolute, 220), new Dimension(), - new Dimension(GridSizeMode.Absolute, 220) + new Dimension(GridSizeMode.Absolute, 220), + new Dimension(GridSizeMode.Absolute, 160), }, Content = new[] { @@ -283,6 +288,12 @@ namespace osu.Game.Screens.Edit RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = 10 }, Child = new PlaybackControl { RelativeSizeAxes = Axes.Both }, + }, + new TestGameplayButton + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding { Left = 10 }, + Size = new Vector2(1), } }, } diff --git a/osu.Game/Screens/Edit/EditorRoundedScreen.cs b/osu.Game/Screens/Edit/EditorRoundedScreen.cs index 508663224d..7f7b3abc2a 100644 --- a/osu.Game/Screens/Edit/EditorRoundedScreen.cs +++ b/osu.Game/Screens/Edit/EditorRoundedScreen.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; +using osu.Game.Overlays; namespace osu.Game.Screens.Edit { @@ -26,7 +27,7 @@ namespace osu.Game.Screens.Edit } [BackgroundDependencyLoader] - private void load() + private void load(OverlayColourProvider colourProvider) { base.Content.Add(new Container { @@ -41,7 +42,7 @@ namespace osu.Game.Screens.Edit { new Box { - Colour = ColourProvider.Background3, + Colour = colourProvider.Background3, RelativeSizeAxes = Axes.Both, }, roundedContent = new Container diff --git a/osu.Game/Screens/Edit/EditorScreen.cs b/osu.Game/Screens/Edit/EditorScreen.cs index 516d7a23e0..2837cdcd9a 100644 --- a/osu.Game/Screens/Edit/EditorScreen.cs +++ b/osu.Game/Screens/Edit/EditorScreen.cs @@ -6,7 +6,6 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; -using osu.Game.Overlays; namespace osu.Game.Screens.Edit { @@ -18,9 +17,6 @@ namespace osu.Game.Screens.Edit [Resolved] protected EditorBeatmap EditorBeatmap { get; private set; } - [Cached] - protected readonly OverlayColourProvider ColourProvider; - protected override Container Content => content; private readonly Container content; @@ -34,8 +30,6 @@ namespace osu.Game.Screens.Edit Origin = Anchor.Centre; RelativeSizeAxes = Axes.Both; - ColourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); - InternalChild = content = new PopoverContainer { RelativeSizeAxes = Axes.Both }; } From 59727ce836b6ac76c8dc60a0b3482f3adffdf991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 10 Nov 2021 23:11:25 +0100 Subject: [PATCH 02/11] Add minimal implementation of gameplay testing from editor --- osu.Game/Screens/Edit/Editor.cs | 37 +++++++++++++++++-- osu.Game/Screens/Edit/EditorPlayer.cs | 22 +++++++++++ .../Edit/SaveBeforeGameplayTestDialog.cs | 32 ++++++++++++++++ 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Screens/Edit/EditorPlayer.cs create mode 100644 osu.Game/Screens/Edit/SaveBeforeGameplayTestDialog.cs diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index ef9cce4bf7..a67ef070f6 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -294,6 +294,7 @@ namespace osu.Game.Screens.Edit RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = 10 }, Size = new Vector2(1), + Action = testGameplay } }, } @@ -521,7 +522,21 @@ namespace osu.Game.Screens.Edit ApplyToBackground(b => b.FadeColour(Color4.White, 500)); resetTrack(); - // To update the game-wide beatmap with any changes, perform a re-fetch on exit. + refetchBeatmap(); + + return base.OnExiting(next); + } + + public override void OnSuspending(IScreen next) + { + refetchBeatmap(); + + base.OnSuspending(next); + } + + private void refetchBeatmap() + { + // To update the game-wide beatmap with any changes, perform a re-fetch on exit/suspend. // This is required as the editor makes its local changes via EditorBeatmap // (which are not propagated outwards to a potentially cached WorkingBeatmap). var refetchedBeatmap = beatmapManager.GetWorkingBeatmap(Beatmap.Value.BeatmapInfo); @@ -531,8 +546,6 @@ namespace osu.Game.Screens.Edit Logger.Log("Editor providing re-fetched beatmap post edit session"); Beatmap.Value = refetchedBeatmap; } - - return base.OnExiting(next); } private void confirmExitWithSave() @@ -763,6 +776,24 @@ namespace osu.Game.Screens.Edit loader?.CancelPendingDifficultySwitch(); } + private void testGameplay() + { + if (HasUnsavedChanges) + { + dialogOverlay.Push(new SaveBeforeGameplayTestDialog(() => + { + Save(); + pushEditorPlayer(); + })); + } + else + { + pushEditorPlayer(); + } + + void pushEditorPlayer() => this.Push(new PlayerLoader(() => new EditorPlayer())); + } + public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime); public double GetBeatLengthAtTime(double referenceTime) => editorBeatmap.GetBeatLengthAtTime(referenceTime); diff --git a/osu.Game/Screens/Edit/EditorPlayer.cs b/osu.Game/Screens/Edit/EditorPlayer.cs new file mode 100644 index 0000000000..f8dd75d94a --- /dev/null +++ b/osu.Game/Screens/Edit/EditorPlayer.cs @@ -0,0 +1,22 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Screens.Play; + +namespace osu.Game.Screens.Edit +{ + public class EditorPlayer : Player + { + public EditorPlayer() + : base(new PlayerConfiguration { ShowResults = false }) + { + } + + protected override void PrepareReplay() + { + // don't record replays. + } + + protected override bool CheckModsAllowFailure() => false; // never fail. + } +} diff --git a/osu.Game/Screens/Edit/SaveBeforeGameplayTestDialog.cs b/osu.Game/Screens/Edit/SaveBeforeGameplayTestDialog.cs new file mode 100644 index 0000000000..7c03664c66 --- /dev/null +++ b/osu.Game/Screens/Edit/SaveBeforeGameplayTestDialog.cs @@ -0,0 +1,32 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using osu.Framework.Graphics.Sprites; +using osu.Game.Overlays.Dialog; + +namespace osu.Game.Screens.Edit +{ + public class SaveBeforeGameplayTestDialog : PopupDialog + { + public SaveBeforeGameplayTestDialog(Action saveAndPreview) + { + HeaderText = "The beatmap will be saved in order to test it."; + + Icon = FontAwesome.Regular.Save; + + Buttons = new PopupDialogButton[] + { + new PopupDialogOkButton + { + Text = "Sounds good, let's go!", + Action = saveAndPreview + }, + new PopupDialogCancelButton + { + Text = "Oops, continue editing", + }, + }; + } + } +} From 6ce1a78723f3c99c67fc3c4fa9cea40f4ed7775d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 11 Nov 2021 15:08:43 +0100 Subject: [PATCH 03/11] Add test coverage for basic gameplay testing scenarios --- .../Editing/TestSceneEditorTestGameplay.cs | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs index a2e210d92f..9c44a6a986 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs @@ -1,13 +1,122 @@ // Copyright (c) ppy Pty Ltd . 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; +using osu.Framework.Screens; +using osu.Framework.Testing; +using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Osu; +using osu.Game.Screens.Edit; +using osu.Game.Screens.Edit.Components.Timelines.Summary; +using osu.Game.Tests.Beatmaps.IO; +using osuTK.Input; namespace osu.Game.Tests.Visual.Editing { public class TestSceneEditorTestGameplay : EditorTestScene { + protected override bool IsolateSavingFromDatabase => false; + protected override Ruleset CreateEditorRuleset() => new OsuRuleset(); + + [Resolved] + private OsuGameBase game { get; set; } + + [Resolved] + private BeatmapManager beatmaps { get; set; } + + private BeatmapSetInfo importedBeatmapSet; + + public override void SetUpSteps() + { + AddStep("import test beatmap", () => importedBeatmapSet = ImportBeatmapTest.LoadOszIntoOsu(game).Result); + base.SetUpSteps(); + } + + protected override void LoadEditor() + { + Beatmap.Value = beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First(b => b.RulesetID == 0)); + base.LoadEditor(); + } + + [Test] + public void TestBasicGameplayTest() + { + AddStep("click test gameplay button", () => + { + var button = Editor.ChildrenOfType().Single(); + + InputManager.MoveMouseTo(button); + InputManager.Click(MouseButton.Left); + }); + + EditorPlayer editorPlayer = null; + AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null); + AddStep("exit player", () => editorPlayer.Exit()); + AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor); + } + + [Test] + public void TestCancelGameplayTestWithUnsavedChanges() + { + AddStep("delete all but first object", () => EditorBeatmap.RemoveRange(EditorBeatmap.HitObjects.Skip(1).ToList())); + + AddStep("click test gameplay button", () => + { + var button = Editor.ChildrenOfType().Single(); + + InputManager.MoveMouseTo(button); + InputManager.Click(MouseButton.Left); + }); + AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveBeforeGameplayTestDialog); + + AddStep("dismiss prompt", () => + { + var button = DialogOverlay.CurrentDialog.Buttons.Last(); + InputManager.MoveMouseTo(button); + InputManager.Click(MouseButton.Left); + }); + + AddWaitStep("wait some", 3); + AddAssert("stayed in editor", () => Stack.CurrentScreen is Editor); + } + + [Test] + public void TestSaveChangesBeforeGameplayTest() + { + AddStep("delete all but first object", () => EditorBeatmap.RemoveRange(EditorBeatmap.HitObjects.Skip(1).ToList())); + // bit of a hack to ensure this test can be ran multiple times without running into UNIQUE constraint failures + AddStep("set unique difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = Guid.NewGuid().ToString()); + + AddStep("click test gameplay button", () => + { + var button = Editor.ChildrenOfType().Single(); + + InputManager.MoveMouseTo(button); + InputManager.Click(MouseButton.Left); + }); + AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveBeforeGameplayTestDialog); + + AddStep("save changes", () => DialogOverlay.CurrentDialog.PerformOkAction()); + + EditorPlayer editorPlayer = null; + AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null); + AddAssert("beatmap has 1 object", () => editorPlayer.Beatmap.Value.Beatmap.HitObjects.Count == 1); + AddStep("exit player", () => editorPlayer.Exit()); + AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor); + } + + public override void TearDownSteps() + { + base.TearDownSteps(); + AddStep("delete imported", () => + { + beatmaps.Delete(importedBeatmapSet); + }); + } } } From 385df51b06d83e72bce2b3cc6b4a2d545e9f614b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 11 Nov 2021 15:25:58 +0100 Subject: [PATCH 04/11] Ensure editor test player is exited on completion --- .../Visual/Editing/TestSceneEditorTestGameplay.cs | 3 +-- osu.Game/Screens/Edit/EditorPlayer.cs | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs index 9c44a6a986..e2a36e1371 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs @@ -106,8 +106,7 @@ namespace osu.Game.Tests.Visual.Editing EditorPlayer editorPlayer = null; AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null); AddAssert("beatmap has 1 object", () => editorPlayer.Beatmap.Value.Beatmap.HitObjects.Count == 1); - AddStep("exit player", () => editorPlayer.Exit()); - AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor); + AddUntilStep("wait for return to editor", () => Stack.CurrentScreen is Editor); } public override void TearDownSteps() diff --git a/osu.Game/Screens/Edit/EditorPlayer.cs b/osu.Game/Screens/Edit/EditorPlayer.cs index f8dd75d94a..15e2ecb73b 100644 --- a/osu.Game/Screens/Edit/EditorPlayer.cs +++ b/osu.Game/Screens/Edit/EditorPlayer.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Screens; using osu.Game.Screens.Play; namespace osu.Game.Screens.Edit @@ -12,6 +13,16 @@ namespace osu.Game.Screens.Edit { } + protected override void LoadComplete() + { + base.LoadComplete(); + ScoreProcessor.HasCompleted.BindValueChanged(completed => + { + if (completed.NewValue) + Scheduler.AddDelayed(this.Exit, RESULTS_DISPLAY_DELAY); + }); + } + protected override void PrepareReplay() { // don't record replays. From c465bcb82104a2e1739348daa89f140bedf7461c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 11 Nov 2021 15:45:10 +0100 Subject: [PATCH 05/11] Ensure track is stopped on player completion --- .../Visual/Editing/TestSceneEditorTestGameplay.cs | 2 ++ osu.Game/Screens/Edit/EditorPlayer.cs | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs index e2a36e1371..db42667033 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs @@ -106,7 +106,9 @@ namespace osu.Game.Tests.Visual.Editing EditorPlayer editorPlayer = null; AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null); AddAssert("beatmap has 1 object", () => editorPlayer.Beatmap.Value.Beatmap.HitObjects.Count == 1); + AddUntilStep("wait for return to editor", () => Stack.CurrentScreen is Editor); + AddAssert("track stopped", () => !Beatmap.Value.Track.IsRunning); } public override void TearDownSteps() diff --git a/osu.Game/Screens/Edit/EditorPlayer.cs b/osu.Game/Screens/Edit/EditorPlayer.cs index 15e2ecb73b..b2fab3fefc 100644 --- a/osu.Game/Screens/Edit/EditorPlayer.cs +++ b/osu.Game/Screens/Edit/EditorPlayer.cs @@ -1,7 +1,9 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Allocation; using osu.Framework.Screens; +using osu.Game.Overlays; using osu.Game.Screens.Play; namespace osu.Game.Screens.Edit @@ -13,6 +15,9 @@ namespace osu.Game.Screens.Edit { } + [Resolved] + private MusicController musicController { get; set; } + protected override void LoadComplete() { base.LoadComplete(); @@ -29,5 +34,11 @@ namespace osu.Game.Screens.Edit } protected override bool CheckModsAllowFailure() => false; // never fail. + + public override bool OnExiting(IScreen next) + { + musicController.Stop(); + return base.OnExiting(next); + } } } From 459ec7b3bf4c60b9521629eead843dc9ebaea2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 11 Nov 2021 20:42:33 +0100 Subject: [PATCH 06/11] Fix test failures due to missing dependencies --- osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs | 4 ++++ osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs b/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs index c3c803ff23..03e78ce854 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneSetupScreen.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; +using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Rulesets.Catch; using osu.Game.Rulesets.Edit; @@ -23,6 +24,9 @@ namespace osu.Game.Tests.Visual.Editing [Cached(typeof(IBeatSnapProvider))] private readonly EditorBeatmap editorBeatmap; + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + public TestSceneSetupScreen() { editorBeatmap = new EditorBeatmap(new OsuBeatmap()); diff --git a/osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs b/osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs index f961fff1e5..4bbffbdc7a 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneTimingScreen.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; +using osu.Game.Overlays; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Osu; using osu.Game.Screens.Edit; @@ -18,6 +19,9 @@ namespace osu.Game.Tests.Visual.Editing [Cached(typeof(IBeatSnapProvider))] private readonly EditorBeatmap editorBeatmap; + [Cached] + private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue); + protected override bool ScrollUsingMouseWheel => false; public TestSceneTimingScreen() From e31ea49dd41091c0252b01776ce71829ba023436 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Nov 2021 13:18:46 +0900 Subject: [PATCH 07/11] Use fixed width font for performance points counter Matches all other display counters for in-game metrics. As mentioned in https://github.com/ppy/osu/discussions/15584. --- osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs index ef289c2a20..e09adad081 100644 --- a/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs +++ b/osu.Game/Screens/Play/HUD/PerformancePointsCounter.cs @@ -184,7 +184,7 @@ namespace osu.Game.Screens.Play.HUD { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Font = OsuFont.Numeric.With(size: 16) + Font = OsuFont.Numeric.With(size: 16, fixedWidth: true) }, new OsuSpriteText { From b9f9c27770b8d14933d6a2adbf3f3b6e56354983 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Nov 2021 13:59:22 +0900 Subject: [PATCH 08/11] Standardise spacing and padding between UR and PP counters --- osu.Game/Screens/Play/HUD/UnstableRateCounter.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/UnstableRateCounter.cs b/osu.Game/Screens/Play/HUD/UnstableRateCounter.cs index 6cd9ca6154..235f0f01fd 100644 --- a/osu.Game/Screens/Play/HUD/UnstableRateCounter.cs +++ b/osu.Game/Screens/Play/HUD/UnstableRateCounter.cs @@ -15,6 +15,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; +using osuTK; namespace osu.Game.Screens.Play.HUD { @@ -98,6 +99,7 @@ namespace osu.Game.Screens.Play.HUD InternalChild = new FillFlowContainer { AutoSizeAxes = Axes.Both, + Spacing = new Vector2(2), Children = new Drawable[] { text = new OsuSpriteText @@ -111,8 +113,8 @@ namespace osu.Game.Screens.Play.HUD Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, Font = OsuFont.Numeric.With(size: 8, fixedWidth: true), - Text = "UR", - Padding = new MarginPadding { Bottom = 1.5f }, + Text = @"UR", + Padding = new MarginPadding { Bottom = 1.5f }, // align baseline better } } }; From 321aa456a785ce47bf2bdf44cf11faa82beaac7b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Nov 2021 14:04:34 +0900 Subject: [PATCH 09/11] Adjust button size slightly --- osu.Game/Screens/Edit/Editor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index a67ef070f6..d7e77b7fbf 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -267,7 +267,7 @@ namespace osu.Game.Screens.Edit new Dimension(GridSizeMode.Absolute, 220), new Dimension(), new Dimension(GridSizeMode.Absolute, 220), - new Dimension(GridSizeMode.Absolute, 160), + new Dimension(GridSizeMode.Absolute, 120), }, Content = new[] { From e891c0ce5362504d95d25120b5a449c5583596d6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Nov 2021 14:13:11 +0900 Subject: [PATCH 10/11] Add keyboard shortcut to start test mode in editor --- osu.Game/Input/Bindings/GlobalActionContainer.cs | 6 +++++- osu.Game/Localisation/GlobalActionKeyBindingStrings.cs | 5 +++++ osu.Game/Screens/Edit/Editor.cs | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 22446634c1..c71cb6a00a 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -76,6 +76,7 @@ namespace osu.Game.Input.Bindings new KeyBinding(new[] { InputKey.J }, GlobalAction.EditorNudgeLeft), new KeyBinding(new[] { InputKey.K }, GlobalAction.EditorNudgeRight), new KeyBinding(new[] { InputKey.G }, GlobalAction.EditorCycleGridDisplayMode), + new KeyBinding(new[] { InputKey.F5 }, GlobalAction.EditorTestGameplay), }; public IEnumerable InGameKeyBindings => new[] @@ -288,6 +289,9 @@ namespace osu.Game.Input.Bindings ToggleChatFocus, [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorCycleGridDisplayMode))] - EditorCycleGridDisplayMode + EditorCycleGridDisplayMode, + + [LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorTestGameplay))] + EditorTestGameplay } } diff --git a/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs b/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs index 06f1b094bf..35a0c2ae74 100644 --- a/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs +++ b/osu.Game/Localisation/GlobalActionKeyBindingStrings.cs @@ -169,6 +169,11 @@ namespace osu.Game.Localisation /// public static LocalisableString EditorCycleGridDisplayMode => new TranslatableString(getKey(@"editor_cycle_grid_display_mode"), @"Cycle grid display mode"); + /// + /// "Test gameplay" + /// + public static LocalisableString EditorTestGameplay => new TranslatableString(getKey(@"editor_test_gameplay"), @"Test gameplay"); + /// /// "Hold for HUD" /// diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index d7e77b7fbf..77f097b79a 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -468,6 +468,10 @@ namespace osu.Game.Screens.Edit menuBar.Mode.Value = EditorScreenMode.Verify; return true; + case GlobalAction.EditorTestGameplay: + testGameplay(); + return true; + default: return false; } From 54ae307a3d7ca38733065a7556a0978312d0cec1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Nov 2021 14:42:33 +0900 Subject: [PATCH 11/11] Trigger test via button click when using keyboard shortcut --- osu.Game/Screens/Edit/Editor.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 77f097b79a..738f607cc8 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -91,6 +91,8 @@ namespace osu.Game.Screens.Edit private DependencyContainer dependencies; + private TestGameplayButton testGameplayButton; + private bool isNewBeatmap; protected override UserActivity InitialActivity => new UserActivity.Editing(Beatmap.Value.BeatmapInfo); @@ -289,7 +291,7 @@ namespace osu.Game.Screens.Edit Padding = new MarginPadding { Left = 10 }, Child = new PlaybackControl { RelativeSizeAxes = Axes.Both }, }, - new TestGameplayButton + testGameplayButton = new TestGameplayButton { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = 10 }, @@ -469,7 +471,7 @@ namespace osu.Game.Screens.Edit return true; case GlobalAction.EditorTestGameplay: - testGameplay(); + testGameplayButton.TriggerClick(); return true; default: