2021-11-23 14:31:07 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2021-11-23 13:54:57 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2021-11-23 13:54:57 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2021-11-23 14:31:07 +08:00
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2021-11-23 13:54:57 +08:00
|
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
|
|
|
|
using osu.Game.Database;
|
|
|
|
|
using osu.Game.Extensions;
|
|
|
|
|
using osu.Game.IO;
|
|
|
|
|
|
2021-11-23 14:31:07 +08:00
|
|
|
|
namespace osu.Game.Skinning
|
2021-11-23 13:54:57 +08:00
|
|
|
|
{
|
2021-11-23 14:31:07 +08:00
|
|
|
|
[Table(@"SkinInfo")]
|
|
|
|
|
public class EFSkinInfo : IHasFiles<SkinFileInfo>, IEquatable<EFSkinInfo>, IHasPrimaryKey, ISoftDelete
|
2021-11-23 13:54:57 +08:00
|
|
|
|
{
|
2021-11-23 14:31:07 +08:00
|
|
|
|
internal const int DEFAULT_SKIN = 0;
|
|
|
|
|
internal const int CLASSIC_SKIN = -1;
|
|
|
|
|
internal const int RANDOM_SKIN = -2;
|
|
|
|
|
|
|
|
|
|
public int ID { get; set; }
|
2021-11-23 13:54:57 +08:00
|
|
|
|
|
|
|
|
|
public string Name { get; set; } = string.Empty;
|
|
|
|
|
|
|
|
|
|
public string Creator { get; set; } = string.Empty;
|
|
|
|
|
|
2021-11-23 14:31:07 +08:00
|
|
|
|
public string Hash { get; set; }
|
2021-11-23 13:54:57 +08:00
|
|
|
|
|
2021-11-23 14:31:07 +08:00
|
|
|
|
public string InstantiationInfo { get; set; }
|
2021-11-23 13:54:57 +08:00
|
|
|
|
|
|
|
|
|
public virtual Skin CreateInstance(IStorageResourceProvider resources)
|
|
|
|
|
{
|
|
|
|
|
var type = string.IsNullOrEmpty(InstantiationInfo)
|
|
|
|
|
// handle the case of skins imported before InstantiationInfo was added.
|
|
|
|
|
? typeof(LegacySkin)
|
|
|
|
|
: Type.GetType(InstantiationInfo).AsNonNull();
|
|
|
|
|
|
|
|
|
|
return (Skin)Activator.CreateInstance(type, this, resources);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 14:31:07 +08:00
|
|
|
|
public List<SkinFileInfo> Files { get; set; } = new List<SkinFileInfo>();
|
2021-11-23 13:54:57 +08:00
|
|
|
|
|
|
|
|
|
public bool DeletePending { get; set; }
|
|
|
|
|
|
2021-11-23 14:31:07 +08:00
|
|
|
|
public static EFSkinInfo Default { get; } = new EFSkinInfo
|
2021-11-23 13:54:57 +08:00
|
|
|
|
{
|
2021-11-23 14:31:07 +08:00
|
|
|
|
ID = DEFAULT_SKIN,
|
2021-11-23 13:54:57 +08:00
|
|
|
|
Name = "osu! (triangles)",
|
|
|
|
|
Creator = "team osu!",
|
|
|
|
|
InstantiationInfo = typeof(DefaultSkin).GetInvariantInstantiationInfo()
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-23 14:31:07 +08:00
|
|
|
|
public bool Equals(EFSkinInfo other) => other != null && ID == other.ID;
|
2021-11-23 13:54:57 +08:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
2021-11-23 14:31:07 +08:00
|
|
|
|
string author = Creator == null ? string.Empty : $"({Creator})";
|
2021-11-23 13:54:57 +08:00
|
|
|
|
return $"{Name} {author}".Trim();
|
|
|
|
|
}
|
2021-12-08 20:34:32 +08:00
|
|
|
|
|
|
|
|
|
public bool IsManaged => ID > 0;
|
2021-11-23 13:54:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|