/*********************************************************************//**
*	\brief Binding.
*	Databaze prikazu prirazenych ke klavese. Uklada do mapy
*			prikazy, ktere vyuziva hlavni menu k nastaveni ovladani.
*
*	\author Michal Jirous
*	\date 14.7.2008
*	\file ctrl_binding.h
**********************************************************************/

#ifndef BINDING_H_
#define BINDING_H_

#include <string>
#include <map>
#include <list>

namespace binding
{
	const int MAX_KEYBOARD_KEYS = 322;	//maximalni SDL klavesa
	const int MAX_MOUSE_BUTTONS = 7;	//maximalni pocet SDL tlacitek mysi
	const int NO_KEY = -1;
	const int MAX_KEYS = MAX_KEYBOARD_KEYS + MAX_MOUSE_BUTTONS;

	void setBind( int key, std::string commands );
	std::string getBind( int key );

	struct Keys
	{
		int key_one;
		int key_two;
		Keys() : key_one(NO_KEY), key_two(NO_KEY) {}
	};

	bool loadDatabase( const char * filename, std::map<std::string, Keys> *bindMap = NULL );
	void setBindsFromWatchedCommandMap( std::map<std::string, Keys> *bindMap = NULL );
	//prida novy sledovany prikaz, kterou pouziva prvek nastaveni ovladani v hlavnim menu
	void addWatchedCommand( std::string command );
	bool updateWatchedCommands( std::string command, int key, std::map<std::string,Keys> &commandMap, std::string lastKeyCommand, bool alternative = false );
	Keys* getKeyOfWatchedCommand( std::string command, std::map<std::string, Keys> *bindMap = NULL );//vraci klavesu z teto mapy
	void copyMapTo( std::map<std::string,Keys> &targetMap );
	void setMap( std::map<std::string,Keys> &commandMap );
	std::string getWatchedCommandName( std::string command );
	std::list<std::string> *getRightOrderList();	//TODO
};
#endif

