mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 17:53:15 +08:00
Move aspect adjustments out of CatchPlayfield
This commit is contained in:
parent
0bc2bcaf14
commit
c3fa7f167f
@ -33,31 +33,23 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
Size = new Vector2(0.86f); // matches stable's vertical offset for catcher plate
|
Size = new Vector2(0.86f); // matches stable's vertical offset for catcher plate
|
||||||
|
|
||||||
InternalChild = new Container
|
InternalChild = new PlayfieldLayer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
FillMode = FillMode.Fit,
|
Children = new Drawable[]
|
||||||
FillAspectRatio = 4f / 3,
|
|
||||||
Child = new PlayfieldLayer
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
explodingFruitContainer = new Container
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
explodingFruitContainer = new Container
|
RelativeSizeAxes = Axes.Both,
|
||||||
{
|
},
|
||||||
RelativeSizeAxes = Axes.Both,
|
catcherArea = new CatcherArea(difficulty)
|
||||||
},
|
{
|
||||||
catcherArea = new CatcherArea(difficulty)
|
GetVisualRepresentation = getVisualRepresentation,
|
||||||
{
|
ExplodingFruitTarget = explodingFruitContainer,
|
||||||
GetVisualRepresentation = getVisualRepresentation,
|
Anchor = Anchor.BottomLeft,
|
||||||
ExplodingFruitTarget = explodingFruitContainer,
|
Origin = Anchor.TopLeft,
|
||||||
Anchor = Anchor.BottomLeft,
|
},
|
||||||
Origin = Anchor.TopLeft,
|
HitObjectContainer
|
||||||
},
|
|
||||||
HitObjectContainer
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
@ -8,12 +9,34 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
{
|
{
|
||||||
public class PlayfieldLayer : Container
|
public class PlayfieldLayer : Container
|
||||||
{
|
{
|
||||||
protected override void Update()
|
protected override Container<Drawable> Content => content;
|
||||||
{
|
private readonly Container content;
|
||||||
base.Update();
|
|
||||||
|
|
||||||
Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.BASE_WIDTH);
|
public PlayfieldLayer()
|
||||||
Size = Vector2.Divide(Vector2.One, Scale);
|
{
|
||||||
|
InternalChild = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
FillAspectRatio = 4f / 3,
|
||||||
|
Child = content = new ScalingContainer { RelativeSizeAxes = Axes.Both }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="Container"/> which scales its content relative to a target width.
|
||||||
|
/// </summary>
|
||||||
|
private class ScalingContainer : Container
|
||||||
|
{
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
Scale = new Vector2(Parent.ChildSize.X / CatchPlayfield.BASE_WIDTH);
|
||||||
|
Size = Vector2.Divide(Vector2.One, Scale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user