mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 14:25:10 +08:00
Simplify orientation locking code magnificently
This commit is contained in:
parent
ffc37cece0
commit
bb7daae080
@ -50,30 +50,22 @@ namespace osu.Game.Mobile
|
|||||||
bool lockCurrentOrientation = localUserPlaying.Value == LocalUserPlayingState.Playing;
|
bool lockCurrentOrientation = localUserPlaying.Value == LocalUserPlayingState.Playing;
|
||||||
bool lockToPortraitOnPhone = requiresPortraitOrientation.Value;
|
bool lockToPortraitOnPhone = requiresPortraitOrientation.Value;
|
||||||
|
|
||||||
if (lockCurrentOrientation)
|
if (IsTablet)
|
||||||
{
|
{
|
||||||
if (!IsTablet && lockToPortraitOnPhone && !IsCurrentOrientationPortrait)
|
if (lockCurrentOrientation)
|
||||||
SetAllowedOrientations(GameOrientation.Portrait);
|
|
||||||
else if (!IsTablet && !lockToPortraitOnPhone && IsCurrentOrientationPortrait)
|
|
||||||
SetAllowedOrientations(GameOrientation.Landscape);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// if the orientation is already portrait/landscape according to the game's specifications,
|
|
||||||
// then use Locked instead of Portrait/Landscape to handle the case where the device is
|
|
||||||
// in landscape-left or reverse-portrait.
|
|
||||||
SetAllowedOrientations(GameOrientation.Locked);
|
SetAllowedOrientations(GameOrientation.Locked);
|
||||||
}
|
else
|
||||||
|
SetAllowedOrientations(null);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!IsTablet && lockToPortraitOnPhone)
|
|
||||||
{
|
{
|
||||||
SetAllowedOrientations(GameOrientation.Portrait);
|
if (lockToPortraitOnPhone)
|
||||||
return;
|
SetAllowedOrientations(GameOrientation.Portrait);
|
||||||
|
else if (lockCurrentOrientation)
|
||||||
|
SetAllowedOrientations(GameOrientation.Locked);
|
||||||
|
else
|
||||||
|
SetAllowedOrientations(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetAllowedOrientations(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user