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:
parent
54564e0557
commit
5a1316f0e5
@ -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()
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user