1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-25 18:57:18 +08:00

Merge pull request #31371 from frenzibyte/ios-ui-scale

Improve default UI scale on iOS
This commit is contained in:
Dean Herbert 2025-02-14 22:57:36 +09:00 committed by GitHub
commit ff81096e1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 50 additions and 20 deletions

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="osu.Android">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

View File

@ -12,6 +12,7 @@ using osu.Game;
using osu.Game.Screens;
using osu.Game.Updater;
using osu.Game.Utils;
using osuTK;
namespace osu.Android
{
@ -20,6 +21,8 @@ namespace osu.Android
[Cached]
private readonly OsuGameActivity gameActivity;
protected override Vector2 ScalingContainerTargetDrawSize => new Vector2(1024, 1024 * DrawHeight / DrawWidth);
public OsuGameAndroid(OsuGameActivity activity)
: base(null)
{

View File

@ -238,7 +238,7 @@ namespace osu.Game.Configuration
public void Migrate()
{
// arrives as 2020.123.0
// arrives as 2020.123.0-lazer
string rawVersion = Get<string>(OsuSetting.Version);
if (rawVersion.Length < 6)
@ -251,11 +251,14 @@ namespace osu.Game.Configuration
if (!int.TryParse(pieces[0], out int year)) return;
if (!int.TryParse(pieces[1], out int monthDay)) return;
// ReSharper disable once UnusedVariable
int combined = (year * 10000) + monthDay;
int combined = year * 10000 + monthDay;
// migrations can be added here using a condition like:
// if (combined < 20220103) { performMigration() }
if (combined < 20250214)
{
// UI scaling on mobile platforms has been internally adjusted such that 1x UI scale looks correctly zoomed in than before.
if (RuntimeInfo.IsMobile)
GetBindable<float>(OsuSetting.UIScale).SetDefault();
}
}
public override TrackedSettings CreateTrackedSettings()

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -26,17 +24,17 @@ namespace osu.Game.Graphics.Containers
{
internal const float TRANSITION_DURATION = 500;
private Bindable<float> sizeX;
private Bindable<float> sizeY;
private Bindable<float> posX;
private Bindable<float> posY;
private Bindable<bool> applySafeAreaPadding;
private Bindable<float> sizeX = null!;
private Bindable<float> sizeY = null!;
private Bindable<float> posX = null!;
private Bindable<float> posY = null!;
private Bindable<bool> applySafeAreaPadding = null!;
private Bindable<MarginPadding> safeAreaPadding;
private Bindable<MarginPadding> safeAreaPadding = null!;
private readonly ScalingMode? targetMode;
private Bindable<ScalingMode> scalingMode;
private Bindable<ScalingMode> scalingMode = null!;
private readonly Container content;
protected override Container<Drawable> Content => content;
@ -45,9 +43,9 @@ namespace osu.Game.Graphics.Containers
private readonly Container sizableContainer;
private BackgroundScreenStack backgroundStack;
private BackgroundScreenStack? backgroundStack;
private Bindable<float> scalingMenuBackgroundDim;
private Bindable<float> scalingMenuBackgroundDim = null!;
private RectangleF? customRect;
private bool customRectIsRelativePosition;
@ -88,7 +86,8 @@ namespace osu.Game.Graphics.Containers
public partial class ScalingDrawSizePreservingFillContainer : DrawSizePreservingFillContainer
{
private readonly bool applyUIScale;
private Bindable<float> uiScale;
private Bindable<float>? uiScale;
protected float CurrentScale { get; private set; } = 1;
@ -99,6 +98,9 @@ namespace osu.Game.Graphics.Containers
this.applyUIScale = applyUIScale;
}
[Resolved(canBeNull: true)]
private OsuGame? game { get; set; }
[BackgroundDependencyLoader]
private void load(OsuConfigManager osuConfig)
{
@ -111,6 +113,8 @@ namespace osu.Game.Graphics.Containers
protected override void Update()
{
if (game != null)
TargetDrawSize = game.ScalingContainerTargetDrawSize;
Scale = new Vector2(CurrentScale);
Size = new Vector2(1 / CurrentScale);
@ -233,13 +237,13 @@ namespace osu.Game.Graphics.Containers
private partial class SizeableAlwaysInputContainer : Container
{
[Resolved]
private GameHost host { get; set; }
private GameHost host { get; set; } = null!;
[Resolved]
private ISafeArea safeArea { get; set; }
private ISafeArea safeArea { get; set; } = null!;
[Resolved]
private OsuConfigManager config { get; set; }
private OsuConfigManager config { get; set; } = null!;
private readonly bool confineHostCursor;
private readonly LayoutValue cursorRectCache = new LayoutValue(Invalidation.RequiredParentSizeToFit);

View File

@ -72,6 +72,7 @@ using osu.Game.Skinning;
using osu.Game.Updater;
using osu.Game.Users;
using osu.Game.Utils;
using osuTK;
using osuTK.Graphics;
using Sentry;
@ -813,6 +814,12 @@ namespace osu.Game
protected virtual UpdateManager CreateUpdateManager() => new UpdateManager();
/// <summary>
/// Adjust the globally applied <see cref="DrawSizePreservingFillContainer.TargetDrawSize"/> in every <see cref="ScalingContainer"/>.
/// Useful for changing how the game handles different aspect ratios.
/// </summary>
protected internal virtual Vector2 ScalingContainerTargetDrawSize { get; } = new Vector2(1024, 768);
protected override Container CreateScalingContainer() => new ScalingContainer(ScalingMode.Everything);
#region Beatmap progression

View File

@ -11,6 +11,7 @@ using osu.Game;
using osu.Game.Screens;
using osu.Game.Updater;
using osu.Game.Utils;
using osuTK;
using UIKit;
namespace osu.iOS
@ -22,6 +23,8 @@ namespace osu.iOS
public override bool HideUnlicensedContent => true;
protected override Vector2 ScalingContainerTargetDrawSize => new Vector2(1024, 1024 * DrawHeight / DrawWidth);
public OsuGameIOS(AppDelegate appDelegate)
{
this.appDelegate = appDelegate;