MCPcopy Create free account
hub / github.com/EasyRPG/Player / RefreshAudioSoundfont

Method RefreshAudioSoundfont

src/window_settings.cpp:350–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350void Window_Settings::RefreshAudioSoundfont() {
351 auto fs = Game_Config::GetSoundfontFilesystem();
352
353 if (!fs) {
354 Pop();
355 }
356
357 fs.ClearCache();
358
359 auto acfg = Audio().GetConfig();
360 AddOption(MenuItem("<Autodetect>", "Attempt to find a suitable soundfont automatically", acfg.soundfont.Get().empty() ? "[x]" : ""), [this]() {
361 Audio().SetFluidsynthSoundfont({});
362 Pop();
363 });
364
365 auto list = fs.ListDirectory();
366 assert(list);
367
368 std::string sf_lower = Utils::LowerCase(Audio().GetFluidsynthSoundfont());
369 for (const auto& item: *list) {
370 if (item.second.type == DirectoryTree::FileType::Regular && (EndsWith(item.first, ".sf2") || EndsWith(item.first, ".soundfont"))) {
371 AddOption(MenuItem(item.second.name, "Use this custom soundfont", EndsWith(sf_lower, item.first) ? "[x]" : ""), [this, fs, item]() {
372 Audio().SetFluidsynthSoundfont(FileFinder::MakePath(fs.GetFullPath(), item.second.name));
373 Pop();
374 });
375 }
376 }
377
378 for (auto& opt: GetFrame().options) {
379 opt.help2 = "Changes take effect when a new MIDI file is played";
380 }
381
382#ifdef EMSCRIPTEN
383 AddOption(MenuItem("<Upload Soundfont>", "Provide a soundfont from your system", ""), [fs]() { Emscripten_Interface::UploadSoundfont(); });
384#elif defined(SUPPORT_FILE_BROWSER)
385 AddOption(MenuItem("<Open Soundfont directory>", "Open the soundfont directory in a file browser", ""), [fs]() { DisplayUi->OpenURL(fs.GetFullPath()); });
386#endif
387}
388
389#ifdef __clang__
390// FIXME: Binding &cfg in the lambdas below is not needed and generates a warning in clang but MSVC requires it

Callers

nothing calls this directly

Calls 10

MenuItemClass · 0.85
GetFullPathMethod · 0.80
ClearCacheMethod · 0.45
GetConfigMethod · 0.45
emptyMethod · 0.45
GetMethod · 0.45
ListDirectoryMethod · 0.45
OpenURLMethod · 0.45

Tested by

no test coverage detected