mirror of https://github.com/ppy/osu
Merge remote-tracking branch 'upstream/master' into add-ruleset-legacy-skin
This commit is contained in:
commit
71192791d5
|
@ -60,7 +60,7 @@
|
|||
<Reference Include="Java.Interop" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.823.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.828.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.830.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.830.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -18,7 +18,7 @@ protected override void InitialiseDefaults()
|
|||
{
|
||||
// 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 @@ private void load(FrameworkConfigManager frameworkConfig)
|
|||
// 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 @@ private void load()
|
|||
|
||||
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);
|
||||
|
|
|
@ -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!"
|
||||
};
|
||||
}
|
||||
}
|
|
@ -19,6 +19,9 @@ public class LegacySkinResourceStore<T> : IResourceStore<byte[]>
|
|||
|
||||
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 @@ public class SkinInfo : IHasFiles<SkinFileInfo>, IEquatable<SkinInfo>, IHasPrima
|
|||
|
||||
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.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 @@ public class SkinManager : ArchiveModelManager<SkinInfo, SkinFileInfo>, ISkinSou
|
|||
{
|
||||
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 @@ public class SkinManager : ArchiveModelManager<SkinInfo, SkinFileInfo>, ISkinSou
|
|||
|
||||
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 =>
|
||||
{
|
||||
|
@ -66,6 +70,7 @@ public List<SkinInfo> GetAllUsableSkins()
|
|||
{
|
||||
var userSkins = GetAllUserSkins();
|
||||
userSkins.Insert(0, SkinInfo.Default);
|
||||
userSkins.Insert(1, DefaultLegacySkin.Info);
|
||||
return userSkins;
|
||||
}
|
||||
|
||||
|
@ -91,7 +96,7 @@ protected override async Task Populate(SkinInfo model, ArchiveReader archive, Ca
|
|||
else
|
||||
{
|
||||
model.Name = model.Name.Replace(".osk", "");
|
||||
model.Creator = "Unknown";
|
||||
model.Creator = model.Creator ?? "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +110,9 @@ public Skin GetSkin(SkinInfo skinInfo)
|
|||
if (skinInfo == SkinInfo.Default)
|
||||
return new DefaultSkin();
|
||||
|
||||
if (skinInfo == DefaultLegacySkin.Info)
|
||||
return new DefaultLegacySkin(legacyDefaultResources, audio);
|
||||
|
||||
return new LegacySkin(skinInfo, Files.Store, audio);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.823.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.828.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.830.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.830.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
|
|
@ -117,9 +117,9 @@
|
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.823.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.828.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.828.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.830.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.830.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.830.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.24.0" />
|
||||
<PackageReference Include="NUnit" Version="3.11.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
|
Loading…
Reference in New Issue