1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 09:27:34 +08:00

allow tooltip to show as percentage as needed

This commit is contained in:
unknown 2020-01-28 12:32:30 +08:00
parent 01cf417569
commit aa264cd2a8
6 changed files with 36 additions and 14 deletions

View File

@ -35,6 +35,7 @@ namespace osu.Game.Graphics.UserInterface
private readonly Container nubContainer;
public virtual string TooltipText { get; private set; }
public bool DisplayAsPercentage { get; set; }
private Color4 accentColour;
@ -172,8 +173,11 @@ namespace osu.Game.Graphics.UserInterface
double floatMinValue = CurrentNumber.MinValue.ToDouble(NumberFormatInfo.InvariantInfo);
double floatMaxValue = CurrentNumber.MaxValue.ToDouble(NumberFormatInfo.InvariantInfo);
if (floatMaxValue == 1 && floatMinValue >= -1)
TooltipText = floatValue.ToString("P0");
if (DisplayAsPercentage)
{
double percentage = floatValue / floatMaxValue;
TooltipText = percentage.ToString("P0");
}
else
{
var decimalPrecision = normalise(CurrentNumber.Precision.ToDecimal(NumberFormatInfo.InvariantInfo), max_decimal_digits);

View File

@ -17,10 +17,10 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
{
Children = new Drawable[]
{
new SettingsSlider<double> { LabelText = "Master", Bindable = audio.Volume, KeyboardStep = 0.01f },
new SettingsSlider<double> { LabelText = "Master (window inactive)", Bindable = config.GetBindable<double>(OsuSetting.VolumeInactive), KeyboardStep = 0.01f },
new SettingsSlider<double> { LabelText = "Effect", Bindable = audio.VolumeSample, KeyboardStep = 0.01f },
new SettingsSlider<double> { LabelText = "Music", Bindable = audio.VolumeTrack, KeyboardStep = 0.01f },
new SettingsSlider<double> { LabelText = "Master", Bindable = audio.Volume, KeyboardStep = 0.01f, DisplayAsPercentage = true },
new SettingsSlider<double> { LabelText = "Master (window inactive)", Bindable = config.GetBindable<double>(OsuSetting.VolumeInactive), KeyboardStep = 0.01f, DisplayAsPercentage = true },
new SettingsSlider<double> { LabelText = "Effect", Bindable = audio.VolumeSample, KeyboardStep = 0.01f, DisplayAsPercentage = true },
new SettingsSlider<double> { LabelText = "Music", Bindable = audio.VolumeTrack, KeyboardStep = 0.01f, DisplayAsPercentage = true },
};
}
}

View File

@ -21,13 +21,15 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
{
LabelText = "Background dim",
Bindable = config.GetBindable<double>(OsuSetting.DimLevel),
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<double>
{
LabelText = "Background blur",
Bindable = config.GetBindable<double>(OsuSetting.BlurLevel),
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsCheckbox
{

View File

@ -98,25 +98,29 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
{
LabelText = "Horizontal position",
Bindable = scalingPositionX,
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<float>
{
LabelText = "Vertical position",
Bindable = scalingPositionY,
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<float>
{
LabelText = "Horizontal scale",
Bindable = scalingSizeX,
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<float>
{
LabelText = "Vertical scale",
Bindable = scalingSizeY,
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
}
},

View File

@ -33,5 +33,11 @@ namespace osu.Game.Overlays.Settings
get => ((TSlider)Control).KeyboardStep;
set => ((TSlider)Control).KeyboardStep = value;
}
public bool DisplayAsPercentage
{
get => ((TSlider)Control).DisplayAsPercentage;
set => ((TSlider)Control).DisplayAsPercentage = value;
}
}
}

View File

@ -27,12 +27,18 @@ namespace osu.Game.Screens.Play.PlayerSettings
{
Text = "Background dim:"
},
dimSliderBar = new PlayerSliderBar<double>(),
dimSliderBar = new PlayerSliderBar<double>
{
DisplayAsPercentage = true
},
new OsuSpriteText
{
Text = "Background blur:"
},
blurSliderBar = new PlayerSliderBar<double>(),
blurSliderBar = new PlayerSliderBar<double>
{
DisplayAsPercentage = true
},
new OsuSpriteText
{
Text = "Toggles:"