diff --git a/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs b/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs index f5ee7366..45ab3c56 100644 --- a/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs +++ b/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs @@ -1,23 +1,48 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using osu.Game.Beatmaps; +using osu.Game.Replays.Legacy; using osu.Game.Rulesets.Replays; +using osu.Game.Rulesets.Replays.Types; using osuTK; namespace osu.Game.Rulesets.Tau.Replays { - public class TauReplayFrame : ReplayFrame + public class TauReplayFrame : ReplayFrame, IConvertibleReplayFrame { public List Actions = new List(); public Vector2 Position; - public TauReplayFrame(double time, Vector2 position, TauAction? button = null) : base(time) + public TauReplayFrame() + { + } + + public TauReplayFrame(double time, Vector2 position, params TauAction[] actions) : base(time) { Position = position; + Actions.AddRange(actions); + } + + public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayFrame lastFrame = null) + { + Position = currentFrame.Position; + + if (currentFrame.MouseLeft) Actions.Add(TauAction.LeftButton); + if (currentFrame.MouseRight) Actions.Add(TauAction.RightButton); + if (currentFrame.MouseLeft2) Actions.Add(TauAction.HardButton); + } + + public LegacyReplayFrame ToLegacy(IBeatmap beatmap) + { + ReplayButtonState state = ReplayButtonState.None; + + if (Actions.Contains(TauAction.LeftButton)) state |= ReplayButtonState.Left1; + if (Actions.Contains(TauAction.RightButton)) state |= ReplayButtonState.Right1; + if (Actions.Contains(TauAction.HardButton)) state |= ReplayButtonState.Left2; - if (button.HasValue) - Actions.Add(button.Value); + return new LegacyReplayFrame(Time, Position.X, Position.Y, state); } } } diff --git a/osu.Game.Rulesets.tau/UI/TauReplayRecorder.cs b/osu.Game.Rulesets.tau/UI/TauReplayRecorder.cs new file mode 100644 index 00000000..928f6ec7 --- /dev/null +++ b/osu.Game.Rulesets.tau/UI/TauReplayRecorder.cs @@ -0,0 +1,23 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using osu.Game.Replays; +using osu.Game.Rulesets.Tau.Replays; +using osu.Game.Rulesets.Replays; +using osu.Game.Rulesets.UI; +using osuTK; + +namespace osu.Game.Rulesets.Tau.UI +{ + public class TauReplayRecorder : ReplayRecorder + { + public TauReplayRecorder(Replay replay) + : base(replay) + { + } + + protected override ReplayFrame HandleFrame(Vector2 mousePosition, List actions, ReplayFrame previousFrame) + => new TauReplayFrame(Time.Current, mousePosition, actions.ToArray() ); + } +} \ No newline at end of file diff --git a/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs b/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs index 8a6ab712..6e9b5d45 100644 --- a/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs +++ b/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; @@ -33,5 +33,7 @@ public DrawabletauRuleset(TauRuleset ruleset, IBeatmap beatmap, IReadOnlyList new TauInputManager(Ruleset?.RulesetInfo); public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TauPlayfieldAdjustmentContainer(); + + protected override ReplayRecorder CreateReplayRecorder(Replay replay) => new TauReplayRecorder(replay); } } diff --git a/osu.Game.Rulesets.tau/osu.Game.Rulesets.tau.csproj b/osu.Game.Rulesets.tau/osu.Game.Rulesets.tau.csproj index a534b8c4..61adb36f 100644 --- a/osu.Game.Rulesets.tau/osu.Game.Rulesets.tau.csproj +++ b/osu.Game.Rulesets.tau/osu.Game.Rulesets.tau.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/osu.Game.Rulesets.tau/tauInputManager.cs b/osu.Game.Rulesets.tau/tauInputManager.cs index 2753b323..20694425 100644 --- a/osu.Game.Rulesets.tau/tauInputManager.cs +++ b/osu.Game.Rulesets.tau/tauInputManager.cs @@ -24,7 +24,7 @@ public bool AllowUserPresses /// public bool AllowUserCursorMovement { get; set; } = true; - protected override RulesetKeyBindingContainer CreateKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) + protected override KeyBindingContainer CreateKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) => new TauKeyBindingContainer(ruleset, variant, unique); public TauInputManager(RulesetInfo ruleset) diff --git a/osu.Game.Rulesets.tau/tauRuleset.cs b/osu.Game.Rulesets.tau/tauRuleset.cs index 61c0171c..47c426be 100644 --- a/osu.Game.Rulesets.tau/tauRuleset.cs +++ b/osu.Game.Rulesets.tau/tauRuleset.cs @@ -12,10 +12,12 @@ using osu.Game.Rulesets.Configuration; using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Tau.Beatmaps; using osu.Game.Rulesets.Tau.Configuration; using osu.Game.Rulesets.Tau.Mods; +using osu.Game.Rulesets.Tau.Replays; using osu.Game.Rulesets.Tau.Scoring; using osu.Game.Rulesets.Tau.UI; using osu.Game.Rulesets.UI; @@ -103,5 +105,7 @@ public override IEnumerable GetDefaultKeyBindings(int variant = 0) = { Texture = new TextureStore(new TextureLoaderStore(CreateResourceStore()), false).Get("Textures/tau"), }; + + public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new TauReplayFrame(); } }