1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 08:23:20 +08:00

Add basic tooltip support to OsuSliderBar.

This commit is contained in:
Dean Herbert 2017-04-20 17:57:58 +09:00
parent c87657707f
commit 0de71ab24d
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
2 changed files with 21 additions and 3 deletions

View File

@ -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
{

View File

@ -1,11 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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<double>;
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<int>;
if (bindableInt != null)
return bindableInt.Value.ToString(@"n0");
return Current.Value.ToString();
}
}
public OsuSliderBar()
{