forked from taulazer/tau
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request taulazer#40 from MATRIX-feather/replay_func
Add local replay support for tau
- Loading branch information
Showing
6 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,48 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. 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<TauAction> Actions = new List<TauAction>(); | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. 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<TauAction> | ||
{ | ||
public TauReplayRecorder(Replay replay) | ||
: base(replay) | ||
{ | ||
} | ||
|
||
protected override ReplayFrame HandleFrame(Vector2 mousePosition, List<TauAction> actions, ReplayFrame previousFrame) | ||
=> new TauReplayFrame(Time.Current, mousePosition, actions.ToArray() ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. 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<Mo | |
protected override PassThroughInputManager CreateInputManager() => new TauInputManager(Ruleset?.RulesetInfo); | ||
|
||
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new TauPlayfieldAdjustmentContainer(); | ||
|
||
protected override ReplayRecorder CreateReplayRecorder(Replay replay) => new TauReplayRecorder(replay); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters