mirror of
https://github.com/ppy/osu
synced 2024-12-27 17:32:56 +00:00
Merge remote-tracking branch 'upstream/master' into kudosu-info
This commit is contained in:
commit
b1f523dae3
@ -15,6 +15,7 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Tests
|
namespace osu.Game.Rulesets.Catch.Tests
|
||||||
{
|
{
|
||||||
@ -92,7 +93,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SampleChannel GetSample(string sampleName) =>
|
public SampleChannel GetSample(ISampleInfo sampleInfo) =>
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
||||||
public Texture GetTexture(string componentName) =>
|
public Texture GetTexture(string componentName) =>
|
||||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
|
|
||||||
int spriteCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSprite));
|
int spriteCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSprite));
|
||||||
int animationCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardAnimation));
|
int animationCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardAnimation));
|
||||||
int sampleCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSample));
|
int sampleCount = background.Elements.Count(x => x.GetType() == typeof(StoryboardSampleInfo));
|
||||||
|
|
||||||
Assert.AreEqual(15, spriteCount);
|
Assert.AreEqual(15, spriteCount);
|
||||||
Assert.AreEqual(1, animationCount);
|
Assert.AreEqual(1, animationCount);
|
||||||
|
@ -10,6 +10,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
@ -253,7 +254,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
||||||
|
|
||||||
public SampleChannel GetSample(string sampleName) => throw new NotImplementedException();
|
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||||
|
|
||||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@ -264,7 +265,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
||||||
|
|
||||||
public SampleChannel GetSample(string sampleName) => throw new NotImplementedException();
|
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||||
|
|
||||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@ -275,7 +276,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
public Texture GetTexture(string componentName) => throw new NotImplementedException();
|
||||||
|
|
||||||
public SampleChannel GetSample(string sampleName) => throw new NotImplementedException();
|
public SampleChannel GetSample(ISampleInfo sampleInfo) => throw new NotImplementedException();
|
||||||
|
|
||||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
var layer = parseLayer(split[2]);
|
var layer = parseLayer(split[2]);
|
||||||
var path = cleanFilename(split[3]);
|
var path = cleanFilename(split[3]);
|
||||||
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
|
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
|
||||||
storyboard.GetLayer(layer).Add(new StoryboardSample(path, time, volume));
|
storyboard.GetLayer(layer).Add(new StoryboardSampleInfo(path, time, (int)volume));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,15 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
|||||||
ItemsContainer.Spacing = new Vector2(panel_padding);
|
ItemsContainer.Spacing = new Vector2(panel_padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override APIRequest<List<APIBeatmapSet>> CreateRequest()
|
protected override APIRequest<List<APIBeatmapSet>> CreateRequest() =>
|
||||||
=> new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
||||||
|
|
||||||
protected override Drawable CreateDrawableItem(APIBeatmapSet item) => new DirectGridPanel(item.ToBeatmapSet(Rulesets))
|
protected override Drawable CreateDrawableItem(APIBeatmapSet model) => !model.OnlineBeatmapSetID.HasValue
|
||||||
{
|
? null
|
||||||
Anchor = Anchor.TopCentre,
|
: new DirectGridPanel(model.ToBeatmapSet(Rulesets))
|
||||||
Origin = Anchor.TopCentre,
|
{
|
||||||
};
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,10 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
ItemsContainer.Direction = FillDirection.Vertical;
|
ItemsContainer.Direction = FillDirection.Vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override APIRequest<List<APIUserMostPlayedBeatmap>> CreateRequest()
|
protected override APIRequest<List<APIUserMostPlayedBeatmap>> CreateRequest() =>
|
||||||
=> new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
|
new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
|
||||||
|
|
||||||
protected override Drawable CreateDrawableItem(APIUserMostPlayedBeatmap item)
|
protected override Drawable CreateDrawableItem(APIUserMostPlayedBeatmap model) =>
|
||||||
=> new DrawableMostPlayedBeatmap(item.GetBeatmapInfo(Rulesets), item.PlayCount);
|
new DrawableMostPlayedBeatmap(model.GetBeatmapInfo(Rulesets), model.PlayCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@ using System.Threading;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Sections
|
namespace osu.Game.Overlays.Profile.Sections
|
||||||
{
|
{
|
||||||
public abstract class PaginatedContainer<T> : FillFlowContainer
|
public abstract class PaginatedContainer<TModel> : FillFlowContainer
|
||||||
{
|
{
|
||||||
private readonly ShowMoreButton moreButton;
|
private readonly ShowMoreButton moreButton;
|
||||||
private readonly OsuSpriteText missingText;
|
private readonly OsuSpriteText missingText;
|
||||||
private APIRequest<List<T>> retrievalRequest;
|
private APIRequest<List<TModel>> retrievalRequest;
|
||||||
private CancellationTokenSource loadCancellation;
|
private CancellationTokenSource loadCancellation;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -104,32 +104,29 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
api.Queue(retrievalRequest);
|
api.Queue(retrievalRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void UpdateItems(List<T> items)
|
protected virtual void UpdateItems(List<TModel> items) => Schedule(() =>
|
||||||
{
|
{
|
||||||
Schedule(() =>
|
if (!items.Any() && VisiblePages == 1)
|
||||||
{
|
{
|
||||||
if (!items.Any() && VisiblePages == 1)
|
moreButton.Hide();
|
||||||
{
|
moreButton.IsLoading = false;
|
||||||
moreButton.Hide();
|
missingText.Show();
|
||||||
moreButton.IsLoading = false;
|
return;
|
||||||
missingText.Show();
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadComponentsAsync(items.Select(CreateDrawableItem), drawables =>
|
LoadComponentsAsync(items.Select(CreateDrawableItem).Where(d => d != null), drawables =>
|
||||||
{
|
{
|
||||||
missingText.Hide();
|
missingText.Hide();
|
||||||
moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0);
|
moreButton.FadeTo(items.Count == ItemsPerPage ? 1 : 0);
|
||||||
moreButton.IsLoading = false;
|
moreButton.IsLoading = false;
|
||||||
|
|
||||||
ItemsContainer.AddRange(drawables);
|
ItemsContainer.AddRange(drawables);
|
||||||
}, loadCancellation.Token);
|
}, loadCancellation.Token);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract APIRequest<List<T>> CreateRequest();
|
protected abstract APIRequest<List<TModel>> CreateRequest();
|
||||||
|
|
||||||
protected abstract Drawable CreateDrawableItem(T item);
|
protected abstract Drawable CreateDrawableItem(TModel model);
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -37,18 +37,18 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
base.UpdateItems(items);
|
base.UpdateItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override APIRequest<List<APILegacyScoreInfo>> CreateRequest()
|
protected override APIRequest<List<APILegacyScoreInfo>> CreateRequest() =>
|
||||||
=> new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
new GetUserScoresRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);
|
||||||
|
|
||||||
protected override Drawable CreateDrawableItem(APILegacyScoreInfo item)
|
protected override Drawable CreateDrawableItem(APILegacyScoreInfo model)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
return new DrawablePerformanceScore(item, includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null);
|
return new DrawablePerformanceScore(model, includeWeight ? Math.Pow(0.95, ItemsContainer.Count) : (double?)null);
|
||||||
|
|
||||||
case ScoreType.Recent:
|
case ScoreType.Recent:
|
||||||
return new DrawableTotalScore(item);
|
return new DrawableTotalScore(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
ItemsPerPage = 5;
|
ItemsPerPage = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override APIRequest<List<APIRecentActivity>> CreateRequest()
|
protected override APIRequest<List<APIRecentActivity>> CreateRequest() =>
|
||||||
=> new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
|
new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++, ItemsPerPage);
|
||||||
|
|
||||||
protected override Drawable CreateDrawableItem(APIRecentActivity item) => new DrawableRecentActivity(item);
|
protected override Drawable CreateDrawableItem(APIRecentActivity model) => new DrawableRecentActivity(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
@ -19,6 +20,6 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public override Texture GetTexture(string componentName) => null;
|
public override Texture GetTexture(string componentName) => null;
|
||||||
|
|
||||||
public override SampleChannel GetSample(string sampleName) => null;
|
public override SampleChannel GetSample(ISampleInfo sampleInfo) => null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
@ -17,7 +18,7 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
Texture GetTexture(string componentName);
|
Texture GetTexture(string componentName);
|
||||||
|
|
||||||
SampleChannel GetSample(string sampleName);
|
SampleChannel GetSample(ISampleInfo sampleInfo);
|
||||||
|
|
||||||
TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration;
|
TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Framework.Text;
|
using osu.Framework.Text;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -179,7 +180,22 @@ namespace osu.Game.Skinning
|
|||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override SampleChannel GetSample(string sampleName) => Samples.Get(getFallbackName(sampleName));
|
public override SampleChannel GetSample(ISampleInfo sampleInfo)
|
||||||
|
{
|
||||||
|
foreach (var lookup in sampleInfo.LookupNames)
|
||||||
|
{
|
||||||
|
var sample = Samples.Get(getFallbackName(lookup));
|
||||||
|
|
||||||
|
if (sample != null)
|
||||||
|
return sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sampleInfo is HitSampleInfo hsi)
|
||||||
|
// Try fallback to non-bank samples.
|
||||||
|
return Samples.Get(hsi.Name);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private bool hasFont(string fontName) => GetTexture($"{fontName}-0") != null;
|
private bool hasFont(string fontName) => GetTexture($"{fontName}-0") != null;
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
@ -49,13 +50,13 @@ namespace osu.Game.Skinning
|
|||||||
return fallbackSource.GetTexture(componentName);
|
return fallbackSource.GetTexture(componentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SampleChannel GetSample(string sampleName)
|
public SampleChannel GetSample(ISampleInfo sampleInfo)
|
||||||
{
|
{
|
||||||
SampleChannel sourceChannel;
|
SampleChannel sourceChannel;
|
||||||
if (beatmapHitsounds.Value && (sourceChannel = skin?.GetSample(sampleName)) != null)
|
if (beatmapHitsounds.Value && (sourceChannel = skin?.GetSample(sampleInfo)) != null)
|
||||||
return sourceChannel;
|
return sourceChannel;
|
||||||
|
|
||||||
return fallbackSource?.GetSample(sampleName);
|
return fallbackSource?.GetSample(sampleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
@ -16,7 +17,7 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public abstract Drawable GetDrawableComponent(string componentName);
|
public abstract Drawable GetDrawableComponent(string componentName);
|
||||||
|
|
||||||
public abstract SampleChannel GetSample(string sampleName);
|
public abstract SampleChannel GetSample(ISampleInfo sampleInfo);
|
||||||
|
|
||||||
public abstract Texture GetTexture(string componentName);
|
public abstract Texture GetTexture(string componentName);
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.IO.Archives;
|
using osu.Game.IO.Archives;
|
||||||
|
|
||||||
@ -120,7 +121,7 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public Texture GetTexture(string componentName) => CurrentSkin.Value.GetTexture(componentName);
|
public Texture GetTexture(string componentName) => CurrentSkin.Value.GetTexture(componentName);
|
||||||
|
|
||||||
public SampleChannel GetSample(string sampleName) => CurrentSkin.Value.GetSample(sampleName);
|
public SampleChannel GetSample(ISampleInfo sampleInfo) => CurrentSkin.Value.GetSample(sampleInfo);
|
||||||
|
|
||||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => CurrentSkin.Value.GetValue(query);
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration => CurrentSkin.Value.GetValue(query);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -37,34 +36,26 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public void Play() => channels?.ForEach(c => c.Play());
|
public void Play() => channels?.ForEach(c => c.Play());
|
||||||
|
|
||||||
public override bool IsPresent => false; // We don't need to receive updates.
|
public override bool IsPresent => Scheduler.HasPendingTasks;
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||||
{
|
{
|
||||||
channels = hitSamples.Select(s =>
|
channels = hitSamples.Select(s =>
|
||||||
{
|
{
|
||||||
var ch = loadChannel(s, skin.GetSample);
|
var ch = skin.GetSample(s);
|
||||||
|
|
||||||
if (ch == null && allowFallback)
|
if (ch == null && allowFallback)
|
||||||
ch = loadChannel(s, audio.Samples.Get);
|
foreach (var lookup in s.LookupNames)
|
||||||
|
if ((ch = audio.Samples.Get($"Gameplay/{lookup}")) != null)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (ch != null)
|
||||||
|
ch.Volume.Value = s.Volume / 100.0;
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
}).Where(c => c != null).ToArray();
|
}).Where(c => c != null).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SampleChannel loadChannel(ISampleInfo info, Func<string, SampleChannel> getSampleFunction)
|
|
||||||
{
|
|
||||||
foreach (var lookup in info.LookupNames)
|
|
||||||
{
|
|
||||||
var ch = getSampleFunction($"Gameplay/{lookup}");
|
|
||||||
if (ch == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ch.Volume.Value = info.Volume / 100.0;
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.IO;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -17,25 +16,24 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const double allowable_late_start = 100;
|
private const double allowable_late_start = 100;
|
||||||
|
|
||||||
private readonly StoryboardSample sample;
|
private readonly StoryboardSampleInfo sampleInfo;
|
||||||
private SampleChannel channel;
|
private SampleChannel channel;
|
||||||
|
|
||||||
public override bool RemoveWhenNotAlive => false;
|
public override bool RemoveWhenNotAlive => false;
|
||||||
|
|
||||||
public DrawableStoryboardSample(StoryboardSample sample)
|
public DrawableStoryboardSample(StoryboardSampleInfo sampleInfo)
|
||||||
{
|
{
|
||||||
this.sample = sample;
|
this.sampleInfo = sampleInfo;
|
||||||
LifetimeStart = sample.StartTime;
|
LifetimeStart = sampleInfo.StartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IBindable<WorkingBeatmap> beatmap)
|
private void load(IBindable<WorkingBeatmap> beatmap)
|
||||||
{
|
{
|
||||||
// Try first with the full name, then attempt with no path
|
channel = beatmap.Value.Skin.GetSample(sampleInfo);
|
||||||
channel = beatmap.Value.Skin.GetSample(sample.Path) ?? beatmap.Value.Skin.GetSample(Path.ChangeExtension(sample.Path, null));
|
|
||||||
|
|
||||||
if (channel != null)
|
if (channel != null)
|
||||||
channel.Volume.Value = sample.Volume / 100;
|
channel.Volume.Value = sampleInfo.Volume / 100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -43,27 +41,27 @@ namespace osu.Game.Storyboards.Drawables
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
// TODO: this logic will need to be consolidated with other game samples like hit sounds.
|
// TODO: this logic will need to be consolidated with other game samples like hit sounds.
|
||||||
if (Time.Current < sample.StartTime)
|
if (Time.Current < sampleInfo.StartTime)
|
||||||
{
|
{
|
||||||
// We've rewound before the start time of the sample
|
// We've rewound before the start time of the sample
|
||||||
channel?.Stop();
|
channel?.Stop();
|
||||||
|
|
||||||
// In the case that the user fast-forwards to a point far beyond the start time of the sample,
|
// In the case that the user fast-forwards to a point far beyond the start time of the sample,
|
||||||
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
|
// we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
|
||||||
LifetimeStart = sample.StartTime;
|
LifetimeStart = sampleInfo.StartTime;
|
||||||
LifetimeEnd = double.MaxValue;
|
LifetimeEnd = double.MaxValue;
|
||||||
}
|
}
|
||||||
else if (Time.Current - Time.Elapsed < sample.StartTime)
|
else if (Time.Current - Time.Elapsed < sampleInfo.StartTime)
|
||||||
{
|
{
|
||||||
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
|
// We've passed the start time of the sample. We only play the sample if we're within an allowable range
|
||||||
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future
|
// from the sample's start, to reduce layering if we've been fast-forwarded far into the future
|
||||||
if (Time.Current - sample.StartTime < allowable_late_start)
|
if (Time.Current - sampleInfo.StartTime < allowable_late_start)
|
||||||
channel?.Play();
|
channel?.Play();
|
||||||
|
|
||||||
// In the case that the user rewinds to a point far behind the start time of the sample,
|
// In the case that the user rewinds to a point far behind the start time of the sample,
|
||||||
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
|
// we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
|
||||||
LifetimeStart = double.MinValue;
|
LifetimeStart = double.MinValue;
|
||||||
LifetimeEnd = sample.StartTime;
|
LifetimeEnd = sampleInfo.StartTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,30 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Audio;
|
||||||
using osu.Game.Storyboards.Drawables;
|
using osu.Game.Storyboards.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Storyboards
|
namespace osu.Game.Storyboards
|
||||||
{
|
{
|
||||||
public class StoryboardSample : IStoryboardElement
|
public class StoryboardSampleInfo : IStoryboardElement, ISampleInfo
|
||||||
{
|
{
|
||||||
public string Path { get; set; }
|
public string Path { get; }
|
||||||
public bool IsDrawable => true;
|
public bool IsDrawable => true;
|
||||||
|
|
||||||
public double StartTime { get; }
|
public double StartTime { get; }
|
||||||
|
|
||||||
public float Volume;
|
public int Volume { get; }
|
||||||
|
|
||||||
public StoryboardSample(string path, double time, float volume)
|
public IEnumerable<string> LookupNames => new[]
|
||||||
|
{
|
||||||
|
// Try first with the full name, then attempt with no path
|
||||||
|
Path,
|
||||||
|
System.IO.Path.ChangeExtension(Path, null),
|
||||||
|
};
|
||||||
|
|
||||||
|
public StoryboardSampleInfo(string path, double time, int volume)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
StartTime = time;
|
StartTime = time;
|
||||||
|
Loading…
Reference in New Issue
Block a user