mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 17:23:21 +08:00
Change skin import to also include directory names in the skin name where appropriate
This commit is contained in:
parent
fed0e15cea
commit
7b3f7cc7c1
@ -136,18 +136,19 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
protected override string ComputeHash(SkinInfo item, ArchiveReader reader = null)
|
protected override string ComputeHash(SkinInfo item, ArchiveReader reader = null)
|
||||||
{
|
{
|
||||||
// we need to populate early to create a hash based off skin.ini contents
|
var instance = GetSkin(item);
|
||||||
if (item.Name?.Contains(".osk", StringComparison.OrdinalIgnoreCase) == true)
|
|
||||||
populateMetadata(item, GetSkin(item));
|
|
||||||
|
|
||||||
if (item.Creator != null && item.Creator != unknown_creator_string)
|
// in the case the skin has a skin.ini file, we are going to create a hash based on that.
|
||||||
|
// we don't want to do this in the case we don't have a skin.ini, as it would match only on the filename portion,
|
||||||
|
// causing potentially unique skin imports to be considered as a duplicate.
|
||||||
|
if (!string.IsNullOrEmpty(instance.Configuration.SkinInfo.Name))
|
||||||
{
|
{
|
||||||
// this is the optimal way to hash legacy skins, but will need to be reconsidered when we move forward with skin implementation.
|
// we need to populate early to create a hash based off skin.ini contents
|
||||||
// likely, the skin should expose a real version (ie. the version of the skin, not the skin.ini version it's targeting).
|
populateMetadata(item, instance, reader?.Name);
|
||||||
|
|
||||||
return item.ToString().ComputeSHA2Hash();
|
return item.ToString().ComputeSHA2Hash();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there was no creator, the ToString above would give the filename, which alone isn't really enough to base any decisions on.
|
|
||||||
return base.ComputeHash(item, reader);
|
return base.ComputeHash(item, reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,13 +158,12 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
model.InstantiationInfo ??= instance.GetType().GetInvariantInstantiationInfo();
|
model.InstantiationInfo ??= instance.GetType().GetInvariantInstantiationInfo();
|
||||||
|
|
||||||
if (model.Name?.Contains(".osk", StringComparison.OrdinalIgnoreCase) == true)
|
populateMetadata(model, instance, archive?.Name);
|
||||||
populateMetadata(model, instance);
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateMetadata(SkinInfo item, Skin instance)
|
private void populateMetadata(SkinInfo item, Skin instance, string archiveName)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(instance.Configuration.SkinInfo.Name))
|
if (!string.IsNullOrEmpty(instance.Configuration.SkinInfo.Name))
|
||||||
{
|
{
|
||||||
@ -175,6 +175,13 @@ namespace osu.Game.Skinning
|
|||||||
item.Name = item.Name.Replace(".osk", "", StringComparison.OrdinalIgnoreCase);
|
item.Name = item.Name.Replace(".osk", "", StringComparison.OrdinalIgnoreCase);
|
||||||
item.Creator ??= unknown_creator_string;
|
item.Creator ??= unknown_creator_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generally when importing from a folder, the ".osk" extension will not be present.
|
||||||
|
// if we ever need a more reliable method of determining this, the type of `ArchiveReader` can be checked.
|
||||||
|
bool isArchiveImport = archiveName?.Contains(".osk", StringComparison.OrdinalIgnoreCase) == true;
|
||||||
|
|
||||||
|
if (archiveName != null && !isArchiveImport && archiveName != item.Name)
|
||||||
|
item.Name = $"{item.Name} ({archiveName})";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user