1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 10:07:25 +08:00
osu-lazer/osu.Desktop.VisualTests/Tests/TestCaseReplay.cs

81 lines
2.5 KiB
C#
Raw Normal View History

2017-02-28 19:14:48 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
2017-03-01 21:56:20 +08:00
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;
2017-02-28 19:14:48 +08:00
namespace osu.Desktop.VisualTests.Tests
{
class TestCaseReplay : TestCasePlayer
2017-02-28 19:14:48 +08:00
{
2017-03-01 21:56:20 +08:00
private WorkingBeatmap beatmap;
private LegacyReplayInputHandler replay;
2017-03-01 21:56:20 +08:00
public override string Name => @"Replay";
public override string Description => @"Testing replay playback.";
public override void Reset()
{
base.Reset();
var list = new List<LegacyReplayInputHandler.LegacyReplayFrame>();
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])
));
}
replay = new LegacyReplayInputHandler(list);
2017-03-01 21:56:20 +08:00
//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);
//}
}
protected override Player CreatePlayer(WorkingBeatmap beatmap)
2017-03-01 21:56:20 +08:00
{
var player = base.CreatePlayer(beatmap);
player.ReplayInputHandler = replay;
return player;
2017-03-01 21:56:20 +08:00
}
2017-02-28 19:14:48 +08:00
}
}