|
|
@ -3,6 +3,7 @@
|
|
|
|
#include <iostream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <map>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <numeric>
|
|
|
|
|
|
|
|
|
|
|
|
#include <osg/Matrixf>
|
|
|
|
#include <osg/Matrixf>
|
|
|
|
|
|
|
|
|
|
|
@ -271,7 +272,6 @@ namespace MWSound
|
|
|
|
return sound;
|
|
|
|
return sound;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Gets the combined volume settings for the given sound type
|
|
|
|
// Gets the combined volume settings for the given sound type
|
|
|
|
float SoundManager::volumeFromType(PlayType type) const
|
|
|
|
float SoundManager::volumeFromType(PlayType type) const
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -298,7 +298,6 @@ namespace MWSound
|
|
|
|
return volume;
|
|
|
|
return volume;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SoundManager::stopMusic()
|
|
|
|
void SoundManager::stopMusic()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(mMusic)
|
|
|
|
if(mMusic)
|
|
|
@ -349,6 +348,7 @@ namespace MWSound
|
|
|
|
void SoundManager::startRandomTitle()
|
|
|
|
void SoundManager::startRandomTitle()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::vector<std::string> filelist;
|
|
|
|
std::vector<std::string> filelist;
|
|
|
|
|
|
|
|
auto &tracklist = mMusicToPlay[mCurrentPlaylist];
|
|
|
|
if (mMusicFiles.find(mCurrentPlaylist) == mMusicFiles.end())
|
|
|
|
if (mMusicFiles.find(mCurrentPlaylist) == mMusicFiles.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const std::map<std::string, VFS::File*>& index = mVFS->getIndex();
|
|
|
|
const std::map<std::string, VFS::File*>& index = mVFS->getIndex();
|
|
|
@ -367,7 +367,6 @@ namespace MWSound
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mMusicFiles[mCurrentPlaylist] = filelist;
|
|
|
|
mMusicFiles[mCurrentPlaylist] = filelist;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
filelist = mMusicFiles[mCurrentPlaylist];
|
|
|
|
filelist = mMusicFiles[mCurrentPlaylist];
|
|
|
@ -375,15 +374,25 @@ namespace MWSound
|
|
|
|
if(filelist.empty())
|
|
|
|
if(filelist.empty())
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
int i = Misc::Rng::rollDice(filelist.size());
|
|
|
|
// Do a Fisher-Yates shuffle
|
|
|
|
|
|
|
|
|
|
|
|
// Don't play the same music track twice in a row
|
|
|
|
// Repopulate if playlist is empty
|
|
|
|
if (filelist[i] == mLastPlayedMusic)
|
|
|
|
if(tracklist.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
i = (i+1) % filelist.size();
|
|
|
|
tracklist.resize(filelist.size());
|
|
|
|
|
|
|
|
std::iota(tracklist.begin(), tracklist.end(), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
advanceMusic(filelist[i]);
|
|
|
|
int i = Misc::Rng::rollDice(tracklist.size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Reshuffle if last played music is the same after a repopulation
|
|
|
|
|
|
|
|
if(filelist[tracklist[i]] == mLastPlayedMusic)
|
|
|
|
|
|
|
|
i = (i+1) % tracklist.size();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Remove music from list after advancing music
|
|
|
|
|
|
|
|
advanceMusic(filelist[tracklist[i]]);
|
|
|
|
|
|
|
|
tracklist[i] = tracklist.back();
|
|
|
|
|
|
|
|
tracklist.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SoundManager::isMusicPlaying()
|
|
|
|
bool SoundManager::isMusicPlaying()
|
|
|
|