mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 15:12:57 +08:00
allow tooltip to show as percentage as needed
This commit is contained in:
parent
01cf417569
commit
aa264cd2a8
@ -35,6 +35,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private readonly Container nubContainer;
|
private readonly Container nubContainer;
|
||||||
|
|
||||||
public virtual string TooltipText { get; private set; }
|
public virtual string TooltipText { get; private set; }
|
||||||
|
public bool DisplayAsPercentage { get; set; }
|
||||||
|
|
||||||
private Color4 accentColour;
|
private Color4 accentColour;
|
||||||
|
|
||||||
@ -172,8 +173,11 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
double floatMinValue = CurrentNumber.MinValue.ToDouble(NumberFormatInfo.InvariantInfo);
|
double floatMinValue = CurrentNumber.MinValue.ToDouble(NumberFormatInfo.InvariantInfo);
|
||||||
double floatMaxValue = CurrentNumber.MaxValue.ToDouble(NumberFormatInfo.InvariantInfo);
|
double floatMaxValue = CurrentNumber.MaxValue.ToDouble(NumberFormatInfo.InvariantInfo);
|
||||||
|
|
||||||
if (floatMaxValue == 1 && floatMinValue >= -1)
|
if (DisplayAsPercentage)
|
||||||
TooltipText = floatValue.ToString("P0");
|
{
|
||||||
|
double percentage = floatValue / floatMaxValue;
|
||||||
|
TooltipText = percentage.ToString("P0");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var decimalPrecision = normalise(CurrentNumber.Precision.ToDecimal(NumberFormatInfo.InvariantInfo), max_decimal_digits);
|
var decimalPrecision = normalise(CurrentNumber.Precision.ToDecimal(NumberFormatInfo.InvariantInfo), max_decimal_digits);
|
||||||
|
@ -17,10 +17,10 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
|
|||||||
{
|
{
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SettingsSlider<double> { LabelText = "Master", Bindable = audio.Volume, 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 },
|
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 },
|
new SettingsSlider<double> { LabelText = "Effect", Bindable = audio.VolumeSample, KeyboardStep = 0.01f, DisplayAsPercentage = true },
|
||||||
new SettingsSlider<double> { LabelText = "Music", Bindable = audio.VolumeTrack, KeyboardStep = 0.01f },
|
new SettingsSlider<double> { LabelText = "Music", Bindable = audio.VolumeTrack, KeyboardStep = 0.01f, DisplayAsPercentage = true },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,15 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
{
|
{
|
||||||
LabelText = "Background dim",
|
LabelText = "Background dim",
|
||||||
Bindable = config.GetBindable<double>(OsuSetting.DimLevel),
|
Bindable = config.GetBindable<double>(OsuSetting.DimLevel),
|
||||||
KeyboardStep = 0.01f
|
KeyboardStep = 0.01f,
|
||||||
|
DisplayAsPercentage = true
|
||||||
},
|
},
|
||||||
new SettingsSlider<double>
|
new SettingsSlider<double>
|
||||||
{
|
{
|
||||||
LabelText = "Background blur",
|
LabelText = "Background blur",
|
||||||
Bindable = config.GetBindable<double>(OsuSetting.BlurLevel),
|
Bindable = config.GetBindable<double>(OsuSetting.BlurLevel),
|
||||||
KeyboardStep = 0.01f
|
KeyboardStep = 0.01f,
|
||||||
|
DisplayAsPercentage = true
|
||||||
},
|
},
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
|
@ -98,25 +98,29 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
|||||||
{
|
{
|
||||||
LabelText = "Horizontal position",
|
LabelText = "Horizontal position",
|
||||||
Bindable = scalingPositionX,
|
Bindable = scalingPositionX,
|
||||||
KeyboardStep = 0.01f
|
KeyboardStep = 0.01f,
|
||||||
|
DisplayAsPercentage = true
|
||||||
},
|
},
|
||||||
new SettingsSlider<float>
|
new SettingsSlider<float>
|
||||||
{
|
{
|
||||||
LabelText = "Vertical position",
|
LabelText = "Vertical position",
|
||||||
Bindable = scalingPositionY,
|
Bindable = scalingPositionY,
|
||||||
KeyboardStep = 0.01f
|
KeyboardStep = 0.01f,
|
||||||
|
DisplayAsPercentage = true
|
||||||
},
|
},
|
||||||
new SettingsSlider<float>
|
new SettingsSlider<float>
|
||||||
{
|
{
|
||||||
LabelText = "Horizontal scale",
|
LabelText = "Horizontal scale",
|
||||||
Bindable = scalingSizeX,
|
Bindable = scalingSizeX,
|
||||||
KeyboardStep = 0.01f
|
KeyboardStep = 0.01f,
|
||||||
|
DisplayAsPercentage = true
|
||||||
},
|
},
|
||||||
new SettingsSlider<float>
|
new SettingsSlider<float>
|
||||||
{
|
{
|
||||||
LabelText = "Vertical scale",
|
LabelText = "Vertical scale",
|
||||||
Bindable = scalingSizeY,
|
Bindable = scalingSizeY,
|
||||||
KeyboardStep = 0.01f
|
KeyboardStep = 0.01f,
|
||||||
|
DisplayAsPercentage = true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -33,5 +33,11 @@ namespace osu.Game.Overlays.Settings
|
|||||||
get => ((TSlider)Control).KeyboardStep;
|
get => ((TSlider)Control).KeyboardStep;
|
||||||
set => ((TSlider)Control).KeyboardStep = value;
|
set => ((TSlider)Control).KeyboardStep = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool DisplayAsPercentage
|
||||||
|
{
|
||||||
|
get => ((TSlider)Control).DisplayAsPercentage;
|
||||||
|
set => ((TSlider)Control).DisplayAsPercentage = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,18 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
|||||||
{
|
{
|
||||||
Text = "Background dim:"
|
Text = "Background dim:"
|
||||||
},
|
},
|
||||||
dimSliderBar = new PlayerSliderBar<double>(),
|
dimSliderBar = new PlayerSliderBar<double>
|
||||||
|
{
|
||||||
|
DisplayAsPercentage = true
|
||||||
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = "Background blur:"
|
Text = "Background blur:"
|
||||||
},
|
},
|
||||||
blurSliderBar = new PlayerSliderBar<double>(),
|
blurSliderBar = new PlayerSliderBar<double>
|
||||||
|
{
|
||||||
|
DisplayAsPercentage = true
|
||||||
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = "Toggles:"
|
Text = "Toggles:"
|
||||||
|
Loading…
Reference in New Issue
Block a user