From 0de71ab24d52f170a175b1378127aef7ea944cde Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 20 Apr 2017 17:57:58 +0900 Subject: [PATCH] Add basic tooltip support to OsuSliderBar. --- .../Tests/TestCaseTooltip.cs | 2 +- .../Graphics/UserInterface/OsuSliderBar.cs | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs b/osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs index f12b9d71e2..633d3036dc 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTooltip.cs @@ -7,8 +7,8 @@ using osu.Framework.Testing; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Framework.Configuration; -using osu.Game.Graphics.Cursor; using OpenTK; +using osu.Game.Graphics; namespace osu.Desktop.VisualTests.Tests { diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index 12d5d2126c..5643ddcec3 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -1,11 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; using OpenTK; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; +using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; @@ -22,7 +22,25 @@ namespace osu.Game.Graphics.UserInterface private readonly Box leftBox; private readonly Box rightBox; - public string TooltipText => Current.Value.ToString(); + public string TooltipText + { + get + { + var bindableDouble = CurrentNumber as BindableNumber; + if (bindableDouble != null) + { + if (bindableDouble.MaxValue == 1 && bindableDouble.MinValue == 0) + return bindableDouble.Value.ToString(@"P0"); + return bindableDouble.Value.ToString(@"n1"); + } + + var bindableInt = CurrentNumber as BindableNumber; + if (bindableInt != null) + return bindableInt.Value.ToString(@"n0"); + + return Current.Value.ToString(); + } + } public OsuSliderBar() {