2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-02-28 15:34:47 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Game.Beatmaps;
|
2018-11-28 16:20:37 +08:00
|
|
|
|
using osu.Game.Replays.Legacy;
|
2018-02-28 15:34:47 +08:00
|
|
|
|
using osu.Game.Rulesets.Replays;
|
|
|
|
|
using osu.Game.Rulesets.Replays.Types;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-02-28 15:34:47 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Replays
|
|
|
|
|
{
|
|
|
|
|
public class OsuReplayFrame : ReplayFrame, IConvertibleReplayFrame
|
|
|
|
|
{
|
|
|
|
|
public Vector2 Position;
|
|
|
|
|
public List<OsuAction> Actions = new List<OsuAction>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-02-28 15:34:47 +08:00
|
|
|
|
public OsuReplayFrame()
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-02-28 15:34:47 +08:00
|
|
|
|
public OsuReplayFrame(double time, Vector2 position, params OsuAction[] actions)
|
|
|
|
|
: base(time)
|
|
|
|
|
{
|
|
|
|
|
Position = position;
|
|
|
|
|
Actions.AddRange(actions);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-07-02 13:33:05 +08:00
|
|
|
|
public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayFrame? lastFrame = null)
|
2018-02-28 15:34:47 +08:00
|
|
|
|
{
|
2019-09-12 17:33:46 +08:00
|
|
|
|
Position = currentFrame.Position;
|
|
|
|
|
if (currentFrame.MouseLeft) Actions.Add(OsuAction.LeftButton);
|
|
|
|
|
if (currentFrame.MouseRight) Actions.Add(OsuAction.RightButton);
|
2022-09-19 08:55:06 +08:00
|
|
|
|
if (currentFrame.Smoke) Actions.Add(OsuAction.Smoke);
|
2018-02-28 15:34:47 +08:00
|
|
|
|
}
|
2020-03-24 13:13:46 +08:00
|
|
|
|
|
2020-03-25 19:21:34 +08:00
|
|
|
|
public LegacyReplayFrame ToLegacy(IBeatmap beatmap)
|
2020-03-24 13:13:46 +08:00
|
|
|
|
{
|
|
|
|
|
ReplayButtonState state = ReplayButtonState.None;
|
|
|
|
|
|
|
|
|
|
if (Actions.Contains(OsuAction.LeftButton))
|
|
|
|
|
state |= ReplayButtonState.Left1;
|
|
|
|
|
if (Actions.Contains(OsuAction.RightButton))
|
|
|
|
|
state |= ReplayButtonState.Right1;
|
2022-09-19 08:55:06 +08:00
|
|
|
|
if (Actions.Contains(OsuAction.Smoke))
|
|
|
|
|
state |= ReplayButtonState.Smoke;
|
2020-03-24 13:13:46 +08:00
|
|
|
|
|
|
|
|
|
return new LegacyReplayFrame(Time, Position.X, Position.Y, state);
|
|
|
|
|
}
|
2018-02-28 15:34:47 +08:00
|
|
|
|
}
|
|
|
|
|
}
|