refactoring; removed configuration setup; added consistent sprite batch; got rid of sprite batch settings; implemented newer setup;
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.Render;
|
||||
using RecrownedAthenaeum.SpecialTypes;
|
||||
using System;
|
||||
|
||||
@@ -49,7 +50,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
|
||||
/// Draws the image with default values.
|
||||
/// </summary>
|
||||
/// <param name="batch">The batch to use.</param>
|
||||
public override void Draw(SpriteBatch batch)
|
||||
public override void Draw(ConsistentSpriteBatch batch)
|
||||
{
|
||||
batch.Draw(texture, situation, null, color, rotation, origin, SpriteEffects.None, 0f);
|
||||
base.Draw(batch);
|
||||
@@ -63,7 +64,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
|
||||
/// <param name="color">The color tint to use.</param>
|
||||
/// <param name="rotation">Rotation of image.</param>
|
||||
/// <param name="origin">Origin for the rotation.</param>
|
||||
public void Draw(SpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
|
||||
public void Draw(ConsistentSpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
|
||||
{
|
||||
this.color = color;
|
||||
this.rotation = rotation;
|
||||
|
@@ -4,6 +4,7 @@ using RecrownedAthenaeum.SpecialTypes;
|
||||
using RecrownedAthenaeum.Input;
|
||||
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
||||
using RecrownedAthenaeum.UI.SkinSystem;
|
||||
using RecrownedAthenaeum.Render;
|
||||
|
||||
namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
|
||||
{
|
||||
@@ -80,7 +81,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
|
||||
/// Draws the button.
|
||||
/// </summary>
|
||||
/// <param name="batch">Batch used to draw the button.</param>
|
||||
public override void Draw(SpriteBatch batch)
|
||||
public override void Draw(ConsistentSpriteBatch batch)
|
||||
{
|
||||
if (disabled)
|
||||
{
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.Render;
|
||||
using RecrownedAthenaeum.SpecialTypes;
|
||||
using RecrownedAthenaeum.UI.SkinSystem;
|
||||
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
|
||||
@@ -84,7 +85,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
|
||||
/// Called whenever game wants to render this button.
|
||||
/// </summary>
|
||||
/// <param name="batch">Batch to use. Batch should already be started.</param>
|
||||
public override void Draw(SpriteBatch batch)
|
||||
public override void Draw(ConsistentSpriteBatch batch)
|
||||
{
|
||||
base.Draw(batch);
|
||||
text.Draw(batch);
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using RecrownedAthenaeum.Render;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
@@ -80,7 +81,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
|
||||
/// Draws the text.
|
||||
/// </summary>
|
||||
/// <param name="batch">Batch to use.</param>
|
||||
public override void Draw(SpriteBatch batch)
|
||||
public override void Draw(ConsistentSpriteBatch batch)
|
||||
{
|
||||
batch.DrawString(font, Content, position, color, 0f, default(Vector2), scale, SpriteEffects.None, 0f);
|
||||
base.Draw(batch);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using RecrownedAthenaeum.Input;
|
||||
using RecrownedAthenaeum.Render;
|
||||
using System;
|
||||
|
||||
namespace RecrownedAthenaeum.UI.Modular
|
||||
@@ -61,7 +62,7 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
/// 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 virtual void Draw(ConsistentSpriteBatch batch)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -14,36 +14,22 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
public class UIModuleGroup : UIModule
|
||||
{
|
||||
List<UIModule> modules = new List<UIModule>();
|
||||
ScissorBox scissorBox;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for starting sprite batch after scissoring. Only used if cropping.
|
||||
/// Set this to crop anything that flows out of the boundaries of this group. Will not crop if this is null.
|
||||
/// </summary>
|
||||
public SpriteBatchSettings spriteBatchSettings;
|
||||
public ScissorBox scissorBox;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a module group.
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="crop">Whether or not to crop out of bounds. Default is false.</param>
|
||||
public UIModuleGroup(bool crop = false)
|
||||
{
|
||||
this.spriteBatchSettings = Configuration.SpriteBatchSettings.Value;
|
||||
if (crop)
|
||||
{
|
||||
scissorBox = new ScissorBox();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws this group of modules.
|
||||
/// </summary>
|
||||
/// <param name="batch">Batch used to draw the group.</param>
|
||||
public override void Draw(SpriteBatch batch)
|
||||
/// <param name="spriteBatch">Batch used to draw the group.</param>
|
||||
public override void Draw(ConsistentSpriteBatch spriteBatch)
|
||||
{
|
||||
if (scissorBox != null)
|
||||
{
|
||||
batch.End();
|
||||
scissorBox.Begin(Boundaries, batch, spriteBatchSettings);
|
||||
spriteBatch.End();
|
||||
scissorBox.Begin(Boundaries, spriteBatch);
|
||||
}
|
||||
|
||||
foreach (UIModule module in modules)
|
||||
@@ -52,7 +38,7 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
int offsetY = module.situation.Y;
|
||||
module.situation.X = situation.X + offsetX;
|
||||
module.situation.Y = situation.Y + offsetY;
|
||||
module.Draw(batch);
|
||||
module.Draw(spriteBatch);
|
||||
module.situation.X = offsetX;
|
||||
module.situation.Y = offsetY;
|
||||
}
|
||||
@@ -61,6 +47,8 @@ namespace RecrownedAthenaeum.UI.Modular
|
||||
{
|
||||
scissorBox.End();
|
||||
|
||||
GraphicsDevice graphics = spriteBatch.GraphicsDevice;
|
||||
spriteBatch.Begin();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user