void CInputEventsTranslator::activateMouseMotionTranslation() { Messages::MessageType mouseMoved("MOUSE_MOVED"); CMessageModule* messageModule = CMessageModule::getInstancePtr(); Messages::Messenger* messageManager = messageModule->getMessageManager(); mouseMotionEventsTranslator = shared_ptr<Messages::Listener> ( new CMouseMotionEventsTranslator() ); mouseMotionStateTranslator = shared_ptr<Messages::Listener> ( new CMouseMotionStateTranslator() ); try { messageManager->addListener ( mouseMotionEventsTranslator, mouseMoved ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "mouseMotionEventsTranslator listener installed" ); messageManager->addListener ( mouseMotionStateTranslator, mouseMoved ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "mouseMotionStateTranslator listener installed" ); } catch(...) { throw; } }
void CInputEventsTranslator::activateKeyboardTranslation() { Messages::MessageType keyDown("KEYBOARD_KEYDOWN"); Messages::MessageType keyUp("KEYBOARD_KEYUP"); Messages::MessageType updateKeyboard("UPDATE_KEYBOARD"); DynamicObjectManager *dom = DynamicObjectManager::getInstancePtr(); shared_ptr< Gnoll::DynamicObject::DynamicObject > keyboardConfig = dom->load("keyboardConfig"); /** * How often will the keyboard module get updated (millisecond) */ unsigned long int period = 300; shared_ptr< Gnoll::DynamicObject::Integer > periodFromConfig = keyboardConfig->getAttribute< Gnoll::DynamicObject::Integer >("period"); period = *periodFromConfig; CMessageModule* messageModule = CMessageModule::getInstancePtr(); Messages::Messenger* messageManager = messageModule->getMessageManager(); keyboardEventsTranslator = shared_ptr<Messages::Listener> ( new CKeyboardEventsTranslator() ); keyboardEventsTrigger = shared_ptr<Messages::Listener> ( new CKeyboardEventsTrigger(static_pointer_cast<CKeyboardEventsTranslator>(keyboardEventsTranslator) )); keyboardStateTranslator = shared_ptr<Messages::Listener> ( new CKeyboardStateTranslator() ); try { /** * Continuous keyboard messages */ messageManager->addListener ( keyboardEventsTranslator, keyDown ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardEventsTranslator listener installed" ); messageManager->addListener ( keyboardEventsTranslator, keyUp ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardEventsTranslator listener installed" ); messageManager->addListener ( keyboardEventsTrigger, updateKeyboard ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardEventsTrigger listener installed" ); /** * State based keyboard messages */ messageManager->addListener ( keyboardStateTranslator, keyDown ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardStateTranslator listener installed" ); messageManager->addListener ( keyboardStateTranslator, keyUp ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "KeyboardStateTranslator listener installed" ); } catch(...) { throw; } CTimeModule* timeModule = CTimeModule::getInstancePtr(); m_periodData = shared_ptr<boost::any> (new boost::any(period)) ; shared_ptr<CMessage> message (new CMessage(updateKeyboard, m_periodData )); timeModule->addPeriodicEvent(0, message, period); }
void CInputEventsTranslator::activateRuleManager() { ruleManager = shared_ptr<Messages::Listener>( new CRuleManager("ruleManager") ); CMessageModule* messageModule = CMessageModule::getInstancePtr(); Messages::Messenger* messageManager = messageModule->getMessageManager(); try { messageManager->addListener ( ruleManager, ACTION_EVENT_TYPE ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "ruleManager installed for ACTION_EVENT_TYPE" ); messageManager->addListener ( ruleManager, ACTION_EVENT_STATE_TYPE ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "ruleManager installed for ACTION_EVENT_STATE_TYPE" ); } catch(...) { throw; } }
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); }
void CInputEventsTranslator::activateMouseButtonTranslation() { Messages::MessageType mousePressed("MOUSE_PRESSED"); Messages::MessageType mouseReleased("MOUSE_RELEASED"); Messages::MessageType updateMouse("UPDATE_MOUSE"); DynamicObjectManager *dom = DynamicObjectManager::getInstancePtr(); shared_ptr< Gnoll::DynamicObject::DynamicObject > mouseConfig = dom->load("mouseConfig"); /** * How often will the mouse button module get updated (millisecond) */ unsigned long int period = 300; shared_ptr< Gnoll::DynamicObject::Integer > periodFromConfig = mouseConfig->getAttribute< Gnoll::DynamicObject::Integer >("period"); period = *periodFromConfig; CMessageModule* messageModule = CMessageModule::getInstancePtr(); Messages::Messenger* messageManager = messageModule->getMessageManager(); mouseButtonEventsTranslator = shared_ptr<Messages::Listener> ( new CMouseButtonEventsTranslator() ); mouseButtonEventsTrigger = shared_ptr<Messages::Listener> ( new CMouseButtonEventsTrigger(static_pointer_cast<CMouseButtonEventsTranslator>(mouseButtonEventsTranslator) ) ); mouseButtonStateTranslator = shared_ptr<Messages::Listener> ( new CMouseButtonStateTranslator() ); try { /** * Continuous mouse messages */ messageManager->addListener ( mouseButtonEventsTranslator, mousePressed ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "mouseButtonEventsTranslator listener installed for MOUSE_PRESSED" ); messageManager->addListener ( mouseButtonEventsTranslator, mouseReleased ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "mouseButtonEventsTranslator listener installed for MOUSE_RELEASED" ); messageManager->addListener ( mouseButtonEventsTrigger, updateMouse ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage ( "mouseButtonEventsTrigger listener installed" ); /** * State based mouse messages */ messageManager->addListener ( mouseButtonStateTranslator, mousePressed ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage ( "mouseButtonStateTranslator listener installed for MOUSE_PRESSED" ); messageManager->addListener ( mouseButtonStateTranslator, mouseReleased ); Gnoll::Log::CLogModule::getInstancePtr()->logMessage ( "mouseButtonStateTranslator listener installed for MOUSE_RELEASED" ); } catch(...) { throw; } CTimeModule* timeModule = CTimeModule::getInstancePtr(); m_periodData = shared_ptr<boost::any> (new boost::any(period)) ; shared_ptr<CMessage> message (new CMessage(updateMouse, m_periodData )); timeModule->addPeriodicEvent(0, message, period); }