1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 11:27:24 +08:00

Add the ability to temporarily disable user scaling on a ScalingContainer

This commit is contained in:
Dean Herbert 2021-04-29 17:19:47 +09:00
parent b460181f15
commit 141d3af302

View File

@ -36,6 +36,24 @@ namespace osu.Game.Graphics.Containers
private BackgroundScreenStack backgroundStack;
private bool allowScaling = true;
/// <summary>
/// Whether user scaling preferences should be applied. Enabled by default.
/// </summary>
public bool AllowScaling
{
get => allowScaling;
set
{
if (value == allowScaling)
return;
allowScaling = value;
updateSize();
}
}
/// <summary>
/// Create a new instance.
/// </summary>
@ -139,7 +157,7 @@ namespace osu.Game.Graphics.Containers
backgroundStack?.FadeOut(fade_time);
}
bool scaling = targetMode == null || scalingMode.Value == targetMode;
bool scaling = AllowScaling && (targetMode == null || scalingMode.Value == targetMode);
var targetSize = scaling ? new Vector2(sizeX.Value, sizeY.Value) : Vector2.One;
var targetPosition = scaling ? new Vector2(posX.Value, posY.Value) * (Vector2.One - targetSize) : Vector2.Zero;