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
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Game.Beatmaps;
|
2018-11-28 16:20:37 +08:00
|
|
|
using osu.Game.Replays.Legacy;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Rulesets.Replays;
|
|
|
|
using osu.Game.Rulesets.Replays.Types;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Replays
|
|
|
|
{
|
|
|
|
public class ManiaReplayFrame : ReplayFrame, IConvertibleReplayFrame
|
|
|
|
{
|
|
|
|
public List<ManiaAction> Actions = new List<ManiaAction>();
|
|
|
|
|
|
|
|
public ManiaReplayFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public ManiaReplayFrame(double time, params ManiaAction[] actions)
|
|
|
|
: base(time)
|
|
|
|
{
|
|
|
|
Actions.AddRange(actions);
|
|
|
|
}
|
|
|
|
|
2022-07-02 13:33:05 +08:00
|
|
|
public void FromLegacy(LegacyReplayFrame legacyFrame, IBeatmap beatmap, ReplayFrame? lastFrame = null)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2024-08-08 05:36:04 +08:00
|
|
|
var action = ManiaAction.Key1;
|
2018-04-13 17:19:50 +08:00
|
|
|
int activeColumns = (int)(legacyFrame.MouseX ?? 0);
|
2019-04-01 11:16:05 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
while (activeColumns > 0)
|
|
|
|
{
|
|
|
|
if ((activeColumns & 1) > 0)
|
2024-08-08 05:36:04 +08:00
|
|
|
Actions.Add(action);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
2024-08-08 05:36:04 +08:00
|
|
|
action++;
|
2018-04-13 17:19:50 +08:00
|
|
|
activeColumns >>= 1;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
2020-03-27 14:50:11 +08:00
|
|
|
int keys = 0;
|
2020-03-24 13:13:46 +08:00
|
|
|
|
|
|
|
foreach (var action in Actions)
|
2024-08-08 05:36:04 +08:00
|
|
|
keys |= 1 << (int)action;
|
2020-03-24 13:13:46 +08:00
|
|
|
|
|
|
|
return new LegacyReplayFrame(Time, keys, null, ReplayButtonState.None);
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|