Merge pull request #12320 from smoogipoo/apply-screen-suspension-changes

Apply changes to AllowScreenSuspension bindable
This commit is contained in:
Dean Herbert 2021-04-07 23:52:18 +09:00 committed by GitHub
commit bdd58103ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 13 deletions

View File

@ -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>

View File

@ -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;
@ -19,6 +18,8 @@ namespace osu.Game.Screens.Play
private readonly GameplayClockContainer gameplayClockContainer;
private Bindable<bool> isPaused;
private readonly Bindable<bool> disableSuspensionBindable = new Bindable<bool>();
[Resolved]
private GameHost host { get; set; }
@ -31,12 +32,14 @@ namespace osu.Game.Screens.Play
{
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)
@ -44,9 +47,7 @@ namespace osu.Game.Screens.Play
base.Dispose(isDisposing);
isPaused?.UnbindAll();
if (host != null)
host.AllowScreenSuspension.Value = true;
host?.AllowScreenSuspension.RemoveSource(disableSuspensionBindable);
}
}
}

View File

@ -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" />

View File

@ -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) -->
@ -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" />