mirror of
https://github.com/ppy/osu.git
synced 2026-05-23 06:59:53 +08:00
Manually fire editor save operations on skin change
This is invariably a test fix but also a valid change to make in isolation. In short, the problem is thus: Now that the beatmap skin is hooked up to realm to receive notifications about changed files (which is required for correctly handling custom samples), tests started failing, because of the following sequence of events - Saving a brand new `.osu` to a beatmap set causes `RealmBackedResourceStore` to fire subscription callbacks because a new file was added to the set - This fires `RealmBackedResourceStore.CacheInvalidated` - Which fires `EditorBeatmapSkin.BeatmapSkinChanged` - Which would previously fire `EditorBeatmap.SaveState()` and as such mark the beatmap dirty / modified. In this scenario this is gratuitous. There's no need to be raising save states here, a new `.osu` was added to the set that is in a consistent saved state and nothing actually changed in the beatmap. However it does not appear sane to attempt to circumvent this with conditional guards or something, because in cases where files are added/removed from the set, *there isn't really any reason to take save states anyway*. The change handler only deals with the `.osu`, any modifications to any of the other files cannot be undone anyway. Therefore, only keep the state save to the one change to beatmap skin that *can* actually be sanely undone which is changing combo colours.
This commit is contained in:
@@ -102,10 +102,7 @@ namespace osu.Game.Screens.Edit
|
||||
this.beatmapInfo = beatmapInfo ?? playableBeatmap.BeatmapInfo;
|
||||
|
||||
if (beatmapSkin is LegacyBeatmapSkin skin)
|
||||
{
|
||||
BeatmapSkin = new EditorBeatmapSkin(playableBeatmap.BeatmapInfo!.BeatmapSet!, skin);
|
||||
BeatmapSkin.BeatmapSkinChanged += SaveState;
|
||||
}
|
||||
BeatmapSkin = new EditorBeatmapSkin(this, skin);
|
||||
|
||||
beatmapProcessor = new EditorBeatmapProcessor(this, playableBeatmap.BeatmapInfo.Ruleset.CreateInstance());
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@@ -34,10 +33,13 @@ namespace osu.Game.Screens.Edit
|
||||
/// </summary>
|
||||
public BindableList<Colour4> ComboColours { get; }
|
||||
|
||||
public EditorBeatmapSkin(BeatmapSetInfo beatmapSet, LegacyBeatmapSkin skin)
|
||||
{
|
||||
Skin = skin;
|
||||
private readonly EditorBeatmap editorBeatmap;
|
||||
|
||||
public EditorBeatmapSkin(EditorBeatmap editorBeatmap, LegacyBeatmapSkin skin)
|
||||
{
|
||||
this.editorBeatmap = editorBeatmap;
|
||||
|
||||
Skin = skin;
|
||||
ComboColours = new BindableList<Colour4>();
|
||||
|
||||
if (Skin.Configuration.ComboColours is IReadOnlyList<Color4> comboColours)
|
||||
@@ -67,6 +69,7 @@ namespace osu.Game.Screens.Edit
|
||||
for (int i = 0; i < ComboColours.Count; ++i)
|
||||
Skin.Configuration.CustomComboColours.Add(ComboColours[(ComboColours.Count + i - 1) % ComboColours.Count]);
|
||||
InvokeSkinChanged();
|
||||
editorBeatmap.SaveState();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user