mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Lock screen rotation while in gameplay.
This commit is contained in:
31
osu.Android/GameplayScreenRotationLocker.cs
Normal file
31
osu.Android/GameplayScreenRotationLocker.cs
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Android.Content.PM;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game;
|
||||
|
||||
namespace osu.Android
|
||||
{
|
||||
public class GameplayScreenRotationLocker : Component
|
||||
{
|
||||
private Bindable<bool> localUserPlaying;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGame game)
|
||||
{
|
||||
localUserPlaying = game.LocalUserPlaying.GetBoundCopy();
|
||||
localUserPlaying.BindValueChanged(_ => updateLock());
|
||||
}
|
||||
|
||||
private void updateLock()
|
||||
{
|
||||
OsuGameActivity.Activity.RunOnUiThread(() =>
|
||||
{
|
||||
OsuGameActivity.Activity.RequestedOrientation = localUserPlaying.Value ? ScreenOrientation.Locked : ScreenOrientation.FullUser;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user