mirror of
https://github.com/osukey/osukey.git
synced 2025-06-29 07:07:55 +09:00
Add return value to EnsureMutableSkin
to understand whether a new skin was made
This commit is contained in:
parent
7a23363d74
commit
aabe586578
@ -143,12 +143,15 @@ namespace osu.Game.Skinning
|
|||||||
/// Ensure that the current skin is in a state it can accept user modifications.
|
/// 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.
|
/// This will create a copy of any internal skin and being tracking in the database if not already.
|
||||||
/// </summary>
|
/// </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)
|
if (!s.Protected)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
string[] existingSkinNames = realm.Run(r => r.All<SkinInfo>()
|
string[] existingSkinNames = realm.Run(r => r.All<SkinInfo>()
|
||||||
.Where(skin => !skin.DeletePending)
|
.Where(skin => !skin.DeletePending)
|
||||||
@ -160,7 +163,7 @@ namespace osu.Game.Skinning
|
|||||||
{
|
{
|
||||||
Creator = s.Creator,
|
Creator = s.Creator,
|
||||||
InstantiationInfo = s.InstantiationInfo,
|
InstantiationInfo = s.InstantiationInfo,
|
||||||
Name = NamingUtils.GetNextBestName(existingSkinNames, $"{s.Name} (modified)")
|
Name = NamingUtils.GetNextBestName(existingSkinNames, $@"{s.Name} (modified)")
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = skinModelManager.Import(skinInfo);
|
var result = skinModelManager.Import(skinInfo);
|
||||||
@ -172,6 +175,8 @@ namespace osu.Game.Skinning
|
|||||||
result.PerformRead(skin => Save(skin.CreateInstance(this)));
|
result.PerformRead(skin => Save(skin.CreateInstance(this)));
|
||||||
CurrentSkinInfo.Value = result;
|
CurrentSkinInfo.Value = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user