Skip to content

Commit

Permalink
Merge pull request ppy#12320 from smoogipoo/apply-screen-suspension-c…
Browse files Browse the repository at this point in the history
…hanges

Apply changes to AllowScreenSuspension bindable
  • Loading branch information
peppy authored Apr 7, 2021
2 parents 6eb809f + 544fff5 commit bdd5810
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion osu.Android.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.402.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.407.0" />
</ItemGroup>
</Project>
19 changes: 10 additions & 9 deletions osu.Game/Screens/Play/ScreenSuspensionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
Expand All @@ -19,6 +18,8 @@ public class ScreenSuspensionHandler : Component
private readonly GameplayClockContainer gameplayClockContainer;
private Bindable<bool> isPaused;

private readonly Bindable<bool> disableSuspensionBindable = new Bindable<bool>();

[Resolved]
private GameHost host { get; set; }

Expand All @@ -31,22 +32,22 @@ protected override void LoadComplete()
{
base.LoadComplete();

// This is the only usage game-wide of suspension changes.
// Assert to ensure we don't accidentally forget this in the future.
Debug.Assert(host.AllowScreenSuspension.Value);

isPaused = gameplayClockContainer.IsPaused.GetBoundCopy();
isPaused.BindValueChanged(paused => host.AllowScreenSuspension.Value = paused.NewValue, true);
isPaused.BindValueChanged(paused =>
{
if (paused.NewValue)
host.AllowScreenSuspension.RemoveSource(disableSuspensionBindable);
else
host.AllowScreenSuspension.AddSource(disableSuspensionBindable);
}, true);
}

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);

isPaused?.UnbindAll();

if (host != null)
host.AllowScreenSuspension.Value = true;
host?.AllowScreenSuspension.RemoveSource(disableSuspensionBindable);
}
}
}
2 changes: 1 addition & 1 deletion osu.Game/osu.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2021.402.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.407.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
<PackageReference Include="Sentry" Version="3.2.0" />
<PackageReference Include="SharpCompress" Version="0.28.1" />
Expand Down
4 changes: 2 additions & 2 deletions osu.iOS.props
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.402.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.407.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.211.1" />
</ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
Expand All @@ -93,7 +93,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2021.402.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.407.0" />
<PackageReference Include="SharpCompress" Version="0.28.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />
Expand Down

0 comments on commit bdd5810

Please sign in to comment.