1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 18:47:27 +08:00

Merge remote-tracking branch 'origin/master' into editor-hitobject-movement

This commit is contained in:
smoogipoo 2018-02-20 14:03:47 +09:00
commit 4da93e8f1d
6 changed files with 28 additions and 40 deletions

View File

@ -75,23 +75,32 @@ namespace osu.Game.Beatmaps
protected override Storyboard GetStoryboard() protected override Storyboard GetStoryboard()
{ {
Storyboard storyboard;
try try
{ {
using (var beatmap = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path)))) using (var beatmap = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path))))
{ {
Decoder decoder = Decoder.GetDecoder(beatmap); Decoder decoder = Decoder.GetDecoder(beatmap);
if (BeatmapSetInfo?.StoryboardFile == null) // todo: support loading from both set-wide storyboard *and* beatmap specific.
return decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap);
using (var storyboard = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile)))) if (BeatmapSetInfo?.StoryboardFile == null)
return decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap, storyboard); storyboard = decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap);
else
{
using (var reader = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile))))
storyboard = decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap, reader);
}
} }
} }
catch catch
{ {
return new Storyboard(); storyboard = new Storyboard();
} }
storyboard.BeatmapInfo = BeatmapInfo;
return storyboard;
} }
} }
} }

View File

@ -57,7 +57,7 @@ namespace osu.Game.Beatmaps
protected abstract Texture GetBackground(); protected abstract Texture GetBackground();
protected abstract Track GetTrack(); protected abstract Track GetTrack();
protected virtual Waveform GetWaveform() => new Waveform(); protected virtual Waveform GetWaveform() => new Waveform();
protected virtual Storyboard GetStoryboard() => new Storyboard(); protected virtual Storyboard GetStoryboard() => new Storyboard { BeatmapInfo = BeatmapInfo };
public bool BeatmapLoaded => beatmap.IsResultAvailable; public bool BeatmapLoaded => beatmap.IsResultAvailable;
public Beatmap Beatmap => beatmap.Value.Result; public Beatmap Beatmap => beatmap.Value.Result;

View File

@ -118,6 +118,7 @@ namespace osu.Game
dependencies.Cache(new OsuColour()); dependencies.Cache(new OsuColour());
fileImporters.Add(BeatmapManager); fileImporters.Add(BeatmapManager);
fileImporters.Add(ScoreStore);
//this completely overrides the framework default. will need to change once we make a proper FontStore. //this completely overrides the framework default. will need to change once we make a proper FontStore.
dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 100 }); dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 100 });

View File

@ -387,7 +387,7 @@ namespace osu.Game.Screens.Play
.FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint); .FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint);
(Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)blurLevel.Value * 25), duration, Easing.OutQuint); (Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)blurLevel.Value * 25), duration, Easing.OutQuint);
Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, duration, Easing.OutQuint); Background?.FadeTo(beatmap.Background != null && (!storyboardVisible || !beatmap.Storyboard.ReplacesBackground) ? opacity : 0, duration, Easing.OutQuint);
} }
private void fadeOut() private void fadeOut()

View File

@ -5,7 +5,6 @@ using OpenTK;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.IO; using osu.Game.IO;
@ -15,13 +14,6 @@ namespace osu.Game.Storyboards.Drawables
{ {
public Storyboard Storyboard { get; private set; } public Storyboard Storyboard { get; private set; }
private readonly Background background;
public Texture BackgroundTexture
{
get { return background.Texture; }
set { background.Texture = value; }
}
private readonly Container<DrawableStoryboardLayer> content; private readonly Container<DrawableStoryboardLayer> content;
protected override Container<DrawableStoryboardLayer> Content => content; protected override Container<DrawableStoryboardLayer> Content => content;
@ -52,11 +44,6 @@ namespace osu.Game.Storyboards.Drawables
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
AddInternal(background = new Background
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
AddInternal(content = new Container<DrawableStoryboardLayer> AddInternal(content = new Container<DrawableStoryboardLayer>
{ {
Size = new Vector2(640, 480), Size = new Vector2(640, 480),
@ -79,10 +66,5 @@ namespace osu.Game.Storyboards.Drawables
foreach (var layer in Children) foreach (var layer in Children)
layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing; layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing;
} }
private class Background : Sprite
{
protected override Vector2 DrawScale => Texture != null ? new Vector2(Parent.DrawHeight / Texture.DisplayHeight) : base.DrawScale;
}
} }
} }

View File

@ -14,6 +14,8 @@ namespace osu.Game.Storyboards
private readonly Dictionary<string, StoryboardLayer> layers = new Dictionary<string, StoryboardLayer>(); private readonly Dictionary<string, StoryboardLayer> layers = new Dictionary<string, StoryboardLayer>();
public IEnumerable<StoryboardLayer> Layers => layers.Values; public IEnumerable<StoryboardLayer> Layers => layers.Values;
public BeatmapInfo BeatmapInfo = new BeatmapInfo();
public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable)); public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable));
public Storyboard() public Storyboard()
@ -36,28 +38,22 @@ namespace osu.Game.Storyboards
/// <summary> /// <summary>
/// Whether the beatmap's background should be hidden while this storyboard is being displayed. /// Whether the beatmap's background should be hidden while this storyboard is being displayed.
/// </summary> /// </summary>
public bool ReplacesBackground(BeatmapInfo beatmapInfo) public bool ReplacesBackground
{ {
var backgroundPath = beatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant(); get
if (backgroundPath == null) {
return false; var backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant();
if (backgroundPath == null)
return false;
return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath); return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath);
}
} }
public float AspectRatio(BeatmapInfo beatmapInfo)
=> beatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f;
public DrawableStoryboard CreateDrawable(WorkingBeatmap working = null) public DrawableStoryboard CreateDrawable(WorkingBeatmap working = null)
{ {
var drawable = new DrawableStoryboard(this); var drawable = new DrawableStoryboard(this);
if (working != null) drawable.Width = drawable.Height * (BeatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f);
{
var beatmapInfo = working.Beatmap.BeatmapInfo;
drawable.Width = drawable.Height * AspectRatio(beatmapInfo);
if (!ReplacesBackground(beatmapInfo))
drawable.BackgroundTexture = working.Background;
}
return drawable; return drawable;
} }