1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-07 20:03:13 +08:00

Merge branch 'master' into fix-key-count-mod-affect

This commit is contained in:
Dan Balasescu 2020-01-29 14:11:59 +09:00 committed by GitHub
commit b10143fdf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 77 additions and 15 deletions

View File

@ -118,6 +118,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.ReleaseKey(Key.Enter); InputManager.ReleaseKey(Key.Enter);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddAssert("ensure selection changed", () => selected != Beatmap.Value); AddAssert("ensure selection changed", () => selected != Beatmap.Value);
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
@ -145,6 +146,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.ReleaseKey(Key.Down); InputManager.ReleaseKey(Key.Down);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value); AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
@ -176,6 +178,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.ReleaseKey(Key.Enter); InputManager.ReleaseKey(Key.Enter);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddAssert("ensure selection changed", () => selected != Beatmap.Value); AddAssert("ensure selection changed", () => selected != Beatmap.Value);
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
@ -208,6 +211,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.ReleaseButton(MouseButton.Left); InputManager.ReleaseButton(MouseButton.Left);
}); });
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value); AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen()); AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());

View File

@ -36,6 +36,11 @@ namespace osu.Game.Graphics.UserInterface
public virtual string TooltipText { get; private set; } public virtual string TooltipText { get; private set; }
/// <summary>
/// Whether to format the tooltip as a percentage or the actual value.
/// </summary>
public bool DisplayAsPercentage { get; set; }
private Color4 accentColour; private Color4 accentColour;
public Color4 AccentColour public Color4 AccentColour
@ -169,11 +174,11 @@ namespace osu.Game.Graphics.UserInterface
else else
{ {
double floatValue = value.ToDouble(NumberFormatInfo.InvariantInfo); double floatValue = value.ToDouble(NumberFormatInfo.InvariantInfo);
double floatMinValue = CurrentNumber.MinValue.ToDouble(NumberFormatInfo.InvariantInfo);
double floatMaxValue = CurrentNumber.MaxValue.ToDouble(NumberFormatInfo.InvariantInfo);
if (floatMaxValue == 1 && floatMinValue >= -1) if (DisplayAsPercentage)
{
TooltipText = floatValue.ToString("P0"); TooltipText = floatValue.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);

View File

@ -17,10 +17,34 @@ 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>
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 }, LabelText = "Master",
new SettingsSlider<double> { LabelText = "Music", Bindable = audio.VolumeTrack, KeyboardStep = 0.01f }, 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", 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
{ {

View File

@ -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
}, },
} }
}, },

View File

@ -3,6 +3,7 @@
using System; using System;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings namespace osu.Game.Overlays.Settings
@ -22,16 +23,32 @@ namespace osu.Game.Overlays.Settings
RelativeSizeAxes = Axes.X RelativeSizeAxes = Axes.X
}; };
/// <summary>
/// When set, value changes based on user input are only transferred to any bound control's Current on commit.
/// This is useful if the UI interaction could be adversely affected by the value changing, such as the position of the <see cref="SliderBar{T}"/> on the screen.
/// </summary>
public bool TransferValueOnCommit public bool TransferValueOnCommit
{ {
get => ((TSlider)Control).TransferValueOnCommit; get => ((TSlider)Control).TransferValueOnCommit;
set => ((TSlider)Control).TransferValueOnCommit = value; set => ((TSlider)Control).TransferValueOnCommit = value;
} }
/// <summary>
/// A custom step value for each key press which actuates a change on this control.
/// </summary>
public float KeyboardStep public float KeyboardStep
{ {
get => ((TSlider)Control).KeyboardStep; get => ((TSlider)Control).KeyboardStep;
set => ((TSlider)Control).KeyboardStep = value; set => ((TSlider)Control).KeyboardStep = value;
} }
/// <summary>
/// Whether to format the tooltip as a percentage or the actual value.
/// </summary>
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:" 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:"