Rename Visible to HasReplayLoaded and change default value

Doesn't make sense to be true by default
This commit is contained in:
Salman Ahmed 2020-02-03 15:47:52 +03:00
parent 443063263e
commit 351cb8ac1a
3 changed files with 13 additions and 15 deletions

View File

@ -30,8 +30,8 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("showhud is set", () => hudOverlay.ShowHud.Value); AddAssert("showhud is set", () => hudOverlay.ShowHud.Value);
AddAssert("hidetarget is visible", () => hideTarget.IsPresent); AddAssert("hidetarget is visible", () => hideTarget.IsPresent);
AddAssert("key counter flow is visible", () => hudOverlay.KeyCounter.KeyFlow.IsPresent);
AddAssert("pause button is visible", () => hudOverlay.HoldToQuit.IsPresent); AddAssert("pause button is visible", () => hudOverlay.HoldToQuit.IsPresent);
AddAssert("key counter flow is hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent);
} }
[Test] [Test]
@ -45,17 +45,19 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
[Test] [Test]
public void TestHideExternally() public void TestChangeVisibilityExternally()
{ {
createNew(); createNew();
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false); AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent); AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);
AddAssert("key counter flow is hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent);
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent); AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
// Key counter flow container should not be affected by this, only the key counter display will be hidden as checked above. AddStep("set showhud false", () => hudOverlay.ShowHud.Value = true);
AddAssert("key counter flow not affected", () => hudOverlay.KeyCounter.KeyFlow.IsPresent); AddUntilStep("hidetarget is visible", () => hideTarget.IsPresent);
AddAssert("key counter flow is still hidden", () => !hudOverlay.KeyCounter.KeyFlow.IsPresent);
AddAssert("pause button is still visible", () => hudOverlay.HoldToQuit.IsPresent);
} }
[Test] [Test]
@ -82,11 +84,7 @@ namespace osu.Game.Tests.Visual.Gameplay
createNew(); createNew();
AddStep("save keycounter visible value", () => keyCounterVisibleValue = config.Get<bool>(OsuSetting.KeyOverlay)); AddStep("save keycounter visible value", () => keyCounterVisibleValue = config.Get<bool>(OsuSetting.KeyOverlay));
AddStep("set keycounter visible false", () => AddStep("set keycounter visible false", () => config.Set<bool>(OsuSetting.KeyOverlay, false));
{
config.Set<bool>(OsuSetting.KeyOverlay, false);
hudOverlay.KeyCounter.Visible.Value = false;
});
AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false); AddStep("set showhud false", () => hudOverlay.ShowHud.Value = false);
AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent); AddUntilStep("hidetarget is hidden", () => !hideTarget.IsPresent);

View File

@ -20,12 +20,12 @@ namespace osu.Game.Screens.Play
private const double key_fade_time = 80; private const double key_fade_time = 80;
/// <summary> /// <summary>
/// Whether to always show key counter regardless of <see cref="Visible"/>. /// Whether to always show key counter regardless of any other condition.
/// This is bound to <see cref="OsuSetting.KeyOverlay"/> configuration setting bindable. /// This is bound to <see cref="OsuSetting.KeyOverlay"/> configuration setting bindable.
/// </summary> /// </summary>
private readonly Bindable<bool> alwaysShow = new Bindable<bool>(); private readonly Bindable<bool> alwaysShow = new Bindable<bool>();
public readonly Bindable<bool> Visible = new Bindable<bool>(true); public readonly Bindable<bool> HasReplayLoaded = new BindableBool();
protected readonly FillFlowContainer<KeyCounter> KeyFlow; protected readonly FillFlowContainer<KeyCounter> KeyFlow;
@ -63,7 +63,7 @@ namespace osu.Game.Screens.Play
{ {
base.LoadComplete(); base.LoadComplete();
Visible.BindValueChanged(_ => updateVisibility()); HasReplayLoaded.BindValueChanged(_ => updateVisibility());
alwaysShow.BindValueChanged(_ => updateVisibility(), true); alwaysShow.BindValueChanged(_ => updateVisibility(), true);
} }
@ -116,7 +116,7 @@ namespace osu.Game.Screens.Play
private void updateVisibility() => private void updateVisibility() =>
// Isolate changing visibility of the key counters from fading this component. // Isolate changing visibility of the key counters from fading this component.
KeyFlow.FadeTo(Visible.Value || alwaysShow.Value ? 1 : 0, duration); KeyFlow.FadeTo(HasReplayLoaded.Value || alwaysShow.Value ? 1 : 0, duration);
public override bool HandleNonPositionalInput => receptor == null; public override bool HandleNonPositionalInput => receptor == null;
public override bool HandlePositionalInput => receptor == null; public override bool HandlePositionalInput => receptor == null;

View File

@ -219,7 +219,7 @@ namespace osu.Game.Screens.Play
IsPaused = { BindTarget = GameplayClockContainer.IsPaused } IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
}, },
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } }, PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
KeyCounter = { Visible = { BindTarget = DrawableRuleset.HasReplayLoaded } }, KeyCounter = { HasReplayLoaded = { BindTarget = DrawableRuleset.HasReplayLoaded } },
RequestSeek = GameplayClockContainer.Seek, RequestSeek = GameplayClockContainer.Seek,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre Origin = Anchor.Centre