1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 19:32:55 +08:00

Fix keybinding offsets due to special keys

This commit is contained in:
smoogipoo 2018-01-22 14:38:41 +09:00
parent feb79ff9e7
commit 293023d99a
3 changed files with 21 additions and 17 deletions

View File

@ -155,7 +155,7 @@ namespace osu.Game.Rulesets.Mania
SpecialKey = InputKey.Space, SpecialKey = InputKey.Space,
SpecialAction = ManiaAction.Special1, SpecialAction = ManiaAction.Special1,
NormalActionStart = ManiaAction.Key1, NormalActionStart = ManiaAction.Key1,
}.GenerateKeyBindingsFor(variant); }.GenerateKeyBindingsFor(variant, out _);
case ManiaKeyBindingVariantType.Coop: case ManiaKeyBindingVariantType.Coop:
case ManiaKeyBindingVariantType.Versus: case ManiaKeyBindingVariantType.Versus:
getMultiVariantKeyCounts(variant, out int p1K, out int p2K); getMultiVariantKeyCounts(variant, out int p1K, out int p2K);
@ -179,7 +179,7 @@ namespace osu.Game.Rulesets.Mania
SpecialKey = InputKey.Tilde, SpecialKey = InputKey.Tilde,
SpecialAction = ManiaAction.Special1, SpecialAction = ManiaAction.Special1,
NormalActionStart = ManiaAction.Key1 NormalActionStart = ManiaAction.Key1
}.GenerateKeyBindingsFor(p1K); }.GenerateKeyBindingsFor(p1K, out var nextNormal);
var player2Bindings = new VariantMappingGenerator var player2Bindings = new VariantMappingGenerator
{ {
@ -199,8 +199,8 @@ namespace osu.Game.Rulesets.Mania
}, },
SpecialKey = InputKey.BackSlash, SpecialKey = InputKey.BackSlash,
SpecialAction = ManiaAction.Special2, SpecialAction = ManiaAction.Special2,
NormalActionStart = ManiaAction.Key1 + p1K NormalActionStart = nextNormal
}.GenerateKeyBindingsFor(p2K); }.GenerateKeyBindingsFor(p2K, out _);
return player1Bindings.Concat(player2Bindings); return player1Bindings.Concat(player2Bindings);
} }
@ -300,8 +300,9 @@ namespace osu.Game.Rulesets.Mania
/// Generates a list of <see cref="KeyBinding"/>s for a specific number of columns. /// Generates a list of <see cref="KeyBinding"/>s for a specific number of columns.
/// </summary> /// </summary>
/// <param name="columns">The number of columns that need to be bound.</param> /// <param name="columns">The number of columns that need to be bound.</param>
/// <param name="nextNormalAction">The next <see cref="ManiaAction"/> to use for normal columns.</param>
/// <returns>The keybindings.</returns> /// <returns>The keybindings.</returns>
public IEnumerable<KeyBinding> GenerateKeyBindingsFor(int columns) public IEnumerable<KeyBinding> GenerateKeyBindingsFor(int columns, out ManiaAction nextNormalAction)
{ {
ManiaAction currentNormalAction = NormalActionStart; ManiaAction currentNormalAction = NormalActionStart;
@ -316,6 +317,7 @@ namespace osu.Game.Rulesets.Mania
if (columns % 2 == 1) if (columns % 2 == 1)
bindings.Add(new KeyBinding(SpecialKey, SpecialAction)); bindings.Add(new KeyBinding(SpecialKey, SpecialAction));
nextNormalAction = currentNormalAction;
return bindings; return bindings;
} }
} }

View File

@ -48,10 +48,12 @@ namespace osu.Game.Rulesets.Mania.UI
Content = new[] { new Drawable[stageDefinitions.Count] } Content = new[] { new Drawable[stageDefinitions.Count] }
}; };
var normalColumnAction = ManiaAction.Key1;
var specialColumnAction = ManiaAction.Special1;
int firstColumnIndex = 0; int firstColumnIndex = 0;
for (int i = 0; i < stageDefinitions.Count; i++) for (int i = 0; i < stageDefinitions.Count; i++)
{ {
var newStage = new ManiaStage(i, firstColumnIndex, stageDefinitions[i]); var newStage = new ManiaStage(firstColumnIndex, stageDefinitions[i], ref normalColumnAction, ref specialColumnAction);
newStage.SpecialColumn.BindTo(SpecialColumnPosition); newStage.SpecialColumn.BindTo(SpecialColumnPosition);
newStage.VisibleTimeRange.BindTo(VisibleTimeRange); newStage.VisibleTimeRange.BindTo(VisibleTimeRange);
newStage.Inverted.BindTo(Inverted); newStage.Inverted.BindTo(Inverted);

View File

@ -49,14 +49,12 @@ namespace osu.Game.Rulesets.Mania.UI
private List<Color4> normalColumnColours = new List<Color4>(); private List<Color4> normalColumnColours = new List<Color4>();
private Color4 specialColumnColour; private Color4 specialColumnColour;
private readonly int stageIndex;
private readonly int firstColumnIndex; private readonly int firstColumnIndex;
private readonly StageDefinition definition; private readonly StageDefinition definition;
public ManiaStage(int stageIndex, int firstColumnIndex, StageDefinition definition) public ManiaStage(int firstColumnIndex, StageDefinition definition, ref ManiaAction normalColumnStartAction, ref ManiaAction specialColumnStartAction)
: base(ScrollingDirection.Up) : base(ScrollingDirection.Up)
{ {
this.stageIndex = stageIndex;
this.firstColumnIndex = firstColumnIndex; this.firstColumnIndex = firstColumnIndex;
this.definition = definition; this.definition = definition;
@ -134,7 +132,16 @@ namespace osu.Game.Rulesets.Mania.UI
}; };
for (int i = 0; i < definition.Columns; i++) for (int i = 0; i < definition.Columns; i++)
AddColumn(new Column()); {
var isSpecial = isSpecialColumn(i);
var column = new Column
{
IsSpecial = isSpecial,
Action = isSpecial ? specialColumnStartAction++ : normalColumnStartAction++
};
AddColumn(column);
}
Inverted.ValueChanged += invertedChanged; Inverted.ValueChanged += invertedChanged;
Inverted.TriggerChange(); Inverted.TriggerChange();
@ -153,13 +160,6 @@ namespace osu.Game.Rulesets.Mania.UI
topLevelContainer.Add(c.TopLevelContainer.CreateProxy()); topLevelContainer.Add(c.TopLevelContainer.CreateProxy());
columnFlow.Add(c); columnFlow.Add(c);
AddNested(c); AddNested(c);
c.IsSpecial = isSpecialColumn(Columns.Count - 1);
if (c.IsSpecial)
c.Action = ManiaAction.Special1 + stageIndex;
else
c.Action = ManiaAction.Key1 + firstColumnIndex + Columns.Count - 1;
} }
/// <summary> /// <summary>