-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31968 from frenzibyte/fix-scaling-issues
Fix osu!taiko and osu!catch being oversized on mobile platforms
- Loading branch information
Showing
6 changed files
with
60 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Game.Rulesets.UI; | ||
|
@@ -15,6 +16,8 @@ public partial class CatchPlayfieldAdjustmentContainer : PlayfieldAdjustmentCont | |
protected override Container<Drawable> Content => content; | ||
private readonly Container content; | ||
|
||
private readonly Container scaleContainer; | ||
|
||
public CatchPlayfieldAdjustmentContainer() | ||
{ | ||
const float base_game_width = 1024f; | ||
|
@@ -26,30 +29,49 @@ public CatchPlayfieldAdjustmentContainer() | |
Anchor = Anchor.Centre; | ||
Origin = Anchor.Centre; | ||
|
||
InternalChild = new Container | ||
InternalChild = scaleContainer = new Container | ||
{ | ||
// This container limits vertical visibility of the playfield to ensure fairness between wide and tall resolutions (i.e. tall resolutions should not see more fruits). | ||
// Note that the container still extends across the screen horizontally, so that hit explosions at the sides of the playfield do not get cut off. | ||
Name = "Visible area", | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
RelativeSizeAxes = Axes.X, | ||
Height = base_game_height + extra_bottom_space, | ||
Y = extra_bottom_space / 2, | ||
Masking = true, | ||
RelativeSizeAxes = Axes.Both, | ||
Child = new Container | ||
{ | ||
Name = "Playable area", | ||
Anchor = Anchor.TopCentre, | ||
Origin = Anchor.TopCentre, | ||
// playfields in stable are positioned vertically at three fourths the difference between the playfield height and the window height in stable. | ||
Y = base_game_height * ((1 - playfield_size_adjust) / 4 * 3), | ||
Size = new Vector2(base_game_width, base_game_height) * playfield_size_adjust, | ||
Child = content = new ScalingContainer { RelativeSizeAxes = Axes.Both } | ||
}, | ||
// This container limits vertical visibility of the playfield to ensure fairness between wide and tall resolutions (i.e. tall resolutions should not see more fruits). | ||
// Note that the container still extends across the screen horizontally, so that hit explosions at the sides of the playfield do not get cut off. | ||
Name = "Visible area", | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
RelativeSizeAxes = Axes.X, | ||
Height = base_game_height + extra_bottom_space, | ||
Y = extra_bottom_space / 2, | ||
Masking = true, | ||
Child = new Container | ||
{ | ||
Name = "Playable area", | ||
Anchor = Anchor.TopCentre, | ||
Origin = Anchor.TopCentre, | ||
// playfields in stable are positioned vertically at three fourths the difference between the playfield height and the window height in stable. | ||
Y = base_game_height * ((1 - playfield_size_adjust) / 4 * 3), | ||
Size = new Vector2(base_game_width, base_game_height) * playfield_size_adjust, | ||
Child = content = new ScalingContainer { RelativeSizeAxes = Axes.Both } | ||
}, | ||
} | ||
}; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(OsuGame? osuGame) | ||
{ | ||
if (osuGame != null) | ||
{ | ||
// on mobile platforms where the base aspect ratio is wider, the catch playfield | ||
// needs to be scaled down to remain playable. | ||
const float base_aspect_ratio = 1024f / 768f; | ||
float aspectRatio = osuGame.ScalingContainerTargetDrawSize.X / osuGame.ScalingContainerTargetDrawSize.Y; | ||
scaleContainer.Scale = new Vector2(base_aspect_ratio / aspectRatio); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// A <see cref="Container"/> which scales its content relative to a target width. | ||
/// </summary> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters