From ed89175964a836efe0e8bacd3def5779ffc213ec Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Wed, 25 Mar 2020 22:44:12 +0800 Subject: [PATCH 1/4] implement the function --- .../Replays/tauReplayFrame.cs | 39 +++++++++++++++++-- osu.Game.Rulesets.tau/UI/TauReplayRecorder.cs | 23 +++++++++++ .../UI/tauDrawableRuleset.cs | 2 + osu.Game.Rulesets.tau/tauRuleset.cs | 4 ++ 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 osu.Game.Rulesets.tau/UI/TauReplayRecorder.cs diff --git a/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs b/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs index f88b4347..6833abff 100644 --- a/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs +++ b/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs @@ -2,20 +2,51 @@ // 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(TauAction? button = null) + public TauReplayFrame() { - if (button.HasValue) - Actions.Add(button.Value); + } + + 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; + + 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 885eb902..fd8500a1 100644 --- a/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs +++ b/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs @@ -31,5 +31,7 @@ public DrawabletauRuleset(TauRuleset ruleset, IBeatmap beatmap, IReadOnlyList CreateDrawableRepresentation(TauHitObject h) => new DrawabletauHitObject(h); protected override PassThroughInputManager CreateInputManager() => new TauInputManager(Ruleset?.RulesetInfo); + + protected override ReplayRecorder CreateReplayRecorder(Replay replay) => new TauReplayRecorder(replay); } } 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(); } } From 2a6622e87b3c954a0a376aacbbde19839d764006 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Wed, 25 Mar 2020 23:04:57 +0800 Subject: [PATCH 2/4] small fixes --- osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs b/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs index 6833abff..6e83636e 100644 --- a/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs +++ b/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs @@ -34,7 +34,6 @@ public void FromLegacy(LegacyReplayFrame currentFrame, IBeatmap beatmap, ReplayF if (currentFrame.MouseLeft2) Actions.Add(TauAction.HardButton); } - public LegacyReplayFrame ToLegacy(IBeatmap beatmap) { ReplayButtonState state = ReplayButtonState.None; From 76d6f9ab7680171b2ddae8ad036889134fad75df Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Wed, 25 Mar 2020 23:20:23 +0800 Subject: [PATCH 3/4] update game version --- osu.Game.Rulesets.tau/osu.Game.Rulesets.tau.csproj | 4 ++-- osu.Game.Rulesets.tau/tauInputManager.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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) From 450a6e0184c54e66cd0ec567e920ad23ef0131f7 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Thu, 26 Mar 2020 11:51:35 +0800 Subject: [PATCH 4/4] commit changes --- osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs | 9 +++------ osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs b/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs index fbda5ad2..45ab3c56 100644 --- a/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs +++ b/osu.Game.Rulesets.tau/Replays/tauReplayFrame.cs @@ -38,12 +38,9 @@ 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 (Actions.Contains(TauAction.LeftButton)) state |= ReplayButtonState.Left1; + if (Actions.Contains(TauAction.RightButton)) state |= ReplayButtonState.Right1; + if (Actions.Contains(TauAction.HardButton)) state |= ReplayButtonState.Left2; return new LegacyReplayFrame(Time, Position.X, Position.Y, state); } diff --git a/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs b/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs index 8fc5e9f1..6e9b5d45 100644 --- a/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs +++ b/osu.Game.Rulesets.tau/UI/tauDrawableRuleset.cs @@ -31,7 +31,7 @@ public DrawabletauRuleset(TauRuleset ruleset, IBeatmap beatmap, IReadOnlyList CreateDrawableRepresentation(TauHitObject h) => new DrawabletauHitObject(h); protected override PassThroughInputManager CreateInputManager() => new TauInputManager(Ruleset?.RulesetInfo); - + public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TauPlayfieldAdjustmentContainer(); protected override ReplayRecorder CreateReplayRecorder(Replay replay) => new TauReplayRecorder(replay);