mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 20:03:21 +08:00
Add minimal implementation of gameplay testing from editor
This commit is contained in:
parent
32b5a736c8
commit
59727ce836
@ -294,6 +294,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding { Left = 10 },
|
Padding = new MarginPadding { Left = 10 },
|
||||||
Size = new Vector2(1),
|
Size = new Vector2(1),
|
||||||
|
Action = testGameplay
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -521,7 +522,21 @@ namespace osu.Game.Screens.Edit
|
|||||||
ApplyToBackground(b => b.FadeColour(Color4.White, 500));
|
ApplyToBackground(b => b.FadeColour(Color4.White, 500));
|
||||||
resetTrack();
|
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
|
// This is required as the editor makes its local changes via EditorBeatmap
|
||||||
// (which are not propagated outwards to a potentially cached WorkingBeatmap).
|
// (which are not propagated outwards to a potentially cached WorkingBeatmap).
|
||||||
var refetchedBeatmap = beatmapManager.GetWorkingBeatmap(Beatmap.Value.BeatmapInfo);
|
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");
|
Logger.Log("Editor providing re-fetched beatmap post edit session");
|
||||||
Beatmap.Value = refetchedBeatmap;
|
Beatmap.Value = refetchedBeatmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnExiting(next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void confirmExitWithSave()
|
private void confirmExitWithSave()
|
||||||
@ -763,6 +776,24 @@ namespace osu.Game.Screens.Edit
|
|||||||
loader?.CancelPendingDifficultySwitch();
|
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 SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
||||||
|
|
||||||
public double GetBeatLengthAtTime(double referenceTime) => editorBeatmap.GetBeatLengthAtTime(referenceTime);
|
public double GetBeatLengthAtTime(double referenceTime) => editorBeatmap.GetBeatLengthAtTime(referenceTime);
|
||||||
|
22
osu.Game/Screens/Edit/EditorPlayer.cs
Normal file
22
osu.Game/Screens/Edit/EditorPlayer.cs
Normal 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 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.
|
||||||
|
}
|
||||||
|
}
|
32
osu.Game/Screens/Edit/SaveBeforeGameplayTestDialog.cs
Normal file
32
osu.Game/Screens/Edit/SaveBeforeGameplayTestDialog.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.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",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user