| 2678 | } |
| 2679 | |
| 2680 | void FEditorUI::CreateGameViewportTool() |
| 2681 | { |
| 2682 | // Player 1 runs in the main world-editor viewport; players 2..N each get a Game Preview pop-up. |
| 2683 | // CreateTool defers the actual add (ToolsPendingAdd), so this is safe to call mid-draw. |
| 2684 | if (WorldEditorTool == nullptr) |
| 2685 | { |
| 2686 | return; |
| 2687 | } |
| 2688 | |
| 2689 | CWorld* Source = WorldEditorTool->GetPIESourceWorld(); |
| 2690 | if (Source == nullptr) |
| 2691 | { |
| 2692 | return; |
| 2693 | } |
| 2694 | |
| 2695 | const int32 NumPlayers = WorldEditorTool->GetPIEPlayerCount(); |
| 2696 | for (int32 PlayerIndex = 1; PlayerIndex < NumPlayers; ++PlayerIndex) |
| 2697 | { |
| 2698 | // Each call duplicates the editor source world -> an independent, self-contained PIE world. |
| 2699 | CWorld* PreviewWorld = GWorldManager->StartPIE(Source, EWorldType::Game, WorldEditorTool->ResolvePlayerNetMode(PlayerIndex)); |
| 2700 | if (PreviewWorld == nullptr) |
| 2701 | { |
| 2702 | LOG_WARN("Failed to start PIE world for player {}", PlayerIndex + 1); |
| 2703 | continue; |
| 2704 | } |
| 2705 | |
| 2706 | // The tool owns the world: FEditorTool::Deinitialize calls DestroyWorldContext on teardown. |
| 2707 | // PlayerIndex is the client number (player 1 is the main viewport), so previews are "Client: 1"..N. |
| 2708 | FGamePreviewTool* Tool = CreateTool<FGamePreviewTool>(this, PreviewWorld, PlayerIndex); |
| 2709 | ExtraGamePreviews.push_back(FExtraGamePreview{ PreviewWorld, Tool }); |
| 2710 | } |
| 2711 | } |
| 2712 | |
| 2713 | void FEditorUI::DestroyGameViewportTool() |
| 2714 | { |
| 2715 | // Schedule each preview tool for destruction; the tool tears down its own PIE world on Deinitialize. |
| 2716 | // DestroyTool also erases the matching ExtraGamePreviews entry, so just clear our list here. |
| 2717 | for (const FExtraGamePreview& Preview : ExtraGamePreviews) |
| 2718 | { |
| 2719 | if (Preview.Tool != nullptr) |
| 2720 | { |
| 2721 | ToolsPendingDestroy.push(Preview.Tool); |
| 2722 | } |
| 2723 | } |
| 2724 | ExtraGamePreviews.clear(); |
| 2725 | } |
| 2726 | |
| 2727 | void FEditorUI::HandleUserInput(const FUpdateContext& UpdateContext) |
| 2728 | { |
| 2729 | |
| 2730 | } |
| 2731 | |
| 2732 | void FEditorUI::OpenAssetSearchModal() |
| 2733 | { |
| 2734 | // Snapshotted at open, not re-queried per frame: the list cannot change under the user while a |
| 2735 | // modal is up, and re-walking the registry on every keystroke would be pure waste. |
| 2736 | struct FEntry |
| 2737 | { |
nothing calls this directly
no test coverage detected