Exemplo n.º 1
0
	void Application::exit()
	{
		timeModule->exit();
		inputmanager.exit();
		inputEventsTranslator->exit();
		graphicmanager->exit();
		messageModule->exit();
		soundmanager->exit();
		logModule->exit();
		statsModule->exit();

		Gnoll::Stats::CStatsModule::destroy();
		CSoundModule::destroy();
		CTimeModule::destroy();
		CInputEventsTranslator::destroy();
		CGraphicModule::destroy();
		CMessageModule::destroy();
		CLogModule::destroy();
		CStatsModule::destroy();
		Gnoll::DynamicObject::AttributeHandlerRegistry::destroy();

		std::ostringstream tmpString;
		tmpString << "Size of DO cache before destroying it : " << DynamicObjectManager::getInstancePtr()->getSize();
		GNOLL_LOG() <<  tmpString.str() << "\n";
		DynamicObjectManager::destroy();

		// Bye bye
		GNOLL_LOG() << "Au revoir !\n";
		::exit(0);
	}
Exemplo n.º 2
0
	void Application::init(int argc, char* argv[])
	{
		done = 0;
		analyzeArguments (argc, argv);
		GNOLL_LOG() << "Arguments analyzed [DONE]\n";
		init();
	}
Exemplo n.º 3
0
		void CRotationComponent::init(Gnoll::Scene::GObject* _parent, CPage* _page)
		{
			parent = _parent;

			/**
			 * A parent must exist
			 */
			if (parent == NULL)
			{
				GNOLL_LOG() << this->getInstance() << " object initialized without any parent";
				return;
			}

			/**
			 * A parent page must exist
			 */
			if (_page == NULL)
			{
				GNOLL_LOG() << parent->getInstance() << ":" << this->getInstance() << " object initialized without any parent page" << "\n";
				return;
			}


			/**
			 * Register the listener
			 */
			MessageModule*  messageModule  = MessageModule::getInstancePtr();
			Messages::Messenger* messageManager = messageModule->getMessageManager();

			rotationListener = shared_ptr<Messages::Listener> (new RotationListener(this));
			messageManager->addListener ( rotationListener, "SET_ROTATION_" + parent->getInstance() );


			shared_ptr< Gnoll::DynamicObject::Vector3 > zero ( new Gnoll::DynamicObject::Vector3());
			rotation = *(this->getAttributeOrDefault < Gnoll::DynamicObject::Vector3 > (CRotationComponent::ATTRIBUTE_ROTATION(), zero));


			/**
			 * Queue the message of the init rotation
			 */
			Messages::MessageType messageType("SET_ROTATION_" + parent->getInstance());
			shared_ptr<boost::any> data(new boost::any(rotation)) ;
			shared_ptr<Message> message = shared_ptr<Message>(new Message(messageType, data));
			messageManager->queueMessage(message);
		}
Exemplo n.º 4
0
		shared_ptr<AudioCodecHandler> AudioCodecManager::getAudioCodecHandler(shared_ptr<AbstractStream> stream, string instance)
		{
			string type;

			/**
			 * Get audio codec from the file extension
			 */
			size_t pos = instance.find_last_of('.') + 1;

			if(pos != string::npos)
				type = instance.substr(pos);
			
			if(m_list_codec.find(type) != m_list_codec.end())
				return m_list_codec[type];
			else
			{
				GNOLL_LOG().logMessage("Codec par defaut (ogg pour le moment)");
				return m_list_codec["ogg"];
			}
			
			//return m_list_codec["ogg"]->handle(stream);
		}
Exemplo n.º 5
0
	void Application::init()
	{
		// The very first thing to do is to add the current directory in DynamicObjectManager's list of repositories
		// In case some modules would need to load some config files
		shared_ptr<ISource> loadChannel(new SourceFile(".", false));
		shared_ptr<ISource> saveChannel(new SourceFile(".", true));

		DynamicObjectManager *pom = DynamicObjectManager::getInstancePtr();
		SoundManager *soundManager = SoundManager::getInstancePtr();

		GNOLL_LOG() << "Adding load/save source for current path to the DynamicObjectManager\n";
		pom->addLoadSource(loadChannel);
		pom->addSaveSource(saveChannel);

		GNOLL_LOG() << "Adding load/save source for current path to the SoundManager\n";
		soundManager->addLoadSource(loadChannel);
		soundManager->addSaveSource(saveChannel);

		/**
		 * Now program options have been parsed,
		 * program is initialized
		 */

		GNOLL_LOG() << "Instanciating modules...\n";
		logModule             = CLogModule::getInstancePtr();
		graphicmanager        = CGraphicModule::getInstancePtr();
		timeModule            = CTimeModule::getInstancePtr();
		messageModule         = CMessageModule::getInstancePtr();
		soundmanager          = CSoundModule::getInstancePtr();
		inputEventsTranslator = CInputEventsTranslator::getInstancePtr();
		statsModule           = CStatsModule::getInstancePtr();
		GNOLL_LOG() << "Instanciating modules...[DONE]\n";


		try
		{
			GNOLL_LOG() << "Initializing message module\n";
			messageModule->init();
			GNOLL_LOG() << "Initializing message module [DONE]\n";

			GNOLL_LOG() << "Initializing graphic module\n";
			graphicmanager->init();
			GNOLL_LOG() << "Initializing graphic module [DONE]\n";

			GNOLL_LOG() << "Initializing input manager\n";
			inputmanager.init();
			GNOLL_LOG() << "Initializing input manager [DONE]\n";

			GNOLL_LOG() << "Initializing sound manager\n";
			soundmanager->init();
			GNOLL_LOG() << "Initializing sound manager [DONE]\n";

			GNOLL_LOG() << "Initializing time module\n";
			timeModule->init();
			GNOLL_LOG() << "Initializing time module [DONE]\n";

			GNOLL_LOG() << "Initializing input event translator\n";
			inputEventsTranslator->init();
			GNOLL_LOG() << "Initializing input event translator [DONE]\n";

			GNOLL_LOG() << "Initializing stats module\n";
			statsModule->init();
			GNOLL_LOG() << "Initializing stats module [DONE]\n";
		}
		catch (Glib::ustring str)
		{
			cout << str << endl;
		}

		/*
		 * Define the listener of the application
		 * like the message on quit
		 */
		shared_ptr<Gnoll::ApplicationListener> listenerInput = shared_ptr<Gnoll::ApplicationListener>(
															   new Gnoll::ApplicationListener());
		messageModule->getMessageManager()->addListener ( listenerInput, Messages::MessageType(Gnoll::Input::ACTION_EVENT_TYPE) );

		/**
		 * Define the listener for the button
		 */
		CEGUI::PushButton *button_quit;
		button_quit = (CEGUI::PushButton *) CEGUI::WindowManager::getSingleton().getWindow("buttonQuit");
		button_quit->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&Application::quit_OnClick, this));
	}
Exemplo n.º 6
0
	void Application::analyzeArguments (int argc, char* argv[])
	{

		// Declare the supported options.
		options_description desc("Allowed options");
		desc.add_options()
			("help,h", "Produce help message")
			("log,l", value<std::string>(), "Log file name")
			("load-source-directory", value< vector<string> >()->composing(), "Add a directory as a load source")
			("save-source-directory", value< vector<string> >()->composing(), "Add a directory as a save source")
		;

		variables_map vm;
		store(parse_command_line(argc, argv, desc), vm);
		notify(vm);


		/**
		 * If help is required
		 *  -> Display usage
		 *  -> Exit
		 */
		if (vm.count("help"))
		{
			cout << desc;
			::exit(1);
		}


		CLogModule *logModule = CLogModule::getInstancePtr();

		if (vm.count("log"))
		{
			std::string logFile = vm["log"].as<std::string>();

			logModule->setLogFileName(logFile);
		}

		logModule->init();



		DynamicObjectManager *pom = DynamicObjectManager::getInstancePtr();
		SoundManager *soundManager = SoundManager::getInstancePtr();
		CameraManager *cameraManager = CameraManager::getInstancePtr();

		/**
		 * If a loading source has to be added
		 */
		if (vm.count("load-source-directory"))
		{


			vector<string> lsd = vm["load-source-directory"].as< vector<string> >();
			for (vector<string>::iterator it = lsd.begin(); it != lsd.end(); it++)
			{

				GNOLL_LOG() << "Adding new load source directory : \n";
				shared_ptr<ISource> userLoadChannel(new SourceFile(*it, false, 10));
				pom->addLoadSource(userLoadChannel);
				soundManager->addLoadSource(userLoadChannel);
				cameraManager->addLoadSource(userLoadChannel);
			}
		}


		/**
		 * If a saving source has to be added
		 */
		if (vm.count("save-source-directory"))
		{

			vector<string> lsd = vm["save-source-directory"].as< vector<string> >();
			for (vector<string>::iterator it = lsd.begin(); it != lsd.end(); it++)
			{

				GNOLL_LOG() << "Adding new save source directory : \n";
				shared_ptr<ISource> userSaveChannel(new SourceFile( *it, true, 10 ));
				pom->addSaveSource(userSaveChannel);
				soundManager->addSaveSource(userSaveChannel);
				cameraManager->addLoadSource(userSaveChannel);
			}
		}


	}