Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 19, 2009, 12:18:41 AM (16 years ago)
Author:
rgrieder
Message:

Several small changes in sound:

  • Fixed a bug that caused a sound source to be initialised on pause() even it already existed
  • The XML parameter is now called "looping" instead of "loop" because looping was used really all over the code
  • The "play" XML parameter doesn't exist anymore, use "playOnLoad" for AmbientSound only.
  • Added "pitch" XML parameter
  • Changes in synchronisation policy: Ambient sound should not synchronise the state but instead th new playOnLoad parameter
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/sound/AmbientSound.cc

    r6370 r6382  
    4242
    4343    AmbientSound::AmbientSound(BaseObject* creator)
    44         : BaseObject(creator), Synchronisable(creator)
     44        : BaseObject(creator)
     45        , Synchronisable(creator)
     46        , bPlayOnLoad_(false)
    4547    {
    4648        RegisterObject(AmbientSound);
     
    4951        this->setVolume(0);
    5052        this->registerVariables();
    51     }
    52 
    53     AmbientSound::~AmbientSound()
    54     {
    5553    }
    5654
     
    6765    {
    6866        registerVariable(ambientSource_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::ambientSourceChanged));
    69         registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged));
    70         registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged));
    71         registerVariable((int&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::stateChanged));
     67        registerVariable(bLooping_,      ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged));
     68        registerVariable(pitch_,         ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged));
     69        registerVariable(bPlayOnLoad_,   ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::playOnLoadChanged));
    7270    }
    7371
     
    7674        SUPER(AmbientSound, XMLPort, xmlelement, mode);
    7775        BaseSound::XMLPortExtern(xmlelement, mode);
    78         XMLPortParam(AmbientSound, "ambientsource", setAmbientSource, getAmbientSource, xmlelement, mode);
     76        XMLPortParam(AmbientSound, "ambientSource", setAmbientSource, getAmbientSource, xmlelement, mode);
     77        XMLPortParam(AmbientSound, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
    7978    }
    8079
     
    8887    {
    8988        if (GameMode::playsSound())
    90         {
    9189            SoundManager::getInstance().registerAmbientSound(this);
    92         }
    93         else
    94             BaseSound::play();
    95     }
    96 
    97     void AmbientSound::doPlay()
    98     {
    99         BaseSound::play();
    10090    }
    10191
     
    10393    {
    10494        if (GameMode::playsSound())
    105         {
    10695            SoundManager::getInstance().unregisterAmbientSound(this);
    107         }
    108         else
    109             BaseSound::stop();
    110     }
    111 
    112     void AmbientSound::doStop()
    113     {
    114         BaseSound::stop();
    11596    }
    11697
     
    11899    {
    119100        if (GameMode::playsSound())
    120         {
    121101            SoundManager::getInstance().pauseAmbientSound(this);
    122         }
    123         else
    124             BaseSound::pause();
    125102    }
    126103   
     
    129106        assert(GameMode::playsSound());
    130107        return SoundManager::getInstance().getRealVolume(SoundType::Music);
    131     }
    132 
    133     void AmbientSound::doPause()
    134     {
    135         BaseSound::pause();
    136108    }
    137109
     
    150122    }
    151123
     124    void AmbientSound::setPlayOnLoad(bool val)
     125    {
     126        this->bPlayOnLoad_ = val;
     127        if (val)
     128            this->play();
     129    }
     130
    152131    void AmbientSound::changedActivity()
    153132    {
Note: See TracChangeset for help on using the changeset viewer.