/*
	This file is part of Hikari, a library that allows developers
	to use Flash in their Ogre3D applications.

	Copyright (C) 2008 Adam J. Simmons

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License as published by the Free Software Foundation; either
	version 2.1 of the License, or (at your option) any later version.

	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
	Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with this library; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

/*********************************************************************************************
   ___ ___ .__ __                 .__ 
 /   |   \|__|  | _______ _______|__|
/    ~    \  |  |/ /\__  \\_  __ \  |
\    Y    /  |    <  / __ \|  | \/  |
 \___|_  /|__|__|_ \(____  /__|  |__|  v0.4
       \/         \/     \/          


* Zed Games PC Development Team - Jaime Crespillo Vilchez (jcrespillo@zed.com)
* Build: 0.1 - Date: 13/10/2008
* Undocked version of Hikari Lib
* Brief: main demo Ogre application using undocked FlashControls 
**********************************************************************************************/

#ifndef __HikariOgreDemo_H__
#define __HikariOgreDemo_H__


#include "Hikari.h"
#include "InputManager.h"
#include "Ogre.h"
#include "FlashControl.h"


class HikariOgreDemo : public OIS::MouseListener, public OIS::KeyListener, public Ogre::WindowEventListener
{
	Ogre::Root* root;
	Ogre::RenderWindow* renderWin;
	Ogre::SceneManager* sceneMgr;
	Ogre::Viewport* viewport;
	
	InputManager* inputMgr;
	Hikari::HikariManager* hikariMgr;

	FlashControl* fps;
	unsigned long lastTime;
	Ogre::Timer timer;
	
	typedef std::map<int, FlashControl*> ControlMap;
	ControlMap controls;
	typedef std::map<int, std::string> NameMap;
	NameMap names;
	typedef std::map<int, std::string> PathMap;
	PathMap paths;

	void parseResources();
	void loadInputSystem();
	void updateStats();
public:
	bool shouldQuit;
	HikariOgreDemo();
	~HikariOgreDemo();

	void createScene();
	void setupHikari();

	void update();

	Hikari::FlashValue onOpacityChange(FlashControl* caller, const Hikari::Arguments& args);
	Hikari::FlashValue onColorChange(FlashControl* caller, const Hikari::Arguments& args);
	Hikari::FlashValue onExitClick(FlashControl* caller, const Hikari::Arguments& args);
	
	bool mouseMoved(const OIS::MouseEvent &arg);
	bool mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
	bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);

	bool keyPressed( const OIS::KeyEvent &arg );
	bool keyReleased( const OIS::KeyEvent &arg );	

	void windowMoved(Ogre::RenderWindow* rw);
	void windowResized(Ogre::RenderWindow* rw);
	void windowClosed(Ogre::RenderWindow* rw);
	void windowFocusChange(Ogre::RenderWindow* rw);
};

#endif