From bfedd42ca442d5a855e2bc300922b6464ef032de Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Fri, 19 May 2017 23:56:48 -0300 Subject: [PATCH 1/8] Add mod tooltips --- osu.Game/Overlays/Mods/ModButton.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index fe1b3b0192..9bbd793934 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -16,6 +16,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using System; using System.Linq; +using osu.Game.Graphics; namespace osu.Game.Overlays.Mods { @@ -23,7 +24,7 @@ namespace osu.Game.Overlays.Mods /// /// Represents a clickable button which can cycle through one of more mods. /// - public class ModButton : ModButtonEmpty + public class ModButton : ModButtonEmpty, IHasTooltip { private ModIcon foregroundIcon; private readonly SpriteText text; @@ -32,6 +33,8 @@ namespace osu.Game.Overlays.Mods public Action Action; // Passed the selected mod or null if none + public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? @""; + private int _selectedIndex = -1; private int selectedIndex { From dcc3dbf5e2e8cd7cbc6c428d1e733298a854e3c2 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 20 May 2017 01:11:20 -0300 Subject: [PATCH 2/8] Make PlaylistItem use Paragraphs --- osu.Game/Overlays/Music/PlaylistItem.cs | 71 ++++++++++++++++--------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 16978903a7..bde043d0d4 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -11,6 +11,9 @@ using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; using osu.Framework.Localisation; +using osu.Framework.Graphics.Sprites; +using System.Collections.Generic; +using System.Linq; namespace osu.Game.Overlays.Music { @@ -19,9 +22,13 @@ namespace osu.Game.Overlays.Music private const float fade_duration = 100; private Color4 hoverColour; + private Color4 artistColour; private TextAwesome handle; - private OsuSpriteText title; + private Paragraph text; + private IEnumerable titleSprites; + private UnicodeBindableString titleBind; + private UnicodeBindableString artistBind; public readonly BeatmapSetInfo BeatmapSetInfo; @@ -37,7 +44,8 @@ namespace osu.Game.Overlays.Music selected = value; Flush(true); - title.FadeColour(Selected ? hoverColour : Color4.White, fade_duration); + foreach (SpriteText s in titleSprites) + s.FadeColour(Selected ? hoverColour : Color4.White, fade_duration); } } @@ -53,8 +61,10 @@ namespace osu.Game.Overlays.Music [BackgroundDependencyLoader] private void load(OsuColour colours, LocalisationEngine localisation) { - BeatmapMetadata metadata = BeatmapSetInfo.Metadata; - + hoverColour = colours.Yellow; + artistColour = colours.Gray9; + + var metadata = BeatmapSetInfo.Metadata; FilterTerms = metadata.SearchableTerms; Children = new Drawable[] @@ -70,33 +80,46 @@ namespace osu.Game.Overlays.Music Margin = new MarginPadding { Left = 5 }, Padding = new MarginPadding { Top = 2 }, }, - new FillFlowContainer + text = new Paragraph { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Left = 20 }, - Spacing = new Vector2(5f, 0f), - Children = new [] - { - title = new OsuSpriteText - { - TextSize = 16, - Font = @"Exo2.0-Regular", - Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title), - }, - new OsuSpriteText - { - TextSize = 14, - Font = @"Exo2.0-Bold", - Colour = colours.Gray9, - Padding = new MarginPadding { Top = 1 }, - Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist), - } - } + ContentIndent = 10f, }, }; - hoverColour = colours.Yellow; + titleBind = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); + artistBind = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); + + titleBind.ValueChanged += newText => recreateText(); + titleBind.TriggerChange(); + } + + private void recreateText() + { + text.Clear(); + + var metadata = BeatmapSetInfo.Metadata; + var t = new List(); + + //space after the title to put a space between the title and artist + text.AddText(titleBind.Value + @" ", sprite => + { + sprite.TextSize = 16; + sprite.Font = @"Exo2.0-Regular"; + t.Add(sprite); + }); + + titleSprites = t; + + text.AddText(artistBind.Value, sprite => + { + sprite.TextSize = 14; + sprite.Font = @"Exo2.0-Bold"; + sprite.Colour = artistColour; + sprite.Padding = new MarginPadding { Top = 1 }; + }); } protected override bool OnHover(Framework.Input.InputState state) From 615082d75734e3e96143b4177cbd95b9680d6a7b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 20 May 2017 01:17:04 -0300 Subject: [PATCH 3/8] Remove whitespace --- osu.Game/Overlays/Music/PlaylistItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index bde043d0d4..269b160672 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -63,7 +63,7 @@ namespace osu.Game.Overlays.Music { hoverColour = colours.Yellow; artistColour = colours.Gray9; - + var metadata = BeatmapSetInfo.Metadata; FilterTerms = metadata.SearchableTerms; From 48417beb81dce79200a375698e13aa067695793f Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 20 May 2017 01:22:33 -0300 Subject: [PATCH 4/8] Unused using directive --- osu.Game/Overlays/Music/PlaylistItem.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 269b160672..9f3ce6a3d4 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -7,13 +7,10 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Database; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using OpenTK; using OpenTK.Graphics; using osu.Framework.Localisation; using osu.Framework.Graphics.Sprites; using System.Collections.Generic; -using System.Linq; namespace osu.Game.Overlays.Music { @@ -100,7 +97,6 @@ namespace osu.Game.Overlays.Music { text.Clear(); - var metadata = BeatmapSetInfo.Metadata; var t = new List(); //space after the title to put a space between the title and artist From 43bd0f686b083b25da7f90f9f0eea3863f4764e9 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 20 May 2017 01:25:42 -0300 Subject: [PATCH 5/8] Fix artist being the opposite value --- osu.Game/Overlays/Music/PlaylistItem.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 9f3ce6a3d4..0f8dc621df 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -90,6 +90,7 @@ namespace osu.Game.Overlays.Music artistBind = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); titleBind.ValueChanged += newText => recreateText(); + artistBind.ValueChanged += newText => recreateText(); titleBind.TriggerChange(); } From 139b03a1ceabab51dc3651eea3c7e90ce2c28c5e Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 20 May 2017 02:05:13 -0300 Subject: [PATCH 6/8] Only recreate text once per unicode option change --- osu.Game/Overlays/Music/PlaylistItem.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 0f8dc621df..3a3be53569 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -89,9 +89,8 @@ namespace osu.Game.Overlays.Music titleBind = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title); artistBind = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist); - titleBind.ValueChanged += newText => recreateText(); artistBind.ValueChanged += newText => recreateText(); - titleBind.TriggerChange(); + artistBind.TriggerChange(); } private void recreateText() From 7485a78128a7b25bef1f75f3d9c6f549ae1f90fc Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 20 May 2017 03:14:22 -0300 Subject: [PATCH 7/8] Update framework --- osu-framework | 2 +- osu.Game/Overlays/Music/PlaylistItem.cs | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/osu-framework b/osu-framework index 4c76571784..d00a7df902 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 4c765717846fef9a141800782a5a968c2bc3a278 +Subproject commit d00a7df902074d0b3f1479904b7f322db9d39c1f diff --git a/osu.Game/Overlays/Music/PlaylistItem.cs b/osu.Game/Overlays/Music/PlaylistItem.cs index 3a3be53569..9b72cfce42 100644 --- a/osu.Game/Overlays/Music/PlaylistItem.cs +++ b/osu.Game/Overlays/Music/PlaylistItem.cs @@ -97,18 +97,13 @@ namespace osu.Game.Overlays.Music { text.Clear(); - var t = new List(); - - //space after the title to put a space between the title and artist - text.AddText(titleBind.Value + @" ", sprite => + //space after the title to put a space between the title and artist + titleSprites = text.AddText(titleBind.Value + @" ", sprite => { sprite.TextSize = 16; sprite.Font = @"Exo2.0-Regular"; - t.Add(sprite); }); - titleSprites = t; - text.AddText(artistBind.Value, sprite => { sprite.TextSize = 14; From 995a573b9c8d0828170738736283b7323866afe1 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Sat, 20 May 2017 03:22:37 -0300 Subject: [PATCH 8/8] @"" -> string.Empty --- osu.Game/Overlays/Mods/ModButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 9bbd793934..831b9082bd 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Mods public Action Action; // Passed the selected mod or null if none - public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? @""; + public string TooltipText => (SelectedMod?.Description ?? Mods.FirstOrDefault()?.Description) ?? string.Empty; private int _selectedIndex = -1; private int selectedIndex