1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-15 14:47:18 +08:00

Add return value to EnsureMutableSkin to understand whether a new skin was made

This commit is contained in:
Dean Herbert 2022-04-28 14:09:30 +09:00
parent 7a23363d74
commit aabe586578

View File

@ -143,12 +143,15 @@ namespace osu.Game.Skinning
/// Ensure that the current skin is in a state it can accept user modifications.
/// This will create a copy of any internal skin and being tracking in the database if not already.
/// </summary>
public void EnsureMutableSkin()
/// <returns>
/// Whether a new skin was created to allow for mutation.
/// </returns>
public bool EnsureMutableSkin()
{
CurrentSkinInfo.Value.PerformRead(s =>
return CurrentSkinInfo.Value.PerformRead(s =>
{
if (!s.Protected)
return;
return false;
string[] existingSkinNames = realm.Run(r => r.All<SkinInfo>()
.Where(skin => !skin.DeletePending)
@ -160,7 +163,7 @@ namespace osu.Game.Skinning
{
Creator = s.Creator,
InstantiationInfo = s.InstantiationInfo,
Name = NamingUtils.GetNextBestName(existingSkinNames, $"{s.Name} (modified)")
Name = NamingUtils.GetNextBestName(existingSkinNames, $@"{s.Name} (modified)")
};
var result = skinModelManager.Import(skinInfo);
@ -172,6 +175,8 @@ namespace osu.Game.Skinning
result.PerformRead(skin => Save(skin.CreateInstance(this)));
CurrentSkinInfo.Value = result;
}
return true;
});
}