|
|
|
@@ -3,9 +3,7 @@ using System.Collections.Generic;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
|
|
using RecrownedAthenaeum.Camera;
|
|
|
|
|
using RecrownedAthenaeum.Render;
|
|
|
|
|
using RecrownedAthenaeum.ScreenSystem;
|
|
|
|
|
|
|
|
|
|
namespace RecrownedAthenaeum.UI.Modular
|
|
|
|
|
{
|
|
|
|
@@ -16,32 +14,23 @@ namespace RecrownedAthenaeum.UI.Modular
|
|
|
|
|
public class UIModuleGroup : UIModule
|
|
|
|
|
{
|
|
|
|
|
List<UIModule> modules = new List<UIModule>();
|
|
|
|
|
Rectangle scissorBounds;
|
|
|
|
|
RasterizerState scissorRasterizer;
|
|
|
|
|
SpriteBatchSettings spriteBatchSettings;
|
|
|
|
|
ScissorBox scissorBox;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Camera used by the module for cropping.
|
|
|
|
|
/// Configuration for starting sprite batch after scissoring. Only used if cropping.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Camera2D camera;
|
|
|
|
|
public SpriteBatchSettings spriteBatchSettings;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a module group.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="crop">Whether or not to crop out of bounds. Default is false.</param>
|
|
|
|
|
/// <param name="camera">What camera to use for cropping. Default is null and will use <see cref="Configuration"/>'s camera if crop is enabled.</param>
|
|
|
|
|
/// <param name="spriteBatchSettings">The settings to be used that begins the batch.</param>
|
|
|
|
|
public UIModuleGroup(bool crop = false, Camera2D camera = null, SpriteBatchSettings? spriteBatchSettings = null)
|
|
|
|
|
public UIModuleGroup(bool crop = false)
|
|
|
|
|
{
|
|
|
|
|
if (spriteBatchSettings == null) spriteBatchSettings = Configuration.spriteBatchSettings;
|
|
|
|
|
if (crop && camera == null) camera = Configuration.Camera2D;
|
|
|
|
|
this.spriteBatchSettings = spriteBatchSettings.Value;
|
|
|
|
|
this.camera = camera;
|
|
|
|
|
this.spriteBatchSettings = Configuration.SpriteBatchSettings.Value;
|
|
|
|
|
if (crop)
|
|
|
|
|
{
|
|
|
|
|
scissorRasterizer = new RasterizerState();
|
|
|
|
|
scissorRasterizer.ScissorTestEnable = true;
|
|
|
|
|
scissorBounds = new Rectangle();
|
|
|
|
|
scissorBox = new ScissorBox();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -51,17 +40,10 @@ namespace RecrownedAthenaeum.UI.Modular
|
|
|
|
|
/// <param name="batch">Batch used to draw the group.</param>
|
|
|
|
|
public override void Draw(SpriteBatch batch)
|
|
|
|
|
{
|
|
|
|
|
if (scissorBounds != null)
|
|
|
|
|
if (scissorBox != null)
|
|
|
|
|
{
|
|
|
|
|
batch.End();
|
|
|
|
|
spriteBatchSettings.BeginSpriteBatch(batch);
|
|
|
|
|
scissorBounds.Width = situation.Width;
|
|
|
|
|
scissorBounds.Height = situation.Height;
|
|
|
|
|
scissorBounds.X = situation.X;
|
|
|
|
|
scissorBounds.Y = situation.Y;
|
|
|
|
|
Rectangle scissor = scissorBounds;
|
|
|
|
|
scissorBounds = batch.GraphicsDevice.ScissorRectangle;
|
|
|
|
|
batch.GraphicsDevice.ScissorRectangle = scissor;
|
|
|
|
|
scissorBox.Begin(Boundaries, batch, spriteBatchSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (UIModule module in modules)
|
|
|
|
@@ -75,11 +57,10 @@ namespace RecrownedAthenaeum.UI.Modular
|
|
|
|
|
module.situation.Y = offsetY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (scissorBounds != null)
|
|
|
|
|
if (scissorBox != null)
|
|
|
|
|
{
|
|
|
|
|
batch.GraphicsDevice.ScissorRectangle = scissorBounds;
|
|
|
|
|
batch.End();
|
|
|
|
|
spriteBatchSettings.BeginSpriteBatch(batch);
|
|
|
|
|
scissorBox.End();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|