mirror of
https://github.com/ppy/osu
synced 2024-12-28 01:42:57 +00:00
Add "osu!classic" as a bundled skin choice
This commit is contained in:
parent
9bb96115bc
commit
40c1c6072e
@ -18,7 +18,7 @@ namespace osu.Game.Configuration
|
||||
{
|
||||
// UI/selection defaults
|
||||
Set(OsuSetting.Ruleset, 0, 0, int.MaxValue);
|
||||
Set(OsuSetting.Skin, 0, 0, int.MaxValue);
|
||||
Set(OsuSetting.Skin, 0, -1, int.MaxValue);
|
||||
|
||||
Set(OsuSetting.BeatmapDetailTab, BeatmapDetailTab.Details);
|
||||
|
||||
|
@ -182,7 +182,26 @@ namespace osu.Game
|
||||
// bind config int to database SkinInfo
|
||||
configSkin = LocalConfig.GetBindable<int>(OsuSetting.Skin);
|
||||
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID;
|
||||
configSkin.ValueChanged += skinId => SkinManager.CurrentSkinInfo.Value = SkinManager.Query(s => s.ID == skinId.NewValue) ?? SkinInfo.Default;
|
||||
configSkin.ValueChanged += skinId =>
|
||||
{
|
||||
var skinInfo = SkinManager.Query(s => s.ID == skinId.NewValue);
|
||||
|
||||
if (skinInfo == null)
|
||||
{
|
||||
switch (skinId.NewValue)
|
||||
{
|
||||
case -1:
|
||||
skinInfo = DefaultLegacySkin.Info;
|
||||
break;
|
||||
|
||||
default:
|
||||
skinInfo = SkinInfo.Default;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SkinManager.CurrentSkinInfo.Value = skinInfo;
|
||||
};
|
||||
configSkin.TriggerChange();
|
||||
|
||||
IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
|
||||
|
@ -158,7 +158,7 @@ namespace osu.Game
|
||||
|
||||
runMigrations();
|
||||
|
||||
dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio));
|
||||
dependencies.Cache(SkinManager = new SkinManager(Host.Storage, contextFactory, Host, Audio, new NamespacedResourceStore<byte[]>(Resources, "Skins/Legacy")));
|
||||
dependencies.CacheAs<ISkinSource>(SkinManager);
|
||||
|
||||
API = new APIAccess(LocalConfig);
|
||||
|
23
osu.Game/Skinning/DefaultLegacySkin.cs
Normal file
23
osu.Game/Skinning/DefaultLegacySkin.cs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.IO.Stores;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class DefaultLegacySkin : LegacySkin
|
||||
{
|
||||
public DefaultLegacySkin(IResourceStore<byte[]> storage, AudioManager audioManager)
|
||||
: base(Info, storage, audioManager, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public static SkinInfo Info { get; } = new SkinInfo
|
||||
{
|
||||
ID = -1, // this is temporary until database storage is decided upon.
|
||||
Name = "osu!classic",
|
||||
Creator = "team osu!"
|
||||
};
|
||||
}
|
||||
}
|
@ -248,6 +248,9 @@ namespace osu.Game.Skinning
|
||||
|
||||
private string getPathForFile(string filename)
|
||||
{
|
||||
if (source.Files == null)
|
||||
return null;
|
||||
|
||||
bool hasExtension = filename.Contains('.');
|
||||
|
||||
var file = source.Files.Find(f =>
|
||||
|
@ -26,7 +26,11 @@ namespace osu.Game.Skinning
|
||||
|
||||
public string FullName => $"\"{Name}\" by {Creator}";
|
||||
|
||||
public static SkinInfo Default { get; } = new SkinInfo { Name = "osu!lazer", Creator = "team osu!" };
|
||||
public static SkinInfo Default { get; } = new SkinInfo
|
||||
{
|
||||
Name = "osu!lazer",
|
||||
Creator = "team osu!"
|
||||
};
|
||||
|
||||
public bool Equals(SkinInfo other) => other != null && ID == other.ID;
|
||||
|
||||
|
@ -14,6 +14,7 @@ using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Database;
|
||||
@ -25,6 +26,8 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
private readonly AudioManager audio;
|
||||
|
||||
private readonly IResourceStore<byte[]> legacyDefaultResources;
|
||||
|
||||
public readonly Bindable<Skin> CurrentSkin = new Bindable<Skin>(new DefaultSkin());
|
||||
public readonly Bindable<SkinInfo> CurrentSkinInfo = new Bindable<SkinInfo>(SkinInfo.Default) { Default = SkinInfo.Default };
|
||||
|
||||
@ -34,10 +37,11 @@ namespace osu.Game.Skinning
|
||||
|
||||
protected override string ImportFromStablePath => "Skins";
|
||||
|
||||
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio)
|
||||
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, IIpcHost importHost, AudioManager audio, IResourceStore<byte[]> legacyDefaultResources)
|
||||
: base(storage, contextFactory, new SkinStore(contextFactory, storage), importHost)
|
||||
{
|
||||
this.audio = audio;
|
||||
this.legacyDefaultResources = legacyDefaultResources;
|
||||
|
||||
ItemRemoved += removedInfo =>
|
||||
{
|
||||
@ -56,6 +60,9 @@ namespace osu.Game.Skinning
|
||||
};
|
||||
}
|
||||
|
||||
private Skin createIfNotExisting(SkinInfo skinInfo) =>
|
||||
GetSkin(Query(s => s.Name == skinInfo.Name) ?? Import(skinInfo).Result);
|
||||
|
||||
protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osk";
|
||||
|
||||
/// <summary>
|
||||
@ -66,6 +73,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
var userSkins = GetAllUserSkins();
|
||||
userSkins.Insert(0, SkinInfo.Default);
|
||||
userSkins.Insert(1, DefaultLegacySkin.Info);
|
||||
return userSkins;
|
||||
}
|
||||
|
||||
@ -91,7 +99,7 @@ namespace osu.Game.Skinning
|
||||
else
|
||||
{
|
||||
model.Name = model.Name.Replace(".osk", "");
|
||||
model.Creator = "Unknown";
|
||||
model.Creator = model.Creator ?? "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,9 +110,15 @@ namespace osu.Game.Skinning
|
||||
/// <returns>A <see cref="Skin"/> instance correlating to the provided <see cref="SkinInfo"/>.</returns>
|
||||
public Skin GetSkin(SkinInfo skinInfo)
|
||||
{
|
||||
if (skinInfo == null)
|
||||
return null;
|
||||
|
||||
if (skinInfo == SkinInfo.Default)
|
||||
return new DefaultSkin();
|
||||
|
||||
if (skinInfo == DefaultLegacySkin.Info)
|
||||
return new DefaultLegacySkin(legacyDefaultResources, audio);
|
||||
|
||||
return new LegacySkin(skinInfo, Files.Store, audio);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user