mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 02:02:53 +08:00
Use existing instance of beatmap rather than adding more resources
This commit is contained in:
parent
ca3186f34c
commit
6c100caba7
@ -19,7 +19,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ImportBeatmapTest
|
public class ImportBeatmapTest
|
||||||
{
|
{
|
||||||
private const string osz_path = @"../../../../osu-resources/osu.Game.Resources/Beatmaps/241526 Soleily - Renatus.osz";
|
public const string TEST_OSZ_PATH = @"../../../../osu-resources/osu.Game.Resources/Beatmaps/241526 Soleily - Renatus.osz";
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestImportWhenClosed()
|
public void TestImportWhenClosed()
|
||||||
@ -265,7 +265,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
private string createTemporaryBeatmap()
|
private string createTemporaryBeatmap()
|
||||||
{
|
{
|
||||||
var temp = Path.GetTempFileName() + ".osz";
|
var temp = Path.GetTempFileName() + ".osz";
|
||||||
File.Copy(osz_path, temp, true);
|
File.Copy(TEST_OSZ_PATH, temp, true);
|
||||||
Assert.IsTrue(File.Exists(temp));
|
Assert.IsTrue(File.Exists(temp));
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ using osu.Framework.Graphics.Audio;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Overlays;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -20,22 +19,14 @@ namespace osu.Game.Tests.Visual
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
Beatmap.Value = new WaveformTestBeatmap();
|
||||||
|
|
||||||
FillFlowContainer flow;
|
FillFlowContainer flow;
|
||||||
Child = flow = new FillFlowContainer
|
Child = flow = new FillFlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Spacing = new Vector2(0, 10),
|
Spacing = new Vector2(0, 10),
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new MusicController
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
Y = 100,
|
|
||||||
State = Visibility.Visible
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 1; i <= 16; i *= 2)
|
for (int i = 1; i <= 16; i *= 2)
|
||||||
@ -44,10 +35,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Resolution = 1f / i,
|
Resolution = 1f / i,
|
||||||
|
Waveform = Beatmap.Value.Waveform,
|
||||||
};
|
};
|
||||||
|
|
||||||
Beatmap.ValueChanged += b => newDisplay.Waveform = b.Waveform;
|
|
||||||
|
|
||||||
flow.Add(new Container
|
flow.Add(new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
|
55
osu.Game.Tests/WaveformTestBeatmap.cs
Normal file
55
osu.Game.Tests/WaveformTestBeatmap.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.Formats;
|
||||||
|
using osu.Game.IO.Archives;
|
||||||
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="WorkingBeatmap"/> that is used for testcases that include waveforms.
|
||||||
|
/// </summary>
|
||||||
|
public class WaveformTestBeatmap : WorkingBeatmap
|
||||||
|
{
|
||||||
|
private readonly ZipArchiveReader reader;
|
||||||
|
private readonly FileStream stream;
|
||||||
|
|
||||||
|
public WaveformTestBeatmap()
|
||||||
|
: base(new BeatmapInfo())
|
||||||
|
{
|
||||||
|
stream = File.OpenRead(ImportBeatmapTest.TEST_OSZ_PATH);
|
||||||
|
reader = new ZipArchiveReader(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Dispose()
|
||||||
|
{
|
||||||
|
base.Dispose();
|
||||||
|
stream?.Dispose();
|
||||||
|
reader?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IBeatmap GetBeatmap() => createTestBeatmap();
|
||||||
|
|
||||||
|
protected override Texture GetBackground() => null;
|
||||||
|
|
||||||
|
protected override Waveform GetWaveform() => new Waveform(getAudioStream());
|
||||||
|
|
||||||
|
protected override Track GetTrack() => new TrackBass(getAudioStream());
|
||||||
|
|
||||||
|
private Stream getAudioStream() => reader.GetStream(reader.Filenames.First(f => f.EndsWith(".mp3")));
|
||||||
|
private Stream getBeatmapStream() => reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu")));
|
||||||
|
|
||||||
|
private Beatmap createTestBeatmap()
|
||||||
|
{
|
||||||
|
using (var beatmapStream = getBeatmapStream())
|
||||||
|
using (var beatmapReader = new StreamReader(beatmapStream))
|
||||||
|
return Decoder.GetDecoder<Beatmap>(beatmapReader).Decode(beatmapReader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user