From 005d66840d9cd3ced7433d3a4ce437bb5265be89 Mon Sep 17 00:00:00 2001 From: Harrison Date: Sat, 28 Dec 2019 15:41:06 -0600 Subject: [PATCH] Replaced color usage with OpenTK's implementation. --- RecrownedAthenaeum/Data/SkinData.cs | 14 ++++--- .../Graphics/Render/BasicCamera.cs | 4 +- RecrownedAthenaeum/Graphics/Render/Batch.cs | 13 ++++++ .../Graphics/Render/Camera2D.cs | 3 +- .../Graphics/Render/PrimitiveBatch.cs | 6 +-- .../Graphics/Render/RectangleRenderer.cs | 9 +++-- .../{ => Graphics}/UI/BookSystem/Book.cs | 5 ++- .../{ => Graphics}/UI/BookSystem/Page.cs | 6 +-- .../UI/Modular/Modules/Image.cs | 6 ++- .../UI/Modular/Modules/Interactive/Button.cs | 6 +-- .../Modular/Modules/Interactive/TextButton.cs | 10 ++--- .../{ => Graphics}/UI/Modular/Modules/Text.cs | 5 +-- .../UI/Modular/Modules/UIScrollable.cs | 14 ++++--- .../{ => Graphics}/UI/Modular/UIModule.cs | 9 +++-- .../UI/Modular/UIModuleGroup.cs | 2 +- .../UI/ScreenSystem/ITransition.cs | 2 +- .../UI/ScreenSystem/LoadingScreen.cs | 18 ++++----- .../{ => Graphics}/UI/ScreenSystem/Screen.cs | 7 ++-- .../UI/ScreenSystem/ScreenManager.cs | 7 ++-- .../Definitions/ButtonSkinDefinition.cs | 4 +- .../SkinSystem/Definitions/SkinDefinition.cs | 2 +- .../Definitions/TextButtonSkinDefinition.cs | 4 +- .../Definitions/UIScrollableSkinDefinition.cs | 4 +- .../{ => Graphics}/UI/SkinSystem/ISkin.cs | 8 ++-- .../UI/SkinSystem/MergedSkin.cs | 8 ++-- .../{ => Graphics}/UI/SkinSystem/Skin.cs | 18 ++++----- .../UI/SkinSystem/SkinManager.cs | 13 +++--- RecrownedAthenaeum/Types/Color.cs | 40 ------------------- RecrownedAthenaeum/Types/Extensions.cs | 33 +++++++++++++++ RecrownedAthenaeum/Types/NinePatch.cs | 6 ++- RecrownedAthenaeum/Types/TextureAtlas.cs | 8 ++-- 31 files changed, 155 insertions(+), 139 deletions(-) create mode 100644 RecrownedAthenaeum/Graphics/Render/Batch.cs rename RecrownedAthenaeum/{ => Graphics}/UI/BookSystem/Book.cs (98%) rename RecrownedAthenaeum/{ => Graphics}/UI/BookSystem/Page.cs (93%) rename RecrownedAthenaeum/{ => Graphics}/UI/Modular/Modules/Image.cs (93%) rename RecrownedAthenaeum/{ => Graphics}/UI/Modular/Modules/Interactive/Button.cs (96%) rename RecrownedAthenaeum/{ => Graphics}/UI/Modular/Modules/Interactive/TextButton.cs (92%) rename RecrownedAthenaeum/{ => Graphics}/UI/Modular/Modules/Text.cs (98%) rename RecrownedAthenaeum/{ => Graphics}/UI/Modular/Modules/UIScrollable.cs (97%) rename RecrownedAthenaeum/{ => Graphics}/UI/Modular/UIModule.cs (97%) rename RecrownedAthenaeum/{ => Graphics}/UI/Modular/UIModuleGroup.cs (98%) rename RecrownedAthenaeum/{ => Graphics}/UI/ScreenSystem/ITransition.cs (97%) rename RecrownedAthenaeum/{ => Graphics}/UI/ScreenSystem/LoadingScreen.cs (92%) rename RecrownedAthenaeum/{ => Graphics}/UI/ScreenSystem/Screen.cs (97%) rename RecrownedAthenaeum/{ => Graphics}/UI/ScreenSystem/ScreenManager.cs (97%) rename RecrownedAthenaeum/{ => Graphics}/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs (87%) rename RecrownedAthenaeum/{ => Graphics}/UI/SkinSystem/Definitions/SkinDefinition.cs (90%) rename RecrownedAthenaeum/{ => Graphics}/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs (86%) rename RecrownedAthenaeum/{ => Graphics}/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs (90%) rename RecrownedAthenaeum/{ => Graphics}/UI/SkinSystem/ISkin.cs (92%) rename RecrownedAthenaeum/{ => Graphics}/UI/SkinSystem/MergedSkin.cs (92%) rename RecrownedAthenaeum/{ => Graphics}/UI/SkinSystem/Skin.cs (95%) rename RecrownedAthenaeum/{ => Graphics}/UI/SkinSystem/SkinManager.cs (95%) delete mode 100644 RecrownedAthenaeum/Types/Color.cs create mode 100644 RecrownedAthenaeum/Types/Extensions.cs diff --git a/RecrownedAthenaeum/Data/SkinData.cs b/RecrownedAthenaeum/Data/SkinData.cs index def7933..9ced374 100644 --- a/RecrownedAthenaeum/Data/SkinData.cs +++ b/RecrownedAthenaeum/Data/SkinData.cs @@ -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 /// /// the name to be referenced by. /// The color value represents. - 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(); } } diff --git a/RecrownedAthenaeum/Graphics/Render/BasicCamera.cs b/RecrownedAthenaeum/Graphics/Render/BasicCamera.cs index 32aa6ca..061e068 100644 --- a/RecrownedAthenaeum/Graphics/Render/BasicCamera.cs +++ b/RecrownedAthenaeum/Graphics/Render/BasicCamera.cs @@ -1,6 +1,4 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - +using OpenTK; namespace RecrownedAthenaeum.Graphics.Render { /// diff --git a/RecrownedAthenaeum/Graphics/Render/Batch.cs b/RecrownedAthenaeum/Graphics/Render/Batch.cs new file mode 100644 index 0000000..e8e6843 --- /dev/null +++ b/RecrownedAthenaeum/Graphics/Render/Batch.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/RecrownedAthenaeum/Graphics/Render/Camera2D.cs b/RecrownedAthenaeum/Graphics/Render/Camera2D.cs index 4a7108c..3eabc1e 100644 --- a/RecrownedAthenaeum/Graphics/Render/Camera2D.cs +++ b/RecrownedAthenaeum/Graphics/Render/Camera2D.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using OpenTK; using System; namespace RecrownedAthenaeum.Graphics.Render diff --git a/RecrownedAthenaeum/Graphics/Render/PrimitiveBatch.cs b/RecrownedAthenaeum/Graphics/Render/PrimitiveBatch.cs index 36abbe0..718e651 100644 --- a/RecrownedAthenaeum/Graphics/Render/PrimitiveBatch.cs +++ b/RecrownedAthenaeum/Graphics/Render/PrimitiveBatch.cs @@ -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 /// /// The vector that represents the vertex. /// The color of that vertex. - 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); diff --git a/RecrownedAthenaeum/Graphics/Render/RectangleRenderer.cs b/RecrownedAthenaeum/Graphics/Render/RectangleRenderer.cs index 5999b30..303d011 100644 --- a/RecrownedAthenaeum/Graphics/Render/RectangleRenderer.cs +++ b/RecrownedAthenaeum/Graphics/Render/RectangleRenderer.cs @@ -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 /// Height of rectangle. /// Color of all vertices of this rectangle. /// Rotation of rectangle. Default is 0 radians. - 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 /// /// Uses the x, y and dimensions to draw a rectangle. /// The color of the rectangle. - public void Draw(Rectangle rectangle, Color color) + public void Draw(Rectangle rectangle, Color4 color) { Draw(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, color); } diff --git a/RecrownedAthenaeum/UI/BookSystem/Book.cs b/RecrownedAthenaeum/Graphics/UI/BookSystem/Book.cs similarity index 98% rename from RecrownedAthenaeum/UI/BookSystem/Book.cs rename to RecrownedAthenaeum/Graphics/UI/BookSystem/Book.cs index e531f40..55caf3b 100644 --- a/RecrownedAthenaeum/UI/BookSystem/Book.cs +++ b/RecrownedAthenaeum/Graphics/UI/BookSystem/Book.cs @@ -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 { /// /// Contains the pages. diff --git a/RecrownedAthenaeum/UI/BookSystem/Page.cs b/RecrownedAthenaeum/Graphics/UI/BookSystem/Page.cs similarity index 93% rename from RecrownedAthenaeum/UI/BookSystem/Page.cs rename to RecrownedAthenaeum/Graphics/UI/BookSystem/Page.cs index 1dc24be..584d9c6 100644 --- a/RecrownedAthenaeum/UI/BookSystem/Page.cs +++ b/RecrownedAthenaeum/Graphics/UI/BookSystem/Page.cs @@ -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 { /// /// A page a part of a . diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Image.cs b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/Image.cs similarity index 93% rename from RecrownedAthenaeum/UI/Modular/Modules/Image.cs rename to RecrownedAthenaeum/Graphics/UI/Modular/Modules/Image.cs index 32f3af4..e43cd4a 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Image.cs +++ b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/Image.cs @@ -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 { /// /// Represents a texture with more information. @@ -62,7 +64,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules /// The color tint to use. /// Rotation of image. /// Origin for the rotation. - 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; diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/Interactive/Button.cs similarity index 96% rename from RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs rename to RecrownedAthenaeum/Graphics/UI/Modular/Modules/Interactive/Button.cs index dac3791..d83fc65 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/Button.cs +++ b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/Interactive/Button.cs @@ -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 { /// /// Function to be called when button is clicked. diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/Interactive/TextButton.cs similarity index 92% rename from RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs rename to RecrownedAthenaeum/Graphics/UI/Modular/Modules/Interactive/TextButton.cs index cebb586..74c7b11 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Interactive/TextButton.cs +++ b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/Interactive/TextButton.cs @@ -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 { /// /// Button that holds a string. @@ -18,7 +18,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules.Interactive /// /// The color the font should be rendered in. /// - public Color FontColor { get { return text.color; } set { text.color = value; } } + public Color4 FontColor { get { return text.color; } set { text.color = value; } } /// /// Constructs text button with the positions represented by diff --git a/RecrownedAthenaeum/UI/Modular/Modules/Text.cs b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/Text.cs similarity index 98% rename from RecrownedAthenaeum/UI/Modular/Modules/Text.cs rename to RecrownedAthenaeum/Graphics/UI/Modular/Modules/Text.cs index 317057e..65f6631 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/Text.cs +++ b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/Text.cs @@ -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 { /// /// Represents text for the UI. diff --git a/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/UIScrollable.cs similarity index 97% rename from RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs rename to RecrownedAthenaeum/Graphics/UI/Modular/Modules/UIScrollable.cs index 2fc9214..8ca0711 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs +++ b/RecrownedAthenaeum/Graphics/UI/Modular/Modules/UIScrollable.cs @@ -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) diff --git a/RecrownedAthenaeum/UI/Modular/UIModule.cs b/RecrownedAthenaeum/Graphics/UI/Modular/UIModule.cs similarity index 97% rename from RecrownedAthenaeum/UI/Modular/UIModule.cs rename to RecrownedAthenaeum/Graphics/UI/Modular/UIModule.cs index 55e4361..f626871 100644 --- a/RecrownedAthenaeum/UI/Modular/UIModule.cs +++ b/RecrownedAthenaeum/Graphics/UI/Modular/UIModule.cs @@ -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 { /// @@ -61,7 +62,7 @@ namespace RecrownedAthenaeum.UI.Modular /// /// The color tint of this module. /// - public Color color = Color.White; + public Color4 color = Color4.White; /// /// Called every frame to update this module. Calculations and movement should go here. diff --git a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs b/RecrownedAthenaeum/Graphics/UI/Modular/UIModuleGroup.cs similarity index 98% rename from RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs rename to RecrownedAthenaeum/Graphics/UI/Modular/UIModuleGroup.cs index 80c1304..7b1113b 100644 --- a/RecrownedAthenaeum/UI/Modular/UIModuleGroup.cs +++ b/RecrownedAthenaeum/Graphics/UI/Modular/UIModuleGroup.cs @@ -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 { /// diff --git a/RecrownedAthenaeum/UI/ScreenSystem/ITransition.cs b/RecrownedAthenaeum/Graphics/UI/ScreenSystem/ITransition.cs similarity index 97% rename from RecrownedAthenaeum/UI/ScreenSystem/ITransition.cs rename to RecrownedAthenaeum/Graphics/UI/ScreenSystem/ITransition.cs index 2527847..b172109 100644 --- a/RecrownedAthenaeum/UI/ScreenSystem/ITransition.cs +++ b/RecrownedAthenaeum/Graphics/UI/ScreenSystem/ITransition.cs @@ -2,7 +2,7 @@ using Microsoft.Xna.Framework.Graphics; using RecrownedAthenaeum.Graphics.Render; -namespace RecrownedAthenaeum.UI.ScreenSystem +namespace RecrownedAthenaeum.Graphics.UI.ScreenSystem { /// /// Contracts a transition that the can use. diff --git a/RecrownedAthenaeum/UI/ScreenSystem/LoadingScreen.cs b/RecrownedAthenaeum/Graphics/UI/ScreenSystem/LoadingScreen.cs similarity index 92% rename from RecrownedAthenaeum/UI/ScreenSystem/LoadingScreen.cs rename to RecrownedAthenaeum/Graphics/UI/ScreenSystem/LoadingScreen.cs index 1c2e18f..2bce360 100644 --- a/RecrownedAthenaeum/UI/ScreenSystem/LoadingScreen.cs +++ b/RecrownedAthenaeum/Graphics/UI/ScreenSystem/LoadingScreen.cs @@ -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 { /// /// 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 /// The window dimensions. 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; diff --git a/RecrownedAthenaeum/UI/ScreenSystem/Screen.cs b/RecrownedAthenaeum/Graphics/UI/ScreenSystem/Screen.cs similarity index 97% rename from RecrownedAthenaeum/UI/ScreenSystem/Screen.cs rename to RecrownedAthenaeum/Graphics/UI/ScreenSystem/Screen.cs index 73dc4e0..c64919e 100644 --- a/RecrownedAthenaeum/UI/ScreenSystem/Screen.cs +++ b/RecrownedAthenaeum/Graphics/UI/ScreenSystem/Screen.cs @@ -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 { /// /// Represents one of the poosible states a screen can be in. @@ -41,7 +40,7 @@ namespace RecrownedAthenaeum.UI.ScreenSystem /// /// The background color to be used to clear the screen. /// - public Color BackgroundColor; + public Color4 BackgroundColor; /// /// The next screen to be displayed after exit transition finishes. May be null, leading to transition to previous screen or loading screen. diff --git a/RecrownedAthenaeum/UI/ScreenSystem/ScreenManager.cs b/RecrownedAthenaeum/Graphics/UI/ScreenSystem/ScreenManager.cs similarity index 97% rename from RecrownedAthenaeum/UI/ScreenSystem/ScreenManager.cs rename to RecrownedAthenaeum/Graphics/UI/ScreenSystem/ScreenManager.cs index 4ccc3b9..8d445e1 100644 --- a/RecrownedAthenaeum/UI/ScreenSystem/ScreenManager.cs +++ b/RecrownedAthenaeum/Graphics/UI/ScreenSystem/ScreenManager.cs @@ -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 { /// /// 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(); diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs similarity index 87% rename from RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs rename to RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs index a60ba8b..62b4330 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs +++ b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/ButtonSkinDefinition.cs @@ -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 { /// /// Skin definition for a button. diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/SkinDefinition.cs b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/SkinDefinition.cs similarity index 90% rename from RecrownedAthenaeum/UI/SkinSystem/Definitions/SkinDefinition.cs rename to RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/SkinDefinition.cs index 311e917..68a27e8 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/Definitions/SkinDefinition.cs +++ b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/SkinDefinition.cs @@ -1,6 +1,6 @@ using System; -namespace RecrownedAthenaeum.UI.SkinSystem.Definitions +namespace RecrownedAthenaeum.Graphics.UI.SkinSystem.Definitions { /// /// A definition containing the data for the skin system. Needs to follow data transfer object model. diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs similarity index 86% rename from RecrownedAthenaeum/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs rename to RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs index d3a9c40..4162e70 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs +++ b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/TextButtonSkinDefinition.cs @@ -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 { /// /// Definition for a text button for a skin theme. diff --git a/RecrownedAthenaeum/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs similarity index 90% rename from RecrownedAthenaeum/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs rename to RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs index c93c16f..af82710 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs +++ b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Definitions/UIScrollableSkinDefinition.cs @@ -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 { /// /// Skin definition of a scroll module. diff --git a/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs b/RecrownedAthenaeum/Graphics/UI/SkinSystem/ISkin.cs similarity index 92% rename from RecrownedAthenaeum/UI/SkinSystem/ISkin.cs rename to RecrownedAthenaeum/Graphics/UI/SkinSystem/ISkin.cs index ca52006..0b0ac3c 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/ISkin.cs +++ b/RecrownedAthenaeum/Graphics/UI/SkinSystem/ISkin.cs @@ -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 { /// /// The output requirements of a skin. This allows for very customized skin systems if needed. @@ -31,7 +33,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// /// Name of defined color. /// The defined color based on the name given. - Color GetColor(string name = null); + Color4 GetColor(string name = null); /// /// Returns a with given name of region. diff --git a/RecrownedAthenaeum/UI/SkinSystem/MergedSkin.cs b/RecrownedAthenaeum/Graphics/UI/SkinSystem/MergedSkin.cs similarity index 92% rename from RecrownedAthenaeum/UI/SkinSystem/MergedSkin.cs rename to RecrownedAthenaeum/Graphics/UI/SkinSystem/MergedSkin.cs index ee31200..f87d0f3 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/MergedSkin.cs +++ b/RecrownedAthenaeum/Graphics/UI/SkinSystem/MergedSkin.cs @@ -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 { diff --git a/RecrownedAthenaeum/UI/SkinSystem/Skin.cs b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Skin.cs similarity index 95% rename from RecrownedAthenaeum/UI/SkinSystem/Skin.cs rename to RecrownedAthenaeum/Graphics/UI/SkinSystem/Skin.cs index 2865b36..121e351 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/Skin.cs +++ b/RecrownedAthenaeum/Graphics/UI/SkinSystem/Skin.cs @@ -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 { /// /// 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 colors; + Dictionary colors; readonly Dictionary definitionOfType; readonly Dictionary> definitions; @@ -39,7 +39,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem { this.textureAtlas = textureAtlas; this.CursorTexture = cursorTexture; - colors = new Dictionary(); + colors = new Dictionary(); definitionOfType = new Dictionary(); definitions = new Dictionary>(); } @@ -66,7 +66,7 @@ namespace RecrownedAthenaeum.UI.SkinSystem /// /// Name of defined color. Will use "default" if null. Default value is null. /// The defined color based on the name given. - 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 /// /// /// - 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); diff --git a/RecrownedAthenaeum/UI/SkinSystem/SkinManager.cs b/RecrownedAthenaeum/Graphics/UI/SkinSystem/SkinManager.cs similarity index 95% rename from RecrownedAthenaeum/UI/SkinSystem/SkinManager.cs rename to RecrownedAthenaeum/Graphics/UI/SkinSystem/SkinManager.cs index c9a4aea..c6570ca 100644 --- a/RecrownedAthenaeum/UI/SkinSystem/SkinManager.cs +++ b/RecrownedAthenaeum/Graphics/UI/SkinSystem/SkinManager.cs @@ -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 { /// /// 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++) diff --git a/RecrownedAthenaeum/Types/Color.cs b/RecrownedAthenaeum/Types/Color.cs deleted file mode 100644 index f1abdfc..0000000 --- a/RecrownedAthenaeum/Types/Color.cs +++ /dev/null @@ -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); - } - } - } -} \ No newline at end of file diff --git a/RecrownedAthenaeum/Types/Extensions.cs b/RecrownedAthenaeum/Types/Extensions.cs new file mode 100644 index 0000000..5b1b587 --- /dev/null +++ b/RecrownedAthenaeum/Types/Extensions.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/RecrownedAthenaeum/Types/NinePatch.cs b/RecrownedAthenaeum/Types/NinePatch.cs index 540ec7d..b8d7410 100644 --- a/RecrownedAthenaeum/Types/NinePatch.cs +++ b/RecrownedAthenaeum/Types/NinePatch.cs @@ -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 /// Batch to use. /// The color of the patch. /// Where to the patch. - 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 /// The tint for each patch. /// Not considered for 9patches. /// Not considered for 9patches. - 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)) diff --git a/RecrownedAthenaeum/Types/TextureAtlas.cs b/RecrownedAthenaeum/Types/TextureAtlas.cs index 9c421cb..62b2604 100644 --- a/RecrownedAthenaeum/Types/TextureAtlas.cs +++ b/RecrownedAthenaeum/Types/TextureAtlas.cs @@ -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 /// Color to use. /// Rotation of texture drawn. /// Origin used by rotation. - 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 /// The color to use. /// Rotation of the final drawing. Ignored if is a 9patch. /// The origin of the drawing. Ignored if is a 9patch. - 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);