summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRealBadAngel <mk@realbadangel.pl>2013-05-01 13:09:10 +0200
committerPilzAdam <pilzadam@minetest.net>2013-05-11 15:39:38 +0200
commit9575b0a2a8bf6f5f24a98215cda494440e4f3831 (patch)
treee2601869adac6cf78137990b789c1582ba4cc9c4
parent6911a7d279f487b832882d95318d432d0afbcc6b (diff)
downloadminetest-9575b0a2a8bf6f5f24a98215cda494440e4f3831.tar.gz
minetest-9575b0a2a8bf6f5f24a98215cda494440e4f3831.tar.bz2
minetest-9575b0a2a8bf6f5f24a98215cda494440e4f3831.zip
Add code to play main_menu.ogg in main menu
-rw-r--r--src/main.cpp61
1 files changed, 60 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index e2ea19295..56cb310ca 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -76,6 +76,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "subgame.h"
#include "quicktune.h"
#include "serverlist.h"
+#include "sound.h"
+#include "sound_openal.h"
/*
Settings.
@@ -200,7 +202,49 @@ u32 getTime(TimePrecision prec) {
return 0;
return g_timegetter->getTime(prec);
}
+#endif
+
+//Client side main menu music fetcher
+#ifndef SERVER
+class MenuMusicFetcher: public OnDemandSoundFetcher
+{
+ std::set<std::string> m_fetched;
+public:
+ void fetchSounds(const std::string &name,
+ std::set<std::string> &dst_paths,
+ std::set<std::string> &dst_datas)
+ {
+ if(m_fetched.count(name))
+ return;
+ m_fetched.insert(name);
+ std::string base;
+ base = porting::path_share + DIR_DELIM + "sounds";
+ dst_paths.insert(base + DIR_DELIM + name + ".ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".0.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".1.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".2.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".3.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".4.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".5.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".6.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".7.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".8.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".9.ogg");
+ base = porting::path_user + DIR_DELIM + "sounds";
+ dst_paths.insert(base + DIR_DELIM + name + ".ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".0.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".1.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".2.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".3.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".4.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".5.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".6.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".7.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".8.ogg");
+ dst_paths.insert(base + DIR_DELIM + name + ".9.ogg");
+ }
+};
#endif
class StderrLogOutput: public ILogOutput
@@ -1776,6 +1820,16 @@ int main(int argc, char *argv[])
// Time is in milliseconds, for clouds
u32 lasttime = device->getTimer()->getTime();
+ MenuMusicFetcher soundfetcher;
+ ISoundManager *sound = NULL;
+ sound = createOpenALSoundManager(&soundfetcher);
+ if(!sound)
+ sound = &dummySoundManager;
+ SimpleSoundSpec spec;
+ spec.name = "main_menu";
+ spec.gain = 1;
+ s32 handle = sound->playSound(spec, true);
+
infostream<<"Created main menu"<<std::endl;
while(device->run() && kill == false)
@@ -1857,7 +1911,12 @@ int main(int argc, char *argv[])
sleep_ms(25);
}
}
-
+ sound->stopSound(handle);
+ if(sound != &dummySoundManager){
+ delete sound;
+ sound = NULL;
+ }
+
infostream<<"Dropping main menu"<<std::endl;
menu->drop();