Many refactors and minor changes. idk.
This commit is contained in:
@@ -10,12 +10,27 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
/// <summary>
|
||||
/// Module for UI layout.
|
||||
/// </summary>
|
||||
public class UIModule : IInputListener
|
||||
public abstract class UIModule : IInputListener
|
||||
{
|
||||
/// <summary>
|
||||
/// The bounds before factoring in the origin.
|
||||
/// The width of the module.
|
||||
/// </summary>
|
||||
public Rectangle situation;
|
||||
public virtual int Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The height of the module.
|
||||
/// </summary>
|
||||
public virtual int Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The X position of the module.
|
||||
/// </summary>
|
||||
public virtual int X { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Y position of the module.
|
||||
/// </summary>
|
||||
public virtual int Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Bounds of this module (after factoring in the origin).
|
||||
@@ -24,7 +39,7 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Rectangle((int)(situation.X - origin.X), (int)(situation.Y - origin.Y), situation.Width, situation.Height);
|
||||
return new Rectangle((int)(X - origin.X), (int)(Y - origin.Y), Width, Height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,16 +130,16 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the origin to be the center of the bounds.
|
||||
/// Sets the origin to be the center using the <see cref="Width"/> and <see cref="Height"/>.
|
||||
/// </summary>
|
||||
public void CenterOrigin()
|
||||
public virtual void CenterOrigin()
|
||||
{
|
||||
origin.X = situation.Width / 2f;
|
||||
origin.Y = situation.Height / 2f;
|
||||
origin.X = Width / 2f;
|
||||
origin.Y = Height / 2f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Centers this module's origin on the horizontal axis relative to the parent <see cref="UIModuleGroup"/>.
|
||||
/// Centers this module's on the horizontal axis relative to the parent <see cref="UIModuleGroup"/>.
|
||||
/// </summary>
|
||||
/// <returns>True if possible and false if not.</returns>
|
||||
public bool CenterHorizontally()
|
||||
@@ -134,7 +149,7 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
Rectangle rectangle = parent.Boundaries;
|
||||
if (parent != null && rectangle.Width >= Boundaries.Width)
|
||||
{
|
||||
situation.X = rectangle.Width / 2 + situation.X;
|
||||
X = rectangle.Width / 2 + X;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -145,18 +160,30 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
/// Centers this module's origin on the vertical axis relative to the parent <see cref="UIModuleGroup"/>.
|
||||
/// </summary>
|
||||
/// <returns>True if possible.</returns>
|
||||
public bool CenterVertically()
|
||||
public virtual bool CenterVertically()
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
Rectangle rectangle = parent.Boundaries;
|
||||
if (rectangle.Height >= Boundaries.Height)
|
||||
{
|
||||
situation.Y = rectangle.Height / 2 + situation.Y;
|
||||
Y = rectangle.Height / 2 + Y;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the position and dimension of this module.
|
||||
/// </summary>
|
||||
/// <param name="rectangle">The rectangle that represents the position and dimensions of the module.</param>
|
||||
public virtual void SetPositionAndDimensions(Rectangle rectangle)
|
||||
{
|
||||
X = rectangle.X;
|
||||
Y = rectangle.Y;
|
||||
Width = rectangle.Width;
|
||||
Height = rectangle.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user