diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 04245534f5..befa657715 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -124,9 +124,9 @@ public override IEnumerable AvailableVariants get { for (int i = 1; i <= 9; i++) - yield return (int)ManiaVariantType.Solo + i; + yield return (int)ManiaKeyBindingVariantType.Solo + i; for (int i = 2; i <= 18; i++) - yield return (int)ManiaVariantType.Coop + i; + yield return (int)ManiaKeyBindingVariantType.Coop + i; // Todo: Versus mode } } @@ -135,7 +135,7 @@ public override IEnumerable GetDefaultKeyBindings(int variant = 0) { switch (getVariantType(variant)) { - case ManiaVariantType.Solo: + case ManiaKeyBindingVariantType.Solo: return new VariantMappingGenerator { LeftKeys = new[] @@ -156,8 +156,8 @@ public override IEnumerable GetDefaultKeyBindings(int variant = 0) SpecialAction = ManiaAction.Special1, NormalActionStart = ManiaAction.Key1, }.GenerateKeyBindingsFor(variant); - case ManiaVariantType.Coop: - case ManiaVariantType.Versus: + case ManiaKeyBindingVariantType.Coop: + case ManiaKeyBindingVariantType.Versus: getMultiVariantKeyCounts(variant, out int p1K, out int p2K); var player1Bindings = new VariantMappingGenerator @@ -199,7 +199,7 @@ public override IEnumerable GetDefaultKeyBindings(int variant = 0) }, SpecialKey = InputKey.BackSlash, SpecialAction = ManiaAction.Special2, - NormalActionStart = ManiaAction.Key10 + NormalActionStart = ManiaAction.Key1 + p1K }.GenerateKeyBindingsFor(p2K); return player1Bindings.Concat(player2Bindings); @@ -213,14 +213,14 @@ public override string GetVariantName(int variant) switch (getVariantType(variant)) { default: - case ManiaVariantType.Solo: + case ManiaKeyBindingVariantType.Solo: return $"{variant}K"; - case ManiaVariantType.Coop: + case ManiaKeyBindingVariantType.Coop: { getMultiVariantKeyCounts(variant, out int p1K, out int p2K); return $"{p1K}K + {p2K}K"; } - case ManiaVariantType.Versus: + case ManiaKeyBindingVariantType.Versus: { getMultiVariantKeyCounts(variant, out int p1K, out int p2K); return $"{p1K}K Vs. {p2K}K"; @@ -229,7 +229,7 @@ public override string GetVariantName(int variant) } /// - /// Finds the number of keys for each player in or . + /// Finds the number of keys for each player in or . /// /// The variant. /// The number of keys for player 1. @@ -241,16 +241,16 @@ private void getMultiVariantKeyCounts(int variant, out int player1Keys, out int switch (getVariantType(variant)) { - case ManiaVariantType.Coop: + case ManiaKeyBindingVariantType.Coop: { - int totalKeys = variant - (int)ManiaVariantType.Coop; + int totalKeys = variant - (int)ManiaKeyBindingVariantType.Coop; player1Keys = (int)Math.Ceiling(totalKeys / 2f); player2Keys = (int)Math.Floor(totalKeys / 2f); break; } - case ManiaVariantType.Versus: + case ManiaKeyBindingVariantType.Versus: { - int totalKeys = variant - (int)ManiaVariantType.Versus; + int totalKeys = variant - (int)ManiaKeyBindingVariantType.Versus; player1Keys = totalKeys; player2Keys = totalKeys; break; @@ -259,13 +259,13 @@ private void getMultiVariantKeyCounts(int variant, out int player1Keys, out int } /// - /// Finds the that corresponds to a variant value. + /// Finds the that corresponds to a variant value. /// /// The variant value. - /// The that corresponds to . - private ManiaVariantType getVariantType(int variant) + /// The that corresponds to . + private ManiaKeyBindingVariantType getVariantType(int variant) { - return (ManiaVariantType)Enum.GetValues(typeof(ManiaVariantType)).Cast().OrderByDescending(i => i).First(v => variant > v); + return (ManiaKeyBindingVariantType)Enum.GetValues(typeof(ManiaKeyBindingVariantType)).Cast().OrderByDescending(i => i).First(v => variant >= v); } } @@ -320,7 +320,7 @@ public IEnumerable GenerateKeyBindingsFor(int columns) } } - public enum ManiaVariantType + public enum ManiaKeyBindingVariantType { /// /// Solo play keybinding variant (single stage). diff --git a/osu.Game.Rulesets.Mania/Mods/IKeyBindingMod.cs b/osu.Game.Rulesets.Mania/Mods/IKeyBindingMod.cs new file mode 100644 index 0000000000..585db9e340 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Mods/IKeyBindingMod.cs @@ -0,0 +1,13 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Mania.Mods +{ + public interface IKeyBindingMod + { + /// + /// The keybinding variant which this requires. + /// + ManiaKeyBindingVariantType Variant { get; } + } +} diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModKeyCoop.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModKeyCoop.cs index 5fbf59e5e6..382eea589c 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModKeyCoop.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModKeyCoop.cs @@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Mania.Mods { - public class ManiaModKeyCoop : Mod, IApplicableToBeatmapConverter, IApplicableToRulesetContainer + public class ManiaModKeyCoop : Mod, IKeyBindingMod, IApplicableToBeatmapConverter, IApplicableToRulesetContainer { public override string Name => "KeyCoop"; public override string ShortenedName => "2P"; @@ -44,5 +44,7 @@ public void ApplyToRulesetContainer(RulesetContainer rulesetCont mrc.Beatmap.Stages = newDefinitions; } + + public ManiaKeyBindingVariantType Variant => ManiaKeyBindingVariantType.Coop; } } diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 3a3aaa0e03..db881c5ba2 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -11,6 +11,7 @@ using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Mania.Beatmaps; +using osu.Game.Rulesets.Mania.Mods; using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects.Drawables; using osu.Game.Rulesets.Mania.Replays; @@ -76,7 +77,11 @@ private void load() public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor(this); - public override PassThroughInputManager CreateInputManager() => new ManiaInputManager(Ruleset.RulesetInfo, Beatmap.TotalColumns); + public override PassThroughInputManager CreateInputManager() + { + var variantType = Mods.OfType().FirstOrDefault()?.Variant ?? ManiaKeyBindingVariantType.Solo; + return new ManiaInputManager(Ruleset.RulesetInfo, (int)variantType + Beatmap.TotalColumns); + } protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(IsForCurrentRuleset, WorkingBeatmap.Beatmap); diff --git a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj index ae29484161..82202df923 100644 --- a/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj +++ b/osu.Game.Rulesets.Mania/osu.Game.Rulesets.Mania.csproj @@ -64,6 +64,7 @@ +