mirror of https://github.com/ppy/osu
Make variant keybindings work
This commit is contained in:
parent
561786c5ef
commit
8a7892b66a
|
@ -124,9 +124,9 @@ public override IEnumerable<int> 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<KeyBinding> 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<KeyBinding> 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<KeyBinding> 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)
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the number of keys for each player in <see cref="ManiaVariantType.Coop"/> or <see cref="ManiaVariantType.Versus"/>.
|
||||
/// Finds the number of keys for each player in <see cref="ManiaKeyBindingVariantType.Coop"/> or <see cref="ManiaKeyBindingVariantType.Versus"/>.
|
||||
/// </summary>
|
||||
/// <param name="variant">The variant.</param>
|
||||
/// <param name="player1Keys">The number of keys for player 1.</param>
|
||||
|
@ -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
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the <see cref="ManiaVariantType"/> that corresponds to a variant value.
|
||||
/// Finds the <see cref="ManiaKeyBindingVariantType"/> that corresponds to a variant value.
|
||||
/// </summary>
|
||||
/// <param name="variant">The variant value.</param>
|
||||
/// <returns>The <see cref="ManiaVariantType"/> that corresponds to <paramref name="variant"/>.</returns>
|
||||
private ManiaVariantType getVariantType(int variant)
|
||||
/// <returns>The <see cref="ManiaKeyBindingVariantType"/> that corresponds to <paramref name="variant"/>.</returns>
|
||||
private ManiaKeyBindingVariantType getVariantType(int variant)
|
||||
{
|
||||
return (ManiaVariantType)Enum.GetValues(typeof(ManiaVariantType)).Cast<int>().OrderByDescending(i => i).First(v => variant > v);
|
||||
return (ManiaKeyBindingVariantType)Enum.GetValues(typeof(ManiaKeyBindingVariantType)).Cast<int>().OrderByDescending(i => i).First(v => variant >= v);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ public IEnumerable<KeyBinding> GenerateKeyBindingsFor(int columns)
|
|||
}
|
||||
}
|
||||
|
||||
public enum ManiaVariantType
|
||||
public enum ManiaKeyBindingVariantType
|
||||
{
|
||||
/// <summary>
|
||||
/// Solo play keybinding variant (single stage).
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public interface IKeyBindingMod
|
||||
{
|
||||
/// <summary>
|
||||
/// The keybinding variant which this <see cref="IKeyBindingMod"/> requires.
|
||||
/// </summary>
|
||||
ManiaKeyBindingVariantType Variant { get; }
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public class ManiaModKeyCoop : Mod, IApplicableToBeatmapConverter<ManiaHitObject>, IApplicableToRulesetContainer<ManiaHitObject>
|
||||
public class ManiaModKeyCoop : Mod, IKeyBindingMod, IApplicableToBeatmapConverter<ManiaHitObject>, IApplicableToRulesetContainer<ManiaHitObject>
|
||||
{
|
||||
public override string Name => "KeyCoop";
|
||||
public override string ShortenedName => "2P";
|
||||
|
@ -44,5 +44,7 @@ public void ApplyToRulesetContainer(RulesetContainer<ManiaHitObject> rulesetCont
|
|||
|
||||
mrc.Beatmap.Stages = newDefinitions;
|
||||
}
|
||||
|
||||
public ManiaKeyBindingVariantType Variant => ManiaKeyBindingVariantType.Coop;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<IKeyBindingMod>().FirstOrDefault()?.Variant ?? ManiaKeyBindingVariantType.Solo;
|
||||
return new ManiaInputManager(Ruleset.RulesetInfo, (int)variantType + Beatmap.TotalColumns);
|
||||
}
|
||||
|
||||
protected override BeatmapConverter<ManiaHitObject> CreateBeatmapConverter() => new ManiaBeatmapConverter(IsForCurrentRuleset, WorkingBeatmap.Beatmap);
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
<Compile Include="Judgements\HoldNoteTickJudgement.cs" />
|
||||
<Compile Include="Judgements\ManiaJudgement.cs" />
|
||||
<Compile Include="ManiaDifficultyCalculator.cs" />
|
||||
<Compile Include="Mods\IKeyBindingMod.cs" />
|
||||
<Compile Include="Mods\ManiaKeyMod.cs" />
|
||||
<Compile Include="Mods\ManiaModAutoplay.cs" />
|
||||
<Compile Include="Mods\ManiaModDaycore.cs" />
|
||||
|
|
Loading…
Reference in New Issue