mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 10:36:42 +00:00
SoundManager: Finish up with Task #172, plus cleanup
This commit is contained in:
parent
ad6175c78a
commit
44620ada86
2 changed files with 21 additions and 27 deletions
|
@ -10,7 +10,6 @@
|
||||||
#include <mangle/sound/clients/ogre_listener_mover.hpp>
|
#include <mangle/sound/clients/ogre_listener_mover.hpp>
|
||||||
#include <mangle/sound/clients/ogre_output_updater.hpp>
|
#include <mangle/sound/clients/ogre_output_updater.hpp>
|
||||||
|
|
||||||
#include <components/file_finder/file_finder.hpp>
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
|
||||||
#include "../mwworld/environment.hpp"
|
#include "../mwworld/environment.hpp"
|
||||||
|
@ -102,9 +101,6 @@ namespace MWSound
|
||||||
// Tell Ogre to update the sound system each frame
|
// Tell Ogre to update the sound system each frame
|
||||||
root->addFrameListener(&updater);
|
root->addFrameListener(&updater);
|
||||||
}
|
}
|
||||||
|
|
||||||
test.name = "";
|
|
||||||
total = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundManager::~SoundManager()
|
SoundManager::~SoundManager()
|
||||||
|
@ -430,15 +426,22 @@ namespace MWSound
|
||||||
void SoundManager::update (float duration)
|
void SoundManager::update (float duration)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
|
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
|
||||||
|
static int total = 0;
|
||||||
|
static std::string regionName = "";
|
||||||
|
static float timePassed = 0.0;
|
||||||
|
timePassed += duration;
|
||||||
|
|
||||||
//If the region has changed
|
//If the region has changed
|
||||||
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10)
|
if(!(current->cell->data.flags & current->cell->Interior) && timePassed >= 10)
|
||||||
{
|
{
|
||||||
timer.restart();
|
|
||||||
if (test.name != current->cell->region)
|
ESM::Region test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
|
||||||
|
|
||||||
|
timePassed = 0;
|
||||||
|
if (regionName != current->cell->region)
|
||||||
{
|
{
|
||||||
|
regionName = current->cell->region;
|
||||||
total = 0;
|
total = 0;
|
||||||
test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(test.soundList.size() > 0)
|
if(test.soundList.size() > 0)
|
||||||
|
@ -462,15 +465,15 @@ namespace MWSound
|
||||||
soundIter = test.soundList.begin();
|
soundIter = test.soundList.begin();
|
||||||
while (soundIter != test.soundList.end())
|
while (soundIter != test.soundList.end())
|
||||||
{
|
{
|
||||||
const ESM::NAME32 go = soundIter->sound;
|
const std::string go = soundIter->sound.toString();
|
||||||
int chance = (int) soundIter->chance;
|
int chance = (int) soundIter->chance;
|
||||||
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
||||||
soundIter++;
|
soundIter++;
|
||||||
if( r - pos < chance)
|
if( r - pos < chance)
|
||||||
{
|
{
|
||||||
//play sound
|
//play sound
|
||||||
std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
std::cout << "Sound: " << go <<" Chance:" << chance << "\n";
|
||||||
mEnvironment.mSoundManager->playSound(go.name, 20.0, 1.0);
|
mEnvironment.mSoundManager->playSound(go, 20.0, 1.0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -480,7 +483,7 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
else if(current->cell->data.flags & current->cell->Interior)
|
else if(current->cell->data.flags & current->cell->Interior)
|
||||||
{
|
{
|
||||||
test.name = "";
|
regionName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,11 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
#include <boost/timer.hpp>
|
|
||||||
|
|
||||||
#include <mangle/sound/clients/ogre_output_updater.hpp>
|
#include <mangle/sound/clients/ogre_output_updater.hpp>
|
||||||
#include <mangle/sound/clients/ogre_listener_mover.hpp>
|
#include <mangle/sound/clients/ogre_listener_mover.hpp>
|
||||||
|
|
||||||
#include <openengine/sound/sndmanager.hpp>
|
#include <openengine/sound/sndmanager.hpp>
|
||||||
#include <components/files/fileops.hpp>
|
|
||||||
#include <components/file_finder/file_finder.hpp>
|
|
||||||
#include <components/files/filelibrary.hpp>
|
#include <components/files/filelibrary.hpp>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
@ -28,17 +24,11 @@ namespace Mangle
|
||||||
namespace Sound
|
namespace Sound
|
||||||
{
|
{
|
||||||
typedef boost::shared_ptr<Sound> SoundPtr;
|
typedef boost::shared_ptr<Sound> SoundPtr;
|
||||||
//struct OgreOutputUpdater;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef OEngine::Sound::SoundManagerPtr OEManagerPtr;
|
typedef OEngine::Sound::SoundManagerPtr OEManagerPtr;
|
||||||
|
|
||||||
namespace ESMS
|
|
||||||
{
|
|
||||||
struct ESMStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
struct Environment;
|
struct Environment;
|
||||||
|
@ -57,10 +47,6 @@ namespace MWSound
|
||||||
|
|
||||||
MWWorld::Environment& mEnvironment;
|
MWWorld::Environment& mEnvironment;
|
||||||
|
|
||||||
int total;
|
|
||||||
ESM::Region test;
|
|
||||||
boost::timer timer;
|
|
||||||
|
|
||||||
void streamMusicFull (const std::string& filename);
|
void streamMusicFull (const std::string& filename);
|
||||||
///< Play a soundifle
|
///< Play a soundifle
|
||||||
/// \param absolute filename
|
/// \param absolute filename
|
||||||
|
@ -85,10 +71,13 @@ namespace MWSound
|
||||||
typedef std::map<MWWorld::Ptr,IDMap> PtrMap;
|
typedef std::map<MWWorld::Ptr,IDMap> PtrMap;
|
||||||
PtrMap sounds;
|
PtrMap sounds;
|
||||||
|
|
||||||
|
// A list of all sound files used to lookup paths
|
||||||
Files::PathContainer mSoundFiles;
|
Files::PathContainer mSoundFiles;
|
||||||
|
|
||||||
|
// A library of all Music file paths stored by the folder they are contained in
|
||||||
Files::FileLibrary mMusicLibrary;
|
Files::FileLibrary mMusicLibrary;
|
||||||
|
|
||||||
|
// Points to the current playlist of music files stored in the music library
|
||||||
const Files::PathContainer* mCurrentPlaylist;
|
const Files::PathContainer* mCurrentPlaylist;
|
||||||
|
|
||||||
std::string lookup(const std::string &soundId,
|
std::string lookup(const std::string &soundId,
|
||||||
|
@ -115,8 +104,10 @@ namespace MWSound
|
||||||
/// \param filename name of a sound file in "Music/" in the data directory.
|
/// \param filename name of a sound file in "Music/" in the data directory.
|
||||||
|
|
||||||
void startRandomTitle();
|
void startRandomTitle();
|
||||||
|
///< Starts a random track from the current playlist
|
||||||
|
|
||||||
bool isMusicPlaying();
|
bool isMusicPlaying();
|
||||||
|
///< Returns true if music is playing
|
||||||
|
|
||||||
bool setPlaylist(std::string playlist="");
|
bool setPlaylist(std::string playlist="");
|
||||||
///< Set the playlist to an existing folder
|
///< Set the playlist to an existing folder
|
||||||
|
|
Loading…
Reference in a new issue