MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / TickPreviewLoop

Method TickPreviewLoop

engine/Poseidon/UI/Options/AudioPage.cpp:323–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323void AudioPage::AudioProvider::TickPreviewLoop()
324{
325 if (!GSoundsys)
326 return;
327 if (m_previewActiveRow < 0)
328 return;
329 uint32_t now = Poseidon::Foundation::GlobalTickCount();
330 uint32_t elapsed = now - m_previewLoopTick;
331 const uint32_t kDwellMs = 250;
332 const uint32_t kLoopGapMs = 5000;
333 // Music is looping internally (Repeat=0 in StartCategoryPreview)
334 // so it doesn't need a 5 s replay — once started it just keeps
335 // playing. Effects + Speech are one-shot and benefit from the
336 // periodic replay so the user doesn't need to re-touch the slider.
337 uint32_t threshold =
338 m_previewStartedThisFocus ? (m_previewActiveRow == kRowMusic ? UINT32_MAX : kLoopGapMs) : kDwellMs;
339 if (elapsed < threshold)
340 return;
341 bool fired = false;
342 switch (m_previewActiveRow)
343 {
344 case kRowMusic:
345 GSoundsys->StartCategoryPreview(WaveMusic);
346 fired = true;
347 break;
348 case kRowEffects:
349 GSoundsys->StartCategoryPreview(WaveEffect);
350 fired = true;
351 break;
352 case kRowSpeech:
353 GSoundsys->StartCategoryPreview(WaveSpeech);
354 fired = true;
355 break;
356 case kRowEax:
357 GSoundsys->StartEAXPreview();
358 fired = true;
359 break;
360 // Output device intentionally NOT auto-started on focus — the
361 // device preview is gated on first value change so opening Audio
362 // doesn't spam audio when the user is just navigating.
363 default:
364 break;
365 }
366 if (fired)
367 {
368 m_previewStartedThisFocus = true;
369 m_previewLoopTick = now;
370 }
371}
372
373void AudioPage::AudioProvider::OnRowAction(int row, Display& host)
374{

Callers 1

OnSimulateMethod · 0.80

Calls 3

GlobalTickCountFunction · 0.85
StartCategoryPreviewMethod · 0.45
StartEAXPreviewMethod · 0.45

Tested by

no test coverage detected