Merge 8623cf227a
into 91e144736b
This commit is contained in:
commit
59a6ce59d4
|
@ -138,6 +138,7 @@ public:
|
|||
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
|
||||
format.cbSize = 0;
|
||||
valid = true;
|
||||
name = std::string(SDL_strrchr(fileName, '/') + 1);
|
||||
end:
|
||||
VVV_free(mem);
|
||||
}
|
||||
|
@ -170,6 +171,7 @@ end:
|
|||
|
||||
ogg_file = mem;
|
||||
valid = true;
|
||||
name = std::string(SDL_strrchr(fileName, '/') + 1);
|
||||
}
|
||||
|
||||
void Dispose(void)
|
||||
|
@ -364,6 +366,8 @@ end:
|
|||
static FAudioSourceVoice** voices;
|
||||
static FAudioWaveFormatEx voice_formats[VVV_MAX_CHANNELS];
|
||||
static float volume;
|
||||
|
||||
std::string name;
|
||||
};
|
||||
FAudioSourceVoice** SoundTrack::voices = NULL;
|
||||
FAudioWaveFormatEx SoundTrack::voice_formats[VVV_MAX_CHANNELS];
|
||||
|
@ -727,6 +731,8 @@ musicclass::musicclass(void)
|
|||
quick_fade = true;
|
||||
|
||||
usingmmmmmm = false;
|
||||
|
||||
stockSoundTracks = 0;
|
||||
}
|
||||
|
||||
void musicclass::init(void)
|
||||
|
@ -772,6 +778,31 @@ void musicclass::init(void)
|
|||
soundTracks.push_back(SoundTrack( "sounds/newrecord.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/trophy.wav" ));
|
||||
soundTracks.push_back(SoundTrack( "sounds/rescue.wav" ));
|
||||
|
||||
stockSoundTracks = soundTracks.size();
|
||||
|
||||
//Here's where we find all the custom sounds in a level's assets folder
|
||||
EnumHandle handle = {};
|
||||
const char* item;
|
||||
while ((item = FILESYSTEM_enumerateAssets("sounds/", &handle)) != NULL)
|
||||
{
|
||||
const std::string str_item = item;
|
||||
bool match;
|
||||
for (int j = 0; j < soundTracks.size(); j++)
|
||||
{
|
||||
match = (str_item == soundTracks[j].name);
|
||||
if (match)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!match)
|
||||
{
|
||||
soundTracks.push_back(SoundTrack( ("sounds/" + str_item).c_str() ));
|
||||
}
|
||||
}
|
||||
FILESYSTEM_freeEnumerate(&handle);
|
||||
|
||||
|
||||
#ifdef VVV_COMPILEMUSIC
|
||||
binaryBlob musicWriteBlob;
|
||||
|
@ -1280,6 +1311,20 @@ void musicclass::playef(int t)
|
|||
soundTracks[t].Play();
|
||||
}
|
||||
|
||||
void musicclass::playef_name(std::string& t)
|
||||
{
|
||||
for (int i = 0; i < soundTracks.size(); i++)
|
||||
{
|
||||
size_t lastindex = soundTracks[i].name.find_last_of('.');
|
||||
std::string rawname = soundTracks[i].name.substr(0, lastindex);
|
||||
if (t == rawname)
|
||||
{
|
||||
soundTracks[i].Play();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void musicclass::pauseef(void)
|
||||
{
|
||||
SoundTrack::Pause();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define MUSIC_H
|
||||
|
||||
#include "BinaryBlob.h"
|
||||
#include <string>
|
||||
|
||||
#define musicroom(rx, ry) ((rx) + ((ry) * 20))
|
||||
|
||||
|
@ -92,6 +93,7 @@ public:
|
|||
int haltedsong;
|
||||
|
||||
void playef(int t);
|
||||
void playef_name(std::string& t);
|
||||
void pauseef(void);
|
||||
void resumeef(void);
|
||||
|
||||
|
@ -117,6 +119,8 @@ public:
|
|||
bool mmmmmm;
|
||||
bool usingmmmmmm;
|
||||
|
||||
int stockSoundTracks;
|
||||
|
||||
binaryBlob pppppp_blob;
|
||||
binaryBlob mmmmmm_blob;
|
||||
int num_pppppp_tracks;
|
||||
|
|
|
@ -430,7 +430,14 @@ void scriptclass::run(void)
|
|||
}
|
||||
if (words[0] == "playef")
|
||||
{
|
||||
music.playef(ss_toi(words[1]));
|
||||
if (is_number(words[1].c_str()) && ss_toi(words[1]) >= 0 && ss_toi(words[1]) < music.stockSoundTracks)
|
||||
{
|
||||
music.playef(ss_toi(words[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
music.playef_name(raw_words[1]);
|
||||
}
|
||||
}
|
||||
if (words[0] == "play")
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue