1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-22 03:02:55 +08:00

Merge remote-tracking branch 'refs/remotes/ppy/master' into overlay-ruleset-selector

This commit is contained in:
Andrei Zavatski 2020-01-02 13:17:22 +03:00
commit 7cab181c12
22 changed files with 143 additions and 35 deletions

View File

@ -26,10 +26,6 @@ namespace osu.Game.Rulesets.Taiko.Audio
var centre = s.GetSampleInfo(); var centre = s.GetSampleInfo();
var rim = s.GetSampleInfo(HitSampleInfo.HIT_CLAP); var rim = s.GetSampleInfo(HitSampleInfo.HIT_CLAP);
// todo: this is ugly
centre.Namespace = "taiko";
rim.Namespace = "taiko";
mappings[s.Time] = new DrumSample mappings[s.Time] = new DrumSample
{ {
Centre = addSound(centre), Centre = addSound(centre),

View File

@ -166,8 +166,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
// Normal and clap samples are handled by the drum // Normal and clap samples are handled by the drum
protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP); protected override IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != HitSampleInfo.HIT_NORMAL && s.Name != HitSampleInfo.HIT_CLAP);
protected override string SampleNamespace => "taiko";
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece(); protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
/// <summary> /// <summary>

View File

@ -0,0 +1,55 @@
// 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 System.Collections.Generic;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko.Skinning
{
public class TaikoLegacySkinTransformer : ISkin
{
private readonly ISkinSource source;
public TaikoLegacySkinTransformer(ISkinSource source)
{
this.source = source;
}
public Drawable GetDrawableComponent(ISkinComponent component) => source.GetDrawableComponent(component);
public Texture GetTexture(string componentName) => source.GetTexture(componentName);
public SampleChannel GetSample(ISampleInfo sampleInfo) => source.GetSample(new LegacyTaikoSampleInfo(sampleInfo));
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => source.GetConfig<TLookup, TValue>(lookup);
private class LegacyTaikoSampleInfo : ISampleInfo
{
private readonly ISampleInfo source;
public LegacyTaikoSampleInfo(ISampleInfo source)
{
this.source = source;
}
public IEnumerable<string> LookupNames
{
get
{
foreach (var name in source.LookupNames)
yield return $"taiko-{name}";
foreach (var name in source.LookupNames)
yield return name;
}
}
public int Volume => source.Volume;
}
}
}

View File

@ -21,6 +21,8 @@ using osu.Game.Rulesets.Taiko.Difficulty;
using osu.Game.Rulesets.Taiko.Scoring; using osu.Game.Rulesets.Taiko.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using System; using System;
using osu.Game.Rulesets.Taiko.Skinning;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko namespace osu.Game.Rulesets.Taiko
{ {
@ -34,6 +36,8 @@ namespace osu.Game.Rulesets.Taiko
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap, this); public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap, this);
public override ISkin CreateLegacySkinProvider(ISkinSource source) => new TaikoLegacySkinTransformer(source);
public const string SHORT_NAME = "taiko"; public const string SHORT_NAME = "taiko";
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[] public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]

View File

@ -0,0 +1,74 @@
// 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 System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.IO.Stores;
using osu.Game.Audio;
using osu.Game.Skinning;
using osu.Game.Tests.Resources;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Gameplay
{
public class TestSceneStoryboardSamples : OsuTestScene
{
[Test]
public void TestRetrieveTopLevelSample()
{
ISkin skin = null;
SampleChannel channel = null;
AddStep("create skin", () => skin = new TestSkin("test-sample", Audio));
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("test-sample")));
AddAssert("sample is non-null", () => channel != null);
}
[Test]
public void TestRetrieveSampleInSubFolder()
{
ISkin skin = null;
SampleChannel channel = null;
AddStep("create skin", () => skin = new TestSkin("folder/test-sample", Audio));
AddStep("retrieve sample", () => channel = skin.GetSample(new SampleInfo("folder/test-sample")));
AddAssert("sample is non-null", () => channel != null);
}
private class TestSkin : LegacySkin
{
public TestSkin(string resourceName, AudioManager audioManager)
: base(DefaultLegacySkin.Info, new TestResourceStore(resourceName), audioManager, "skin.ini")
{
}
}
private class TestResourceStore : IResourceStore<byte[]>
{
private readonly string resourceName;
public TestResourceStore(string resourceName)
{
this.resourceName = resourceName;
}
public byte[] Get(string name) => name == resourceName ? TestResources.GetStore().Get("Resources/test-sample.mp3") : null;
public Task<byte[]> GetAsync(string name) => name == resourceName ? TestResources.GetStore().GetAsync("Resources/test-sample.mp3") : null;
public Stream GetStream(string name) => name == resourceName ? TestResources.GetStore().GetStream("Resources/test-sample.mp3") : null;
public IEnumerable<string> GetAvailableResources() => new[] { resourceName };
public void Dispose()
{
}
}
}
}

View File

@ -13,7 +13,7 @@ namespace osu.Game.Tests.Resources
public static Stream OpenResource(string name) => GetStore().GetStream($"Resources/{name}"); public static Stream OpenResource(string name) => GetStore().GetStream($"Resources/{name}");
public static Stream GetTestBeatmapStream(bool virtualTrack = false) => new DllResourceStore("osu.Game.Resources.dll").GetStream($"Beatmaps/241526 Soleily - Renatus{(virtualTrack ? "_virtual" : "")}.osz"); public static Stream GetTestBeatmapStream(bool virtualTrack = false) => OpenResource($"Archives/241526 Soleily - Renatus{(virtualTrack ? "_virtual" : "")}.osz");
public static string GetTestBeatmapForImport(bool virtualTrack = false) public static string GetTestBeatmapForImport(bool virtualTrack = false)
{ {

Binary file not shown.

View File

@ -17,11 +17,6 @@ namespace osu.Game.Audio
public const string HIT_NORMAL = @"hitnormal"; public const string HIT_NORMAL = @"hitnormal";
public const string HIT_CLAP = @"hitclap"; public const string HIT_CLAP = @"hitclap";
/// <summary>
/// An optional ruleset namespace.
/// </summary>
public string Namespace;
/// <summary> /// <summary>
/// The bank to load the sample from. /// The bank to load the sample from.
/// </summary> /// </summary>
@ -49,15 +44,6 @@ namespace osu.Game.Audio
{ {
get get
{ {
if (!string.IsNullOrEmpty(Namespace))
{
if (!string.IsNullOrEmpty(Suffix))
yield return $"{Namespace}/{Bank}-{Name}{Suffix}";
yield return $"{Namespace}/{Bank}-{Name}";
}
// check non-namespace as a fallback even when we have a namespace
if (!string.IsNullOrEmpty(Suffix)) if (!string.IsNullOrEmpty(Suffix))
yield return $"{Bank}-{Name}{Suffix}"; yield return $"{Bank}-{Name}{Suffix}";

View File

@ -31,9 +31,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// </summary> /// </summary>
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>(Color4.Gray); public readonly Bindable<Color4> AccentColour = new Bindable<Color4>(Color4.Gray);
// Todo: Rulesets should be overriding the resources instead, but we need to figure out where/when to apply overrides first
protected virtual string SampleNamespace => null;
protected SkinnableSound Samples { get; private set; } protected SkinnableSound Samples { get; private set; }
protected virtual IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples; protected virtual IEnumerable<HitSampleInfo> GetSamples() => HitObject.Samples;
@ -154,11 +151,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
+ $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}."); + $" This is an indication that {nameof(HitObject.ApplyDefaults)} has not been invoked on {this}.");
} }
samples = samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s)).ToArray(); AddInternal(Samples = new SkinnableSound(samples.Select(s => HitObject.SampleControlPoint.ApplyTo(s))));
foreach (var s in samples)
s.Namespace = SampleNamespace;
AddInternal(Samples = new SkinnableSound(samples));
} }
private void onDefaultsApplied() => apply(HitObject); private void onDefaultsApplied() => apply(HitObject);

View File

@ -175,7 +175,7 @@ namespace osu.Game.Skinning
{ {
foreach (var lookup in sampleInfo.LookupNames) foreach (var lookup in sampleInfo.LookupNames)
{ {
var sample = Samples?.Get(getFallbackName(lookup)); var sample = Samples?.Get(lookup);
if (sample != null) if (sample != null)
return sample; return sample;

View File

@ -105,7 +105,7 @@ namespace osu.Game.Tests.Visual
} }
[Resolved] [Resolved]
private AudioManager audio { get; set; } protected AudioManager Audio { get; private set; }
protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset); protected virtual IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset);
@ -113,7 +113,7 @@ namespace osu.Game.Tests.Visual
CreateWorkingBeatmap(CreateBeatmap(ruleset), null); CreateWorkingBeatmap(CreateBeatmap(ruleset), null);
protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => protected virtual WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) =>
new ClockBackedTestWorkingBeatmap(beatmap, storyboard, Clock, audio); new ClockBackedTestWorkingBeatmap(beatmap, storyboard, Clock, Audio);
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(RulesetStore rulesets) private void load(RulesetStore rulesets)

View File

@ -14,8 +14,6 @@
<string>0.1.0</string> <string>0.1.0</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>MinimumOSVersion</key> <key>MinimumOSVersion</key>
<string>10.0</string> <string>10.0</string>
<key>UIDeviceFamily</key> <key>UIDeviceFamily</key>
@ -23,6 +21,8 @@
<integer>1</integer> <integer>1</integer>
<integer>2</integer> <integer>2</integer>
</array> </array>
<key>UIFileSharingEnabled</key>
<true/>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key> <key>UIRequiredDeviceCapabilities</key>
@ -51,7 +51,7 @@
<dict> <dict>
<key>UTTypeConformsTo</key> <key>UTTypeConformsTo</key>
<array> <array>
<string></string> <string>public.data</string>
</array> </array>
<key>UTTypeIdentifier</key> <key>UTTypeIdentifier</key>
<string>sh.ppy.osu.items</string> <string>sh.ppy.osu.items</string>
@ -105,6 +105,8 @@
<string>Owner</string> <string>Owner</string>
<key>CFBundleTypeName</key> <key>CFBundleTypeName</key>
<string>Supported osu! files</string> <string>Supported osu! files</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key> <key>LSItemContentTypes</key>
<array> <array>
<string>sh.ppy.osu.items</string> <string>sh.ppy.osu.items</string>