| 423 | } |
| 424 | |
| 425 | void Overlay::SetCaptureState(bool active) |
| 426 | { |
| 427 | pmlog_info(std::format("Capture set to {}", active)); |
| 428 | |
| 429 | using FR = infra::util::FolderResolver; |
| 430 | |
| 431 | if (active && !pWriter) { |
| 432 | std::wstring fullPath; |
| 433 | const std::chrono::zoned_time now{ std::chrono::current_zone(), std::chrono::system_clock::now() }; |
| 434 | if (pSpec->captureFullPathOverride) { |
| 435 | fullPath = std::move(*pSpec->captureFullPathOverride); |
| 436 | } |
| 437 | else { |
| 438 | const auto folder = FR::Get().Resolve(FR::Folder::Documents, FR::capturesSubdirectory); |
| 439 | fullPath = std::format(L"{0}\\{1}-{3}-{2:%y}{2:%m}{2:%d}-{2:%H}{2:%M}{2:%OS}.csv", |
| 440 | folder, pSpec->captureName, now, proc.name); |
| 441 | } |
| 442 | // create optional path for stats file |
| 443 | auto fullStatsPath = [&]() -> std::optional<std::wstring> { |
| 444 | if (pSpec->generateStats) { |
| 445 | const auto folder = FR::Get().Resolve(FR::Folder::Documents, FR::capturesSubdirectory); |
| 446 | return std::format(L"{0}\\{1}-{3}-{2:%y}{2:%m}{2:%d}-{2:%H}{2:%M}{2:%OS}-stats.csv", |
| 447 | folder, pSpec->captureName, now, proc.name); |
| 448 | } |
| 449 | else { |
| 450 | return std::nullopt; |
| 451 | } |
| 452 | }(); |
| 453 | const auto frameAdapterId = (pSpec->frameQueryAdapterId && *pSpec->frameQueryAdapterId > 0) |
| 454 | ? pSpec->frameQueryAdapterId |
| 455 | : std::optional<uint32_t>{}; |
| 456 | pWriter = { pm->MakeRawFrameDataWriter(std::move(fullPath), std::move(fullStatsPath), proc.pid, |
| 457 | frameAdapterId) }; |
| 458 | } |
| 459 | else if (!active && pWriter) { |
| 460 | pWriter.reset(); |
| 461 | } |
| 462 | |
| 463 | // handle window visibility |
| 464 | if (pWindow) { |
| 465 | if (IsHidden_()) { |
| 466 | pWindow->Hide(); |
| 467 | } |
| 468 | else { |
| 469 | pWindow->Show(); |
| 470 | pWindow->Reorder(proc.hWnd); |
| 471 | } |
| 472 | } |
| 473 | |
| 474 | // update indicator on overlay |
| 475 | UpdateCaptureStatusText_(); |
| 476 | } |
| 477 | |
| 478 | bool Overlay::IsTargetLive() const |
| 479 | { |
no test coverage detected