2018-04-13 09:19:50 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Replays;
|
|
|
|
|
using osu.Game.Rulesets.Replays.Types;
|
2018-04-13 13:41:35 +00:00
|
|
|
|
using osu.Game.Beatmaps.Legacy;
|
2018-06-11 04:17:08 +00:00
|
|
|
|
using osu.Game.Configuration;
|
2018-06-11 05:36:19 +00:00
|
|
|
|
using osu.Game.Overlays.Settings;
|
2018-06-11 04:17:08 +00:00
|
|
|
|
using osu.Game.Rulesets.Configuration;
|
2018-05-15 08:38:04 +00:00
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
2018-06-07 07:08:37 +00:00
|
|
|
|
using osu.Game.Rulesets.Edit;
|
2018-04-19 13:04:12 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
2018-06-11 04:17:08 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Configuration;
|
2018-05-15 08:40:19 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Difficulty;
|
2018-06-07 07:08:37 +00:00
|
|
|
|
using osu.Game.Rulesets.Mania.Edit;
|
2018-05-15 16:24:53 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania
|
|
|
|
|
{
|
|
|
|
|
public class ManiaRuleset : Ruleset
|
|
|
|
|
{
|
2018-05-07 01:17:54 +00:00
|
|
|
|
public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap) => new ManiaRulesetContainer(this, beatmap);
|
2018-04-19 13:04:12 +00:00
|
|
|
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
2018-06-14 07:04:48 +00:00
|
|
|
|
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, Score score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
2018-06-07 07:08:37 +00:00
|
|
|
|
|
|
|
|
|
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-04-16 12:14:40 +00:00
|
|
|
|
public override IEnumerable<Mod> ConvertLegacyMods(LegacyMods mods)
|
2018-04-13 13:41:35 +00:00
|
|
|
|
{
|
2018-04-16 12:14:40 +00:00
|
|
|
|
if (mods.HasFlag(LegacyMods.Nightcore))
|
2018-04-13 13:41:35 +00:00
|
|
|
|
yield return new ManiaModNightcore();
|
|
|
|
|
else if (mods.HasFlag(LegacyMods.DoubleTime))
|
|
|
|
|
yield return new ManiaModDoubleTime();
|
|
|
|
|
|
2018-04-16 12:14:40 +00:00
|
|
|
|
if (mods.HasFlag(LegacyMods.Autoplay))
|
2018-04-13 13:41:35 +00:00
|
|
|
|
yield return new ManiaModAutoplay();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Easy))
|
|
|
|
|
yield return new ManiaModEasy();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.FadeIn))
|
|
|
|
|
yield return new ManiaModFadeIn();
|
|
|
|
|
|
2018-04-16 12:14:40 +00:00
|
|
|
|
if (mods.HasFlag(LegacyMods.Flashlight))
|
2018-04-13 13:41:35 +00:00
|
|
|
|
yield return new ManiaModFlashlight();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.HalfTime))
|
|
|
|
|
yield return new ManiaModHalfTime();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.HardRock))
|
|
|
|
|
yield return new ManiaModHardRock();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Hidden))
|
|
|
|
|
yield return new ManiaModHidden();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key1))
|
|
|
|
|
yield return new ManiaModKey1();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key2))
|
|
|
|
|
yield return new ManiaModKey2();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key3))
|
|
|
|
|
yield return new ManiaModKey3();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key4))
|
|
|
|
|
yield return new ManiaModKey4();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key5))
|
|
|
|
|
yield return new ManiaModKey5();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key6))
|
|
|
|
|
yield return new ManiaModKey6();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key7))
|
|
|
|
|
yield return new ManiaModKey7();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key8))
|
|
|
|
|
yield return new ManiaModKey8();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key9))
|
|
|
|
|
yield return new ManiaModKey9();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.NoFail))
|
|
|
|
|
yield return new ManiaModNoFail();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Perfect))
|
|
|
|
|
yield return new ManiaModPerfect();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Random))
|
|
|
|
|
yield return new ManiaModRandom();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.SuddenDeath))
|
|
|
|
|
yield return new ManiaModSuddenDeath();
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public override IEnumerable<Mod> GetModsFor(ModType type)
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case ModType.DifficultyReduction:
|
|
|
|
|
return new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModEasy(),
|
|
|
|
|
new ManiaModNoFail(),
|
2018-06-06 05:07:50 +00:00
|
|
|
|
new MultiMod(new ManiaModHalfTime(), new ManiaModDaycore()),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
};
|
|
|
|
|
case ModType.DifficultyIncrease:
|
|
|
|
|
return new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModHardRock(),
|
2018-06-06 05:07:50 +00:00
|
|
|
|
new MultiMod(new ManiaModSuddenDeath(), new ManiaModPerfect()),
|
|
|
|
|
new MultiMod(new ManiaModDoubleTime(), new ManiaModNightcore()),
|
|
|
|
|
new MultiMod(new ManiaModFadeIn(), new ManiaModHidden()),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
new ManiaModFlashlight(),
|
|
|
|
|
};
|
2018-07-31 09:00:42 +00:00
|
|
|
|
case ModType.Conversion:
|
2018-04-13 09:19:50 +00:00
|
|
|
|
return new Mod[]
|
|
|
|
|
{
|
2018-06-06 05:07:50 +00:00
|
|
|
|
new MultiMod(new ManiaModKey4(),
|
|
|
|
|
new ManiaModKey5(),
|
|
|
|
|
new ManiaModKey6(),
|
|
|
|
|
new ManiaModKey7(),
|
|
|
|
|
new ManiaModKey8(),
|
|
|
|
|
new ManiaModKey9(),
|
|
|
|
|
new ManiaModKey1(),
|
|
|
|
|
new ManiaModKey2(),
|
|
|
|
|
new ManiaModKey3()),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
new ManiaModRandom(),
|
|
|
|
|
new ManiaModDualStages(),
|
|
|
|
|
new ManiaModMirror(),
|
2018-07-31 09:00:42 +00:00
|
|
|
|
};
|
|
|
|
|
case ModType.Automation:
|
|
|
|
|
return new Mod[]
|
|
|
|
|
{
|
2018-06-06 05:07:50 +00:00
|
|
|
|
new MultiMod(new ManiaModAutoplay(), new ModCinema()),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
};
|
|
|
|
|
default:
|
|
|
|
|
return new Mod[] { };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Description => "osu!mania";
|
|
|
|
|
|
|
|
|
|
public override string ShortName => "mania";
|
|
|
|
|
|
|
|
|
|
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_mania_o };
|
|
|
|
|
|
2018-06-14 06:54:05 +00:00
|
|
|
|
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new ManiaDifficultyCalculator(this, beatmap);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
public override int? LegacyID => 3;
|
|
|
|
|
|
|
|
|
|
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new ManiaReplayFrame();
|
|
|
|
|
|
2018-06-11 04:17:08 +00:00
|
|
|
|
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new ManiaConfigManager(settings, RulesetInfo);
|
|
|
|
|
|
2018-06-11 05:36:19 +00:00
|
|
|
|
public override RulesetSettingsSubsection CreateSettings() => new ManiaSettingsSubsection(this);
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public ManiaRuleset(RulesetInfo rulesetInfo = null)
|
|
|
|
|
: base(rulesetInfo)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<int> AvailableVariants
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i <= 9; i++)
|
|
|
|
|
yield return (int)PlayfieldType.Single + i;
|
|
|
|
|
for (int i = 2; i <= 18; i += 2)
|
|
|
|
|
yield return (int)PlayfieldType.Dual + i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0)
|
|
|
|
|
{
|
|
|
|
|
switch (getPlayfieldType(variant))
|
|
|
|
|
{
|
|
|
|
|
case PlayfieldType.Single:
|
|
|
|
|
return new VariantMappingGenerator
|
|
|
|
|
{
|
|
|
|
|
LeftKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.A,
|
|
|
|
|
InputKey.S,
|
|
|
|
|
InputKey.D,
|
|
|
|
|
InputKey.F
|
|
|
|
|
},
|
|
|
|
|
RightKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.J,
|
|
|
|
|
InputKey.K,
|
|
|
|
|
InputKey.L,
|
|
|
|
|
InputKey.Semicolon
|
|
|
|
|
},
|
|
|
|
|
SpecialKey = InputKey.Space,
|
|
|
|
|
SpecialAction = ManiaAction.Special1,
|
|
|
|
|
NormalActionStart = ManiaAction.Key1,
|
|
|
|
|
}.GenerateKeyBindingsFor(variant, out _);
|
|
|
|
|
case PlayfieldType.Dual:
|
|
|
|
|
int keys = getDualStageKeyCount(variant);
|
|
|
|
|
|
|
|
|
|
var stage1Bindings = new VariantMappingGenerator
|
|
|
|
|
{
|
|
|
|
|
LeftKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.Number1,
|
|
|
|
|
InputKey.Number2,
|
|
|
|
|
InputKey.Number3,
|
|
|
|
|
InputKey.Number4,
|
|
|
|
|
},
|
|
|
|
|
RightKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.Z,
|
|
|
|
|
InputKey.X,
|
|
|
|
|
InputKey.C,
|
|
|
|
|
InputKey.V
|
|
|
|
|
},
|
|
|
|
|
SpecialKey = InputKey.Tilde,
|
|
|
|
|
SpecialAction = ManiaAction.Special1,
|
|
|
|
|
NormalActionStart = ManiaAction.Key1
|
|
|
|
|
}.GenerateKeyBindingsFor(keys, out var nextNormal);
|
|
|
|
|
|
|
|
|
|
var stage2Bindings = new VariantMappingGenerator
|
|
|
|
|
{
|
|
|
|
|
LeftKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.Number7,
|
|
|
|
|
InputKey.Number8,
|
|
|
|
|
InputKey.Number9,
|
|
|
|
|
InputKey.Number0
|
|
|
|
|
},
|
|
|
|
|
RightKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.O,
|
|
|
|
|
InputKey.P,
|
|
|
|
|
InputKey.BracketLeft,
|
|
|
|
|
InputKey.BracketRight
|
|
|
|
|
},
|
|
|
|
|
SpecialKey = InputKey.BackSlash,
|
|
|
|
|
SpecialAction = ManiaAction.Special2,
|
|
|
|
|
NormalActionStart = nextNormal
|
|
|
|
|
}.GenerateKeyBindingsFor(keys, out _);
|
|
|
|
|
|
|
|
|
|
return stage1Bindings.Concat(stage2Bindings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new KeyBinding[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetVariantName(int variant)
|
|
|
|
|
{
|
|
|
|
|
switch (getPlayfieldType(variant))
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
return $"{variant}K";
|
|
|
|
|
case PlayfieldType.Dual:
|
|
|
|
|
{
|
|
|
|
|
var keys = getDualStageKeyCount(variant);
|
|
|
|
|
return $"{keys}K + {keys}K";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finds the number of keys for each stage in a <see cref="PlayfieldType.Dual"/> variant.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="variant">The variant.</param>
|
|
|
|
|
private int getDualStageKeyCount(int variant) => (variant - (int)PlayfieldType.Dual) / 2;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finds the <see cref="PlayfieldType"/> that corresponds to a variant value.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="variant">The variant value.</param>
|
|
|
|
|
/// <returns>The <see cref="PlayfieldType"/> that corresponds to <paramref name="variant"/>.</returns>
|
|
|
|
|
private PlayfieldType getPlayfieldType(int variant)
|
|
|
|
|
{
|
|
|
|
|
return (PlayfieldType)Enum.GetValues(typeof(PlayfieldType)).Cast<int>().OrderByDescending(i => i).First(v => variant >= v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private 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>
|
|
|
|
|
/// The <see cref="ManiaAction"/> at which the normal columns should begin.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ManiaAction NormalActionStart;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The <see cref="ManiaAction"/> for the special column.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ManiaAction SpecialAction;
|
|
|
|
|
|
|
|
|
|
/// <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>
|
|
|
|
|
/// <param name="nextNormalAction">The next <see cref="ManiaAction"/> to use for normal columns.</param>
|
|
|
|
|
/// <returns>The keybindings.</returns>
|
|
|
|
|
public IEnumerable<KeyBinding> GenerateKeyBindingsFor(int columns, out ManiaAction nextNormalAction)
|
|
|
|
|
{
|
|
|
|
|
ManiaAction currentNormalAction = NormalActionStart;
|
|
|
|
|
|
|
|
|
|
var bindings = new List<KeyBinding>();
|
|
|
|
|
|
|
|
|
|
for (int i = LeftKeys.Length - columns / 2; i < LeftKeys.Length; i++)
|
|
|
|
|
bindings.Add(new KeyBinding(LeftKeys[i], currentNormalAction++));
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < columns / 2; i++)
|
|
|
|
|
bindings.Add(new KeyBinding(RightKeys[i], currentNormalAction++));
|
|
|
|
|
|
|
|
|
|
if (columns % 2 == 1)
|
|
|
|
|
bindings.Add(new KeyBinding(SpecialKey, SpecialAction));
|
|
|
|
|
|
|
|
|
|
nextNormalAction = currentNormalAction;
|
|
|
|
|
return bindings;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum PlayfieldType
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Columns are grouped into a single stage.
|
|
|
|
|
/// Number of columns in this stage lies at (item - Single).
|
|
|
|
|
/// </summary>
|
|
|
|
|
Single = 0,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Columns are grouped into two stages.
|
|
|
|
|
/// Overall number of columns lies at (item - Dual), further computation is required for
|
|
|
|
|
/// number of columns in each individual stage.
|
|
|
|
|
/// </summary>
|
|
|
|
|
Dual = 1000,
|
|
|
|
|
}
|
|
|
|
|
}
|