1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-08 20:44:19 +08:00

Fix touch input area not handling settings changes

This commit is contained in:
Salman Alshamrani
2025-03-11 09:17:19 -04:00
Unverified
parent b64e69d581
commit b3ea63598e
2 changed files with 27 additions and 28 deletions
@@ -50,9 +50,7 @@ namespace osu.Game.Rulesets.Mania.UI
public IEnumerable<BarLine> BarLines;
private bool playsWithTouchableColumns => Config.Get<ManiaMobileLayout>(ManiaRulesetSetting.MobileLayout) == ManiaMobileLayout.Portrait;
public override bool RequiresPortraitOrientation => Beatmap.Stages.Count == 1 && playsWithTouchableColumns;
public override bool RequiresPortraitOrientation => Beatmap.Stages.Count == 1 && mobileLayout.Value == ManiaMobileLayout.Portrait;
protected override bool RelativeScaleBeatLengths => true;
@@ -60,6 +58,7 @@ namespace osu.Game.Rulesets.Mania.UI
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
private readonly BindableDouble configScrollSpeed = new BindableDouble();
private readonly Bindable<ManiaMobileLayout> mobileLayout = new Bindable<ManiaMobileLayout>();
private double currentTimeRange;
protected double TargetTimeRange;
@@ -114,7 +113,27 @@ namespace osu.Game.Rulesets.Mania.UI
TimeRange.Value = TargetTimeRange = currentTimeRange = ComputeScrollTime(configScrollSpeed.Value);
KeyBindingInputManager.Add(new ManiaTouchInputArea(this));
Config.BindWith(ManiaRulesetSetting.MobileLayout, mobileLayout);
mobileLayout.BindValueChanged(_ => updateMobileLayout(), true);
}
private ManiaTouchInputArea? touchInputArea;
private void updateMobileLayout()
{
switch (mobileLayout.Value)
{
case ManiaMobileLayout.LandscapeWithOverlay:
KeyBindingInputManager.Add(touchInputArea = new ManiaTouchInputArea(this));
break;
default:
if (touchInputArea != null)
KeyBindingInputManager.Remove(touchInputArea, true);
touchInputArea = null;
break;
}
}
protected override void AdjustScrollSpeed(int amount) => configScrollSpeed.Value += amount;
@@ -46,8 +46,6 @@ namespace osu.Game.Rulesets.Mania.UI
private GridContainer gridContainer = null!;
private readonly BindableBool touchControls = new BindableBool();
public ManiaTouchInputArea(DrawableManiaRuleset drawableRuleset)
{
this.drawableRuleset = drawableRuleset;
@@ -80,7 +78,6 @@ namespace osu.Game.Rulesets.Mania.UI
receptorGridContent.Add(new ColumnInputReceptor
{
Action = { BindTarget = column.Action },
Enabled = { BindTarget = touchControls },
});
receptorGridDimensions.Add(new Dimension());
@@ -97,15 +94,9 @@ namespace osu.Game.Rulesets.Mania.UI
};
}
private IBindable<ManiaMobileLayout> mobilePlayStyle = null!;
protected override void LoadComplete()
{
base.LoadComplete();
mobilePlayStyle = rulesetConfig.GetBindable<ManiaMobileLayout>(ManiaRulesetSetting.MobileLayout);
mobilePlayStyle.BindValueChanged(p => touchControls.Value = p.NewValue == ManiaMobileLayout.LandscapeWithOverlay, true);
Opacity.BindValueChanged(o => Alpha = o.NewValue, true);
}
@@ -118,13 +109,8 @@ namespace osu.Game.Rulesets.Mania.UI
protected override bool OnTouchDown(TouchDownEvent e)
{
if (touchControls.Value)
{
Show();
return true;
}
return false;
Show();
return true;
}
protected override void PopIn()
@@ -140,7 +126,6 @@ namespace osu.Game.Rulesets.Mania.UI
public partial class ColumnInputReceptor : CompositeDrawable
{
public readonly IBindable<ManiaAction> Action = new Bindable<ManiaAction>();
public readonly IBindable<bool> Enabled = new BindableBool();
private readonly Box highlightOverlay;
@@ -180,13 +165,8 @@ namespace osu.Game.Rulesets.Mania.UI
protected override bool OnTouchDown(TouchDownEvent e)
{
if (Enabled.Value)
{
updateButton(true);
return false; // handled by parent container to show overlay.
}
return false;
updateButton(true);
return false; // handled by parent container to show overlay.
}
protected override void OnTouchUp(TouchUpEvent e)