2020-04-20 12:28:36 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-04-20 12:28:36 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania
|
|
|
|
{
|
|
|
|
public class VariantMappingGenerator
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// All the <see cref="InputKey"/>s available to the left hand.
|
|
|
|
/// </summary>
|
|
|
|
public InputKey[] LeftKeys;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// All the <see cref="InputKey"/>s available to the right hand.
|
|
|
|
/// </summary>
|
|
|
|
public InputKey[] RightKeys;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The <see cref="InputKey"/> for the special key.
|
|
|
|
/// </summary>
|
|
|
|
public InputKey SpecialKey;
|
|
|
|
|
|
|
|
/// <summary>
|
2024-08-07 21:36:03 +00:00
|
|
|
/// The <see cref="ManiaAction"/> at which the columns should begin.
|
2020-04-20 12:28:36 +00:00
|
|
|
/// </summary>
|
2024-08-07 21:36:03 +00:00
|
|
|
public ManiaAction ActionStart;
|
2020-04-20 12:28:36 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Generates a list of <see cref="KeyBinding"/>s for a specific number of columns.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="columns">The number of columns that need to be bound.</param>
|
|
|
|
/// <returns>The keybindings.</returns>
|
2024-08-07 21:36:03 +00:00
|
|
|
public IEnumerable<KeyBinding> GenerateKeyBindingsFor(int columns)
|
2020-04-20 12:28:36 +00:00
|
|
|
{
|
2024-08-07 21:36:03 +00:00
|
|
|
ManiaAction currentAction = ActionStart;
|
2020-04-20 12:28:36 +00:00
|
|
|
|
|
|
|
var bindings = new List<KeyBinding>();
|
|
|
|
|
|
|
|
for (int i = LeftKeys.Length - columns / 2; i < LeftKeys.Length; i++)
|
2024-08-07 21:36:03 +00:00
|
|
|
bindings.Add(new KeyBinding(LeftKeys[i], currentAction++));
|
2020-04-20 12:28:36 +00:00
|
|
|
|
|
|
|
if (columns % 2 == 1)
|
2024-08-07 21:36:03 +00:00
|
|
|
bindings.Add(new KeyBinding(SpecialKey, currentAction++));
|
2020-04-20 12:28:36 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < columns / 2; i++)
|
2024-08-07 21:36:03 +00:00
|
|
|
bindings.Add(new KeyBinding(RightKeys[i], currentAction++));
|
2020-04-20 12:28:36 +00:00
|
|
|
|
|
|
|
return bindings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|