2018-01-05 19:21:19 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-11-29 13:20:15 +08:00
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2018-02-28 15:34:47 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
2017-11-29 13:20:15 +08:00
|
|
|
using osu.Game.Rulesets.Replays;
|
2018-02-28 15:34:47 +08:00
|
|
|
using osu.Game.Rulesets.Replays.Legacy;
|
|
|
|
using osu.Game.Rulesets.Replays.Types;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2017-11-29 13:20:15 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania.Replays
|
|
|
|
{
|
2018-02-28 15:34:47 +08:00
|
|
|
public class ManiaReplayFrame : ReplayFrame, IConvertibleReplayFrame
|
2017-11-29 13:20:15 +08:00
|
|
|
{
|
2018-02-28 15:34:47 +08:00
|
|
|
public List<ManiaAction> Actions = new List<ManiaAction>();
|
2017-11-29 13:20:15 +08:00
|
|
|
|
2018-02-28 15:34:47 +08:00
|
|
|
public ManiaReplayFrame(double time, params ManiaAction[] actions)
|
|
|
|
: base(time)
|
2017-11-29 13:20:15 +08:00
|
|
|
{
|
2018-02-28 15:34:47 +08:00
|
|
|
Actions.AddRange(actions);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ConvertFrom(LegacyReplayFrame legacyFrame, Score score, Beatmap beatmap)
|
|
|
|
{
|
|
|
|
// We don't need to fully convert, just create the converter
|
|
|
|
var converter = new ManiaBeatmapConverter(beatmap.BeatmapInfo.Ruleset.Equals(score.Ruleset), beatmap);
|
|
|
|
|
|
|
|
// Todo: Apply mods to converter
|
|
|
|
// NB: Via co-op mod, osu-stable can have two stages with floor(col/2) and ceil(col/2) columns. This will need special handling
|
|
|
|
// elsewhere in the game if we do choose to support the old co-op mod anyway. For now, assume that there is only one stage.
|
|
|
|
|
2018-02-28 23:36:32 +08:00
|
|
|
var stage = new StageDefinition { Columns = converter.TargetColumns };
|
2018-02-28 15:34:47 +08:00
|
|
|
|
|
|
|
var normalAction = ManiaAction.Key1;
|
|
|
|
var specialAction = ManiaAction.Special1;
|
|
|
|
|
|
|
|
int activeColumns = (int)(legacyFrame.MouseX ?? 0);
|
|
|
|
int counter = 0;
|
|
|
|
while (activeColumns > 0)
|
|
|
|
{
|
|
|
|
Actions.Add((activeColumns & 1) > 0 ? specialAction : normalAction);
|
|
|
|
|
2018-02-28 23:36:32 +08:00
|
|
|
if (stage.IsSpecialColumn(counter))
|
2018-02-28 15:34:47 +08:00
|
|
|
normalAction++;
|
|
|
|
else
|
|
|
|
specialAction++;
|
|
|
|
|
|
|
|
counter++;
|
|
|
|
activeColumns >>= 1;
|
|
|
|
}
|
2017-11-29 13:20:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|