1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-02 05:42:55 +08:00

Fix key binding generators

This commit is contained in:
clayton 2024-08-07 14:36:03 -07:00
parent 85805bffde
commit 606b0556d5
No known key found for this signature in database
GPG Key ID: 0E5962B8D84F9B2E
3 changed files with 11 additions and 23 deletions

View File

@ -45,18 +45,15 @@ namespace osu.Game.Rulesets.Mania
LeftKeys = stage1LeftKeys, LeftKeys = stage1LeftKeys,
RightKeys = stage1RightKeys, RightKeys = stage1RightKeys,
SpecialKey = InputKey.V, SpecialKey = InputKey.V,
SpecialAction = ManiaAction.Special1, }.GenerateKeyBindingsFor(singleStageVariant);
NormalActionStart = ManiaAction.Key1
}.GenerateKeyBindingsFor(singleStageVariant, out var nextNormal);
var stage2Bindings = new VariantMappingGenerator var stage2Bindings = new VariantMappingGenerator
{ {
LeftKeys = stage2LeftKeys, LeftKeys = stage2LeftKeys,
RightKeys = stage2RightKeys, RightKeys = stage2RightKeys,
SpecialKey = InputKey.B, SpecialKey = InputKey.B,
SpecialAction = ManiaAction.Special2, ActionStart = (ManiaAction)singleStageVariant,
NormalActionStart = nextNormal }.GenerateKeyBindingsFor(singleStageVariant);
}.GenerateKeyBindingsFor(singleStageVariant, out _);
return stage1Bindings.Concat(stage2Bindings); return stage1Bindings.Concat(stage2Bindings);
} }

View File

@ -34,8 +34,6 @@ namespace osu.Game.Rulesets.Mania
LeftKeys = leftKeys, LeftKeys = leftKeys,
RightKeys = rightKeys, RightKeys = rightKeys,
SpecialKey = InputKey.Space, SpecialKey = InputKey.Space,
SpecialAction = ManiaAction.Special1, }.GenerateKeyBindingsFor(variant);
NormalActionStart = ManiaAction.Key1,
}.GenerateKeyBindingsFor(variant, out _);
} }
} }

View File

@ -26,37 +26,30 @@ namespace osu.Game.Rulesets.Mania
public InputKey SpecialKey; public InputKey SpecialKey;
/// <summary> /// <summary>
/// The <see cref="ManiaAction"/> at which the normal columns should begin. /// The <see cref="ManiaAction"/> at which the columns should begin.
/// </summary> /// </summary>
public ManiaAction NormalActionStart; public ManiaAction ActionStart;
/// <summary>
/// The <see cref="ManiaAction"/> for the special column.
/// </summary>
public ManiaAction SpecialAction;
/// <summary> /// <summary>
/// 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, out ManiaAction nextNormalAction) public IEnumerable<KeyBinding> GenerateKeyBindingsFor(int columns)
{ {
ManiaAction currentNormalAction = NormalActionStart; ManiaAction currentAction = ActionStart;
var bindings = new List<KeyBinding>(); var bindings = new List<KeyBinding>();
for (int i = LeftKeys.Length - columns / 2; i < LeftKeys.Length; i++) for (int i = LeftKeys.Length - columns / 2; i < LeftKeys.Length; i++)
bindings.Add(new KeyBinding(LeftKeys[i], currentNormalAction++)); bindings.Add(new KeyBinding(LeftKeys[i], currentAction++));
if (columns % 2 == 1) if (columns % 2 == 1)
bindings.Add(new KeyBinding(SpecialKey, SpecialAction)); bindings.Add(new KeyBinding(SpecialKey, currentAction++));
for (int i = 0; i < columns / 2; i++) for (int i = 0; i < columns / 2; i++)
bindings.Add(new KeyBinding(RightKeys[i], currentNormalAction++)); bindings.Add(new KeyBinding(RightKeys[i], currentAction++));
nextNormalAction = currentNormalAction;
return bindings; return bindings;
} }
} }