mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 08:03:22 +08:00
Merge pull request #17592 from peppy/skin-mutation-better-naming
Fix automatically created "(modified)" skins getting conflicting names
This commit is contained in:
commit
6776c37bbc
@ -24,6 +24,7 @@ using osu.Game.Database;
|
|||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.IO.Archives;
|
using osu.Game.IO.Archives;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
@ -144,20 +145,26 @@ namespace osu.Game.Skinning
|
|||||||
if (!s.Protected)
|
if (!s.Protected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
string[] existingSkinNames = realm.Run(r => r.All<SkinInfo>()
|
||||||
|
.Where(skin => !skin.DeletePending)
|
||||||
|
.AsEnumerable()
|
||||||
|
.Select(skin => skin.Name).ToArray());
|
||||||
|
|
||||||
// if the user is attempting to save one of the default skin implementations, create a copy first.
|
// if the user is attempting to save one of the default skin implementations, create a copy first.
|
||||||
var result = skinModelManager.Import(new SkinInfo
|
var skinInfo = new SkinInfo
|
||||||
{
|
{
|
||||||
Name = s.Name + @" (modified)",
|
|
||||||
Creator = s.Creator,
|
Creator = s.Creator,
|
||||||
InstantiationInfo = s.InstantiationInfo,
|
InstantiationInfo = s.InstantiationInfo,
|
||||||
});
|
Name = NamingUtils.GetNextBestName(existingSkinNames, $"{s.Name} (modified)")
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = skinModelManager.Import(skinInfo);
|
||||||
|
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
// save once to ensure the required json content is populated.
|
// save once to ensure the required json content is populated.
|
||||||
// currently this only happens on save.
|
// currently this only happens on save.
|
||||||
result.PerformRead(skin => Save(skin.CreateInstance(this)));
|
result.PerformRead(skin => Save(skin.CreateInstance(this)));
|
||||||
|
|
||||||
CurrentSkinInfo.Value = result;
|
CurrentSkinInfo.Value = result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user