1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 11:23:00 +08:00

Make ManiaFramedReplayInputHandler properly account for special keys

These are interleaved into the playfield, so we have to use the playfield's columns' actions.
This commit is contained in:
smoogipoo 2017-11-28 15:27:20 +09:00
parent 84702211ec
commit b97cab4f29
2 changed files with 14 additions and 4 deletions

View File

@ -2,29 +2,39 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays;
namespace osu.Game.Rulesets.Mania.Replays namespace osu.Game.Rulesets.Mania.Replays
{ {
internal class ManiaFramedReplayInputHandler : FramedReplayInputHandler internal class ManiaFramedReplayInputHandler : FramedReplayInputHandler
{ {
public ManiaFramedReplayInputHandler(Replay replay) private readonly ManiaRulesetContainer container;
public ManiaFramedReplayInputHandler(Replay replay, ManiaRulesetContainer container)
: base(replay) : base(replay)
{ {
this.container = container;
} }
protected override bool AtImportantFrame => CurrentFrame.MouseX != PreviousFrame.MouseX;
private ManiaPlayfield playfield;
public override List<InputState> GetPendingStates() public override List<InputState> GetPendingStates()
{ {
var actions = new List<ManiaAction>(); var actions = new List<ManiaAction>();
int activeColumns = (int)(CurrentFrame.MouseX ?? 0); if (playfield == null)
playfield = (ManiaPlayfield)container.Playfield;
int activeColumns = (int)(CurrentFrame.MouseX ?? 0);
int counter = 0; int counter = 0;
while (activeColumns > 0) while (activeColumns > 0)
{ {
if ((activeColumns & 1) > 0) if ((activeColumns & 1) > 0)
actions.Add(ManiaAction.Key1 + counter); actions.Add(playfield.Columns.ElementAt(counter).Action);
counter++; counter++;
activeColumns >>= 1; activeColumns >>= 1;
} }

View File

@ -124,6 +124,6 @@ namespace osu.Game.Rulesets.Mania.UI
protected override SpeedAdjustmentContainer CreateSpeedAdjustmentContainer(MultiplierControlPoint controlPoint) => new ManiaSpeedAdjustmentContainer(controlPoint, ScrollingAlgorithm.Basic); protected override SpeedAdjustmentContainer CreateSpeedAdjustmentContainer(MultiplierControlPoint controlPoint) => new ManiaSpeedAdjustmentContainer(controlPoint, ScrollingAlgorithm.Basic);
protected override FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new ManiaFramedReplayInputHandler(replay); protected override FramedReplayInputHandler CreateReplayInputHandler(Replay replay) => new ManiaFramedReplayInputHandler(replay, this);
} }
} }