From 627d491e6aa81e6ac35bd1b829b85b9a9963593b Mon Sep 17 00:00:00 2001
From: Alfred Burgess <alfred.burgess95@gmail.com>
Date: Mon, 11 Dec 2023 20:04:19 +0800
Subject: [PATCH] Added back struct for colours. WIP

---
 include/colour.h | 23 +++++++++++++++++++++++
 include/window.h |  4 ++++
 src/colour.cpp   |  7 +++++++
 src/window.cpp   | 18 ++++++++++++++++--
 4 files changed, 50 insertions(+), 2 deletions(-)
 create mode 100644 include/colour.h
 create mode 100644 src/colour.cpp

diff --git a/include/colour.h b/include/colour.h
new file mode 100644
index 0000000..8f1f23c
--- /dev/null
+++ b/include/colour.h
@@ -0,0 +1,23 @@
+#ifndef __COLOUR_H__
+#define __COLOUR_H__
+
+#include <cstdint>;
+
+struct RGBA{
+	uint8_t r;
+	uint8_t g;
+	uint8_t b;
+	uint8_t a;
+};
+
+class Colour
+{
+	public:
+		Colour( uint8_t r, uint8_t g, uint8_t b, uint8_t a  );
+		~Colour();
+	private:
+		RGBA _col;
+	
+};
+
+#endif //__COLOUR_H__
\ No newline at end of file
diff --git a/include/window.h b/include/window.h
index 7970780..75c3b85 100644
--- a/include/window.h
+++ b/include/window.h
@@ -9,6 +9,7 @@
 #include <cstring>
 #include <string>
 #include "logger.h"
+#include "colour.h"
 #include "maths/vec2.h"
 #include "components/cTexture.h"
 
@@ -33,6 +34,8 @@ class Window
 	public:
 		static SDL_Renderer* renderer;
 		static bool sdlIsInit;
+		static RGBA KeyColour;
+		static RGBA RenderColour;
 		Window();
 		~Window();
 
@@ -58,6 +61,7 @@ class Window
 		cTexture* _textureSprite;
 		SDL_Rect _sprites[4];
 
+
 		SDL_Renderer* _renderer;
 		SDL_Surface* _screenSurface;
 		SDL_Surface* _renderSurface;
diff --git a/src/colour.cpp b/src/colour.cpp
new file mode 100644
index 0000000..75bf78d
--- /dev/null
+++ b/src/colour.cpp
@@ -0,0 +1,7 @@
+#include "colour.h"
+
+Colour::Colour( uint8_t r, uint8_t g, uint8_t b, uint8_t a  )
+	: _col( {r,g,b,a} )
+{}
+Colour::~Colour()
+{}
\ No newline at end of file
diff --git a/src/window.cpp b/src/window.cpp
index 810c82c..82652ec 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -2,6 +2,8 @@
 
 bool Window::sdlIsInit = false;
 SDL_Renderer* Window::renderer = NULL;
+RGBA Window::KeyColour = { 0xFF, 0x00, 0xFF, 0xFF };
+RGBA Window::RenderColour = { 0xFF, 0xFF, 0xFF, 0xFF };
 
 Window::Window()
 	: _logger( Logger::instance() ), _hasInit( false )
@@ -114,7 +116,13 @@ void Window::loadMedia( std::string path )
 }
 
 void Window::update() {
-	SDL_SetRenderDrawColor( this->_renderer, 0xFF, 0xFF, 0xFF, 0xFF );
+	SDL_SetRenderDrawColor(
+		this->_renderer,
+		Window::RenderColour.r,
+		Window::RenderColour.g,
+		Window::RenderColour.b,
+		Window::RenderColour.a
+	);
 	SDL_RenderClear( this->_renderer );
 
 	SDL_Rect bg = this->_createViewport( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
@@ -223,7 +231,13 @@ void Window::spawn()
 			{
 				printf( "Renderer could not be created! SDL Error: %s\n", SDL_GetError() );
 			} else {
-				SDL_SetRenderDrawColor( this->_renderer, 0xFF, 0x00, 0xFF, 0xFF );
+				SDL_SetRenderDrawColor(
+					this->_renderer,
+					Window::RenderColour.r,
+					Window::RenderColour.g,
+					Window::RenderColour.b,
+					Window::RenderColour.a
+				);
 			}
 			Window::renderer = this->_renderer;
 		} else {
-- 
GitLab