Replaced color usage with OpenTK's implementation.

This commit is contained in:
Harrison Deng 2019-12-28 15:41:06 -06:00
parent c9ad922341
commit 005d66840d
31 changed files with 155 additions and 139 deletions

View File

@ -1,4 +1,6 @@
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
using System;
using RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions;
using OpenTK.Graphics;
using RecrownedAthenaeum.Types;
namespace RecrownedAthenaeum.Data
@ -74,13 +76,13 @@ namespace RecrownedAthenaeum.Data
/// </summary>
/// <param name="name">the name to be referenced by.</param>
/// <param name="color">The color value <paramref name="name"/> represents.</param>
public ColorData(string name, Color color)
public ColorData(string name, Color4 color)
{
this.name = name;
r = color.r;
g = color.g;
b = color.b;
a = color.a;
r = color.GetRedAsByte();
g = color.GetGreenAsByte();
b = color.GetBlueAsByte();
a = color.GetAlphaAsByte();
}
}

View File

@ -1,6 +1,4 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OpenTK;
namespace RecrownedAthenaeum.Graphics.Render
{
/// <summary>

View File

@ -0,0 +1,13 @@
using System;
namespace RecrownedAthenaeum.Graphics.Render {
public class Batch {
private bool begun;
public Batch() {
}
public void Begin() {
if (begun) throw new InvalidOperationException("This batch has already been started.");
begun = true;
}
}
}

View File

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

View File

@ -1,5 +1,5 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OpenTK.Graphics;
using OpenTK;
using System;
namespace RecrownedAthenaeum.Graphics.Render
@ -78,7 +78,7 @@ namespace RecrownedAthenaeum.Graphics.Render
/// </summary>
/// <param name="vertex">The vector that represents the vertex.</param>
/// <param name="color">The color of that vertex.</param>
public void AddVertex(Vector2 vertex, Color color)
public void AddVertex(Vector2 vertex, Color4 color)
{
if (!began) throw new InvalidOperationException("Begin needs to be called before adding vertex.");
if (disposed) throw new ObjectDisposedException(this.GetType().Name);

View File

@ -1,5 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OpenTK.Graphics;
using OpenTK;
using RecrownedAthenaeum.Types;
using System;
namespace RecrownedAthenaeum.Graphics.Render
@ -73,7 +74,7 @@ namespace RecrownedAthenaeum.Graphics.Render
/// <param name="height">Height of rectangle.</param>
/// <param name="color">Color of all vertices of this rectangle.</param>
/// <param name="rotation">Rotation of rectangle. Default is 0 radians.</param>
public void Draw(int x, int y, int width, int height, Color color, float rotation = 0)
public void Draw(int x, int y, int width, int height, Color4 color, float rotation = 0)
{
primitiveBatch.primitiveCount = filled ? 3 : 4;
Vector2[] corners = new Vector2[4];
@ -110,7 +111,7 @@ namespace RecrownedAthenaeum.Graphics.Render
/// </summary>
/// <param name="rectangle">Uses the x, y and dimensions to draw a rectangle.</param>
/// <param name="color">The color of the rectangle.</param>
public void Draw(Rectangle rectangle, Color color)
public void Draw(Rectangle rectangle, Color4 color)
{
Draw(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, color);
}

View File

@ -1,13 +1,14 @@
using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.Assets;
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.UI.SkinSystem;
using RecrownedAthenaeum.Graphics.UI.SkinSystem;
using System;
using System.Collections.Generic;
using System.Linq;
using RecrownedAthenaeum.Types;
using OpenTK;
namespace RecrownedAthenaeum.UI.BookSystem
namespace RecrownedAthenaeum.Graphics.UI.BookSystem
{
/// <summary>
/// Contains the pages.

View File

@ -1,9 +1,9 @@
using RecrownedAthenaeum.Assets;
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.UI.Modular;
using RecrownedAthenaeum.UI.SkinSystem;
using RecrownedAthenaeum.Graphics.UI.Modular;
using RecrownedAthenaeum.Graphics.UI.SkinSystem;
namespace RecrownedAthenaeum.UI.BookSystem
namespace RecrownedAthenaeum.Graphics.UI.BookSystem
{
/// <summary>
/// A page a part of a <see cref="Book"/>.

View File

@ -1,8 +1,10 @@
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.Types;
using OpenTK;
using OpenTK.Graphics;
using System;
namespace RecrownedAthenaeum.UI.Modular.Modules
namespace RecrownedAthenaeum.Graphics.UI.Modular.Modules
{
/// <summary>
/// Represents a texture with more information.
@ -62,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(ConsistentSpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
public void Draw(ConsistentSpriteBatch spriteBatch, Rectangle destination, Color4 color, float rotation = 0, Vector2 origin = default(Vector2))
{
this.color = color;
this.rotation = rotation;

View File

@ -1,10 +1,10 @@
using RecrownedAthenaeum.Types;
using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
using RecrownedAthenaeum.UI.SkinSystem;
using RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions;
using RecrownedAthenaeum.Graphics.UI.SkinSystem;
using RecrownedAthenaeum.Graphics.Render;
namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
namespace RecrownedAthenaeum.Graphics.UI.Modular.Modules.Interactive
{
/// <summary>
/// Function to be called when button is clicked.

View File

@ -1,9 +1,9 @@
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.Types;
using RecrownedAthenaeum.UI.SkinSystem;
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
using OpenTK.Graphics;
using RecrownedAthenaeum.Graphics.UI.SkinSystem;
using RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions;
namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
namespace RecrownedAthenaeum.Graphics.UI.Modular.Modules.Interactive
{
/// <summary>
/// Button that holds a string.
@ -18,7 +18,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive
/// <summary>
/// The color the font should be rendered in.
/// </summary>
public Color FontColor { get { return text.color; } set { text.color = value; } }
public Color4 FontColor { get { return text.color; } set { text.color = value; } }
/// <summary>
/// Constructs text button with the positions represented by <see cref="ISpecialDrawable"/>

View File

@ -1,10 +1,9 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OpenTK;
using RecrownedAthenaeum.Graphics.Render;
using System;
using System.Text;
namespace RecrownedAthenaeum.UI.Modular.Modules
namespace RecrownedAthenaeum.Graphics.UI.Modular.Modules
{
/// <summary>
/// Represents text for the UI.

View File

@ -1,11 +1,13 @@
using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.Types;
using RecrownedAthenaeum.UI.SkinSystem;
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
using RecrownedAthenaeum.Graphics.UI.SkinSystem;
using RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions;
using OpenTK;
using OpenTK.Graphics;
using System;
namespace RecrownedAthenaeum.UI.Modular.Modules
namespace RecrownedAthenaeum.Graphics.UI.Modular.Modules
{
public class UIScrollable : UIModule
{
@ -13,7 +15,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
Rectangle viewport;
UIModuleGroup group;
Color scrollBarColor = Color.White;
Color4 scrollBarColor = Color4.White;
float opacityOfBar = 1f;
bool showingBars;
private bool mouseWasPressed;
@ -105,7 +107,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
if (!value)
{
opacityOfBar = 1f;
scrollBarColor = color * opacityOfBar;
scrollBarColor = color.ReturnMultipliedByFloat(opacityOfBar);
}
}
}
@ -207,7 +209,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
{
opacityOfBar = 1f;
}
scrollBarColor = color * opacityOfBar;
scrollBarColor = color.ReturnMultipliedByFloat(opacityOfBar);
}
if (horScrollAvailable)

View File

@ -1,10 +1,11 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using RecrownedAthenaeum.Types;
using OpenTK;
using OpenTK.Graphics;
using RecrownedAthenaeum.Input;
using RecrownedAthenaeum.Graphics.Render;
using System;
namespace RecrownedAthenaeum.UI.Modular
namespace RecrownedAthenaeum.Graphics.UI.Modular
{
/// <summary>
@ -61,7 +62,7 @@ namespace RecrownedAthenaeum.UI.Modular
/// <summary>
/// The color tint of this module.
/// </summary>
public Color color = Color.White;
public Color4 color = Color4.White;
/// <summary>
/// Called every frame to update this module. Calculations and movement should go here.

View File

@ -4,7 +4,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using RecrownedAthenaeum.Graphics.Render;
namespace RecrownedAthenaeum.UI.Modular
namespace RecrownedAthenaeum.Graphics.UI.Modular
{
/// <summary>

View File

@ -2,7 +2,7 @@
using Microsoft.Xna.Framework.Graphics;
using RecrownedAthenaeum.Graphics.Render;
namespace RecrownedAthenaeum.UI.ScreenSystem
namespace RecrownedAthenaeum.Graphics.UI.ScreenSystem
{
/// <summary>
/// Contracts a transition that the <see cref="ScreenManager"/> can use.

View File

@ -1,10 +1,10 @@

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OpenTK.Graphics;
using OpenTK;
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.Types;
using System;
namespace RecrownedAthenaeum.UI.ScreenSystem
namespace RecrownedAthenaeum.Graphics.UI.ScreenSystem
{
/// <summary>
/// A screen specifically meant to fill in loading times.
@ -15,7 +15,7 @@ namespace RecrownedAthenaeum.UI.ScreenSystem
private const float EXIT_TIME = 1f;
Game game;
readonly Texture2D texture;
Color color;
Color4 color;
Rectangle textureBounds;
readonly float proportion;
bool recorded;
@ -62,7 +62,7 @@ namespace RecrownedAthenaeum.UI.ScreenSystem
/// <param name="dimensions">The window dimensions.</param>
public void InitiateTransition(Rectangle dimensions)
{
color = Color.White;
color = Color4.White;
textureBounds.Width = (int)(height * proportion);
textureBounds.Height = (int)(height * proportion);
textureBounds.X = (width) / 2;
@ -108,9 +108,9 @@ namespace RecrownedAthenaeum.UI.ScreenSystem
{
if (!recorded)
{
rR = (Color.White.R - BackgroundColor.R) / ENTER_TIME;
rG = (Color.White.G - BackgroundColor.G) / ENTER_TIME;
rB = (Color.White.B - BackgroundColor.B) / ENTER_TIME;
rR = (Color4.White.R - BackgroundColor.R) / ENTER_TIME;
rG = (Color4.White.G - BackgroundColor.G) / ENTER_TIME;
rB = (Color4.White.B - BackgroundColor.B) / ENTER_TIME;
recorded = true;
}
progR += rR * deltaf;

View File

@ -1,9 +1,8 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OpenTK.Graphics;
using RecrownedAthenaeum.Graphics.Render;
using System.Collections.Generic;
namespace RecrownedAthenaeum.UI.ScreenSystem
namespace RecrownedAthenaeum.Graphics.UI.ScreenSystem
{
/// <summary>
/// Represents one of the poosible states a screen can be in.
@ -41,7 +40,7 @@ namespace RecrownedAthenaeum.UI.ScreenSystem
/// <summary>
/// The background color to be used to clear the screen.
/// </summary>
public Color BackgroundColor;
public Color4 BackgroundColor;
/// <summary>
/// The next screen to be displayed after exit transition finishes. May be null, leading to transition to previous screen or loading screen.

View File

@ -1,10 +1,9 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OpenTK.Graphics;
using RecrownedAthenaeum.Graphics.Render;
using System;
using System.Diagnostics;
namespace RecrownedAthenaeum.UI.ScreenSystem
namespace RecrownedAthenaeum.Graphics.UI.ScreenSystem
{
/// <summary>
/// Called when the first screen is being shown.
@ -55,7 +54,7 @@ namespace RecrownedAthenaeum.UI.ScreenSystem
previousScreenRenderTarget = new RenderTarget2D(graphics.GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
}
graphics.GraphicsDevice.SetRenderTarget(previousScreenRenderTarget);
graphics.GraphicsDevice.Clear(Color.Black);
graphics.GraphicsDevice.Clear(Color4.Black);
Debug.WriteLine("Showing " + value.GetType().Name);
Screen.Show();

View File

@ -1,6 +1,6 @@
using RecrownedAthenaeum.UI.Modular.Modules.Interactive;
using RecrownedAthenaeum.Graphics.UI.Modular.Modules.Interactive;
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
namespace RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions
{
/// <summary>
/// Skin definition for a button.

View File

@ -1,6 +1,6 @@
using System;
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
namespace RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions
{
/// <summary>
/// A definition containing the data for the skin system. Needs to follow data transfer object model.

View File

@ -1,6 +1,6 @@
using RecrownedAthenaeum.UI.Modular.Modules.Interactive;
using RecrownedAthenaeum.Graphics.UI.Modular.Modules.Interactive;
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
namespace RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions
{
/// <summary>
/// Definition for a text button for a skin theme.

View File

@ -1,11 +1,11 @@
using RecrownedAthenaeum.UI.Modular.Modules;
using RecrownedAthenaeum.Graphics.UI.Modular.Modules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RecrownedAthenaeum.UI.SkinSystem.Definitions
namespace RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions
{
/// <summary>
/// Skin definition of a scroll module.

View File

@ -1,8 +1,10 @@
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.Types;
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
using RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions;
using OpenTK.Graphics;
using OpenTK;
namespace RecrownedAthenaeum.UI.SkinSystem
namespace RecrownedAthenaeum.Graphics.UI.SkinSystem
{
/// <summary>
/// The output requirements of a skin. This allows for very customized skin systems if needed.
@ -31,7 +33,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
/// </summary>
/// <param name="name">Name of defined color.</param>
/// <returns>The defined color based on the name given.</returns>
Color GetColor(string name = null);
Color4 GetColor(string name = null);
/// <summary>
/// Returns a <see cref="TextureAtlas.Region"/> with given name of region.

View File

@ -2,9 +2,11 @@
using System.Collections.Generic;
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.Types;
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
using RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions;
using OpenTK.Graphics;
using OpenTK;
namespace RecrownedAthenaeum.UI.SkinSystem
namespace RecrownedAthenaeum.Graphics.UI.SkinSystem
{
internal class MergedSkin : ISkin
{
@ -44,7 +46,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
}
}
public Color GetColor(string name)
public Color4 GetColor(string name)
{
try
{

View File

@ -1,12 +1,12 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.Graphics.Render;
using RecrownedAthenaeum.Types;
using RecrownedAthenaeum.UI.SkinSystem.Definitions;
using RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions;
using System;
using System.Collections.Generic;
using OpenTK.Graphics;
using OpenTK;
namespace RecrownedAthenaeum.UI.SkinSystem
namespace RecrownedAthenaeum.Graphics.UI.SkinSystem
{
/// <summary>
/// A skin is used to group a theme which can then be applied to the UI via the use of modules.
@ -21,7 +21,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
private TextureAtlas textureAtlas;
Dictionary<string, Color> colors;
Dictionary<string, Color4> colors;
readonly Dictionary<string, string> definitionOfType;
readonly Dictionary<string, Dictionary<string, SkinDefinitionData>> definitions;
@ -39,7 +39,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
{
this.textureAtlas = textureAtlas;
this.CursorTexture = cursorTexture;
colors = new Dictionary<string, Color>();
colors = new Dictionary<string, Color4>();
definitionOfType = new Dictionary<string, string>();
definitions = new Dictionary<string, Dictionary<string, SkinDefinitionData>>();
}
@ -66,7 +66,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
/// </summary>
/// <param name="name">Name of defined color. Will use "default" if null. Default value is null.</param>
/// <returns>The defined color based on the name given.</returns>
public Color GetColor(string name = null)
public Color4 GetColor(string name = null)
{
if (name == null) name = "default";
return colors[name];
@ -133,7 +133,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
/// </summary>
/// <param name="name"></param>
/// <param name="color"></param>
public void AddColor(string name, Color color)
public void AddColor(string name, Color4 color)
{
if (Laminated) throw new InvalidOperationException("This skin has been laminated and cannot be edited.");
colors.Add(name, color);

View File

@ -1,7 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OpenTK;
using OpenTK.Graphics;
using Newtonsoft.Json;
using RecrownedAthenaeum.ContentReaders;
using RecrownedAthenaeum.Data;
using RecrownedAthenaeum.Types;
using System;
@ -9,7 +8,7 @@ using System.Collections.Generic;
using System.IO;
using System.Threading;
namespace RecrownedAthenaeum.UI.SkinSystem
namespace RecrownedAthenaeum.Graphics.UI.SkinSystem
{
/// <summary>
/// Called when the skin manager has completed a async action.
@ -170,7 +169,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
atlasTexture.GetData(data);
for (int i = 0; i < data.Length; i++)
{
Color.FromNonPremultiplied(data[i]);
Color4Ext.FromNonPremultiplied(ref data[i]);
}
atlasTexture.SetData(data);
}
@ -186,7 +185,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
atlasTexture.GetData(data);
for (int i = 0; i < data.Length; i++)
{
Color.FromNonPremultiplied(data[i]);
Color4Ext.FromNonPremultiplied(ref data[i]);
}
cursorTexture.SetData(data);
}
@ -200,7 +199,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem
for (int i = 0; i < skinData.colors.Length; i++)
{
SkinData.ColorData colorData = skinData.colors[i];
skin.AddColor(colorData.name, new Color(colorData.r, colorData.g, colorData.b, colorData.a));
skin.AddColor(colorData.name, new Color4(colorData.r, colorData.g, colorData.b, colorData.a));
}
for (int i = 0; i < skinData.definitions.Length; i++)

View File

@ -1,40 +0,0 @@
using System;
namespace RecrownedAthenaeum.Types
{
public struct Color
{
public byte r, g, b, a;
public float R {
set {
r = (byte)Math.Min(Math.Round(Byte.MaxValue * value), Byte.MaxValue);
}
get {
return r / (float)(byte.MaxValue);
}
}
public float G {
set {
g = (byte)Math.Min(Math.Round(Byte.MaxValue * value), Byte.MaxValue);
}
get {
return g / (float)(byte.MaxValue);
}
}
public float B {
set {
g = (byte)Math.Min(Math.Round(Byte.MaxValue * value), Byte.MaxValue);
}
get {
return g / (float)(byte.MaxValue);
}
}
public float A {
set {
a = (byte)Math.Min(Math.Round(Byte.MaxValue * value), Byte.MaxValue);
}
get {
return a / (float)(byte.MaxValue);
}
}
}
}

View File

@ -0,0 +1,33 @@
using System;
using OpenTK.Graphics;
using OpenTK;
namespace RecrownedAthenaeum.Types {
public static class Color4Ext {
public static byte GetRedAsByte(this Color4 color) {
return (byte) (color.R * Byte.MaxValue);
}
public static byte GetGreenAsByte(this Color4 color) {
return (byte) (color.G * Byte.MaxValue);
}
public static byte GetBlueAsByte(this Color4 color) {
return (byte) (color.B * Byte.MaxValue);
}
public static byte GetAlphaAsByte(this Color4 color) {
return (byte) (color.A * Byte.MaxValue);
}
public static void MultiplyByFloat(this Color4 color, float val) {
color.A *= val;
color.R *= val;
color.G *= val;
color.B *= val;
}
public static Color4 ReturnMultipliedByFloat(this Color4 color, float val) {
Color4 output = new Color4(color.R * val, color.G * val, color.B * val, color.A * val);
return output;
}
public static void FromNonPremultiplied(ref Vector4 vector) {
//Premultiplied.
vector = new Vector4(vector.W * vector.X, vector.W * vector.Y, vector.W * vector.Z, vector.W);
}
}
}

View File

@ -1,5 +1,7 @@
using RecrownedAthenaeum.Graphics.Render;
using System;
using OpenTK;
using OpenTK.Graphics;
namespace RecrownedAthenaeum.Types
{
@ -83,7 +85,7 @@ namespace RecrownedAthenaeum.Types
/// <param name="spriteBatch">Batch to use.</param>
/// <param name="color">The color of the patch.</param>
/// <param name="destination">Where to the patch.</param>
public void Draw(ConsistentSpriteBatch spriteBatch, Color color, Rectangle destination)
public void Draw(ConsistentSpriteBatch spriteBatch, Color4 color, Rectangle destination)
{
try
{
@ -114,7 +116,7 @@ namespace RecrownedAthenaeum.Types
/// <param name="color">The tint for each patch.</param>
/// <param name="rotation">Not considered for 9patches.</param>
/// <param name="origin">Not considered for 9patches.</param>
public void Draw(ConsistentSpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
public void Draw(ConsistentSpriteBatch spriteBatch, Rectangle destination, Color4 color, float rotation = 0, Vector2 origin = default(Vector2))
{
if (rotation != 0) throw new NotImplementedException("Ninepatches can't be rotated.");
if (origin != default(Vector2))

View File

@ -2,6 +2,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenTK;
using OpenTK.Graphics;
namespace RecrownedAthenaeum.Types
{
@ -55,7 +57,7 @@ namespace RecrownedAthenaeum.Types
/// <param name="color">Color to use.</param>
/// <param name="rotation">Rotation of texture drawn.</param>
/// <param name="origin">Origin used by rotation.</param>
public void Draw(string name, ConsistentSpriteBatch batch, Rectangle destination, Color color = default(Color), float rotation = 0, Vector2 origin = new Vector2())
public void Draw(string name, ConsistentSpriteBatch batch, Rectangle destination, Color4 color = default(Color4), float rotation = 0, Vector2 origin = new Vector2())
{
dictionaryOfRegions[name].Draw(batch, destination, color, rotation, origin);
}
@ -166,7 +168,7 @@ namespace RecrownedAthenaeum.Types
/// <param name="color">The color to use.</param>
/// <param name="rotation">Rotation of the final drawing. Ignored if is a 9patch.</param>
/// <param name="origin">The origin of the drawing. Ignored if is a 9patch.</param>
public void Draw(ConsistentSpriteBatch batch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
public void Draw(ConsistentSpriteBatch batch, Rectangle destination, Color4 color, float rotation = 0, Vector2 origin = default(Vector2))
{
if (Disposed) throw new ObjectDisposedException(GetType().Name);
@ -191,7 +193,7 @@ namespace RecrownedAthenaeum.Types
if (regionTexture == null)
{
Color[] data = new Color[sourceRectangle.Width * sourceRectangle.Height];
Color4[] data = new Color4[sourceRectangle.Width * sourceRectangle.Height];
regionTexture = new Texture2D(graphicsDevice, sourceRectangle.Width, sourceRectangle.Height);
atlasTexture.GetData(0, sourceRectangle, data, 0, sourceRectangle.Width * sourceRectangle.Height);
regionTexture.SetData(data);