Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 22, 2009, 4:01:16 PM (15 years ago)
Author:
rgrieder
Message:

Merged sound3 branch to presentation2.

Location:
code/branches/presentation2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2

  • code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.cc

    r6105 r6117  
    3636#include "core/Game.h"
    3737#include "core/ConsoleCommand.h"
     38#include "core/ConfigValueIncludes.h"
    3839#include "core/GraphicsManager.h"
    3940#include "core/GUIManager.h"
     
    4950        , inputState_(0)
    5051    {
     52        RegisterRootObject(GSMainMenu);
    5153        inputState_ = InputManager::getInstance().createInputState("mainMenu");
    5254        inputState_->setMouseMode(MouseMode::Nonexclusive);
     
    6466            // Load sound
    6567            this->ambient_ = new AmbientSound(0);
    66             this->ambient_->setSource("ambient/mainmenu.wav");
    6768        }
    6869    }
     
    9192        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startDedicated), "startDedicated"));
    9293        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu), "startMainMenu"));
     94       
     95        // create command to change sound path
     96        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::setMainMenuSoundPath, this), "setMMSoundPath"));
    9397
    9498        KeyBinderManager::getInstance().setToDefault();
     
    97101        if (GameMode::playsSound())
    98102        {
    99             this->ambient_->setLoop(true);
    100             this->ambient_->play();
     103            this->ambient_->setLooping(true);
     104            this->ambient_->play(); // works without source
    101105        }
     106
     107        this->setConfigValues();
    102108    }
    103109
     
    117123    void GSMainMenu::update(const Clock& time)
    118124    {
     125    }
     126
     127    void GSMainMenu::setConfigValues()
     128    {
     129        SetConfigValue(soundPathMain_, "mainmenu.ogg")
     130            .description("Contains the path to the main menu sound file.")
     131            .callback(this, &GSMainMenu::reloadSound);
     132    }
     133
     134    void GSMainMenu::reloadSound()
     135    {
     136        if (GameMode::playsSound())
     137        {
     138            this->ambient_->setAmbientSource(soundPathMain_);
     139        }
     140    }
     141
     142    const std::string& GSMainMenu::getMainMenuSoundPath()
     143    {
     144        return soundPathMain_;
     145    }
     146
     147    void GSMainMenu::setMainMenuSoundPath(const std::string& path)
     148    {
     149        ModifyConfigValue(soundPathMain_, set, path);
    119150    }
    120151
  • code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.h

    r5929 r6117  
    3434#include "util/OgreForwardRefs.h"
    3535#include "core/GameState.h"
     36#include "core/OrxonoxClass.h"
    3637
    3738namespace orxonox
    3839{
    39     class _OrxonoxExport GSMainMenu : public GameState
     40    class _OrxonoxExport GSMainMenu : public GameState, public OrxonoxClass
    4041    {
    4142    public:
     
    4647        void deactivate();
    4748        void update(const Clock& time);
     49
     50        void setConfigValues();
     51        void reloadSound();
     52        const std::string& getMainMenuSoundPath();
     53        void setMainMenuSoundPath(const std::string& path);
    4854
    4955        static void startStandalone();
     
    6167        // ambient sound for the main menu
    6268        AmbientSound*     ambient_;
     69        std::string       soundPathMain_;
    6370    };
    6471}
Note: See TracChangeset for help on using the changeset viewer.