MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / GetCurrentSubtitle

Function GetCurrentSubtitle

TombEngine/Sound/sound.cpp:472–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470}
471
472std::optional<std::string> GetCurrentSubtitle()
473{
474 if (!g_Configuration.EnableSound || !g_Configuration.EnableSubtitles)
475 return std::nullopt;
476
477 auto channel = SoundtrackSlot[(int)SoundTrackType::Voice].Channel;
478
479 if (!BASS_ChannelIsActive(channel))
480 return std::nullopt;
481
482 if (Subtitles.empty())
483 return std::nullopt;
484
485 long time = long(BASS_ChannelBytes2Seconds(channel, BASS_ChannelGetPosition(channel, BASS_POS_BYTE)) * SOUND_MILLISECONDS_IN_SECOND);
486
487 for (auto* stringPtr : Subtitles)
488 {
489 if (time >= stringPtr->getStartTime() && time <= stringPtr->getEndTime())
490 return stringPtr->getText();
491 }
492
493 return std::nullopt;
494}
495
496void PlaySoundTrack(const std::string& track, SoundTrackType type, std::optional<QWORD> pos, int forceFadeInTime)
497{

Callers 1

Calls 4

getStartTimeMethod · 0.80
getEndTimeMethod · 0.80
getTextMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected