2018-11-30 02:41:06 +00:00
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
2018-12-04 13:45:09 +00:00
|
|
|
|
using RecrownedAthenaeum.Camera;
|
|
|
|
|
using RecrownedAthenaeum.Input;
|
2018-11-30 02:41:06 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2018-12-04 13:45:09 +00:00
|
|
|
|
namespace RecrownedAthenaeum.UI.Modular
|
2018-11-30 02:41:06 +00:00
|
|
|
|
{
|
|
|
|
|
public class UIModule : IInputListener
|
|
|
|
|
{
|
|
|
|
|
public Rectangle bounds;
|
|
|
|
|
public Vector2 origin;
|
|
|
|
|
public UIModuleGroup Parent;
|
|
|
|
|
public string Name;
|
|
|
|
|
public Color color = Color.White;
|
|
|
|
|
|
|
|
|
|
public virtual void Update(GameTime gameTime)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Draw(SpriteBatch batch)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Rectangle ConvertToParentCoordinates(Rectangle bounds)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
return bounds;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveFromParent()
|
|
|
|
|
{
|
|
|
|
|
if (Parent == null)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Parent is null.");
|
|
|
|
|
}
|
|
|
|
|
Parent.RemoveModule(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called whenever the keyboard state is changed.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="state">The current keyboard state.</param>
|
|
|
|
|
/// <returns>Returning whether or not to continue to call the next listener.</returns>
|
|
|
|
|
public virtual bool KeyboardStateChanged(KeyboardState state)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called whenever the state of the mouse changes. This includes movement.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="state">The current state of the mouse.</param>
|
|
|
|
|
/// <returns>Returning whether or not to continue to call the next listener.</returns>
|
|
|
|
|
public virtual bool MouseStateChanged(MouseState state)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|