00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (C) 2010 Guillaume Martres <smarter@ubuntu.com> 00004 * Copyright (c) 2010 Dan Leinir Turthra Jensen <admin@leinir.dk> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #include "soundlistenercomponent.h" 00022 00023 #include <audio/engine.h> 00024 #include <gameobject.h> 00025 00026 REGISTER_OBJECTTYPE( GluonEngine, SoundListenerComponent ) 00027 00028 using namespace GluonEngine; 00029 00030 SoundListenerComponent* SoundListenerComponent::m_activeInstance = 0; 00031 00032 SoundListenerComponent::SoundListenerComponent( QObject* parent ) 00033 : Component( parent ) 00034 { 00035 GluonAudio::Engine::instance(); 00036 } 00037 00038 SoundListenerComponent::SoundListenerComponent( const SoundListenerComponent& other ) 00039 : Component( other ) 00040 { 00041 } 00042 00043 QString SoundListenerComponent::category() const 00044 { 00045 return QString( "Audio" ); 00046 } 00047 00048 void SoundListenerComponent::start() 00049 { 00050 if( isActive() ) 00051 GluonAudio::Engine::instance()->setListenerPosition( gameObject()->position() ); 00052 } 00053 00054 void SoundListenerComponent::draw( int timeLapse ) 00055 { 00056 Q_UNUSED( timeLapse ); 00057 00058 if( isActive() ) 00059 GluonAudio::Engine::instance()->setListenerPosition( gameObject()->position() ); 00060 } 00061 00062 void SoundListenerComponent::setActive( bool active ) 00063 { 00064 if( active ) 00065 m_activeInstance = this; 00066 } 00067 00068 void SoundListenerComponent::setEffectsEnabled( bool enable ) 00069 { 00070 m_effectsEnabled = enable; 00071 } 00072 00073 SoundListenerComponent* SoundListenerComponent::activeInstance() 00074 { 00075 return m_activeInstance; 00076 } 00077 00078 Q_EXPORT_PLUGIN2( gluon_component_soundlistener, GluonEngine::SoundListenerComponent ) 00079 00080 #include "soundlistenercomponent.moc"