diff --git a/osu.Game.Rulesets.Catch/CatchRuleset.cs b/osu.Game.Rulesets.Catch/CatchRuleset.cs index 69f22f7121..8d45ea8fa2 100644 --- a/osu.Game.Rulesets.Catch/CatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/CatchRuleset.cs @@ -20,24 +20,6 @@ namespace osu.Game.Rulesets.Catch { public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new CatchRulesetContainer(this, beatmap, isForCurrentRuleset); - public override IEnumerable GetAllMods() => new Mod[] - { - new CatchModEasy(), - new CatchModNoFail(), - new CatchModHalfTime(), - new CatchModDaycore(), - new CatchModHardRock(), - new CatchModSuddenDeath(), - new CatchModPerfect(), - new CatchModDoubleTime(), - new CatchModNightcore(), - new CatchModHidden(), - new CatchModFlashlight(), - new CatchModRelax(), - new ModAutoplay(), - new ModCinema() - }; - 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 3a7c072604..50ad6960ae 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -19,36 +19,6 @@ namespace osu.Game.Rulesets.Mania { public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new ManiaRulesetContainer(this, beatmap, isForCurrentRuleset); - public override IEnumerable GetAllMods() => new Mod[] - { - new ManiaModEasy(), - new ManiaModNoFail(), - new ManiaModHalfTime(), - new ManiaModDaycore(), - new ManiaModHardRock(), - new ManiaModSuddenDeath(), - new ManiaModPerfect(), - new ManiaModDoubleTime(), - new ManiaModNightcore(), - new ManiaModFadeIn(), - new ManiaModHidden(), - new ManiaModFlashlight(), - new ManiaModKey4(), - new ManiaModKey5(), - new ManiaModKey6(), - new ManiaModKey7(), - new ManiaModKey8(), - new ManiaModKey9(), - new ManiaModKey1(), - new ManiaModKey2(), - new ManiaModKey3(), - new ManiaModRandom(), - new ManiaModKeyCoop(), - new ModAutoplay(), - new ModCinema(), - new ManiaModGravity() - }; - 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 fbcb5e3abf..212c634aaf 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -24,27 +24,6 @@ namespace osu.Game.Rulesets.Osu { public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new OsuRulesetContainer(this, beatmap, isForCurrentRuleset); - public override IEnumerable GetAllMods() => new Mod[] - { - new OsuModEasy(), - new OsuModNoFail(), - new OsuModHalfTime(), - new OsuModDaycore(), - new OsuModHardRock(), - new OsuModSuddenDeath(), - new OsuModPerfect(), - new OsuModDoubleTime(), - new OsuModNightcore(), - new OsuModHidden(), - new OsuModFlashlight(), - new OsuModRelax(), - new OsuModAutopilot(), - new OsuModSpunOut(), - new OsuModAutoplay(), - new ModCinema(), - new OsuModTarget(), - }; - public override IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new[] { new BeatmapStatistic diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 3e126cec4e..4d4bbb7bc5 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -20,24 +20,6 @@ namespace osu.Game.Rulesets.Taiko { public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new TaikoRulesetContainer(this, beatmap, isForCurrentRuleset); - public override IEnumerable GetAllMods() => new Mod[] - { - new TaikoModEasy(), - new TaikoModNoFail(), - new TaikoModHalfTime(), - new TaikoModDaycore(), - new TaikoModHardRock(), - new TaikoModSuddenDeath(), - new TaikoModPerfect(), - new TaikoModDoubleTime(), - new TaikoModNightcore(), - new TaikoModHidden(), - new TaikoModFlashlight(), - new TaikoModRelax(), - new TaikoModAutoplay(), - new ModCinema() - }; - public override IEnumerable GetModsFor(ModType type) { switch (type) diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index f807b5828f..2fb9a568f8 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -58,8 +58,6 @@ namespace osu.Game.Beatmaps private class DummyRuleset : Ruleset { - public override IEnumerable GetAllMods() => new Mod[] { }; - public override IEnumerable GetModsFor(ModType type) => new Mod[] { }; public override Mod GetAutoplayMod() => new ModAutoplay(); diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index b6bcd48562..56a255eda5 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; +using System.Linq; using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -19,19 +21,29 @@ namespace osu.Game.Rulesets public virtual IEnumerable GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { }; - public abstract IEnumerable GetAllMods(); + public IEnumerable GetAllMods() + { + List modList = new List(); + + foreach (ModType type in Enum.GetValues(typeof(ModType))) + modList.AddRange(GetModsFor(type).SelectMany(mod => + { + var multiMod = mod as MultiMod; + + if (multiMod != null) + return multiMod.Mods; + + return new Mod[] { mod }; + })); + + return modList.ToArray(); + } public abstract IEnumerable GetModsFor(ModType type); public Mod GetModByShortenedName(string shortenedName) { - foreach(Mod mod in GetAllMods()) - { - if (string.Equals(mod.ShortenedName, shortenedName)) - return mod; - } - - return null; + return GetAllMods().First(mod => mod.ShortenedName == shortenedName); } public abstract Mod GetAutoplayMod(); diff --git a/osu.Game/Rulesets/Scoring/Score.cs b/osu.Game/Rulesets/Scoring/Score.cs index 0200e883ba..b9fe54677d 100644 --- a/osu.Game/Rulesets/Scoring/Score.cs +++ b/osu.Game/Rulesets/Scoring/Score.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Linq; using System.Collections.Generic; using Newtonsoft.Json; using osu.Game.Beatmaps; @@ -104,14 +105,7 @@ namespace osu.Game.Rulesets.Scoring private void handleModString() { - List modList = new List(); - - Ruleset rulesetInstance = Ruleset.CreateInstance(); - - foreach (string modShortenedName in modStrings) - modList.Add(rulesetInstance.GetModByShortenedName(modShortenedName)); - - Mods = modList.ToArray(); + Mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray(); } } } diff --git a/osu.Game/Rulesets/UI/ModIcon.cs b/osu.Game/Rulesets/UI/ModIcon.cs index 986d8c92dc..47a39d4644 100644 --- a/osu.Game/Rulesets/UI/ModIcon.cs +++ b/osu.Game/Rulesets/UI/ModIcon.cs @@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.UI private readonly SpriteIcon modIcon; private readonly SpriteIcon background; - private const float icon_size = 80; + private const float background_size = 80; public FontAwesome Icon { @@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.UI { Origin = Anchor.Centre, Anchor = Anchor.Centre, - Size = new Vector2(icon_size), + Size = new Vector2(background_size), Icon = FontAwesome.fa_osu_mod_bg, Shadow = true, }, @@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.UI Origin = Anchor.TopCentre, Anchor = Anchor.TopCentre, Colour = OsuColour.Gray(84), - Size = new Vector2(icon_size - 35), + Size = new Vector2(background_size - 35), Y = 25, Icon = mod.Icon }, diff --git a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs index 993186ffdf..fcd87363d6 100644 --- a/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs +++ b/osu.Game/Screens/Select/Leaderboards/LeaderboardScore.cs @@ -3,17 +3,18 @@ using OpenTK; using OpenTK.Graphics; +using osu.Framework; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Framework.Extensions.Color4Extensions; -using osu.Game.Rulesets.Mods; -using osu.Game.Users; -using osu.Framework; -using osu.Game.Rulesets.Scoring; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Scoring; +using osu.Game.Rulesets.UI; +using osu.Game.Users; namespace osu.Game.Screens.Select.Leaderboards { @@ -38,7 +39,7 @@ namespace osu.Game.Screens.Select.Leaderboards private readonly ScoreComponentLabel maxCombo; private readonly ScoreComponentLabel accuracy; private readonly Container flagBadgeContainer; - private readonly FillFlowContainer modsContainer; + private readonly FillFlowContainer modsContainer; private Visibility state; public Visibility State @@ -239,7 +240,7 @@ namespace osu.Game.Screens.Select.Leaderboards }, }, }, - modsContainer = new FillFlowContainer + modsContainer = new FillFlowContainer { Anchor = Anchor.BottomRight, Origin = Anchor.BottomRight, @@ -256,23 +257,11 @@ namespace osu.Game.Screens.Select.Leaderboards { foreach (Mod mod in Score.Mods) { - Color4 modColor; - - switch (mod.Type) + modsContainer.Add(new ModIcon(mod) { - default: - case ModType.DifficultyIncrease: - modColor = OsuColour.FromHex(@"ffcc22"); - break; - case ModType.DifficultyReduction: - modColor = OsuColour.FromHex(@"88b300"); - break; - case ModType.Special: - modColor = OsuColour.FromHex(@"66ccff"); - break; - } - - modsContainer.Add(new ScoreModIcon(mod.Icon, modColor)); + AutoSizeAxes = Axes.Both, + Scale = new Vector2(0.375f) + }); } } } @@ -341,36 +330,6 @@ namespace osu.Game.Screens.Select.Leaderboards } } - private class ScoreModIcon : Container - { - public ScoreModIcon(FontAwesome icon, Color4 colour) - { - AutoSizeAxes = Axes.Both; - - Children = new[] - { - new SpriteIcon - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Icon = FontAwesome.fa_osu_mod_bg, - Colour = colour, - Shadow = true, - Size = new Vector2(30), - }, - new SpriteIcon - { - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Icon = icon, - Colour = OsuColour.Gray(84), - Size = new Vector2(18), - Position = new Vector2(0f, 2f), - }, - }; - } - } - private class ScoreComponentLabel : Container { public ScoreComponentLabel(FontAwesome icon, string value)