diff --git a/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs index 1a95848500..d089f3bca7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs @@ -3,13 +3,105 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; +using osu.Framework.Allocation; +using osu.Framework.Screens.Testing; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Formats; +using OpenTK; +using osu.Framework.Graphics.Sprites; +using osu.Game.Beatmaps.IO; +using osu.Game.Database; +using osu.Game.Input.Handlers; +using osu.Game.IO.Legacy; +using osu.Game.Modes; +using osu.Game.Modes.Objects; +using osu.Game.Modes.Osu.Objects; +using osu.Game.Screens.Play; +using OpenTK.Graphics; +using SharpCompress.Archives.SevenZip; +using SharpCompress.Readers; namespace osu.Desktop.VisualTests.Tests { - class TestCaseReplay + class TestCaseReplay : TestCase { + private WorkingBeatmap beatmap; + public override string Name => @"Replay"; + + public override string Description => @"Testing replay playback."; + + [BackgroundDependencyLoader] + private void load(BeatmapDatabase db) + { + var beatmapInfo = db.Query().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault(); + if (beatmapInfo != null) + beatmap = db.GetWorkingBeatmap(beatmapInfo); + } + + public override void Reset() + { + base.Reset(); + + Add(new Box + { + RelativeSizeAxes = Framework.Graphics.Axes.Both, + Colour = Color4.Black, + }); + + + var list = new List(); + + float lastTime = 0; + foreach (var l in File.ReadAllText(@"C:\Users\Dean\Desktop\2157025197").Split(',')) + { + var split = l.Split('|'); + + if (split.Length < 4 || float.Parse(split[0]) < 0) continue; + + lastTime += float.Parse(split[0]); + + list.Add(new LegacyReplayInputHandler.LegacyReplayFrame( + lastTime, + float.Parse(split[1]), + 384 - float.Parse(split[2]), + (LegacyReplayInputHandler.LegacyButtonState)int.Parse(split[3]) + )); + } + + + var replay = new LegacyReplayInputHandler(list); + + //var data = File.ReadAllBytes(@"C:\Users\Dean\.osu\Replays\Tao - O2i3 - Ooi [Game Edit] [Advanced] (2016-08-08) Osu.osr"); + //using (MemoryStream dataStream = new MemoryStream(data)) + //{ + // var obj = SerializationReader.DynamicDeserializer.Deserialize(dataStream); + + + // Console.WriteLine(obj); + //} + + + Add(new PlayerLoader(new Player + { + PreferredPlayMode = PlayMode.Osu, + ReplayInputHandler = replay, + Beatmap = beatmap + }) + { + Beatmap = beatmap + }); + } + + class TestWorkingBeatmap : WorkingBeatmap + { + public TestWorkingBeatmap(Beatmap beatmap) + : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) + { + Beatmap = beatmap; + } + + protected override ArchiveReader GetReader() => null; + } } } diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 0f8c7031de..2426ff9d2e 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -86,6 +86,10 @@ $(SolutionDir)\packages\ppy.OpenTK.2.0.50727.1340\lib\net45\OpenTK.dll True + + ..\packages\SharpCompress.0.15.1\lib\net45\SharpCompress.dll + True + False $(SolutionDir)\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll diff --git a/osu.Desktop.VisualTests/packages.config b/osu.Desktop.VisualTests/packages.config index 3da209ee61..5a30c50600 100644 --- a/osu.Desktop.VisualTests/packages.config +++ b/osu.Desktop.VisualTests/packages.config @@ -6,6 +6,7 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste + diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 527a027ca2..7e85f09d8c 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -101,8 +101,8 @@ $(SolutionDir)\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll True - - $(SolutionDir)\packages\squirrel.windows.1.5.2\lib\Net45\ICSharpCode.SharpZipLib.dll + + ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll True diff --git a/osu.Desktop/packages.config b/osu.Desktop/packages.config index bdeaf1de89..35305fb5d8 100644 --- a/osu.Desktop/packages.config +++ b/osu.Desktop/packages.config @@ -7,6 +7,7 @@ Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/maste + \ No newline at end of file diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index e1c99ea82c..98344e7017 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -142,17 +142,7 @@ namespace osu.Game.Screens.Play hitRenderer = ruleset.CreateHitRendererWith(beatmap, new PlayerInputManager { - ReplayInputHandler = new LegacyReplayInputHandler(new List - { - new LegacyReplayInputHandler.LegacyReplayFrame(0, 0, 0, LegacyReplayInputHandler.LegacyButtonState.None), - new LegacyReplayInputHandler.LegacyReplayFrame(500, 512, 0, LegacyReplayInputHandler.LegacyButtonState.None), - new LegacyReplayInputHandler.LegacyReplayFrame(1000, 512, 384, LegacyReplayInputHandler.LegacyButtonState.None), - new LegacyReplayInputHandler.LegacyReplayFrame(1500, 0, 384, LegacyReplayInputHandler.LegacyButtonState.None), - new LegacyReplayInputHandler.LegacyReplayFrame(2000, 0, 0, LegacyReplayInputHandler.LegacyButtonState.None), - new LegacyReplayInputHandler.LegacyReplayFrame(2500, 512, 0, LegacyReplayInputHandler.LegacyButtonState.None), - new LegacyReplayInputHandler.LegacyReplayFrame(3000, 512, 384, LegacyReplayInputHandler.LegacyButtonState.None), - new LegacyReplayInputHandler.LegacyReplayFrame(3500, 0, 384, LegacyReplayInputHandler.LegacyButtonState.None), - }) + ReplayInputHandler = ReplayInputHandler }); //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) @@ -350,6 +340,8 @@ namespace osu.Game.Screens.Play private Bindable mouseWheelDisabled; + public LegacyReplayInputHandler ReplayInputHandler; + protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !isPaused; } } \ No newline at end of file