1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:43:04 +08:00

split save logic

This commit is contained in:
cdwcgt 2023-03-09 22:23:13 +09:00
parent 54564e0557
commit 5a1316f0e5
2 changed files with 16 additions and 6 deletions

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
@ -108,13 +107,10 @@ namespace osu.Game.Overlays.Mods
private void trySaveCurrentMod()
{
if (button.Active.Value || !selectedMods.Value.Any())
if (button.SaveCurrentMod())
return;
button.Preset.PerformWrite(s =>
{
s.Mods = selectedMods.Value.ToArray();
});
Body.Shake();
}
protected override void LoadComplete()

View File

@ -98,6 +98,20 @@ namespace osu.Game.Overlays.Mods
#endregion
public bool SaveCurrentMod()
{
if (!checkCurrentModCanBeSave())
return false;
Preset.PerformWrite(s =>
{
s.Mods = selectedMods.Value.ToArray();
});
return true;
}
private bool checkCurrentModCanBeSave() => (!Active.Value && selectedMods.Value.Any());
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);