Add BeatmapSkin to EditorBeatmap

This commit is contained in:
Craftplacer
2020-08-30 21:12:45 +02:00
parent 2fd98e29bb
commit db413686bb
4 changed files with 13 additions and 18 deletions

View File

@ -13,7 +13,7 @@ namespace osu.Game.Tests.Editing
[Test] [Test]
public void TestSaveRestoreState() public void TestSaveRestoreState()
{ {
var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()), null); var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()));
Assert.That(handler.CanUndo.Value, Is.False); Assert.That(handler.CanUndo.Value, Is.False);
Assert.That(handler.CanRedo.Value, Is.False); Assert.That(handler.CanRedo.Value, Is.False);
@ -32,7 +32,7 @@ namespace osu.Game.Tests.Editing
[Test] [Test]
public void TestMaxStatesSaved() public void TestMaxStatesSaved()
{ {
var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()), null); var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()));
Assert.That(handler.CanUndo.Value, Is.False); Assert.That(handler.CanUndo.Value, Is.False);
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Editing
[Test] [Test]
public void TestMaxStatesExceeded() public void TestMaxStatesExceeded()
{ {
var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()), null); var handler = new EditorChangeHandler(new EditorBeatmap(new Beatmap()));
Assert.That(handler.CanUndo.Value, Is.False); Assert.That(handler.CanUndo.Value, Is.False);

View File

@ -33,7 +33,6 @@ using osu.Game.Screens.Edit.Compose;
using osu.Game.Screens.Edit.Setup; using osu.Game.Screens.Edit.Setup;
using osu.Game.Screens.Edit.Timing; using osu.Game.Screens.Edit.Timing;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Skinning;
using osu.Game.Users; using osu.Game.Users;
namespace osu.Game.Screens.Edit namespace osu.Game.Screens.Edit
@ -65,7 +64,6 @@ namespace osu.Game.Screens.Edit
private IBeatmap playableBeatmap; private IBeatmap playableBeatmap;
private EditorBeatmap editorBeatmap; private EditorBeatmap editorBeatmap;
private EditorChangeHandler changeHandler; private EditorChangeHandler changeHandler;
private IBeatmapSkin beatmapSkin;
private DependencyContainer dependencies; private DependencyContainer dependencies;
@ -103,11 +101,9 @@ namespace osu.Game.Screens.Edit
return; return;
} }
AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap)); AddInternal(editorBeatmap = new EditorBeatmap(playableBeatmap, Beatmap.Value.Skin));
dependencies.CacheAs(editorBeatmap); dependencies.CacheAs(editorBeatmap);
changeHandler = new EditorChangeHandler(editorBeatmap);
beatmapSkin = Beatmap.Value.Skin;
changeHandler = new EditorChangeHandler(editorBeatmap, beatmapSkin);
dependencies.CacheAs<IEditorChangeHandler>(changeHandler); dependencies.CacheAs<IEditorChangeHandler>(changeHandler);
EditorMenuBar menuBar; EditorMenuBar menuBar;
@ -402,7 +398,7 @@ namespace osu.Game.Screens.Edit
clock.SeekForward(!clock.IsRunning, amount); clock.SeekForward(!clock.IsRunning, amount);
} }
private void saveBeatmap() => beatmapManager.Save(playableBeatmap.BeatmapInfo, editorBeatmap, beatmapSkin); private void saveBeatmap() => beatmapManager.Save(playableBeatmap.BeatmapInfo, editorBeatmap, editorBeatmap.BeatmapSkin);
private void exportBeatmap() private void exportBeatmap()
{ {

View File

@ -15,6 +15,7 @@ using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Skinning;
namespace osu.Game.Screens.Edit namespace osu.Game.Screens.Edit
{ {
@ -47,6 +48,8 @@ namespace osu.Game.Screens.Edit
public readonly IBeatmap PlayableBeatmap; public readonly IBeatmap PlayableBeatmap;
public readonly IBeatmapSkin BeatmapSkin;
[Resolved] [Resolved]
private BindableBeatDivisor beatDivisor { get; set; } private BindableBeatDivisor beatDivisor { get; set; }
@ -54,9 +57,10 @@ namespace osu.Game.Screens.Edit
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) public EditorBeatmap(IBeatmap playableBeatmap, IBeatmapSkin beatmapSkin = null)
{ {
PlayableBeatmap = playableBeatmap; PlayableBeatmap = playableBeatmap;
BeatmapSkin = beatmapSkin;
beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateBeatmapProcessor(PlayableBeatmap); beatmapProcessor = playableBeatmap.BeatmapInfo.Ruleset?.CreateInstance().CreateBeatmapProcessor(PlayableBeatmap);

View File

@ -8,7 +8,6 @@ using System.Text;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Skinning;
namespace osu.Game.Screens.Edit namespace osu.Game.Screens.Edit
{ {
@ -26,7 +25,6 @@ namespace osu.Game.Screens.Edit
private int currentState = -1; private int currentState = -1;
private readonly EditorBeatmap editorBeatmap; private readonly EditorBeatmap editorBeatmap;
private readonly IBeatmapSkin beatmapSkin;
private int bulkChangesStarted; private int bulkChangesStarted;
private bool isRestoring; private bool isRestoring;
@ -36,8 +34,7 @@ namespace osu.Game.Screens.Edit
/// Creates a new <see cref="EditorChangeHandler"/>. /// Creates a new <see cref="EditorChangeHandler"/>.
/// </summary> /// </summary>
/// <param name="editorBeatmap">The <see cref="EditorBeatmap"/> to track the <see cref="HitObject"/>s of.</param> /// <param name="editorBeatmap">The <see cref="EditorBeatmap"/> to track the <see cref="HitObject"/>s of.</param>
/// <param name="beatmapSkin">The skin to track the inline skin configuration of.</param> public EditorChangeHandler(EditorBeatmap editorBeatmap)
public EditorChangeHandler(EditorBeatmap editorBeatmap, IBeatmapSkin beatmapSkin)
{ {
this.editorBeatmap = editorBeatmap; this.editorBeatmap = editorBeatmap;
@ -47,8 +44,6 @@ namespace osu.Game.Screens.Edit
patcher = new LegacyEditorBeatmapPatcher(editorBeatmap); patcher = new LegacyEditorBeatmapPatcher(editorBeatmap);
this.beatmapSkin = beatmapSkin;
// Initial state. // Initial state.
SaveState(); SaveState();
} }
@ -90,7 +85,7 @@ namespace osu.Game.Screens.Edit
using (var stream = new MemoryStream()) using (var stream = new MemoryStream())
{ {
using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true)) using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true))
new LegacyBeatmapEncoder(editorBeatmap, beatmapSkin).Encode(sw); new LegacyBeatmapEncoder(editorBeatmap, editorBeatmap.BeatmapSkin).Encode(sw);
savedStates.Add(stream.ToArray()); savedStates.Add(stream.ToArray());
} }