documentation

This commit is contained in:
2019-01-13 23:23:03 -06:00
parent 4ac011f3cf
commit 32c2f25196
6 changed files with 117 additions and 36 deletions

View File

@@ -14,29 +14,46 @@ namespace RecrownedAthenaeum.UI.Modular
public string Name;
public Color color = Color.White;
/// <summary>
/// Called every frame to update this module. Calculations and movement should go here.
/// </summary>
/// <param name="gameTime">Game time information.</param>
public virtual void Update(GameTime gameTime)
{
}
/// <summary>
/// Called every frame to draw this module. Anything that needs to be drawn should go here.
/// </summary>
/// <param name="batch">Batch used to draw.</param>
public virtual void Draw(SpriteBatch batch)
{
}
public Rectangle ConvertToParentCoordinates(Rectangle bounds)
/// <summary>
/// Converts the given rectangle to the coordinates of the parent.
/// </summary>
/// <param name="rectangle">Rectangle to convert.</param>
/// <returns></returns>
public Rectangle ConvertToParentCoordinates(Rectangle rectangle)
{
if (Parent != null)
{
Rectangle parentHitbox = Parent.ConvertToParentCoordinates(bounds);
int tX = bounds.X + parentHitbox.X;
int tY = bounds.Y + parentHitbox.Y;
return new Rectangle(tX, tY, bounds.Width, bounds.Height);
Rectangle parentHitbox = Parent.ConvertToParentCoordinates(rectangle);
int tX = rectangle.X + parentHitbox.X;
int tY = rectangle.Y + parentHitbox.Y;
return new Rectangle(tX, tY, rectangle.Width, rectangle.Height);
} else
{
return bounds;
return rectangle;
}
}
/// <summary>
/// Removes this module from the parent.
/// </summary>
public void RemoveFromParent()
{
if (Parent == null)

View File

@@ -65,6 +65,10 @@ namespace RecrownedAthenaeum.UI.Modular
}
}
/// <summary>
/// Adds module(s) to this group.
/// </summary>
/// <param name="addModules">The module(s) to add.</param>
public void AddModule(params UIModule[] addModules)
{
foreach (UIModule module in addModules)
@@ -78,6 +82,10 @@ namespace RecrownedAthenaeum.UI.Modular
}
}
/// <summary>
/// Removes given module from group.
/// </summary>
/// <param name="module">module to remove.</param>
public void RemoveModule(UIModule module)
{
module.Parent = null;