1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Merge remote-tracking branch 'upstream/master' into add-ruleset-legacy-skin

This commit is contained in:
Dean Herbert 2019-08-30 14:12:56 +09:00
commit 71192791d5
10 changed files with 70 additions and 13 deletions

View File

@ -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>

View File

@ -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);

View File

@ -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);

View File

@ -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);

View 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!"
};
}
}

View File

@ -19,6 +19,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 =>

View File

@ -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;

View File

@ -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 =>
{
@ -66,6 +70,7 @@ namespace osu.Game.Skinning
{
var userSkins = GetAllUserSkins();
userSkins.Insert(0, SkinInfo.Default);
userSkins.Insert(1, DefaultLegacySkin.Info);
return userSkins;
}
@ -91,7 +96,7 @@ namespace osu.Game.Skinning
else
{
model.Name = model.Name.Replace(".osk", "");
model.Creator = "Unknown";
model.Creator = model.Creator ?? "Unknown";
}
}
@ -105,6 +110,9 @@ namespace osu.Game.Skinning
if (skinInfo == SkinInfo.Default)
return new DefaultSkin();
if (skinInfo == DefaultLegacySkin.Info)
return new DefaultLegacySkin(legacyDefaultResources, audio);
return new LegacySkin(skinInfo, Files.Store, audio);
}

View File

@ -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" />

View File

@ -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" />