#pragma once
#include <Windows.h>
#include <cstdint>
#include "singleton.h"
namespace engineapi {
	class Window : public Singleton<Window> {
	protected:
		int mWidth;
		int mHeight;
		HWND mPtr;
	protected:
		class WindowClass
		{
		public:
			static const char* GetName() noexcept {
				return wndClassName;
			}
			static HINSTANCE GetInstance() noexcept {
				return wndClass.hInst;
			}
		private:
			WindowClass() noexcept;
			WindowClass(const WindowClass&) = delete;
			WindowClass& operator=(const WindowClass&) = delete;
			static constexpr const char* wndClassName = "MainWnd";
			static WindowClass wndClass;
			HINSTANCE hInst;
		};
		static LRESULT CALLBACK HandleMsgSetup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) noexcept;
		static LRESULT CALLBACK HandleMsgThunk(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) noexcept;
		LRESULT HandleMsg(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) noexcept;
	public:
		Window(int width, int height, const char* title);
		HWND Ptr() {
			return mPtr;
		}
		void GetSize(uint32_t& width, uint32_t& height) {
			width = mWidth;
			height = mHeight;
		}
	public:
		static bool ProcessMessages(int& code);
		static Window* MakeInstance(int frames, uint32_t width, uint32_t height, const char* title);
	};
};
template<>
engineapi::Window* Singleton<engineapi::Window>::ms_Singleton = nullptr;