Scissoring now works and implemented; Refactoring as well;

This commit is contained in:
2019-03-27 02:35:20 -05:00
parent b045033b25
commit d7ca521b9b
17 changed files with 129 additions and 119 deletions

View File

@@ -1,7 +1,5 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using RecrownedAthenaeum.Camera;
using RecrownedAthenaeum.ContentSystem;
using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.Render;
@@ -28,11 +26,7 @@ namespace RecrownedAthenaeum.UI.BookSystem
/// The camera to use to change between pages.
/// </summary>
public Camera2D camera;
/// <summary>
/// The scissorbox used to crop things.
/// </summary>
public ScissorBox scissorBox;
private BasicScissor basicScissor;
/// <summary>
/// Creates a book.
@@ -40,14 +34,13 @@ namespace RecrownedAthenaeum.UI.BookSystem
/// <param name="assets"><see cref="ContentManagerController"/> that holds the assets that are to be used in the pages for this book during initialization.</param>
/// <param name="skin">The skin that will be passed to pages during their initialization.</param>
/// <param name="camera">Camera to move to change pages.</param>
/// <param name="scissorBox">The scissor box to use to crop the pages to the given dimensions. Default is null, and will not crop anything.</param>
public Book(ContentManagerController assets, ISkin skin, Camera2D camera, ScissorBox scissorBox = null)
public Book(ContentManagerController assets, ISkin skin, Camera2D camera)
{
this.assets = assets;
this.skin = skin;
this.camera = camera ?? throw new ArgumentNullException("Camera can't be null since book needs a camera to move to change between the slides (pages).");
this.scissorBox = scissorBox;
this.basicScissor = new BasicScissor();
}
/// <summary>
@@ -57,8 +50,7 @@ namespace RecrownedAthenaeum.UI.BookSystem
/// </summary>
/// <param name="camera">Camera to move to change pages.</param>
/// <param name="dimensions">Dimensions of the book and the dimensions the pages will use.</param>
/// <param name="scissorBox">The scissor box to use to crop the pages to the given dimensions. Default is null, and will not crop anything.</param>
public void Initiate(Camera2D camera, Rectangle dimensions, ScissorBox scissorBox = null)
public void Initiate(Camera2D camera, Rectangle dimensions)
{
this.camera = camera;
}
@@ -133,7 +125,7 @@ namespace RecrownedAthenaeum.UI.BookSystem
{
orderedPages.Add(page);
this.pages.Add(page.name, page);
page.Initialize(assets, skin, scissorBox);
page.Initialize(assets, skin, basicScissor);
}
}

View File

@@ -48,10 +48,10 @@ namespace RecrownedAthenaeum.UI.BookSystem
/// </summary>
/// <param name="assets">The assets to be used during initialization passed by the book this page belongs to.</param>
/// <param name="skin">The skin the book containing this page is given that can be used by this page.</param>
/// <param name="scissorBox">The scissor box to use for cropping.</param>
protected internal virtual void Initialize(ContentManagerController assets, ISkin skin, ScissorBox scissorBox)
/// <param name="basicScissor">The scissor box to use for cropping.</param>
protected internal virtual void Initialize(ContentManagerController assets, ISkin skin, BasicScissor basicScissor)
{
this.scissorBox = scissorBox;
this.basicScissor = basicScissor;
}
}
}

View File

@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input;
using RecrownedAthenaeum.SpecialTypes;
using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.UI.SkinSystem.Definitions;

View File

@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.Render;

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using RecrownedAthenaeum.Render;
@@ -18,18 +17,18 @@ namespace RecrownedAthenaeum.UI.Modular
/// <summary>
/// Set this to crop anything that flows out of the boundaries of this group. Will not crop if this is null.
/// </summary>
public ScissorBox scissorBox;
public BasicScissor basicScissor;
/// <summary>
/// Draws this group of modules. If scissoring, will use the matrix and effect designated in the <see cref="ScissorBox"/> to begin the batch normally again.
/// Draws this group of modules. If scissoring, will use the matrix and effect designated in the <see cref="BasicScissor"/> to begin the batch normally again.
/// </summary>
/// <param name="spriteBatch">Batch used to draw the group.</param>
public override void Draw(ConsistentSpriteBatch spriteBatch)
{
if (scissorBox != null)
if (basicScissor != null)
{
spriteBatch.End();
scissorBox.Begin(Boundaries, spriteBatch);
basicScissor.Begin(Boundaries, spriteBatch);
}
foreach (UIModule module in modules)
@@ -43,11 +42,9 @@ namespace RecrownedAthenaeum.UI.Modular
module.situation.Y = offsetY;
}
if (scissorBox != null)
if (basicScissor != null)
{
scissorBox.End();
GraphicsDevice graphics = spriteBatch.GraphicsDevice;
basicScissor.End();
spriteBatch.Begin();
}
}