Rename RestoreDefaultValueButton to RevertToDefaultButton

Because I can't find it every time I search.
This commit is contained in:
Dean Herbert 2023-07-13 13:46:50 +09:00
parent a891dcd9e6
commit 1bfe5a18cb
7 changed files with 32 additions and 32 deletions

View File

@ -195,16 +195,16 @@ namespace osu.Game.Tests.Visual.Settings
InputManager.ReleaseKey(Key.P);
});
AddUntilStep("restore button shown", () => settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha > 0);
AddUntilStep("restore button shown", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha > 0);
AddStep("click reset button for bindings", () =>
{
var resetButton = settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First();
var resetButton = settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First();
resetButton.TriggerClick();
});
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha == 0);
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha == 0);
AddAssert("binding cleared",
() => settingsKeyBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.KeyCombination.Equals(settingsKeyBindingRow.Defaults.ElementAt(0)));
@ -225,7 +225,7 @@ namespace osu.Game.Tests.Visual.Settings
InputManager.ReleaseKey(Key.P);
});
AddUntilStep("restore button shown", () => settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha > 0);
AddUntilStep("restore button shown", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha > 0);
AddStep("click reset button for bindings", () =>
{
@ -234,7 +234,7 @@ namespace osu.Game.Tests.Visual.Settings
resetButton.TriggerClick();
});
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RestoreDefaultValueButton<bool>>().First().Alpha == 0);
AddUntilStep("restore button hidden", () => settingsKeyBindingRow.ChildrenOfType<RevertToDefaultButton<bool>>().First().Alpha == 0);
AddAssert("binding cleared",
() => settingsKeyBindingRow.ChildrenOfType<KeyBindingRow.KeyButton>().ElementAt(0).KeyBinding.KeyCombination.Equals(settingsKeyBindingRow.Defaults.ElementAt(0)));

View File

@ -15,7 +15,7 @@ using osuTK;
namespace osu.Game.Tests.Visual.Settings
{
public partial class TestSceneRestoreDefaultValueButton : OsuTestScene
public partial class TestSceneRevertToDefaultButton : OsuTestScene
{
[Resolved]
private OsuColour colours { get; set; }
@ -31,7 +31,7 @@ namespace osu.Game.Tests.Visual.Settings
[Test]
public void TestBasic()
{
RestoreDefaultValueButton<float> restoreDefaultValueButton = null;
RevertToDefaultButton<float> revertToDefaultButton = null;
AddStep("create button", () => Child = new Container
{
@ -43,7 +43,7 @@ namespace osu.Game.Tests.Visual.Settings
RelativeSizeAxes = Axes.Both,
Colour = colours.GreySeaFoam
},
restoreDefaultValueButton = new RestoreDefaultValueButton<float>
revertToDefaultButton = new RevertToDefaultButton<float>
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -55,8 +55,8 @@ namespace osu.Game.Tests.Visual.Settings
AddSliderStep("set scale", 1, 4, 1, scale =>
{
this.scale = scale;
if (restoreDefaultValueButton != null)
restoreDefaultValueButton.Scale = new Vector2(scale);
if (revertToDefaultButton != null)
revertToDefaultButton.Scale = new Vector2(scale);
});
AddToggleStep("toggle default state", state => current.Value = state ? default : 1);
AddToggleStep("toggle disabled state", state => current.Disabled = state);

View File

@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual.Settings
public void TestRestoreDefaultValueButtonVisibility()
{
SettingsTextBox textBox = null;
RestoreDefaultValueButton<string> restoreDefaultValueButton = null;
RevertToDefaultButton<string> revertToDefaultButton = null;
AddStep("create settings item", () =>
{
@ -33,22 +33,22 @@ namespace osu.Game.Tests.Visual.Settings
};
});
AddUntilStep("wait for loaded", () => textBox.IsLoaded);
AddStep("retrieve restore default button", () => restoreDefaultValueButton = textBox.ChildrenOfType<RestoreDefaultValueButton<string>>().Single());
AddStep("retrieve restore default button", () => revertToDefaultButton = textBox.ChildrenOfType<RevertToDefaultButton<string>>().Single());
AddAssert("restore button hidden", () => restoreDefaultValueButton.Alpha == 0);
AddAssert("restore button hidden", () => revertToDefaultButton.Alpha == 0);
AddStep("change value from default", () => textBox.Current.Value = "non-default");
AddUntilStep("restore button shown", () => restoreDefaultValueButton.Alpha > 0);
AddUntilStep("restore button shown", () => revertToDefaultButton.Alpha > 0);
AddStep("restore default", () => textBox.Current.SetDefault());
AddUntilStep("restore button hidden", () => restoreDefaultValueButton.Alpha == 0);
AddUntilStep("restore button hidden", () => revertToDefaultButton.Alpha == 0);
}
[Test]
public void TestSetAndClearLabelText()
{
SettingsTextBox textBox = null;
RestoreDefaultValueButton<string> restoreDefaultValueButton = null;
RevertToDefaultButton<string> revertToDefaultButton = null;
OsuTextBox control = null;
AddStep("create settings item", () =>
@ -61,25 +61,25 @@ namespace osu.Game.Tests.Visual.Settings
AddUntilStep("wait for loaded", () => textBox.IsLoaded);
AddStep("retrieve components", () =>
{
restoreDefaultValueButton = textBox.ChildrenOfType<RestoreDefaultValueButton<string>>().Single();
revertToDefaultButton = textBox.ChildrenOfType<RevertToDefaultButton<string>>().Single();
control = textBox.ChildrenOfType<OsuTextBox>().Single();
});
AddStep("set non-default value", () => restoreDefaultValueButton.Current.Value = "non-default");
AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, control.DrawHeight, 1));
AddStep("set non-default value", () => revertToDefaultButton.Current.Value = "non-default");
AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(revertToDefaultButton.Parent.DrawHeight, control.DrawHeight, 1));
AddStep("set label", () => textBox.LabelText = "label text");
AddAssert("default value button centre aligned to label size", () =>
{
var label = textBox.ChildrenOfType<OsuSpriteText>().Single(spriteText => spriteText.Text == "label text");
return Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, label.DrawHeight, 1);
return Precision.AlmostEquals(revertToDefaultButton.Parent.DrawHeight, label.DrawHeight, 1);
});
AddStep("clear label", () => textBox.LabelText = default);
AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, control.DrawHeight, 1));
AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(revertToDefaultButton.Parent.DrawHeight, control.DrawHeight, 1));
AddStep("set warning text", () => textBox.SetNoticeText("This is some very important warning text! Hopefully it doesn't break the alignment of the default value indicator...", true));
AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, control.DrawHeight, 1));
AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(revertToDefaultButton.Parent.DrawHeight, control.DrawHeight, 1));
}
/// <summary>
@ -92,7 +92,7 @@ namespace osu.Game.Tests.Visual.Settings
{
BindableFloat current = null;
SettingsSlider<float> sliderBar = null;
RestoreDefaultValueButton<float> restoreDefaultValueButton = null;
RevertToDefaultButton<float> revertToDefaultButton = null;
AddStep("create settings item", () =>
{
@ -107,15 +107,15 @@ namespace osu.Game.Tests.Visual.Settings
};
});
AddUntilStep("wait for loaded", () => sliderBar.IsLoaded);
AddStep("retrieve restore default button", () => restoreDefaultValueButton = sliderBar.ChildrenOfType<RestoreDefaultValueButton<float>>().Single());
AddStep("retrieve restore default button", () => revertToDefaultButton = sliderBar.ChildrenOfType<RevertToDefaultButton<float>>().Single());
AddAssert("restore button hidden", () => restoreDefaultValueButton.Alpha == 0);
AddAssert("restore button hidden", () => revertToDefaultButton.Alpha == 0);
AddStep("change value to next closest", () => sliderBar.Current.Value += current.Precision * 0.6f);
AddUntilStep("restore button shown", () => restoreDefaultValueButton.Alpha > 0);
AddUntilStep("restore button shown", () => revertToDefaultButton.Alpha > 0);
AddStep("restore default", () => sliderBar.Current.SetDefault());
AddUntilStep("restore button hidden", () => restoreDefaultValueButton.Alpha == 0);
AddUntilStep("restore button hidden", () => revertToDefaultButton.Alpha == 0);
}
[Test]

View File

@ -793,7 +793,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("open customisation area", () => modSelectOverlay.CustomisationButton!.TriggerClick());
AddStep("reset half time speed to default", () => modSelectOverlay.ChildrenOfType<ModSettingsArea>().Single()
.ChildrenOfType<RestoreDefaultValueButton<double>>().Single().TriggerClick());
.ChildrenOfType<RevertToDefaultButton<double>>().Single().TriggerClick());
AddUntilStep("difficulty multiplier display shows correct value", () => modSelectOverlay.ChildrenOfType<DifficultyMultiplierDisplay>().Single().Current.Value, () => Is.EqualTo(0.7));
}

View File

@ -22,7 +22,7 @@ using osu.Game.Localisation;
namespace osu.Game.Overlays
{
public partial class RestoreDefaultValueButton<T> : OsuClickableContainer, IHasCurrentValue<T>
public partial class RevertToDefaultButton<T> : OsuClickableContainer, IHasCurrentValue<T>
{
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
@ -58,7 +58,7 @@ namespace osu.Game.Overlays
private CircularContainer circle = null!;
private Box background = null!;
public RestoreDefaultValueButton()
public RevertToDefaultButton()
: base(HoverSampleSet.Button)
{
}

View File

@ -103,7 +103,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
RelativeSizeAxes = Axes.Y,
Width = SettingsPanel.CONTENT_MARGINS,
Child = new RestoreDefaultValueButton<bool>
Child = new RevertToDefaultButton<bool>
{
Current = isDefault,
Action = RestoreDefaults,

View File

@ -217,7 +217,7 @@ namespace osu.Game.Overlays.Settings
// intentionally done before LoadComplete to avoid overhead.
if (ShowsDefaultIndicator)
{
defaultValueIndicatorContainer.Add(new RestoreDefaultValueButton<T>
defaultValueIndicatorContainer.Add(new RevertToDefaultButton<T>
{
Current = controlWithCurrent.Current,
Anchor = Anchor.Centre,