From b23b0a445be8628db6d019a61912df1519429d36 Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Fri, 13 Apr 2018 15:41:35 +0200 Subject: [PATCH 1/5] Add support for replay mods --- osu.Game.Rulesets.Catch/CatchRuleset.cs | 40 +++++++++++ osu.Game.Rulesets.Mania/ManiaRuleset.cs | 69 +++++++++++++++++++ osu.Game.Rulesets.Osu/OsuRuleset.cs | 49 +++++++++++++ osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 40 +++++++++++ osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 3 + osu.Game/Beatmaps/Legacy/LegacyMods.cs | 43 ++++++++++++ osu.Game/OsuGame.cs | 1 + osu.Game/Rulesets/Ruleset.cs | 3 + .../Scoring/Legacy/LegacyScoreParser.cs | 5 +- 9 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Beatmaps/Legacy/LegacyMods.cs diff --git a/osu.Game.Rulesets.Catch/CatchRuleset.cs b/osu.Game.Rulesets.Catch/CatchRuleset.cs index 8930b09089..87de1aed97 100644 --- a/osu.Game.Rulesets.Catch/CatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/CatchRuleset.cs @@ -12,6 +12,7 @@ using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Game.Rulesets.Catch.Replays; using osu.Game.Rulesets.Replays.Types; +using osu.Game.Beatmaps.Legacy; namespace osu.Game.Rulesets.Catch { @@ -29,6 +30,45 @@ namespace osu.Game.Rulesets.Catch new KeyBinding(InputKey.Shift, CatchAction.Dash), }; + public override IEnumerable GetLegacyModsFor(LegacyMods mods) + { + if (mods.HasFlag(LegacyMods.NightCore)) + yield return new CatchModNightcore(); + else if (mods.HasFlag(LegacyMods.DoubleTime)) + yield return new CatchModDoubleTime(); + + + if (mods.HasFlag(LegacyMods.AutoPlay)) + yield return new CatchModAutoplay(); + + if (mods.HasFlag(LegacyMods.Easy)) + yield return new CatchModEasy(); + + if (mods.HasFlag(LegacyMods.FlashLight)) + yield return new CatchModFlashlight(); + + if (mods.HasFlag(LegacyMods.HalfTime)) + yield return new CatchModHalfTime(); + + if (mods.HasFlag(LegacyMods.HardRock)) + yield return new CatchModHardRock(); + + if (mods.HasFlag(LegacyMods.Hidden)) + yield return new CatchModHidden(); + + if (mods.HasFlag(LegacyMods.NoFail)) + yield return new CatchModNoFail(); + + if (mods.HasFlag(LegacyMods.Perfect)) + yield return new CatchModPerfect(); + + if (mods.HasFlag(LegacyMods.Relax)) + yield return new CatchModRelax(); + + if (mods.HasFlag(LegacyMods.SuddenDeath)) + yield return new CatchModSuddenDeath(); + } + public override IEnumerable GetModsFor(ModType type) { switch (type) diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 7f37f55d14..4bd243664b 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -14,6 +14,7 @@ using osu.Framework.Input.Bindings; using osu.Game.Graphics; using osu.Game.Rulesets.Mania.Replays; using osu.Game.Rulesets.Replays.Types; +using osu.Game.Beatmaps.Legacy; namespace osu.Game.Rulesets.Mania { @@ -21,6 +22,74 @@ namespace osu.Game.Rulesets.Mania { public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new ManiaRulesetContainer(this, beatmap, isForCurrentRuleset); + public override IEnumerable GetLegacyModsFor(LegacyMods mods) + { + if (mods.HasFlag(LegacyMods.NightCore)) + yield return new ManiaModNightcore(); + else if (mods.HasFlag(LegacyMods.DoubleTime)) + yield return new ManiaModDoubleTime(); + + if (mods.HasFlag(LegacyMods.AutoPlay)) + yield return new ManiaModAutoplay(); + + if (mods.HasFlag(LegacyMods.Easy)) + yield return new ManiaModEasy(); + + if (mods.HasFlag(LegacyMods.FadeIn)) + yield return new ManiaModFadeIn(); + + if (mods.HasFlag(LegacyMods.FlashLight)) + 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(); + } + public override IEnumerable GetModsFor(ModType type) { switch (type) diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 37e6ec3817..7611f160ae 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -21,6 +21,7 @@ using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Replays; using osu.Game.Rulesets.Replays.Types; +using osu.Game.Beatmaps.Legacy; namespace osu.Game.Rulesets.Osu { @@ -66,6 +67,54 @@ namespace osu.Game.Rulesets.Osu }; } + public override IEnumerable GetLegacyModsFor(LegacyMods mods) + { + if (mods.HasFlag(LegacyMods.NightCore)) + yield return new OsuModNightcore(); + else if (mods.HasFlag(LegacyMods.DoubleTime)) + yield return new OsuModDoubleTime(); + + + if (mods.HasFlag(LegacyMods.AutoPilot)) + yield return new OsuModAutopilot(); + + if (mods.HasFlag(LegacyMods.AutoPlay)) + yield return new OsuModAutoplay(); + + if (mods.HasFlag(LegacyMods.Easy)) + yield return new OsuModEasy(); + + if (mods.HasFlag(LegacyMods.FlashLight)) + yield return new OsuModFlashlight(); + + if (mods.HasFlag(LegacyMods.HalfTime)) + yield return new OsuModHalfTime(); + + if (mods.HasFlag(LegacyMods.HardRock)) + yield return new OsuModHardRock(); + + if (mods.HasFlag(LegacyMods.Hidden)) + yield return new OsuModHidden(); + + if (mods.HasFlag(LegacyMods.NoFail)) + yield return new OsuModNoFail(); + + if (mods.HasFlag(LegacyMods.Perfect)) + yield return new OsuModPerfect(); + + if (mods.HasFlag(LegacyMods.Relax)) + yield return new OsuModRelax(); + + if (mods.HasFlag(LegacyMods.SpunOut)) + yield return new OsuModSpunOut(); + + if (mods.HasFlag(LegacyMods.SuddenDeath)) + yield return new OsuModSuddenDeath(); + + if (mods.HasFlag(LegacyMods.TargetPractice)) + yield return new OsuModTarget(); + } + public override IEnumerable GetModsFor(ModType type) { switch (type) diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index cb5e020601..1881e84fb0 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -12,6 +12,7 @@ using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Taiko.Replays; +using osu.Game.Beatmaps.Legacy; namespace osu.Game.Rulesets.Taiko { @@ -31,6 +32,45 @@ namespace osu.Game.Rulesets.Taiko new KeyBinding(InputKey.MouseRight, TaikoAction.RightRim), }; + public override IEnumerable GetLegacyModsFor(LegacyMods mods) + { + if (mods.HasFlag(LegacyMods.NightCore)) + yield return new TaikoModNightcore(); + else if (mods.HasFlag(LegacyMods.DoubleTime)) + yield return new TaikoModDoubleTime(); + + + if (mods.HasFlag(LegacyMods.AutoPlay)) + yield return new TaikoModAutoplay(); + + if (mods.HasFlag(LegacyMods.Easy)) + yield return new TaikoModEasy(); + + if (mods.HasFlag(LegacyMods.FlashLight)) + yield return new TaikoModFlashlight(); + + if (mods.HasFlag(LegacyMods.HalfTime)) + yield return new TaikoModHalfTime(); + + if (mods.HasFlag(LegacyMods.HardRock)) + yield return new TaikoModHardRock(); + + if (mods.HasFlag(LegacyMods.Hidden)) + yield return new TaikoModHidden(); + + if (mods.HasFlag(LegacyMods.NoFail)) + yield return new TaikoModNoFail(); + + if (mods.HasFlag(LegacyMods.Perfect)) + yield return new TaikoModPerfect(); + + if (mods.HasFlag(LegacyMods.Relax)) + yield return new TaikoModRelax(); + + if (mods.HasFlag(LegacyMods.SuddenDeath)) + yield return new TaikoModSuddenDeath(); + } + public override IEnumerable GetModsFor(ModType type) { switch (type) diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 0424ff84f1..4a33e5eb7e 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Textures; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; +using osu.Game.Beatmaps.Legacy; namespace osu.Game.Beatmaps { @@ -53,6 +54,8 @@ namespace osu.Game.Beatmaps { public override IEnumerable GetModsFor(ModType type) => new Mod[] { }; + public override IEnumerable GetLegacyModsFor(LegacyMods mods) => new Mod[] { }; + public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) { throw new NotImplementedException(); diff --git a/osu.Game/Beatmaps/Legacy/LegacyMods.cs b/osu.Game/Beatmaps/Legacy/LegacyMods.cs new file mode 100644 index 0000000000..2ac7324778 --- /dev/null +++ b/osu.Game/Beatmaps/Legacy/LegacyMods.cs @@ -0,0 +1,43 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; + +namespace osu.Game.Beatmaps.Legacy +{ + [Flags] + public enum LegacyMods + { + None = 0, + NoFail = 1, + Easy = 2, + TouchDevice = 4, + Hidden = 8, + HardRock = 16, + SuddenDeath = 32, + DoubleTime = 64, + Relax = 128, + HalfTime = 256, + NightCore = 512, + FlashLight = 1024, + AutoPlay = 2048, + SpunOut = 4096, + AutoPilot = 8192, + Perfect = 16384, + Key4 = 32768, + Key5 = 65536, + Key6 = 131072, + Key7 = 262144, + Key8 = 524288, + keyMod = 1015808,// k4+k5+k6+k7+k8 + FadeIn = 1048576, + Random = 2097152, + Cinema = 4194304, + TargetPractice = 8388608, + Key9 = 16777216, + Coop = 33554432, + Key1 = 67108864, + Key3 = 134217728, + Key2 = 268435456, + } +} diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index d1cf372067..6c35a2ecea 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -194,6 +194,7 @@ namespace osu.Game } Beatmap.Value = BeatmapManager.GetWorkingBeatmap(s.Beatmap); + Beatmap.Value.Mods.BindTo(new Bindable>(s.Mods)); menu.Push(new PlayerLoader(new ReplayPlayer(s.Replay))); } diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index c2af4d566c..f2cf813d38 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; +using osu.Game.Beatmaps.Legacy; namespace osu.Game.Rulesets { @@ -33,6 +34,8 @@ namespace osu.Game.Rulesets public abstract IEnumerable GetModsFor(ModType type); + public abstract IEnumerable GetLegacyModsFor(LegacyMods mods); + public Mod GetAutoplayMod() => GetAllMods().First(mod => mod is ModAutoplay); protected Ruleset(RulesetInfo rulesetInfo = null) diff --git a/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs b/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs index 5ee009ba98..806e8d2fdb 100644 --- a/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs +++ b/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs @@ -9,6 +9,9 @@ using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.Replays.Legacy; using osu.Game.Users; using SharpCompress.Compressors.LZMA; +using osu.Game.Beatmaps.Legacy; +using osu.Game.Rulesets.Mods; +using System.Linq; namespace osu.Game.Rulesets.Scoring.Legacy { @@ -64,7 +67,7 @@ namespace osu.Game.Rulesets.Scoring.Legacy /* score.Perfect = */ sr.ReadBoolean(); /* score.EnabledMods = (Mods)*/ - sr.ReadInt32(); + score.Mods = currentRuleset.GetLegacyModsFor((LegacyMods)sr.ReadInt32()).ToArray(); /* score.HpGraphString = */ sr.ReadString(); /* score.Date = */ From 73ba8e1c876d2e57bdda27e8c87ea0f39a63c4df Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Fri, 13 Apr 2018 16:10:01 +0200 Subject: [PATCH 2/5] CI: remove unused directive --- osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs b/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs index 806e8d2fdb..62d1cb3a32 100644 --- a/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs +++ b/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs @@ -10,7 +10,6 @@ using osu.Game.Rulesets.Replays.Legacy; using osu.Game.Users; using SharpCompress.Compressors.LZMA; using osu.Game.Beatmaps.Legacy; -using osu.Game.Rulesets.Mods; using System.Linq; namespace osu.Game.Rulesets.Scoring.Legacy From 3454ec1ca385d1725432d7322c98fc9dd1f6226f Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Sun, 15 Apr 2018 20:23:57 +0200 Subject: [PATCH 3/5] Set Value instead of BindTo --- osu.Game/OsuGame.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 18dc9f4ea1..f69135e5c9 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -196,7 +196,7 @@ namespace osu.Game } Beatmap.Value = BeatmapManager.GetWorkingBeatmap(s.Beatmap); - Beatmap.Value.Mods.BindTo(new Bindable>(s.Mods)); + Beatmap.Value.Mods.Value = s.Mods; menu.Push(new PlayerLoader(new ReplayPlayer(s.Replay))); } From 9b36cf2066d499f9ca0c57cb7741cee6db6cfc7f Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Mon, 16 Apr 2018 14:14:40 +0200 Subject: [PATCH 4/5] Review changes --- osu.Game.Rulesets.Catch/CatchRuleset.cs | 9 ++- osu.Game.Rulesets.Mania/ManiaRuleset.cs | 8 +-- osu.Game.Rulesets.Osu/OsuRuleset.cs | 13 ++-- osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 9 ++- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 2 - osu.Game/Beatmaps/Legacy/LegacyMods.cs | 59 +++++++++---------- osu.Game/Rulesets/Ruleset.cs | 7 ++- .../Scoring/Legacy/LegacyScoreParser.cs | 2 +- 8 files changed, 54 insertions(+), 55 deletions(-) diff --git a/osu.Game.Rulesets.Catch/CatchRuleset.cs b/osu.Game.Rulesets.Catch/CatchRuleset.cs index 87de1aed97..cfe0fc5cec 100644 --- a/osu.Game.Rulesets.Catch/CatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/CatchRuleset.cs @@ -30,21 +30,20 @@ namespace osu.Game.Rulesets.Catch new KeyBinding(InputKey.Shift, CatchAction.Dash), }; - public override IEnumerable GetLegacyModsFor(LegacyMods mods) + public override IEnumerable ConvertLegacyMods(LegacyMods mods) { - if (mods.HasFlag(LegacyMods.NightCore)) + if (mods.HasFlag(LegacyMods.Nightcore)) yield return new CatchModNightcore(); else if (mods.HasFlag(LegacyMods.DoubleTime)) yield return new CatchModDoubleTime(); - - if (mods.HasFlag(LegacyMods.AutoPlay)) + if (mods.HasFlag(LegacyMods.Autoplay)) yield return new CatchModAutoplay(); if (mods.HasFlag(LegacyMods.Easy)) yield return new CatchModEasy(); - if (mods.HasFlag(LegacyMods.FlashLight)) + if (mods.HasFlag(LegacyMods.Flashlight)) yield return new CatchModFlashlight(); if (mods.HasFlag(LegacyMods.HalfTime)) diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 4bd243664b..0546cbc174 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -22,14 +22,14 @@ namespace osu.Game.Rulesets.Mania { public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new ManiaRulesetContainer(this, beatmap, isForCurrentRuleset); - public override IEnumerable GetLegacyModsFor(LegacyMods mods) + public override IEnumerable ConvertLegacyMods(LegacyMods mods) { - if (mods.HasFlag(LegacyMods.NightCore)) + if (mods.HasFlag(LegacyMods.Nightcore)) yield return new ManiaModNightcore(); else if (mods.HasFlag(LegacyMods.DoubleTime)) yield return new ManiaModDoubleTime(); - if (mods.HasFlag(LegacyMods.AutoPlay)) + if (mods.HasFlag(LegacyMods.Autoplay)) yield return new ManiaModAutoplay(); if (mods.HasFlag(LegacyMods.Easy)) @@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Mania if (mods.HasFlag(LegacyMods.FadeIn)) yield return new ManiaModFadeIn(); - if (mods.HasFlag(LegacyMods.FlashLight)) + if (mods.HasFlag(LegacyMods.Flashlight)) yield return new ManiaModFlashlight(); if (mods.HasFlag(LegacyMods.HalfTime)) diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 7611f160ae..e0ecee97a3 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -67,24 +67,23 @@ namespace osu.Game.Rulesets.Osu }; } - public override IEnumerable GetLegacyModsFor(LegacyMods mods) + public override IEnumerable ConvertLegacyMods(LegacyMods mods) { - if (mods.HasFlag(LegacyMods.NightCore)) + if (mods.HasFlag(LegacyMods.Nightcore)) yield return new OsuModNightcore(); else if (mods.HasFlag(LegacyMods.DoubleTime)) yield return new OsuModDoubleTime(); - - if (mods.HasFlag(LegacyMods.AutoPilot)) + if (mods.HasFlag(LegacyMods.Autopilot)) yield return new OsuModAutopilot(); - if (mods.HasFlag(LegacyMods.AutoPlay)) + if (mods.HasFlag(LegacyMods.Autoplay)) yield return new OsuModAutoplay(); if (mods.HasFlag(LegacyMods.Easy)) yield return new OsuModEasy(); - if (mods.HasFlag(LegacyMods.FlashLight)) + if (mods.HasFlag(LegacyMods.Flashlight)) yield return new OsuModFlashlight(); if (mods.HasFlag(LegacyMods.HalfTime)) @@ -111,7 +110,7 @@ namespace osu.Game.Rulesets.Osu if (mods.HasFlag(LegacyMods.SuddenDeath)) yield return new OsuModSuddenDeath(); - if (mods.HasFlag(LegacyMods.TargetPractice)) + if (mods.HasFlag(LegacyMods.Target)) yield return new OsuModTarget(); } diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 1881e84fb0..06a8e44a14 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -32,21 +32,20 @@ namespace osu.Game.Rulesets.Taiko new KeyBinding(InputKey.MouseRight, TaikoAction.RightRim), }; - public override IEnumerable GetLegacyModsFor(LegacyMods mods) + public override IEnumerable ConvertLegacyMods(LegacyMods mods) { - if (mods.HasFlag(LegacyMods.NightCore)) + if (mods.HasFlag(LegacyMods.Nightcore)) yield return new TaikoModNightcore(); else if (mods.HasFlag(LegacyMods.DoubleTime)) yield return new TaikoModDoubleTime(); - - if (mods.HasFlag(LegacyMods.AutoPlay)) + if (mods.HasFlag(LegacyMods.Autoplay)) yield return new TaikoModAutoplay(); if (mods.HasFlag(LegacyMods.Easy)) yield return new TaikoModEasy(); - if (mods.HasFlag(LegacyMods.FlashLight)) + if (mods.HasFlag(LegacyMods.Flashlight)) yield return new TaikoModFlashlight(); if (mods.HasFlag(LegacyMods.HalfTime)) diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 4a33e5eb7e..48cee0d512 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -54,8 +54,6 @@ namespace osu.Game.Beatmaps { public override IEnumerable GetModsFor(ModType type) => new Mod[] { }; - public override IEnumerable GetLegacyModsFor(LegacyMods mods) => new Mod[] { }; - public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) { throw new NotImplementedException(); diff --git a/osu.Game/Beatmaps/Legacy/LegacyMods.cs b/osu.Game/Beatmaps/Legacy/LegacyMods.cs index 2ac7324778..0983610ba0 100644 --- a/osu.Game/Beatmaps/Legacy/LegacyMods.cs +++ b/osu.Game/Beatmaps/Legacy/LegacyMods.cs @@ -9,35 +9,34 @@ namespace osu.Game.Beatmaps.Legacy public enum LegacyMods { None = 0, - NoFail = 1, - Easy = 2, - TouchDevice = 4, - Hidden = 8, - HardRock = 16, - SuddenDeath = 32, - DoubleTime = 64, - Relax = 128, - HalfTime = 256, - NightCore = 512, - FlashLight = 1024, - AutoPlay = 2048, - SpunOut = 4096, - AutoPilot = 8192, - Perfect = 16384, - Key4 = 32768, - Key5 = 65536, - Key6 = 131072, - Key7 = 262144, - Key8 = 524288, - keyMod = 1015808,// k4+k5+k6+k7+k8 - FadeIn = 1048576, - Random = 2097152, - Cinema = 4194304, - TargetPractice = 8388608, - Key9 = 16777216, - Coop = 33554432, - Key1 = 67108864, - Key3 = 134217728, - Key2 = 268435456, + NoFail = 1 << 0, + Easy = 1 << 1, + TouchDevice = 1 << 2, + Hidden = 1 << 3, + HardRock = 1 << 4, + SuddenDeath = 1 << 5, + DoubleTime = 1 << 6, + Relax = 1 << 7, + HalfTime = 1 << 8, + Nightcore = 1 << 9, + Flashlight = 1 << 10, + Autoplay = 1 << 11, + SpunOut = 1 << 12, + Autopilot = 1 << 13, + Perfect = 1 << 14, + Key4 = 1 << 15, + Key5 = 1 << 16, + Key6 = 1 << 17, + Key7 = 1 << 18, + Key8 = 1 << 19, + FadeIn = 1 << 20, + Random = 1 << 21, + Cinema = 1 << 22, + Target = 1 << 23, + Key9 = 1 << 24, + KeyCoop = 1 << 25, + Key1 = 1 << 26, + Key3 = 1 << 27, + Key2 = 1 << 28, } } diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index f2cf813d38..cd1d030afe 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -34,7 +34,12 @@ namespace osu.Game.Rulesets public abstract IEnumerable GetModsFor(ModType type); - public abstract IEnumerable GetLegacyModsFor(LegacyMods mods); + /// + /// Converts mods from legacy enum values. Do not override if you're not a legacy ruleset. + /// + /// The legacy enum which will be converted + /// An enumerable of constructed s + public virtual IEnumerable ConvertLegacyMods(LegacyMods mods) => new Mod[] { }; public Mod GetAutoplayMod() => GetAllMods().First(mod => mod is ModAutoplay); diff --git a/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs b/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs index 62d1cb3a32..239f200e29 100644 --- a/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs +++ b/osu.Game/Rulesets/Scoring/Legacy/LegacyScoreParser.cs @@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Scoring.Legacy /* score.Perfect = */ sr.ReadBoolean(); /* score.EnabledMods = (Mods)*/ - score.Mods = currentRuleset.GetLegacyModsFor((LegacyMods)sr.ReadInt32()).ToArray(); + score.Mods = currentRuleset.ConvertLegacyMods((LegacyMods)sr.ReadInt32()).ToArray(); /* score.HpGraphString = */ sr.ReadString(); /* score.Date = */ From 1feba556ebee972cd812795bd2e0a6135de154e6 Mon Sep 17 00:00:00 2001 From: tgi74000 Date: Mon, 16 Apr 2018 14:25:43 +0200 Subject: [PATCH 5/5] CI: unused directive --- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 48cee0d512..0424ff84f1 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -8,7 +8,6 @@ using osu.Framework.Graphics.Textures; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; -using osu.Game.Beatmaps.Legacy; namespace osu.Game.Beatmaps {