| 413 | } |
| 414 | |
| 415 | void EnumerateLegacyTracks() |
| 416 | { |
| 417 | auto dir = std::filesystem::path{ FullAudioDirectory }; |
| 418 | if (!std::filesystem::is_directory(dir)) |
| 419 | { |
| 420 | TENLog("Folder \"" + dir.string() + "\" does not exist. ", LogLevel::Warning, LogConfig::All); |
| 421 | return; |
| 422 | } |
| 423 | |
| 424 | try |
| 425 | { |
| 426 | // Capture three-digit filenames, or those which start with three digits. |
| 427 | std::regex upToThreeDigits("((\\d{1,3})[^\\.]*)"); |
| 428 | std::smatch result; |
| 429 | |
| 430 | for (const auto& file : std::filesystem::directory_iterator{ dir }) |
| 431 | { |
| 432 | auto fileName = file.path().filename().u8string(); |
| 433 | auto bResult = std::regex_search(fileName, result, upToThreeDigits); |
| 434 | if (!result.empty()) |
| 435 | { |
| 436 | // result[0] is the whole match including the leading backslash, so ignore it |
| 437 | // result[1] is the full file name, not including the extension |
| 438 | int index = std::stoi(result[2].str()); |
| 439 | SoundTrackInfo s; |
| 440 | |
| 441 | // TRLE default looping tracks |
| 442 | if (index >= LegacyLoopingTrackMin && index <= LegacyLoopingTrackMax) |
| 443 | { |
| 444 | s.Mode = SoundTrackType::BGM; |
| 445 | } |
| 446 | s.Name = result[1]; |
| 447 | SoundTracks.insert(std::make_pair(index, s)); |
| 448 | SecretSoundIndex = std::max(SecretSoundIndex, index); |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | catch (std::filesystem::filesystem_error const& e) |
| 453 | { |
| 454 | TENLog(e.what(), LogLevel::Error, LogConfig::All); |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | float GetSoundTrackLoudness(SoundTrackType type) |
| 459 | { |