ue-mcp 1.4.13 → 1.4.14-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/bridge/bridge-timeouts.js +4 -0
- package/dist/bridge/bridge-timeouts.js.map +1 -1
- package/dist/cli/cli-commands.js +1 -0
- package/dist/cli/cli-commands.js.map +1 -1
- package/dist/cli/doctor.js +2 -1
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/init.js +1 -1
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/projects-cli.d.ts +3 -0
- package/dist/cli/projects-cli.js +72 -0
- package/dist/cli/projects-cli.js.map +1 -0
- package/dist/config/user-state.d.ts +10 -0
- package/dist/config/user-state.js +21 -0
- package/dist/config/user-state.js.map +1 -1
- package/dist/core/env.d.ts +2 -0
- package/dist/core/env.js +2 -0
- package/dist/core/env.js.map +1 -1
- package/dist/core/types.d.ts +27 -0
- package/dist/daemon/daemon.js +44 -5
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/extension-api.d.ts +8 -5
- package/dist/daemon-api.d.ts +2 -1
- package/dist/daemon-api.js +1 -0
- package/dist/daemon-api.js.map +1 -1
- package/dist/dispatch/offline.js +1 -0
- package/dist/dispatch/offline.js.map +1 -1
- package/dist/editor/dialog-guard.d.ts +12 -2
- package/dist/editor/dialog-guard.js +68 -2
- package/dist/editor/dialog-guard.js.map +1 -1
- package/dist/editor/editor-control.js +1 -1
- package/dist/editor/editor-control.js.map +1 -1
- package/dist/flow/write-methods.js +1 -1
- package/dist/flow/write-methods.js.map +1 -1
- package/dist/machine/projects.d.ts +85 -0
- package/dist/machine/projects.js +286 -0
- package/dist/machine/projects.js.map +1 -0
- package/dist/pie/script-events.d.ts +4 -1
- package/dist/pie/script-events.js.map +1 -1
- package/dist/surface/context/instructions.js +20 -0
- package/dist/surface/context/instructions.js.map +1 -1
- package/dist/tool-counts.json +12 -12
- package/dist/tools/asset.js +2 -1
- package/dist/tools/asset.js.map +1 -1
- package/dist/tools/editor.js +1 -1
- package/dist/tools/editor.js.map +1 -1
- package/dist/tools/epic/effects.js +11 -0
- package/dist/tools/epic/effects.js.map +1 -1
- package/dist/tools/epic/fab.generated.d.ts +6 -0
- package/dist/tools/epic/fab.generated.js +67 -0
- package/dist/tools/epic/fab.generated.js.map +1 -0
- package/dist/tools/epic/index.d.ts +2 -0
- package/dist/tools/epic/index.js +2 -0
- package/dist/tools/epic/index.js.map +1 -1
- package/dist/tools/epic/toolset-routes.js +2 -0
- package/dist/tools/epic/toolset-routes.js.map +1 -1
- package/dist/tools/epic.js +4 -4
- package/dist/tools/epic.js.map +1 -1
- package/dist/tools/fab-epic.d.ts +23 -0
- package/dist/tools/fab-epic.js +109 -0
- package/dist/tools/fab-epic.js.map +1 -0
- package/dist/tools/fab.js +27 -18
- package/dist/tools/fab.js.map +1 -1
- package/dist/tools/level.js +9 -2
- package/dist/tools/level.js.map +1 -1
- package/dist/tools/material.js +1 -1
- package/dist/tools/material.js.map +1 -1
- package/dist/tools/pie.js +1 -1
- package/dist/tools/pie.js.map +1 -1
- package/dist/tools/specs/asset.generated.js +92 -3
- package/dist/tools/specs/asset.generated.js.map +1 -1
- package/dist/tools/specs/fab.generated.js +143 -3
- package/dist/tools/specs/fab.generated.js.map +1 -1
- package/dist/tools/specs/level.generated.js +183 -9
- package/dist/tools/specs/level.generated.js.map +1 -1
- package/dist/tools/specs/pie.generated.js +28 -8
- package/dist/tools/specs/pie.generated.js.map +1 -1
- package/dist/tools/specs/widget.generated.js +8 -1
- package/dist/tools/specs/widget.generated.js.map +1 -1
- package/dist/ue-mcp.default.yml +522 -76
- package/package.json +2 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeServer.cpp +26 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.cpp +24 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.h +7 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_Mesh.cpp +483 -10
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Dialog/DialogHandlers.cpp +345 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_AIAssistant.cpp +34 -6
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabDownloads.cpp +766 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabDownloads.h +26 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabHandlers.cpp +159 -55
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabHandlers.h +23 -12
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabLibrary.cpp +306 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabLibrary.h +55 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.cpp +34 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.h +9 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Blockout.cpp +12 -8
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_PerfAudit.cpp +3 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Refresh.cpp +479 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_ReplaceActors.cpp +2 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_WorldPartition.cpp +824 -12
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Material/MaterialHandlers.cpp +95 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers.cpp +13 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/MCPPIETestScript.h +8 -3
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers.cpp +2 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Record.cpp +6 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Replay.cpp +1 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Script.cpp +2 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputRecorder.cpp +52 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputRecorder.h +16 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputReplayer.cpp +65 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputReplayer.h +15 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEReplayInputLock.cpp +146 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEReplayInputLock.h +53 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptRunner.cpp +351 -14
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptRunner.h +55 -6
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptValidation.cpp +8 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIESequenceFormat.cpp +59 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIESequenceFormat.h +15 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEUIPointer.cpp +567 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEUIPointer.h +173 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/SMCPPIEStudioPanel.cpp +41 -6
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers.cpp +92 -32
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabDownloadTests.cpp +140 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabEndToEndTests.cpp +365 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabLibraryTests.cpp +52 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PCGGraphAuthoringTests.cpp +5 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEReplayInputLockTests.cpp +77 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEScriptTests.cpp +256 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEScriptValidationTests.cpp +18 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEUIPointerTests.cpp +246 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/UE_MCP_Bridge.cpp +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/UE_MCP_Bridge.Build.cs +85 -13
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Private/MCPPIEActionTrigger.cpp +48 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Private/MCPPIERemoteControl.cpp +93 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Public/MCPPIEActionTrigger.h +52 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Public/MCPPIERemoteControl.h +54 -0
- package/plugin/ue_mcp_bridge/UE_MCP_Bridge.uplugin +2 -2
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "CoreMinimal.h"
|
|
4
|
+
#include "Framework/Application/IInputProcessor.h"
|
|
5
|
+
#include "Handlers/PIE/PIESequenceFormat.h"
|
|
6
|
+
#include "InputCoreTypes.h"
|
|
7
|
+
#include "UObject/WeakObjectPtrTemplates.h"
|
|
8
|
+
|
|
9
|
+
class UWorld;
|
|
10
|
+
class APlayerController;
|
|
11
|
+
class FSlateApplication;
|
|
12
|
+
struct FPointerEvent;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Cursor and UI (Slate/UMG) pointer input for the PIE recorder and replayer
|
|
16
|
+
* (#1822). Enhanced Input never sees the cursor, so a UMG hover, click or
|
|
17
|
+
* drag-and-drop is invisible to the action sampler. This records the mouse
|
|
18
|
+
* at the Slate layer and plays it back through FSlateApplication, the same
|
|
19
|
+
* path a real mouse takes, so hover, press and drag all happen.
|
|
20
|
+
*
|
|
21
|
+
* Positions are stored relative to the PIE viewport (0..1 on each axis), so a
|
|
22
|
+
* recording stays valid when the viewport is a different size on replay.
|
|
23
|
+
*
|
|
24
|
+
* Timing uses the world's real time (undilated, and still running while the
|
|
25
|
+
* game is paused), because menus are often opened with the game paused and
|
|
26
|
+
* world time would collapse every event in the menu onto one instant.
|
|
27
|
+
*/
|
|
28
|
+
namespace MCPPIE
|
|
29
|
+
{
|
|
30
|
+
enum class EUIPointerEvent : uint8
|
|
31
|
+
{
|
|
32
|
+
Move,
|
|
33
|
+
Down,
|
|
34
|
+
Up,
|
|
35
|
+
DoubleClick,
|
|
36
|
+
Wheel
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
FString UIPointerEventToString(EUIPointerEvent Event);
|
|
40
|
+
bool ParseUIPointerEvent(const FString& Str, EUIPointerEvent& Out);
|
|
41
|
+
|
|
42
|
+
// Modifier bits stored on a ui_input step.
|
|
43
|
+
namespace UIModifier
|
|
44
|
+
{
|
|
45
|
+
constexpr uint8 Shift = 1 << 0;
|
|
46
|
+
constexpr uint8 Control = 1 << 1;
|
|
47
|
+
constexpr uint8 Alt = 1 << 2;
|
|
48
|
+
constexpr uint8 Command = 1 << 3;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
TArray<FString> UIModifiersToStrings(uint8 Bits);
|
|
52
|
+
uint8 UIModifiersFromStrings(const TArray<FString>& Names);
|
|
53
|
+
|
|
54
|
+
// One captured pointer event, before it is turned into a sequence step.
|
|
55
|
+
struct FUIPointerSample
|
|
56
|
+
{
|
|
57
|
+
double RealTime = 0.0; // UWorld::GetRealTimeSeconds() when captured
|
|
58
|
+
uint64 FrameNumber = 0; // GFrameCounter, used to coalesce moves
|
|
59
|
+
EUIPointerEvent Event = EUIPointerEvent::Move;
|
|
60
|
+
FVector2D Position = FVector2D::ZeroVector; // viewport-relative, 0..1
|
|
61
|
+
FString Button; // FKey name for down/up/double_click
|
|
62
|
+
float WheelDelta = 0.f;
|
|
63
|
+
uint8 Modifiers = 0;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// ── Pure helpers (no Slate, unit tested) ─────────────────────────────
|
|
67
|
+
|
|
68
|
+
// Screen-space position to viewport-relative. Returns true when the point
|
|
69
|
+
// is inside the viewport. A zero-sized viewport yields (0,0) and false.
|
|
70
|
+
bool ScreenToViewportRelative(const FVector2D& Screen, const FVector2D& ViewOrigin,
|
|
71
|
+
const FVector2D& ViewSize, FVector2D& OutRelative);
|
|
72
|
+
FVector2D ViewportRelativeToScreen(const FVector2D& Relative, const FVector2D& ViewOrigin,
|
|
73
|
+
const FVector2D& ViewSize);
|
|
74
|
+
|
|
75
|
+
// Append a sample. Consecutive moves in the same frame collapse into the
|
|
76
|
+
// latest one, so a high-rate mouse does not write a step per OS event.
|
|
77
|
+
void AppendUIPointerSample(TArray<FUIPointerSample>& Samples, const FUIPointerSample& Sample);
|
|
78
|
+
|
|
79
|
+
// Turn captured samples into ui_input steps. Delays are measured from
|
|
80
|
+
// BaseRealTime (the real time of the recording's first row); samples
|
|
81
|
+
// before it are dropped.
|
|
82
|
+
void BuildUIPointerSteps(const TArray<FUIPointerSample>& Samples, double BaseRealTime,
|
|
83
|
+
TArray<FStep>& OutSteps);
|
|
84
|
+
|
|
85
|
+
// ── Enhanced Input overlap filter ────────────────────────────────────
|
|
86
|
+
|
|
87
|
+
// True when Enhanced Input maps the key behind this event: Button for a
|
|
88
|
+
// press or double click, any wheel key for the wheel. Moves never match.
|
|
89
|
+
bool IsUIPointerInputMapped(const TSet<FKey>& MappedKeys, EUIPointerEvent Event, const FKey& Button);
|
|
90
|
+
|
|
91
|
+
// A press, double click or wheel that lands on the game viewport itself
|
|
92
|
+
// (no UMG widget under the cursor to take it) on a key Enhanced Input
|
|
93
|
+
// maps already reaches the recording as an action value. Recording it
|
|
94
|
+
// as ui_input too would fire it twice on replay, so it is skipped.
|
|
95
|
+
bool ShouldSkipUIPointerEvent(EUIPointerEvent Event, bool bReachesGameViewport, bool bMappedInEnhancedInput);
|
|
96
|
+
|
|
97
|
+
// ── Capture ──────────────────────────────────────────────────────────
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Slate input pre-processor that watches the mouse during a recording.
|
|
101
|
+
* Never consumes input. Records only while the target player shows its
|
|
102
|
+
* mouse cursor (with the cursor hidden, the mouse is driving gameplay,
|
|
103
|
+
* which Enhanced Input already records) and only inside the PIE
|
|
104
|
+
* viewport, except that a button pressed inside keeps reporting moves
|
|
105
|
+
* and its release until it comes up, so a drag that leaves the viewport
|
|
106
|
+
* is still whole. Presses and wheel that Enhanced Input already handles
|
|
107
|
+
* are skipped (see ShouldSkipUIPointerEvent).
|
|
108
|
+
*/
|
|
109
|
+
class FPIEUIPointerCapture : public IInputProcessor
|
|
110
|
+
{
|
|
111
|
+
public:
|
|
112
|
+
void SetTarget(UWorld* World, APlayerController* PC);
|
|
113
|
+
void Reset();
|
|
114
|
+
const TArray<FUIPointerSample>& GetSamples() const { return Samples; }
|
|
115
|
+
// Presses and wheel left to Enhanced Input this recording.
|
|
116
|
+
int32 GetSkippedForEnhancedInput() const { return SkippedForEnhancedInput; }
|
|
117
|
+
|
|
118
|
+
// Register with / unregister from FSlateApplication. Safe to call
|
|
119
|
+
// when Slate is not initialised (no-op).
|
|
120
|
+
static TSharedPtr<FPIEUIPointerCapture> Start(UWorld* World, APlayerController* PC);
|
|
121
|
+
static void Stop(const TSharedPtr<FPIEUIPointerCapture>& Capture);
|
|
122
|
+
|
|
123
|
+
// IInputProcessor
|
|
124
|
+
virtual void Tick(const float DeltaTime, FSlateApplication& SlateApp, TSharedRef<ICursor> Cursor) override {}
|
|
125
|
+
virtual bool HandleMouseMoveEvent(FSlateApplication& SlateApp, const FPointerEvent& MouseEvent) override;
|
|
126
|
+
virtual bool HandleMouseButtonDownEvent(FSlateApplication& SlateApp, const FPointerEvent& MouseEvent) override;
|
|
127
|
+
virtual bool HandleMouseButtonUpEvent(FSlateApplication& SlateApp, const FPointerEvent& MouseEvent) override;
|
|
128
|
+
virtual bool HandleMouseButtonDoubleClickEvent(FSlateApplication& SlateApp, const FPointerEvent& MouseEvent) override;
|
|
129
|
+
virtual bool HandleMouseWheelOrGestureEvent(FSlateApplication& SlateApp, const FPointerEvent& InWheelEvent, const FPointerEvent* InGestureEvent) override;
|
|
130
|
+
virtual const TCHAR* GetDebugName() const override { return TEXT("UE_MCP_PIEUIPointerCapture"); }
|
|
131
|
+
|
|
132
|
+
private:
|
|
133
|
+
void Record(EUIPointerEvent Event, const FPointerEvent& MouseEvent);
|
|
134
|
+
// Applies ShouldSkipUIPointerEvent to a live press or wheel; logs the decision.
|
|
135
|
+
bool SkipForEnhancedInput(EUIPointerEvent Event, const FKey& Button, const FPointerEvent& MouseEvent);
|
|
136
|
+
|
|
137
|
+
TWeakObjectPtr<UWorld> World;
|
|
138
|
+
TWeakObjectPtr<APlayerController> PlayerController;
|
|
139
|
+
TArray<FUIPointerSample> Samples;
|
|
140
|
+
TSet<FKey> HeldButtons; // pressed inside the viewport, not yet released
|
|
141
|
+
int32 SkippedForEnhancedInput = 0;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// ── Replay ───────────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Plays ui_input steps through FSlateApplication. Keeps the buttons it
|
|
148
|
+
* has pressed so the pointer events carry the right pressed set, and so
|
|
149
|
+
* a replay that stops mid-drag releases them.
|
|
150
|
+
*/
|
|
151
|
+
class FPIEUIPointerPlayer
|
|
152
|
+
{
|
|
153
|
+
public:
|
|
154
|
+
bool Play(const FStep& Step, UWorld* World, FString& OutError);
|
|
155
|
+
// Release every button this player pressed. Call when a replay ends.
|
|
156
|
+
void ReleaseAll(UWorld* World);
|
|
157
|
+
void Reset();
|
|
158
|
+
int32 GetPlayedCount() const { return Played; }
|
|
159
|
+
|
|
160
|
+
// True while a replayed event is being processed, so the capture does
|
|
161
|
+
// not record it again when a recording runs during a replay.
|
|
162
|
+
static bool IsInjecting();
|
|
163
|
+
|
|
164
|
+
private:
|
|
165
|
+
TSet<FKey> Pressed;
|
|
166
|
+
FVector2D LastScreen = FVector2D::ZeroVector;
|
|
167
|
+
bool bHasLast = false;
|
|
168
|
+
int32 Played = 0;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// Absolute (desktop) rectangle of the world's game viewport widget.
|
|
172
|
+
bool GetPIEViewportRect(UWorld* World, FVector2D& OutOrigin, FVector2D& OutSize);
|
|
173
|
+
}
|
package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/SMCPPIEStudioPanel.cpp
CHANGED
|
@@ -71,6 +71,18 @@ static void UnregisterPIEStudioStyle()
|
|
|
71
71
|
|
|
72
72
|
namespace
|
|
73
73
|
{
|
|
74
|
+
// Studio's "Capture Cursor / UI" and "Lock Input During Replay" toggles (#1822). Editor-session only; off by default.
|
|
75
|
+
bool GStudioCaptureUIPointer = false;
|
|
76
|
+
bool GStudioLockInputOnReplay = false;
|
|
77
|
+
|
|
78
|
+
// Arm config for every PIE Studio record button, so they all honour the toggle.
|
|
79
|
+
MCPPIE::FRecorderArmConfig MakeStudioArmConfig()
|
|
80
|
+
{
|
|
81
|
+
MCPPIE::FRecorderArmConfig Cfg;
|
|
82
|
+
Cfg.bCaptureUIPointer = GStudioCaptureUIPointer;
|
|
83
|
+
return Cfg;
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
FString RecorderStateStr(MCPPIE::ERecorderState S)
|
|
75
87
|
{
|
|
76
88
|
switch (S)
|
|
@@ -159,7 +171,7 @@ void SMCPPIEStudioPanel::RegisterToolbarButton()
|
|
|
159
171
|
"Record",
|
|
160
172
|
FExecuteAction::CreateLambda([]()
|
|
161
173
|
{
|
|
162
|
-
MCPPIE::FRecorderArmConfig Cfg;
|
|
174
|
+
MCPPIE::FRecorderArmConfig Cfg = MakeStudioArmConfig();
|
|
163
175
|
FString Err, Msg;
|
|
164
176
|
MCPPIE::FPIEInputRecorder::Get().Arm(Cfg, Err, Msg);
|
|
165
177
|
}),
|
|
@@ -176,7 +188,7 @@ void SMCPPIEStudioPanel::RegisterToolbarButton()
|
|
|
176
188
|
"RecordPlay",
|
|
177
189
|
FExecuteAction::CreateLambda([]()
|
|
178
190
|
{
|
|
179
|
-
MCPPIE::FRecorderArmConfig Cfg;
|
|
191
|
+
MCPPIE::FRecorderArmConfig Cfg = MakeStudioArmConfig();
|
|
180
192
|
FString Err, Msg;
|
|
181
193
|
MCPPIE::FPIEInputRecorder::Get().Arm(Cfg, Err, Msg);
|
|
182
194
|
if (GEditor && !GEditor->PlayWorld)
|
|
@@ -206,7 +218,7 @@ void SMCPPIEStudioPanel::RegisterToolbarButton()
|
|
|
206
218
|
FSlateIcon(FAppStyle::GetAppStyleSetName(), "Icons.Recording"),
|
|
207
219
|
FUIAction(FExecuteAction::CreateLambda([]()
|
|
208
220
|
{
|
|
209
|
-
MCPPIE::FRecorderArmConfig Cfg;
|
|
221
|
+
MCPPIE::FRecorderArmConfig Cfg = MakeStudioArmConfig();
|
|
210
222
|
FString Err, Msg;
|
|
211
223
|
MCPPIE::FPIEInputRecorder::Get().Arm(Cfg, Err, Msg);
|
|
212
224
|
if (GEditor && !GEditor->PlayWorld)
|
|
@@ -222,12 +234,24 @@ void SMCPPIEStudioPanel::RegisterToolbarButton()
|
|
|
222
234
|
FSlateIcon(FAppStyle::GetAppStyleSetName(), "Icons.Recording"),
|
|
223
235
|
FUIAction(FExecuteAction::CreateLambda([]()
|
|
224
236
|
{
|
|
225
|
-
MCPPIE::FRecorderArmConfig Cfg;
|
|
237
|
+
MCPPIE::FRecorderArmConfig Cfg = MakeStudioArmConfig();
|
|
226
238
|
FString Err, Msg;
|
|
227
239
|
MCPPIE::FPIEInputRecorder::Get().Arm(Cfg, Err, Msg);
|
|
228
240
|
}))
|
|
229
241
|
);
|
|
230
242
|
|
|
243
|
+
Menu.AddMenuEntry(
|
|
244
|
+
FText::FromString(TEXT("Capture Cursor / UI")),
|
|
245
|
+
FText::FromString(TEXT("Also record the mouse cursor, UMG hover, clicks, drag and wheel while the cursor is shown (ui_input steps). Applies the next time the recorder is armed.")),
|
|
246
|
+
FSlateIcon(),
|
|
247
|
+
FUIAction(
|
|
248
|
+
FExecuteAction::CreateLambda([]() { GStudioCaptureUIPointer = !GStudioCaptureUIPointer; }),
|
|
249
|
+
FCanExecuteAction(),
|
|
250
|
+
FIsActionChecked::CreateLambda([]() { return GStudioCaptureUIPointer; })),
|
|
251
|
+
NAME_None,
|
|
252
|
+
EUserInterfaceActionType::ToggleButton
|
|
253
|
+
);
|
|
254
|
+
|
|
231
255
|
const auto RecState = MCPPIE::FPIEInputRecorder::Get().GetStatus().State;
|
|
232
256
|
|
|
233
257
|
if (RecState == MCPPIE::ERecorderState::Armed || RecState == MCPPIE::ERecorderState::WaitingForPawn)
|
|
@@ -351,7 +375,7 @@ TSharedRef<SWidget> SMCPPIEStudioPanel::BuildRecorderSection()
|
|
|
351
375
|
.Text(FText::FromString(TEXT("Record + Play")))
|
|
352
376
|
.OnClicked_Lambda([]()
|
|
353
377
|
{
|
|
354
|
-
MCPPIE::FRecorderArmConfig Cfg;
|
|
378
|
+
MCPPIE::FRecorderArmConfig Cfg = MakeStudioArmConfig();
|
|
355
379
|
FString Err, Msg;
|
|
356
380
|
MCPPIE::FPIEInputRecorder::Get().Arm(Cfg, Err, Msg);
|
|
357
381
|
if (GEditor && !GEditor->PlayWorld)
|
|
@@ -367,7 +391,7 @@ TSharedRef<SWidget> SMCPPIEStudioPanel::BuildRecorderSection()
|
|
|
367
391
|
.Text(FText::FromString(TEXT("Arm")))
|
|
368
392
|
.OnClicked_Lambda([]()
|
|
369
393
|
{
|
|
370
|
-
MCPPIE::FRecorderArmConfig Cfg;
|
|
394
|
+
MCPPIE::FRecorderArmConfig Cfg = MakeStudioArmConfig();
|
|
371
395
|
FString Err, Msg;
|
|
372
396
|
MCPPIE::FPIEInputRecorder::Get().Arm(Cfg, Err, Msg);
|
|
373
397
|
return FReply::Handled();
|
|
@@ -394,6 +418,16 @@ TSharedRef<SWidget> SMCPPIEStudioPanel::BuildRecorderSection()
|
|
|
394
418
|
return FReply::Handled();
|
|
395
419
|
})
|
|
396
420
|
]
|
|
421
|
+
+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center).Padding(8, 0, 0, 0)
|
|
422
|
+
[
|
|
423
|
+
SNew(SCheckBox)
|
|
424
|
+
.IsChecked_Lambda([]() { return GStudioLockInputOnReplay ? ECheckBoxState::Checked : ECheckBoxState::Unchecked; })
|
|
425
|
+
.OnCheckStateChanged_Lambda([](ECheckBoxState S) { GStudioLockInputOnReplay = (S == ECheckBoxState::Checked); })
|
|
426
|
+
.ToolTipText(FText::FromString(TEXT("While a Studio replay runs, your keyboard, mouse and gamepad stop reaching the game, so only the recording drives the player. Esc, Shift+F1 and F8 still work.")))
|
|
427
|
+
[
|
|
428
|
+
SNew(STextBlock).Text(FText::FromString(TEXT("Lock Input During Replay")))
|
|
429
|
+
]
|
|
430
|
+
]
|
|
397
431
|
];
|
|
398
432
|
}
|
|
399
433
|
|
|
@@ -705,6 +739,7 @@ void SMCPPIEStudioPanel::RefreshRecordings()
|
|
|
705
739
|
MCPPIE::FReplayerArmConfig Cfg;
|
|
706
740
|
Cfg.SourceRecordingId = Id;
|
|
707
741
|
Cfg.CaptureFrameEvery = bCaptureGifOnReplay ? 2 : 0;
|
|
742
|
+
Cfg.bLockInput = GStudioLockInputOnReplay;
|
|
708
743
|
FString Err, Msg;
|
|
709
744
|
MCPPIE::FPIEInputReplayer::Get().Arm(Cfg, Err, Msg);
|
|
710
745
|
for (const FString& ProfilePath : ActiveProfilePaths)
|
package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers.cpp
CHANGED
|
@@ -443,6 +443,7 @@ void FWidgetHandlers::RegisterHandlers(FMCPHandlerRegistry& Registry)
|
|
|
443
443
|
MCPParam::Required(TEXT("widgetClass"), EType::String, TEXT("Widget class: a short name (TextBlock, CanvasPanel), a full path, or a Widget Blueprint path")).Alias(TEXT("typeName")),
|
|
444
444
|
MCPParam::Optional(TEXT("widgetName"), EType::String, TEXT("Name of a widget inside the tree (#798)")).Alias(TEXT("name")),
|
|
445
445
|
MCPParam::Optional(TEXT("parentWidgetName"), EType::String, TEXT("Name of the parent panel widget (#798)")),
|
|
446
|
+
MCPParam::Optional(TEXT("childIndex"), EType::Integer, TEXT("Sibling index to insert at within the parent panel, 0 to its current child count (default: append). Refused when out of range or when the widget becomes the root (#1440)")),
|
|
446
447
|
});
|
|
447
448
|
Registry.RegisterHandler(TEXT("build_tree"), &BuildTree, {
|
|
448
449
|
AssetPath(),
|
|
@@ -1101,6 +1102,10 @@ TSharedPtr<FJsonValue> FWidgetHandlers::AddWidget(const TSharedPtr<FJsonObject>&
|
|
|
1101
1102
|
|
|
1102
1103
|
FString ParentWidgetName = OptionalString(Params, TEXT("parentWidgetName"));
|
|
1103
1104
|
|
|
1105
|
+
// #1440: an absent childIndex appends; a given one is honoured or refused.
|
|
1106
|
+
const bool bHasChildIndex = HasParam(Params, TEXT("childIndex"));
|
|
1107
|
+
const int32 RequestedChildIndex = OptionalInt(Params, TEXT("childIndex"), INDEX_NONE);
|
|
1108
|
+
|
|
1104
1109
|
// ── Load the WidgetBlueprint ──
|
|
1105
1110
|
TSharedPtr<FJsonValue> ResolveError;
|
|
1106
1111
|
UWidgetBlueprint* WidgetBP = MCPWidget::ResolveWidgetBlueprintOrError(AssetPath, ResolveError);
|
|
@@ -1150,12 +1155,60 @@ TSharedPtr<FJsonValue> FWidgetHandlers::AddWidget(const TSharedPtr<FJsonObject>&
|
|
|
1150
1155
|
if (UPanelWidget* ExistingParent = Existing->GetParent())
|
|
1151
1156
|
{
|
|
1152
1157
|
ExistingResult->SetStringField(TEXT("parentWidgetName"), ExistingParent->GetName());
|
|
1158
|
+
ExistingResult->SetNumberField(TEXT("childIndex"), ExistingParent->GetChildIndex(Existing));
|
|
1153
1159
|
}
|
|
1154
1160
|
ExistingResult->SetBoolField(TEXT("isRoot"), WidgetBP->WidgetTree->RootWidget == Existing);
|
|
1155
1161
|
return MCPResult(ExistingResult);
|
|
1156
1162
|
}
|
|
1157
1163
|
}
|
|
1158
1164
|
|
|
1165
|
+
// ── Resolve the parent panel and validate childIndex before anything is built ──
|
|
1166
|
+
UPanelWidget* TargetPanel = nullptr;
|
|
1167
|
+
if (!ParentWidgetName.IsEmpty())
|
|
1168
|
+
{
|
|
1169
|
+
UWidget* ParentRaw = MCPWidget::FindWidgetByName(WidgetBP->WidgetTree, ParentWidgetName);
|
|
1170
|
+
if (!ParentRaw)
|
|
1171
|
+
{
|
|
1172
|
+
return MCPError(FString::Printf(TEXT("Parent widget '%s' not found"), *ParentWidgetName));
|
|
1173
|
+
}
|
|
1174
|
+
TargetPanel = Cast<UPanelWidget>(ParentRaw);
|
|
1175
|
+
if (!TargetPanel)
|
|
1176
|
+
{
|
|
1177
|
+
return MCPError(FString::Printf(TEXT("Parent widget '%s' (%s) is not a panel widget and cannot have children"), *ParentWidgetName, *ParentRaw->GetClass()->GetName()));
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
else if (WidgetBP->WidgetTree->RootWidget != nullptr)
|
|
1181
|
+
{
|
|
1182
|
+
TargetPanel = Cast<UPanelWidget>(WidgetBP->WidgetTree->RootWidget);
|
|
1183
|
+
if (!TargetPanel)
|
|
1184
|
+
{
|
|
1185
|
+
return MCPError(TEXT("Root widget is not a panel. Specify parentWidgetName or set a panel as root first."));
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
if (bHasChildIndex)
|
|
1190
|
+
{
|
|
1191
|
+
if (!TargetPanel)
|
|
1192
|
+
{
|
|
1193
|
+
return MCPError(FString::Printf(
|
|
1194
|
+
TEXT("childIndex %d cannot be honoured: '%s' has no root, so the new widget becomes the root and has no siblings. ")
|
|
1195
|
+
TEXT("Omit childIndex, or add a panel first and pass it as parentWidgetName."), RequestedChildIndex, *AssetPath));
|
|
1196
|
+
}
|
|
1197
|
+
const int32 SiblingCount = TargetPanel->GetChildrenCount();
|
|
1198
|
+
if (RequestedChildIndex < 0 || RequestedChildIndex > SiblingCount)
|
|
1199
|
+
{
|
|
1200
|
+
return MCPError(FString::Printf(
|
|
1201
|
+
TEXT("childIndex %d is out of range for '%s', which has %d child(ren): pass 0 to %d, or omit it to append. Nothing was added."),
|
|
1202
|
+
RequestedChildIndex, *TargetPanel->GetName(), SiblingCount, SiblingCount));
|
|
1203
|
+
}
|
|
1204
|
+
if (!TargetPanel->CanHaveMultipleChildren() && SiblingCount > 0)
|
|
1205
|
+
{
|
|
1206
|
+
return MCPError(FString::Printf(
|
|
1207
|
+
TEXT("'%s' (%s) holds a single child and already has one, so nothing can be inserted at childIndex %d."),
|
|
1208
|
+
*TargetPanel->GetName(), *TargetPanel->GetClass()->GetName(), RequestedChildIndex));
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1159
1212
|
// ── Construct the widget ──
|
|
1160
1213
|
UWidget* NewWidget = WidgetBP->WidgetTree->ConstructWidget<UWidget>(WClass, WidgetName.IsEmpty() ? NAME_None : FName(*WidgetName));
|
|
1161
1214
|
if (!NewWidget)
|
|
@@ -1167,47 +1220,44 @@ TSharedPtr<FJsonValue> FWidgetHandlers::AddWidget(const TSharedPtr<FJsonObject>&
|
|
|
1167
1220
|
|
|
1168
1221
|
// ── Place in hierarchy ──
|
|
1169
1222
|
bool bIsRoot = false;
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1223
|
+
int32 PlacedChildIndex = INDEX_NONE;
|
|
1224
|
+
if (TargetPanel)
|
|
1225
|
+
{
|
|
1226
|
+
// A refused placement must not leave the new widget owned by the tree,
|
|
1227
|
+
// where the compiler would still generate a variable for it (#728).
|
|
1228
|
+
auto DiscardNewWidget = [&]()
|
|
1229
|
+
{
|
|
1230
|
+
if (NewWidget->GetParent()) NewWidget->GetParent()->RemoveChild(NewWidget);
|
|
1231
|
+
int32 Discarded = 0;
|
|
1232
|
+
MCPWidgetGuidMap::EvictUnreachableWidgets(WidgetBP, Discarded);
|
|
1233
|
+
};
|
|
1234
|
+
UPanelSlot* Slot = TargetPanel->AddChild(NewWidget);
|
|
1235
|
+
if (!Slot)
|
|
1176
1236
|
{
|
|
1177
|
-
|
|
1237
|
+
DiscardNewWidget();
|
|
1238
|
+
return MCPError(FString::Printf(TEXT("Failed to add '%s' as child of '%s'"), *NewWidget->GetName(), *TargetPanel->GetName()));
|
|
1178
1239
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
if (
|
|
1240
|
+
// AddChild appends on every panel class; move it to the requested slot
|
|
1241
|
+
// the same way reorder_child does (#1440).
|
|
1242
|
+
if (bHasChildIndex && TargetPanel->GetChildIndex(NewWidget) != RequestedChildIndex)
|
|
1182
1243
|
{
|
|
1183
|
-
|
|
1244
|
+
TargetPanel->ShiftChild(RequestedChildIndex, NewWidget);
|
|
1184
1245
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
if (!Slot)
|
|
1246
|
+
PlacedChildIndex = TargetPanel->GetChildIndex(NewWidget);
|
|
1247
|
+
if (bHasChildIndex && PlacedChildIndex != RequestedChildIndex)
|
|
1188
1248
|
{
|
|
1189
|
-
|
|
1249
|
+
DiscardNewWidget();
|
|
1250
|
+
return MCPError(FString::Printf(
|
|
1251
|
+
TEXT("'%s' (%s) placed the new widget at index %d instead of childIndex %d, so it was taken back out. Nothing was added."),
|
|
1252
|
+
*TargetPanel->GetName(), *TargetPanel->GetClass()->GetName(), PlacedChildIndex, RequestedChildIndex));
|
|
1190
1253
|
}
|
|
1191
1254
|
}
|
|
1192
|
-
else
|
|
1255
|
+
else
|
|
1193
1256
|
{
|
|
1194
1257
|
// No root yet - make this the root widget
|
|
1195
1258
|
WidgetBP->WidgetTree->RootWidget = NewWidget;
|
|
1196
1259
|
bIsRoot = true;
|
|
1197
1260
|
}
|
|
1198
|
-
else
|
|
1199
|
-
{
|
|
1200
|
-
// Root exists, try to add as child of root if it's a panel
|
|
1201
|
-
UPanelWidget* RootPanel = Cast<UPanelWidget>(WidgetBP->WidgetTree->RootWidget);
|
|
1202
|
-
if (RootPanel)
|
|
1203
|
-
{
|
|
1204
|
-
RootPanel->AddChild(NewWidget);
|
|
1205
|
-
}
|
|
1206
|
-
else
|
|
1207
|
-
{
|
|
1208
|
-
return MCPError(TEXT("Root widget is not a panel. Specify parentWidgetName or set a panel as root first."));
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
1261
|
|
|
1212
1262
|
// ── Save ──
|
|
1213
1263
|
// Read the name back off the widget after the compile, not before: the
|
|
@@ -1257,6 +1307,11 @@ TSharedPtr<FJsonValue> FWidgetHandlers::AddWidget(const TSharedPtr<FJsonObject>&
|
|
|
1257
1307
|
{
|
|
1258
1308
|
Result->SetStringField(TEXT("parentWidgetName"), ParentWidgetName);
|
|
1259
1309
|
}
|
|
1310
|
+
if (TargetPanel)
|
|
1311
|
+
{
|
|
1312
|
+
Result->SetStringField(TEXT("parent"), TargetPanel->GetName());
|
|
1313
|
+
Result->SetNumberField(TEXT("childIndex"), PlacedChildIndex);
|
|
1314
|
+
}
|
|
1260
1315
|
MCPSetWidgetGuidOutcome(Result, GuidSync, AssetPath);
|
|
1261
1316
|
MCPWidgetClassDefaults::Report(Result, RestoredDefaults);
|
|
1262
1317
|
|
|
@@ -1340,6 +1395,7 @@ TSharedPtr<FJsonValue> FWidgetHandlers::RemoveWidget(const TSharedPtr<FJsonObjec
|
|
|
1340
1395
|
const FString RemovedClassPath = FoundWidget->GetClass()->GetPathName();
|
|
1341
1396
|
const UPanelWidget* RemovedParent = FoundWidget->GetParent();
|
|
1342
1397
|
const FString RemovedParentName = RemovedParent ? RemovedParent->GetName() : FString();
|
|
1398
|
+
const int32 RemovedChildIndex = RemovedParent ? RemovedParent->GetChildIndex(FoundWidget) : INDEX_NONE;
|
|
1343
1399
|
const bool bRemovedWasRoot = (WidgetBP->WidgetTree->RootWidget == FoundWidget);
|
|
1344
1400
|
int32 RemovedChildCount = 0;
|
|
1345
1401
|
if (const UPanelWidget* RemovedPanel = Cast<UPanelWidget>(FoundWidget))
|
|
@@ -1404,9 +1460,9 @@ TSharedPtr<FJsonValue> FWidgetHandlers::RemoveWidget(const TSharedPtr<FJsonObjec
|
|
|
1404
1460
|
Result->SetNumberField(TEXT("removedChildCount"), RemovedChildCount);
|
|
1405
1461
|
MCPSetWidgetGuidOutcome(Result, GuidSync, AssetPath);
|
|
1406
1462
|
|
|
1407
|
-
// add_widget puts a widget of the same class back under the same parent
|
|
1408
|
-
// under the same name: the removal evicted the
|
|
1409
|
-
// package, so the name is free again. What it cannot put back is the state
|
|
1463
|
+
// add_widget puts a widget of the same class back under the same parent, at
|
|
1464
|
+
// the same sibling index and under the same name: the removal evicted the
|
|
1465
|
+
// old object into the transient package, so the name is free again. What it cannot put back is the state
|
|
1410
1466
|
// that lived on the removed widget - its property values, its slot layout,
|
|
1411
1467
|
// its bindings and its whole subtree, all of which went with it. An empty
|
|
1412
1468
|
// parentWidgetName means "no parent", which is what add_widget needs to see
|
|
@@ -1418,6 +1474,10 @@ TSharedPtr<FJsonValue> FWidgetHandlers::RemoveWidget(const TSharedPtr<FJsonObjec
|
|
|
1418
1474
|
if (!RemovedParentName.IsEmpty())
|
|
1419
1475
|
{
|
|
1420
1476
|
Payload->SetStringField(TEXT("parentWidgetName"), RemovedParentName);
|
|
1477
|
+
if (RemovedChildIndex != INDEX_NONE)
|
|
1478
|
+
{
|
|
1479
|
+
Payload->SetNumberField(TEXT("childIndex"), RemovedChildIndex);
|
|
1480
|
+
}
|
|
1421
1481
|
}
|
|
1422
1482
|
MCPSetRollback(Result, TEXT("add_widget"), Payload);
|
|
1423
1483
|
Result->SetBoolField(TEXT("rollbackLossy"), true);
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#if WITH_DEV_AUTOMATION_TESTS
|
|
2
|
+
#include "CoreMinimal.h"
|
|
3
|
+
#if ENGINE_MAJOR_VERSION == 5 && ENGINE_MINOR_VERSION >= 8
|
|
4
|
+
|
|
5
|
+
#include "Handlers/Fab/FabDownloads.h"
|
|
6
|
+
#include "Handlers/Fab/FabHandlers.h"
|
|
7
|
+
#include "HandlerRegistry.h"
|
|
8
|
+
#include "BuildPatchSettings.h"
|
|
9
|
+
#include "Interfaces/IBuildPatchServicesModule.h"
|
|
10
|
+
#include "Interfaces/IDirectoryChunker.h"
|
|
11
|
+
#include "HAL/FileManager.h"
|
|
12
|
+
#include "HAL/PlatformTime.h"
|
|
13
|
+
#include "HAL/PlatformProcess.h"
|
|
14
|
+
#include "Misc/ScopeExit.h"
|
|
15
|
+
#include "Misc/AutomationTest.h"
|
|
16
|
+
#include "Misc/FileHelper.h"
|
|
17
|
+
#include "Misc/Paths.h"
|
|
18
|
+
#include "Modules/ModuleManager.h"
|
|
19
|
+
#include "Serialization/JsonReader.h"
|
|
20
|
+
#include "Serialization/JsonSerializer.h"
|
|
21
|
+
|
|
22
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FFabVersionSelectionTest, "UE.MCP.Fab.Download.VersionAndPaths",
|
|
23
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
24
|
+
|
|
25
|
+
bool FFabVersionSelectionTest::RunTest(const FString& Parameters)
|
|
26
|
+
{
|
|
27
|
+
using namespace MCPFab;
|
|
28
|
+
const FString Id = TEXT("01234567-89ab-cdef-0123-456789abcdef");
|
|
29
|
+
const FString Text = TEXT("{\"results\":[{\"title\":\"Fixture\",\"url\":\"https://www.fab.com/listings/") + Id
|
|
30
|
+
+ TEXT("\",\"assetId\":\"asset\",\"assetNamespace\":\"namespace\",\"projectVersions\":[{\"artifactId\":\"fixtureV1\",\"engineVersions\":[\"UE_5.8\"],\"targetPlatforms\":[\"Mac\"]}]}]}");
|
|
31
|
+
TSharedPtr<FJsonObject> Json; FJsonSerializer::Deserialize(TJsonReaderFactory<>::Create(Text), Json);
|
|
32
|
+
FAssetVersion Version; FString Error;
|
|
33
|
+
TestTrue(TEXT("select exact owned engine and platform"), ResolveVersion(Json->GetArrayField(TEXT("results")), Id, TEXT("5.8"), TEXT("Mac"), Version, Error));
|
|
34
|
+
TestEqual(TEXT("artifact selected"), Version.ArtifactId, FString(TEXT("fixtureV1")));
|
|
35
|
+
TestFalse(TEXT("unsupported engine cannot silently pick another version"), ResolveVersion(Json->GetArrayField(TEXT("results")), Id, TEXT("5.7"), TEXT("Mac"), Version, Error));
|
|
36
|
+
TestFalse(TEXT("unsupported platform refused"), ResolveVersion(Json->GetArrayField(TEXT("results")), Id, TEXT("5.8"), TEXT("Windows"), Version, Error));
|
|
37
|
+
TestTrue(TEXT("normal Content path"), SafePackPath(TEXT("Content/Fixture/M_Wall.uasset")));
|
|
38
|
+
for (const FString& Path : {TEXT("../Content/x"), TEXT("Content/../x"), TEXT("/Content/x"), TEXT("Content\\x"), TEXT("Plugins/x.dll"), TEXT("Content//x"), TEXT("Content/x:stream")})
|
|
39
|
+
TestFalse(TEXT("unsafe path rejected: ") + Path, SafePackPath(Path));
|
|
40
|
+
TestEqual(TEXT("signature follows complete chunk path"), ChunkUrl(TEXT("https://cdn.example/pack/fixture.manifest?Signature=a%2Bb&Key=xyz"), TEXT(""), TEXT("ChunksV4/00/chunk.chunk")),
|
|
41
|
+
FString(TEXT("https://cdn.example/pack/ChunksV4/00/chunk.chunk?Signature=a%2Bb&Key=xyz")));
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
namespace MCPFabDownloadTests
|
|
46
|
+
{
|
|
47
|
+
static bool RunNativeTransfer(FAutomationTestBase& Test)
|
|
48
|
+
{
|
|
49
|
+
FMCPHandlerRegistry Registry; FFabHandlers::RegisterHandlers(Registry);
|
|
50
|
+
const FString Suffix = FGuid::NewGuid().ToString(EGuidFormats::Digits);
|
|
51
|
+
const FString Root = FPaths::ConvertRelativePathToFull(FPaths::ProjectSavedDir() / TEXT("UE_MCP/FabTests") / Suffix);
|
|
52
|
+
const FString Relative = TEXT("Content/UEMCP/Fab_") + Suffix + TEXT("/Fixture.ubulk");
|
|
53
|
+
const FString Destination = FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir() / Relative.Mid(8));
|
|
54
|
+
ON_SCOPE_EXIT
|
|
55
|
+
{
|
|
56
|
+
MCPFab::ShutdownDownloads();
|
|
57
|
+
IFileManager::Get().Delete(*Destination);
|
|
58
|
+
IFileManager::Get().DeleteDirectory(*Root, false, true);
|
|
59
|
+
IFileManager::Get().DeleteDirectory(*FPaths::GetPath(Destination), false, true);
|
|
60
|
+
};
|
|
61
|
+
IFileManager::Get().MakeDirectory(*FPaths::GetPath(Root / TEXT("source") / Relative), true);
|
|
62
|
+
IFileManager::Get().MakeDirectory(*(Root / TEXT("cloud")), true);
|
|
63
|
+
TArray<uint8> Bytes; Bytes.SetNumUninitialized(3 * 1024 * 1024);
|
|
64
|
+
uint32 Value = 1729;
|
|
65
|
+
for (uint8& Byte : Bytes) { Value = Value * 1664525 + 1013904223; Byte = Value >> 24; }
|
|
66
|
+
FFileHelper::SaveArrayToFile(Bytes, *(Root / TEXT("source") / Relative));
|
|
67
|
+
// Chunk generation pumps a core ticker and must run in its own process,
|
|
68
|
+
// never recursively inside the editor's bridge ticker.
|
|
69
|
+
FString Tool = FPaths::ConvertRelativePathToFull(FPaths::EngineDir() / TEXT("Binaries") / FPlatformProcess::GetBinariesSubdirectory() / TEXT("BuildPatchTool"));
|
|
70
|
+
#if PLATFORM_WINDOWS
|
|
71
|
+
Tool += TEXT(".exe");
|
|
72
|
+
#endif
|
|
73
|
+
const FString Arguments = FString::Printf(TEXT("-mode=ChunkBuildDirectory -FeatureLevel=Latest -BuildRoot=\"%s\" -CloudDir=\"%s\" -ArtifactId=MCPFabFixture -BuildVersion=1 -AppLaunch=\"\" -AppArgs=\"\" -OutputFilename=fixture.manifest -abslog=\"%s\""),
|
|
74
|
+
*(Root / TEXT("source")), *(Root / TEXT("cloud")), *(Root / TEXT("chunker.log")));
|
|
75
|
+
int32 ExitCode = -1;
|
|
76
|
+
if (!Test.TestTrue(TEXT("native fixture generator ran"), FPlatformProcess::ExecProcess(*Tool, *Arguments, &ExitCode, nullptr, nullptr))) return false;
|
|
77
|
+
if (!Test.TestEqual(TEXT("native fixture generation succeeded"), ExitCode, 0)) return false;
|
|
78
|
+
auto& Bps = FModuleManager::LoadModuleChecked<IBuildPatchServicesModule>(TEXT("BuildPatchServices"));
|
|
79
|
+
auto Manifest = Bps.LoadManifestFromFile(Root / TEXT("cloud/fixture.manifest"));
|
|
80
|
+
if (!Test.TestTrue(TEXT("native manifest parsed"), Manifest.IsValid())) return false;
|
|
81
|
+
FString JobId = MCPFab::StartFixtureDownload(Manifest.ToSharedRef(), Root / TEXT("cloud"), Root / TEXT("output"));
|
|
82
|
+
auto Params = MakeShared<FJsonObject>(); Params->SetStringField(TEXT("jobId"), JobId);
|
|
83
|
+
ON_SCOPE_EXIT { Registry.ExecuteHandler(TEXT("fab_cancel_download"), Params); };
|
|
84
|
+
const auto Paused = Registry.ExecuteHandler(TEXT("fab_pause_download"), Params)->AsObject();
|
|
85
|
+
Test.TestTrue(TEXT("pause active native transfer"), Paused->GetBoolField(TEXT("success")));
|
|
86
|
+
auto Wait = [&](const FString& Target)
|
|
87
|
+
{
|
|
88
|
+
const double Deadline = FPlatformTime::Seconds() + 15.0;
|
|
89
|
+
TSharedPtr<FJsonObject> Job;
|
|
90
|
+
do
|
|
91
|
+
{
|
|
92
|
+
Job = Registry.ExecuteHandler(TEXT("fab_download_status"), Params)->AsObject()->GetObjectField(TEXT("job"));
|
|
93
|
+
const FString State = Job->GetStringField(TEXT("state"));
|
|
94
|
+
if (State == Target || State == TEXT("failed") || State == TEXT("complete")) return Job;
|
|
95
|
+
FPlatformProcess::Sleep(0.001f);
|
|
96
|
+
} while (FPlatformTime::Seconds() < Deadline);
|
|
97
|
+
Test.AddError(TEXT("Native transfer timed out waiting for ") + Target); return Job;
|
|
98
|
+
};
|
|
99
|
+
Test.TestEqual(TEXT("native transfer paused"), Wait(TEXT("paused"))->GetStringField(TEXT("state")), FString(TEXT("paused")));
|
|
100
|
+
Test.TestTrue(TEXT("resume paused transfer"), Registry.ExecuteHandler(TEXT("fab_resume_download"), Params)->AsObject()->GetBoolField(TEXT("success")));
|
|
101
|
+
const auto Status = Wait(TEXT("complete"));
|
|
102
|
+
if (!Test.TestEqual(TEXT("native transfer succeeded"), Status->GetStringField(TEXT("state")), FString(TEXT("complete")))) return false;
|
|
103
|
+
TArray<uint8> Downloaded; FFileHelper::LoadFileToArray(Downloaded, *(Root / TEXT("output") / Relative));
|
|
104
|
+
Test.TestTrue(TEXT("chunk transfer reconstructed exact bytes"), Downloaded == Bytes);
|
|
105
|
+
Test.TestTrue(TEXT("native downloader transferred data"), Status->GetNumberField(TEXT("downloadedBytes")) > 0);
|
|
106
|
+
const auto Installed = Registry.ExecuteHandler(TEXT("fab_install_pack"), Params)->AsObject();
|
|
107
|
+
if (!Test.TestTrue(TEXT("verified pack installs"), Installed->GetBoolField(TEXT("success")))) return false;
|
|
108
|
+
Test.TestEqual(TEXT("one new project file"), Installed->GetIntegerField(TEXT("copiedFiles")), 1);
|
|
109
|
+
const auto Again = Registry.ExecuteHandler(TEXT("fab_install_pack"), Params)->AsObject();
|
|
110
|
+
Test.TestTrue(TEXT("identical installation is unchanged"), Again->GetBoolField(TEXT("unchanged")));
|
|
111
|
+
FFileHelper::SaveStringToFile(TEXT("user edit"), *Destination);
|
|
112
|
+
Test.TestFalse(TEXT("removal preserves modified files"), Registry.ExecuteHandler(TEXT("fab_remove_installation"), Params)->AsObject()->GetBoolField(TEXT("success")));
|
|
113
|
+
Test.TestTrue(TEXT("edited file retained"), IFileManager::Get().FileExists(*Destination));
|
|
114
|
+
FFileHelper::SaveArrayToFile(Bytes, *Destination);
|
|
115
|
+
const auto Removed = Registry.ExecuteHandler(TEXT("fab_remove_installation"), Params)->AsObject();
|
|
116
|
+
Test.TestTrue(TEXT("unchanged owned installation removable"), Removed->GetBoolField(TEXT("success")));
|
|
117
|
+
Test.TestEqual(TEXT("only created file removed"), Removed->GetIntegerField(TEXT("removedFiles")), 1);
|
|
118
|
+
TArray<uint8> Corrupt = Bytes; Corrupt[0] ^= 0x80;
|
|
119
|
+
FFileHelper::SaveArrayToFile(Corrupt, *(Root / TEXT("output") / Relative));
|
|
120
|
+
JobId = MCPFab::StartFixtureDownload(Manifest.ToSharedRef(), Root / TEXT("cloud"), Root / TEXT("output"), true);
|
|
121
|
+
Params->SetStringField(TEXT("jobId"), JobId);
|
|
122
|
+
const auto Verified = Wait(TEXT("failed"));
|
|
123
|
+
Test.TestEqual(TEXT("corruption fails SHA verification"), Verified->GetStringField(TEXT("state")), FString(TEXT("failed")));
|
|
124
|
+
Test.TestEqual(TEXT("verify-only downloads no data"), Verified->GetNumberField(TEXT("downloadedBytes")), 0.0);
|
|
125
|
+
TArray<uint8> AfterVerify; FFileHelper::LoadFileToArray(AfterVerify, *(Root / TEXT("output") / Relative));
|
|
126
|
+
Test.TestTrue(TEXT("verify-only preserves corrupt source bytes"), AfterVerify == Corrupt);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FFabNativeTransferTest, "UE.MCP.Fab.Download.NativeTransferAndInstallation",
|
|
132
|
+
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
133
|
+
|
|
134
|
+
bool FFabNativeTransferTest::RunTest(const FString& Parameters)
|
|
135
|
+
{
|
|
136
|
+
return MCPFabDownloadTests::RunNativeTransfer(*this);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#endif
|
|
140
|
+
#endif
|