1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Fix multiple issues with settings items unhiding on search

This commit is contained in:
Bartłomiej Dach 2022-11-16 22:58:32 +09:00 committed by Dean Herbert
parent 24deb5f5f4
commit 8f78d6179b
4 changed files with 37 additions and 32 deletions

View File

@ -177,13 +177,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
updateScreenModeWarning();
}, true);
windowModes.BindCollectionChanged((_, _) =>
{
if (windowModes.Count > 1)
windowModeDropdown.Show();
else
windowModeDropdown.Hide();
}, true);
windowModes.BindCollectionChanged((_, _) => updateDisplaySettingsVisibility());
currentDisplay.BindValueChanged(display => Schedule(() =>
{
@ -219,7 +213,11 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
scalingSettings.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
scalingSettings.AutoSizeAxes = scalingMode.Value != ScalingMode.Off ? Axes.Y : Axes.None;
scalingSettings.ForEach(s => s.TransferValueOnCommit = scalingMode.Value == ScalingMode.Everything);
scalingSettings.ForEach(s =>
{
s.TransferValueOnCommit = scalingMode.Value == ScalingMode.Everything;
s.CanBeShown.Value = scalingMode.Value != ScalingMode.Off;
});
}
}
@ -234,20 +232,10 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
private void updateDisplaySettingsVisibility()
{
if (resolutions.Count > 1 && windowModeDropdown.Current.Value == WindowMode.Fullscreen)
resolutionDropdown.Show();
else
resolutionDropdown.Hide();
if (displayDropdown.Items.Count() > 1)
displayDropdown.Show();
else
displayDropdown.Hide();
if (host.Window?.SafeAreaPadding.Value.Total != Vector2.Zero)
safeAreaConsiderationsCheckbox.Show();
else
safeAreaConsiderationsCheckbox.Hide();
windowModeDropdown.CanBeShown.Value = windowModes.Count > 1;
resolutionDropdown.CanBeShown.Value = resolutions.Count > 1 && windowModeDropdown.Current.Value == WindowMode.Fullscreen;
displayDropdown.CanBeShown.Value = displayDropdown.Items.Count() > 1;
safeAreaConsiderationsCheckbox.CanBeShown.Value = host.Window?.SafeAreaPadding.Value.Total != Vector2.Zero;
}
private void updateScreenModeWarning()

View File

@ -143,6 +143,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
areaOffset.SetDefault();
areaSize.SetDefault();
},
CanBeShown = { BindTarget = enabled }
},
new SettingsButton
{
@ -150,25 +151,29 @@ namespace osu.Game.Overlays.Settings.Sections.Input
Action = () =>
{
forceAspectRatio((float)host.Window.ClientSize.Width / host.Window.ClientSize.Height);
}
},
CanBeShown = { BindTarget = enabled }
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = TabletSettingsStrings.XOffset,
Current = offsetX
Current = offsetX,
CanBeShown = { BindTarget = enabled }
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = TabletSettingsStrings.YOffset,
Current = offsetY
Current = offsetY,
CanBeShown = { BindTarget = enabled }
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = TabletSettingsStrings.Rotation,
Current = rotation
Current = rotation,
CanBeShown = { BindTarget = enabled }
},
new RotationPresetButtons(tabletHandler)
{
@ -181,24 +186,28 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
TransferValueOnCommit = true,
LabelText = TabletSettingsStrings.AspectRatio,
Current = aspectRatio
Current = aspectRatio,
CanBeShown = { BindTarget = enabled }
},
new SettingsCheckbox
{
LabelText = TabletSettingsStrings.LockAspectRatio,
Current = aspectLock
Current = aspectLock,
CanBeShown = { BindTarget = enabled }
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = CommonStrings.Width,
Current = sizeX
Current = sizeX,
CanBeShown = { BindTarget = enabled }
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = CommonStrings.Height,
Current = sizeY
Current = sizeY,
CanBeShown = { BindTarget = enabled }
},
}
},

View File

@ -3,14 +3,16 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterfaceV2;
namespace osu.Game.Overlays.Settings
{
public partial class SettingsButton : RoundedButton, IHasTooltip
public partial class SettingsButton : RoundedButton, IHasTooltip, IConditionalFilterable
{
public SettingsButton()
{
@ -20,6 +22,9 @@ namespace osu.Game.Overlays.Settings
public LocalisableString TooltipText { get; set; }
public BindableBool CanBeShown { get; } = new BindableBool(true);
IBindable<bool> IConditionalFilterable.CanBeShown => CanBeShown;
public override IEnumerable<LocalisableString> FilterTerms
{
get

View File

@ -22,7 +22,7 @@ using osuTK;
namespace osu.Game.Overlays.Settings
{
public abstract partial class SettingsItem<T> : Container, IFilterable, ISettingsItem, IHasCurrentValue<T>, IHasTooltip
public abstract partial class SettingsItem<T> : Container, IConditionalFilterable, ISettingsItem, IHasCurrentValue<T>, IHasTooltip
{
protected abstract Drawable CreateControl();
@ -144,6 +144,9 @@ namespace osu.Game.Overlays.Settings
public bool FilteringActive { get; set; }
public BindableBool CanBeShown { get; } = new BindableBool(true);
IBindable<bool> IConditionalFilterable.CanBeShown => CanBeShown;
public event Action SettingChanged;
private T classicDefault;