From 28a6d6211c17ba10440fe4b164dfb4e9b3a9ef8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 31 Dec 2025 12:01:50 +0100 Subject: [PATCH] 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. --- osu.Game/Screens/Edit/EditorBeatmap.cs | 5 +---- osu.Game/Screens/Edit/EditorBeatmapSkin.cs | 11 +++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Edit/EditorBeatmap.cs b/osu.Game/Screens/Edit/EditorBeatmap.cs index 248779a9f8..48b793d1b5 100644 --- a/osu.Game/Screens/Edit/EditorBeatmap.cs +++ b/osu.Game/Screens/Edit/EditorBeatmap.cs @@ -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()); diff --git a/osu.Game/Screens/Edit/EditorBeatmapSkin.cs b/osu.Game/Screens/Edit/EditorBeatmapSkin.cs index 0fbfb7b2d0..50090b7035 100644 --- a/osu.Game/Screens/Edit/EditorBeatmapSkin.cs +++ b/osu.Game/Screens/Edit/EditorBeatmapSkin.cs @@ -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 /// public BindableList 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(); if (Skin.Configuration.ComboColours is IReadOnlyList 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