diff --git a/osu.Game/Rulesets/UI/HudOverlay.cs b/osu.Game/Rulesets/UI/HudOverlay.cs index 47cf157732..9bd900da4b 100644 --- a/osu.Game/Rulesets/UI/HudOverlay.cs +++ b/osu.Game/Rulesets/UI/HudOverlay.cs @@ -27,6 +27,7 @@ namespace osu.Game.Rulesets.UI public readonly RollingCounter AccuracyCounter; public readonly HealthDisplay HealthDisplay; public readonly SongProgress Progress; + public readonly ModsContainer ModsContainer; private Bindable showKeyCounter; private Bindable showHud; @@ -39,6 +40,7 @@ namespace osu.Game.Rulesets.UI protected abstract ScoreCounter CreateScoreCounter(); protected abstract HealthDisplay CreateHealthDisplay(); protected abstract SongProgress CreateProgress(); + protected abstract ModsContainer CreateModsContainer(); protected HudOverlay() { @@ -56,6 +58,7 @@ namespace osu.Game.Rulesets.UI AccuracyCounter = CreateAccuracyCounter(), HealthDisplay = CreateHealthDisplay(), Progress = CreateProgress(), + ModsContainer = CreateModsContainer(), } }); } diff --git a/osu.Game/Rulesets/UI/StandardHudOverlay.cs b/osu.Game/Rulesets/UI/StandardHudOverlay.cs index c68e29f98a..a51a1ba434 100644 --- a/osu.Game/Rulesets/UI/StandardHudOverlay.cs +++ b/osu.Game/Rulesets/UI/StandardHudOverlay.cs @@ -64,7 +64,15 @@ namespace osu.Game.Rulesets.UI RelativeSizeAxes = Axes.X, }; - [BackgroundDependencyLoader] + protected override ModsContainer CreateModsContainer() => new ModsContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Position = new Vector2(0, 30), + }; + + [BackgroundDependencyLoader] private void load(OsuColour colours) { ComboCounter.AccentColour = colours.BlueLighter; diff --git a/osu.Game/Screens/Play/ModsContainer.cs b/osu.Game/Screens/Play/ModsContainer.cs new file mode 100644 index 0000000000..6ee7292dae --- /dev/null +++ b/osu.Game/Screens/Play/ModsContainer.cs @@ -0,0 +1,88 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.UI; +using osu.Framework.Graphics; +using OpenTK.Graphics; +using osu.Game.Graphics; +using osu.Framework.Allocation; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Screens.Play +{ + public class ModsContainer : Container + { + private readonly FillFlowContainer iconsContainer; + + private bool showMods; + public bool ShowMods + { + get { return showMods; } + set + { + if (showMods == value) return; + + showMods = value; + } + } + + public ModsContainer() + { + Children = new Drawable[] + { + iconsContainer = new FillFlowContainer + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Horizontal, + }, + new OsuSpriteText + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.TopCentre, + Text = @"/UNRANKED/", + Font = @"Venera", + TextSize = 15, + } + }; + } + + public void Add(Mod mod) + { + iconsContainer.Add(new ModIcon + { + AutoSizeAxes = Axes.Both, + Icon = mod.Icon, + Colour = selectColour(mod), + IconSize = 60, + }); + } + + private Color4 selectColour(Mod mod) + { + switch (mod.Type) + { + case ModType.DifficultyIncrease: + return OsuColour.FromHex(@"ffcc22"); + case ModType.DifficultyReduction: + return OsuColour.FromHex(@"88b300"); + case ModType.Special: + return OsuColour.FromHex(@"66ccff"); + + default: return Color4.White; + } + } + + [BackgroundDependencyLoader] + private void load() + { + if (ShowMods) + Show(); + else + Hide(); + } + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 37b4cf5b45..948594235f 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -169,6 +169,10 @@ namespace osu.Game.Screens.Play hudOverlay.Progress.AllowSeeking = HitRenderer.HasReplayLoaded; hudOverlay.Progress.OnSeek = pos => decoupledClock.Seek(pos); + hudOverlay.ModsContainer.ShowMods = HitRenderer.HasReplayLoaded; + foreach (var mod in Beatmap.Mods.Value) + hudOverlay.ModsContainer.Add(mod); + //bind HitRenderer to ScoreProcessor and ourselves (for a pass situation) HitRenderer.OnAllJudged += onCompletion; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2a1195135a..d637660ea9 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -227,6 +227,7 @@ +