#ifndef __GAMEAPPLICATION_H__
#define __GAMEAPPLICATION_H__

#include "Ogre.h"
#include "OgreConfigFile.h"

#include "CEGUI_fix.h"

#include "GameWorldClient.h"


using namespace DinastyOnline::Network;
using namespace Ogre;

namespace DinastyOnline {
	namespace Graphics {

		class GameFrameListener;

		class GameApplication
		{
		public:
			GameApplication();
			virtual ~GameApplication();
			/// Start
			virtual void go(void);

		protected:
			Root *mRoot;
			Camera* mCamera;
			SceneManager* mSceneMgr;
			GameFrameListener* mFrameListener;
			RenderWindow* mWindow;
			CEGUI::Renderer* mGUIRenderer;	   // cegui renderer
			CEGUI::System *mGUISystem;
			std::deque<Vector3> mWalkList;	// Walk points
			TNL::StringTableEntry login;
			TNL::StringTableEntry password;
			
			GameWorldClient *world;

			/// Builds base (camera, viewports, resources, framelistener...)
			virtual bool setup(void);
			/// Configures the application :: Output system, full-screen, resolution...
			virtual bool configure(void);
			/// Type of SceneManager
			virtual void chooseSceneManager(void);
			virtual void createCamera(void);
			virtual void createFrameListener(void);
			/// Main menu
			virtual void createMenu(void);
			/// Set Handlers for Menu elements
			virtual void setupEventHandlers(void);
			/// Game Scene
			virtual void createScene(void);
			virtual void destroyScene(void);
			virtual void createViewports(void);
			/// Load resources from file
			virtual void setupResources(void);
			/// Used for creating resource listeners (e.g. for loading screens)
			virtual void createResourceListener(void);
			/// Resource Group loading and/or initialise
			virtual void loadResources(void);

			/// Handlers for menu elements
			bool handleLogin(const CEGUI::EventArgs& e);
			bool handleStart(const CEGUI::EventArgs& e);
			bool handleQuit(const CEGUI::EventArgs& e);

		};

	}
}

#endif

