Skip to content

Commit

Permalink
Merge pull request #26575 from bdach/touch-device-multiplayer
Browse files Browse the repository at this point in the history
Fix touch device not always activating when it should
  • Loading branch information
frenzibyte committed Jan 16, 2024
2 parents 658fa14 + e5f6717 commit 15a5fd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -51,7 +51,6 @@ public override void SetUpSteps()
public void TestUserAlreadyHasTouchDeviceActive()
{
loadPlayer();
// it is presumed that a previous screen (i.e. song select) will set this up
AddStep("set up touchscreen user", () =>
{
currentPlayer.Score.ScoreInfo.Mods = currentPlayer.Score.ScoreInfo.Mods.Append(new OsuModTouchDevice()).ToArray();
Expand All @@ -69,6 +68,14 @@ public void TestUserAlreadyHasTouchDeviceActive()
AddAssert("touch device mod activated", () => currentPlayer.Score.ScoreInfo.Mods, () => Has.One.InstanceOf<OsuModTouchDevice>());
}

[Test]
public void TestTouchActivePriorToPlayerLoad()
{
AddStep("set touch input active", () => statics.SetValue(Static.TouchInputActive, true));
loadPlayer();
AddUntilStep("touch device mod activated", () => currentPlayer.Score.ScoreInfo.Mods, () => Has.One.InstanceOf<OsuModTouchDevice>());
}

[Test]
public void TestTouchDuringBreak()
{
Expand Down
6 changes: 5 additions & 1 deletion osu.Game/Screens/Play/PlayerTouchInputDetector.cs
Expand Up @@ -20,12 +20,16 @@ public partial class PlayerTouchInputDetector : Component
private GameplayState gameplayState { get; set; } = null!;

private IBindable<bool> touchActive = new BindableBool();
private IBindable<bool> isBreakTime = null!;

[BackgroundDependencyLoader]
private void load(SessionStatics statics)
{
touchActive = statics.GetBindable<bool>(Static.TouchInputActive);
touchActive.BindValueChanged(_ => updateState());

isBreakTime = player.IsBreakTime.GetBoundCopy();
isBreakTime.BindValueChanged(_ => updateState(), true);
}

private void updateState()
Expand All @@ -39,7 +43,7 @@ private void updateState()
if (gameplayState.Score.ScoreInfo.Mods.OfType<ModTouchDevice>().Any())
return;

if (player.IsBreakTime.Value)
if (isBreakTime.Value)
return;

var touchDeviceMod = gameplayState.Ruleset.GetTouchDeviceMod();
Expand Down

0 comments on commit 15a5fd7

Please sign in to comment.