From 2ed5cf7c91112f9263dc41b5b1f17d6370f9cf39 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 30 Jan 2017 13:35:40 +0900 Subject: [PATCH] Hook up icons better. --- osu.Game.Modes.Catch/CatchRuleset.cs | 3 +++ osu.Game.Modes.Mania/ManiaRuleset.cs | 3 +++ osu.Game.Modes.Osu/OsuRuleset.cs | 2 ++ osu.Game.Modes.Taiko/TaikoRuleset.cs | 3 +++ osu.Game/Beatmaps/Drawables/BeatmapGroup.cs | 2 ++ osu.Game/Beatmaps/Drawables/BeatmapPanel.cs | 3 ++- osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs | 15 +++++++++------ osu.Game/Beatmaps/Drawables/DifficultyIcon.cs | 8 +++++--- osu.Game/Modes/Ruleset.cs | 5 ++--- osu.Game/Overlays/Toolbar/ToolbarModeButton.cs | 14 +------------- 10 files changed, 32 insertions(+), 26 deletions(-) diff --git a/osu.Game.Modes.Catch/CatchRuleset.cs b/osu.Game.Modes.Catch/CatchRuleset.cs index 9ee0e2c4c3..cebc7967c4 100644 --- a/osu.Game.Modes.Catch/CatchRuleset.cs +++ b/osu.Game.Modes.Catch/CatchRuleset.cs @@ -2,6 +2,7 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Game.Graphics; using osu.Game.Modes.Catch.UI; using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.Objects; @@ -18,6 +19,8 @@ namespace osu.Game.Modes.Catch protected override PlayMode PlayMode => PlayMode.Catch; + public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o; + public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null; public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); diff --git a/osu.Game.Modes.Mania/ManiaRuleset.cs b/osu.Game.Modes.Mania/ManiaRuleset.cs index 6671b0efaf..be444adb99 100644 --- a/osu.Game.Modes.Mania/ManiaRuleset.cs +++ b/osu.Game.Modes.Mania/ManiaRuleset.cs @@ -2,6 +2,7 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Game.Graphics; using osu.Game.Modes.Mania.UI; using osu.Game.Modes.Objects; using osu.Game.Modes.Osu; @@ -19,6 +20,8 @@ namespace osu.Game.Modes.Mania protected override PlayMode PlayMode => PlayMode.Mania; + public override FontAwesome Icon => FontAwesome.fa_osu_mania_o; + public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null; public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); diff --git a/osu.Game.Modes.Osu/OsuRuleset.cs b/osu.Game.Modes.Osu/OsuRuleset.cs index b46036fd48..76e3bacb65 100644 --- a/osu.Game.Modes.Osu/OsuRuleset.cs +++ b/osu.Game.Modes.Osu/OsuRuleset.cs @@ -34,6 +34,8 @@ namespace osu.Game.Modes.Osu } }; + public override FontAwesome Icon => FontAwesome.fa_osu_osu_o; + public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => new OsuScoreProcessor(hitObjectCount); diff --git a/osu.Game.Modes.Taiko/TaikoRuleset.cs b/osu.Game.Modes.Taiko/TaikoRuleset.cs index b8a066bc8b..f844db0169 100644 --- a/osu.Game.Modes.Taiko/TaikoRuleset.cs +++ b/osu.Game.Modes.Taiko/TaikoRuleset.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using osu.Game.Graphics; using osu.Game.Modes.Objects; using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.UI; @@ -19,6 +20,8 @@ namespace osu.Game.Modes.Taiko protected override PlayMode PlayMode => PlayMode.Taiko; + public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o; + public override ScoreProcessor CreateScoreProcessor(int hitObjectCount) => null; public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser(); diff --git a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs index 6c1d04909e..9efefaf8c3 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapGroup.cs @@ -74,6 +74,8 @@ namespace osu.Game.Beatmaps.Drawables StartRequested = p => { StartRequested?.Invoke(p.Beatmap); }, RelativeSizeAxes = Axes.X, }).ToList(); + + Header.AddDifficultyIcons(BeatmapPanels); } private void headerGainedSelection(BeatmapSetHeader panel) diff --git a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs index ed5db58418..220aa1f56d 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapPanel.cs @@ -17,6 +17,7 @@ using osu.Game.Graphics.UserInterface; using OpenTK; using OpenTK.Graphics; using osu.Framework.Input; +using osu.Game.Modes; namespace osu.Game.Beatmaps.Drawables { @@ -83,7 +84,7 @@ namespace osu.Game.Beatmaps.Drawables Origin = Anchor.CentreLeft, Children = new Drawable[] { - new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)) + new DifficultyIcon(beatmap) { Scale = new Vector2(1.8f), Anchor = Anchor.CentreLeft, diff --git a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs index 99942de133..b15942c5bb 100644 --- a/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs +++ b/osu.Game/Beatmaps/Drawables/BeatmapSetHeader.cs @@ -2,6 +2,7 @@ //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -23,6 +24,7 @@ namespace osu.Game.Beatmaps.Drawables private OsuConfigManager config; private Bindable preferUnicode; private WorkingBeatmap beatmap; + private FlowContainer difficultyIcons; public BeatmapSetHeader(WorkingBeatmap beatmap) { @@ -56,15 +58,10 @@ namespace osu.Game.Beatmaps.Drawables TextSize = 17, Shadow = true, }, - new FlowContainer + difficultyIcons = new FlowContainer { Margin = new MarginPadding { Top = 5 }, AutoSizeAxes = Axes.Both, - Children = new[] - { - new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(159, 198, 0, 255)), - new DifficultyIcon(FontAwesome.fa_dot_circle_o, new Color4(246, 101, 166, 255)), - } } } } @@ -177,5 +174,11 @@ namespace osu.Game.Beatmaps.Drawables }); } } + + public void AddDifficultyIcons(IEnumerable panels) + { + foreach (var p in panels) + difficultyIcons.Add(new DifficultyIcon(p.Beatmap)); + } } } \ No newline at end of file diff --git a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs index 4bb02d53c4..460af12d65 100644 --- a/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs +++ b/osu.Game/Beatmaps/Drawables/DifficultyIcon.cs @@ -3,7 +3,9 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Database; using osu.Game.Graphics; +using osu.Game.Modes; using OpenTK; using OpenTK.Graphics; @@ -11,7 +13,7 @@ namespace osu.Game.Beatmaps.Drawables { class DifficultyIcon : Container { - public DifficultyIcon(FontAwesome icon, Color4 color) + public DifficultyIcon(BeatmapInfo beatmap) { const float size = 20; Size = new Vector2(size); @@ -21,8 +23,8 @@ namespace osu.Game.Beatmaps.Drawables { Anchor = Anchor.Centre, TextSize = size, - Colour = color, - Icon = icon + Colour = new Color4(159, 198, 0, 255), + Icon = Ruleset.GetRuleset(beatmap.Mode).Icon } }; } diff --git a/osu.Game/Modes/Ruleset.cs b/osu.Game/Modes/Ruleset.cs index 3f11bf8aef..a587f82daa 100644 --- a/osu.Game/Modes/Ruleset.cs +++ b/osu.Game/Modes/Ruleset.cs @@ -4,11 +4,8 @@ using System.Collections.Generic; using osu.Game.Modes.Objects; using osu.Game.Modes.UI; -using System.Reflection; -using osu.Framework.Extensions; using System; using System.Collections.Concurrent; -using System.Linq; using osu.Game.Beatmaps; using osu.Game.Graphics; @@ -39,6 +36,8 @@ namespace osu.Game.Modes protected abstract PlayMode PlayMode { get; } + public virtual FontAwesome Icon => FontAwesome.fa_question_circle; + public static Ruleset GetRuleset(PlayMode mode) { Type type; diff --git a/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs b/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs index 60ce228164..84c2a390aa 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarModeButton.cs @@ -3,7 +3,6 @@ using osu.Framework.Extensions; using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; using osu.Game.Modes; using OpenTK.Graphics; @@ -20,7 +19,7 @@ namespace osu.Game.Overlays.Toolbar mode = value; TooltipMain = mode.GetDescription(); TooltipSub = $"Play some {mode.GetDescription()}"; - Icon = getModeIcon(mode); + Icon = Ruleset.GetRuleset(mode).Icon; } } @@ -48,17 +47,6 @@ namespace osu.Game.Overlays.Toolbar } } - private FontAwesome getModeIcon(PlayMode mode) - { - switch (mode) - { - default: return FontAwesome.fa_osu_osu_o; - case PlayMode.Taiko: return FontAwesome.fa_osu_taiko_o; - case PlayMode.Catch: return FontAwesome.fa_osu_fruits_o; - case PlayMode.Mania: return FontAwesome.fa_osu_mania_o; - } - } - protected override void LoadComplete() { base.LoadComplete();