Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5892 for code/branches/core5


Ignore:
Timestamp:
Oct 6, 2009, 9:18:40 AM (15 years ago)
Author:
rgrieder
Message:

Removed hard coded sound in Level, Engine and PongBall and replaced SoundMainMenu with a simple SoundBase.

Location:
code/branches/core5/src
Files:
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/modules/pong/PongBall.cc

    r5889 r5892  
    3333#include "gametypes/Gametype.h"
    3434#include "PongBat.h"
    35 #include "sound/SoundBase.h"
    3635
    3736namespace orxonox
     
    4342    PongBall::PongBall(BaseObject* creator)
    4443        : MovableEntity(creator)
    45         , sidesound_(NULL)
    46         , batsound_(NULL)
    47         , scoresound_(NULL)
    4844    {
    4945        RegisterObject(PongBall);
     
    5753
    5854        this->registerVariables();
    59 
    60         if (GameMode::playsSound())
    61         {
    62             this->sidesound_ = new SoundBase(this);
    63             this->sidesound_->loadFile("sounds/pong_side.wav");
    64 
    65             this->batsound_ = new SoundBase(this);
    66             this->batsound_->loadFile("sounds/pong_bat.wav");
    67 
    68             this->scoresound_ = new SoundBase(this);
    69             this->scoresound_->loadFile("sounds/pong_score.wav");
    70         }
    7155    }
    7256
    7357    PongBall::~PongBall()
    7458    {
    75         if (this->sidesound_)
    76             delete this->sidesound_;
    77         if (this->batsound_)
    78             delete this->batsound_;
    79         if (this->scoresound_)
    80             delete this->scoresound_;
    8159    }
    8260
     
    10886
    10987            this->fireEvent();
    110             if (GameMode::playsSound())
    111                 this->sidesound_->play();
    11288        }
    11389
     
    128104                       
    129105                        this->fireEvent();
    130                         if (GameMode::playsSound())
    131                             this->batsound_->play();
    132106                    }
    133107                    else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
     
    136110                        {
    137111                            this->getGametype()->playerScored(this->bat_[0]->getPlayer());
    138                             if (GameMode::playsSound())
    139                                 this->scoresound_->play();
    140112                            return;
    141113                        }
     
    152124
    153125                        this->fireEvent();
    154                         if (GameMode::playsSound())
    155                             this->batsound_->play();
    156126                    }
    157127                    else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
     
    159129                        if (this->getGametype() && this->bat_[1])
    160130                        {
    161                             if (GameMode::playsSound())
    162                                 this->scoresound_->play();
    163131                            this->getGametype()->playerScored(this->bat_[1]->getPlayer());
    164132                            return;
  • code/branches/core5/src/modules/pong/PongBall.h

    r5881 r5892  
    7676            unsigned int* batID_;
    7777            float relMercyOffset_;
    78 
    79             SoundBase* sidesound_;
    80             SoundBase* batsound_;
    81             SoundBase* scoresound_;
    8278    };
    8379}
  • code/branches/core5/src/orxonox/Level.cc

    r5836 r5892  
    3939#include "gametypes/Gametype.h"
    4040#include "overlays/OverlayGroup.h"
    41 #include "sound/SoundBase.h"
    4241#include "LevelManager.h"
    4342
     
    5352        this->xmlfilename_ = this->getFilename();
    5453        this->xmlfile_ = 0;
    55         this->ambientsound_ = 0;
    5654    }
    5755
     
    6563            if (this->xmlfile_)
    6664                Loader::unload(this->xmlfile_);
    67 
    68             if (this->ambientsound_ != NULL)
    69                 delete this->ambientsound_;
    7065        }
    7166    }
     
    7772        XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
    7873        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
    79 
    80         XMLPortParamLoadOnly(Level, "ambientsound", loadAmbientSound, xmlelement, mode);
    8174
    8275        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
     
    150143    }
    151144
    152     void Level::loadAmbientSound(const std::string& filename)
    153     {
    154         if(filename == "") return;
    155         else
    156         {
    157             if(this->ambientsound_ == NULL)
    158             {
    159                 this->ambientsound_ = new SoundBase();
    160             }
    161 
    162             this->ambientsound_->loadFile(filename);
    163             this->ambientsound_->play(true);
    164         }
    165     }
    166 
    167145    void Level::playerEntered(PlayerInfo* player)
    168146    {
  • code/branches/core5/src/orxonox/Level.h

    r5738 r5892  
    5353                { return this->description_; }
    5454
    55             void loadAmbientSound(const std::string& filename);
    56 
    5755            void playerEntered(PlayerInfo* player);
    5856            void playerLeft(PlayerInfo* player);
     
    7371            XMLFile*               xmlfile_;
    7472            std::list<BaseObject*> objects_;
    75 
    76             SoundBase*             ambientsound_;
    7773    };
    7874}
  • code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc

    r5878 r5892  
    3939#include "core/GUIManager.h"
    4040#include "Scene.h"
    41 #include "sound/SoundMainMenu.h"
     41#include "sound/SoundBase.h"
    4242
    4343namespace orxonox
     
    6262        {
    6363            // Load sound
    64             this->ambient_ = new SoundMainMenu();
     64            this->ambient_ = new SoundBase(0);
     65            this->ambient_->loadFile("ambient/mainmenu.wav");
    6566        }
    6667    }
     
    6970    {
    7071        if (GameMode::playsSound())
    71         {
    72             this->ambient_->destroy();
    73         }
     72            delete this->ambient_;
    7473
    7574        InputManager::getInstance().destroyState("mainMenu");
  • code/branches/core5/src/orxonox/gamestates/GSMainMenu.h

    r5876 r5892  
    5959
    6060        // ambient sound for the main menu
    61         SoundMainMenu* ambient_;
     61        SoundBase*        ambient_;
    6262    };
    6363}
  • code/branches/core5/src/orxonox/items/Engine.cc

    r5801 r5892  
    3737#include "pickup/ModifierType.h"
    3838#include "tools/Shader.h"
    39 #include "sound/SoundBase.h"
    4039
    4140namespace orxonox
     
    6867        this->setConfigValues();
    6968        this->registerVariables();
    70 
    71         this->sound_ = NULL;
    7269    }
    7370
     
    8077            if (this->boostBlur_)
    8178                this->boostBlur_->destroy();
    82 
    83             if(this->sound_ != NULL)
    84                 delete this->sound_;
    8579        }
    8680    }
     
    10296        XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode);
    10397        XMLPortParam(Engine, "accelerationupdown",    setAccelerationUpDown,    setAccelerationUpDown,    xmlelement, mode);
    104 
    105         XMLPortParamLoadOnly(Engine, "sound", loadSound, xmlelement, mode);
    10698    }
    10799
     
    240232                this->boostBlur_ = 0;
    241233            }
    242 
    243             if(this->sound_ != NULL)
    244                 this->sound_->attachToEntity(ship);
    245234        }
    246235    }
     
    253242            return Vector3::ZERO;
    254243    }
    255 
    256     void Engine::loadSound(const std::string filename)
    257     {
    258         if(filename == "") return;
    259         else
    260         {
    261             if(this->sound_ == NULL)
    262             {
    263                 this->sound_ = new SoundBase(this->ship_);
    264             }
    265 
    266             this->sound_->loadFile(filename);
    267             this->sound_->play(true);
    268         }
    269     }
    270244}
  • code/branches/core5/src/orxonox/items/Engine.h

    r5738 r5892  
    130130            Shader* boostBlur_;
    131131            float blurStrength_;
    132 
    133             SoundBase* sound_;
    134132    };
    135133}
  • code/branches/core5/src/orxonox/sound/CMakeLists.txt

    r3196 r5892  
    22    SoundManager.cc
    33    SoundBase.cc
    4     SoundMainMenu.cc
    54)
    65
Note: See TracChangeset for help on using the changeset viewer.