| 348 | } |
| 349 | |
| 350 | void 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 |
nothing calls this directly
no test coverage detected