@@ -76,6 +76,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
76
76
#include " subgame.h"
77
77
#include " quicktune.h"
78
78
#include " serverlist.h"
79
+ #include " sound.h"
80
+ #include " sound_openal.h"
79
81
80
82
/*
81
83
Settings.
@@ -200,7 +202,49 @@ u32 getTime(TimePrecision prec) {
200
202
return 0 ;
201
203
return g_timegetter->getTime (prec);
202
204
}
205
+ #endif
206
+
207
+ // Client side main menu music fetcher
208
+ #ifndef SERVER
209
+ class MenuMusicFetcher : public OnDemandSoundFetcher
210
+ {
211
+ std::set<std::string> m_fetched;
212
+ public:
203
213
214
+ void fetchSounds (const std::string &name,
215
+ std::set<std::string> &dst_paths,
216
+ std::set<std::string> &dst_datas)
217
+ {
218
+ if (m_fetched.count (name))
219
+ return ;
220
+ m_fetched.insert (name);
221
+ std::string base;
222
+ base = porting::path_share + DIR_DELIM + " sounds" ;
223
+ dst_paths.insert (base + DIR_DELIM + name + " .ogg" );
224
+ dst_paths.insert (base + DIR_DELIM + name + " .0.ogg" );
225
+ dst_paths.insert (base + DIR_DELIM + name + " .1.ogg" );
226
+ dst_paths.insert (base + DIR_DELIM + name + " .2.ogg" );
227
+ dst_paths.insert (base + DIR_DELIM + name + " .3.ogg" );
228
+ dst_paths.insert (base + DIR_DELIM + name + " .4.ogg" );
229
+ dst_paths.insert (base + DIR_DELIM + name + " .5.ogg" );
230
+ dst_paths.insert (base + DIR_DELIM + name + " .6.ogg" );
231
+ dst_paths.insert (base + DIR_DELIM + name + " .7.ogg" );
232
+ dst_paths.insert (base + DIR_DELIM + name + " .8.ogg" );
233
+ dst_paths.insert (base + DIR_DELIM + name + " .9.ogg" );
234
+ base = porting::path_user + DIR_DELIM + " sounds" ;
235
+ dst_paths.insert (base + DIR_DELIM + name + " .ogg" );
236
+ dst_paths.insert (base + DIR_DELIM + name + " .0.ogg" );
237
+ dst_paths.insert (base + DIR_DELIM + name + " .1.ogg" );
238
+ dst_paths.insert (base + DIR_DELIM + name + " .2.ogg" );
239
+ dst_paths.insert (base + DIR_DELIM + name + " .3.ogg" );
240
+ dst_paths.insert (base + DIR_DELIM + name + " .4.ogg" );
241
+ dst_paths.insert (base + DIR_DELIM + name + " .5.ogg" );
242
+ dst_paths.insert (base + DIR_DELIM + name + " .6.ogg" );
243
+ dst_paths.insert (base + DIR_DELIM + name + " .7.ogg" );
244
+ dst_paths.insert (base + DIR_DELIM + name + " .8.ogg" );
245
+ dst_paths.insert (base + DIR_DELIM + name + " .9.ogg" );
246
+ }
247
+ };
204
248
#endif
205
249
206
250
class StderrLogOutput : public ILogOutput
@@ -1776,6 +1820,16 @@ int main(int argc, char *argv[])
1776
1820
// Time is in milliseconds, for clouds
1777
1821
u32 lasttime = device->getTimer ()->getTime ();
1778
1822
1823
+ MenuMusicFetcher soundfetcher;
1824
+ ISoundManager *sound = NULL ;
1825
+ sound = createOpenALSoundManager (&soundfetcher);
1826
+ if (!sound)
1827
+ sound = &dummySoundManager;
1828
+ SimpleSoundSpec spec;
1829
+ spec.name = " main_menu" ;
1830
+ spec.gain = 1 ;
1831
+ s32 handle = sound->playSound (spec, true );
1832
+
1779
1833
infostream<<" Created main menu" <<std::endl;
1780
1834
1781
1835
while (device->run () && kill == false )
@@ -1857,7 +1911,12 @@ int main(int argc, char *argv[])
1857
1911
sleep_ms (25 );
1858
1912
}
1859
1913
}
1860
-
1914
+ sound->stopSound (handle);
1915
+ if (sound != &dummySoundManager){
1916
+ delete sound;
1917
+ sound = NULL ;
1918
+ }
1919
+
1861
1920
infostream<<" Dropping main menu" <<std::endl;
1862
1921
1863
1922
menu->drop ();
0 commit comments