/*	Copyright (C) 2016 Richard W. Allen
Program Name:  SDL Pong C++
Author:        Richard W. Allen
Version:       V1.0
Date Started:  August 24, 2016
Date End:
Webpage:       http://www.richardallenonline.com
IDE:           Visual Studio 2015
Compiler:      C\C++ 2014
Langage:       C++
License:       GNU GENERAL PUBLIC LICENSE Version 2
see license.txt for details

*/

/*** TrooperEngine DLL Header Files ***/
#include "TrooperEngine.hpp"

/*** SDL Header Files ***/
#include "SDL.h"

#include "UTest/UTest.hpp"

#include "UtilityEngineTest/StringTest.hpp"
#include "GUIEngineTest/GUIXMLTest.hpp"

using UtilityEngine::cString;

void CleanUp() 
{
	TrooperEngineCore::cTrooperEngineCore::Delete();
}

int main(int argc, char *argv[])
{
	argc, argv;

	printf(cString("TrooperEngine V") + TrooperEngineCore::cTrooperEngineCore::Version() + "\n");


	UTest u("cVideo");

	printf("\nTesting cVideo\n");

	TrooperEngineCore::cTrooperEngineCore::Inst();
	VideoEngine::cVideo& video = VideoEngine::cVideo::Inst();
	video.Initialize();
	//core.VideoInit();

	if (!video.Setup()) {
		printf("database failed to open.\n");
		return 1;
	}

	u.test("Video Initialize open", video.IsInit());

	StringTest();

	GUIXMLTest();

	
	UTest::OverAllReport();
	SDL_Event event;
	bool run = true;
	while (run) {
		VideoEngine::cVideo::Inst().Display();
		//EventEngine::cEventControl::Inst().CheckEvents();
		while (SDL_PollEvent(&event)) {
			/* We are only worried about SDL_KEYDOWN and SDL_KEYUP events */
			switch (event.type) {
			case SDL_KEYDOWN:
				switch (event.key.keysym.sym) {
				case SDLK_SPACE:
					run = false;
					break;
				case SDLK_RETURN:
					VideoEngine::cVideo::Inst().ScreenShot("test.bmp");
				default:
					break;
				}
				break;

			case SDL_KEYUP:
				printf("Key release detected\n");
				break;

			default:
				break;
			}
		}
	}

	CleanUp();

	//system("pause");

	return 0;
}