mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Standardise drawable state access and split large nested classes out of MainMenu.ButtonSystem
This commit is contained in:
36
osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs
Normal file
36
osu.Game/GameModes/Menu/FlowContainerWithOrigin.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.GameModes.Menu
|
||||
{
|
||||
/// <summary>
|
||||
/// A flow container with an origin based on one of its contained drawables.
|
||||
/// </summary>
|
||||
public class FlowContainerWithOrigin : FlowContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// A target drawable which this flowcontainer should be centered around.
|
||||
/// This target MUST be in this FlowContainer's *direct* children.
|
||||
/// </summary>
|
||||
internal Drawable CentreTarget;
|
||||
|
||||
public override Anchor Origin => Anchor.Custom;
|
||||
|
||||
public override Vector2 OriginPosition
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CentreTarget == null)
|
||||
return base.OriginPosition;
|
||||
|
||||
return CentreTarget.Position + CentreTarget.Size / 2;
|
||||
}
|
||||
}
|
||||
|
||||
public FlowContainerWithOrigin()
|
||||
{
|
||||
Direction = FlowDirection.HorizontalOnly;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user