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.
Files changed (137) hide show
  1. package/README.md +5 -5
  2. package/dist/bridge/bridge-timeouts.js +4 -0
  3. package/dist/bridge/bridge-timeouts.js.map +1 -1
  4. package/dist/cli/cli-commands.js +1 -0
  5. package/dist/cli/cli-commands.js.map +1 -1
  6. package/dist/cli/doctor.js +2 -1
  7. package/dist/cli/doctor.js.map +1 -1
  8. package/dist/cli/init.js +1 -1
  9. package/dist/cli/init.js.map +1 -1
  10. package/dist/cli/projects-cli.d.ts +3 -0
  11. package/dist/cli/projects-cli.js +72 -0
  12. package/dist/cli/projects-cli.js.map +1 -0
  13. package/dist/config/user-state.d.ts +10 -0
  14. package/dist/config/user-state.js +21 -0
  15. package/dist/config/user-state.js.map +1 -1
  16. package/dist/core/env.d.ts +2 -0
  17. package/dist/core/env.js +2 -0
  18. package/dist/core/env.js.map +1 -1
  19. package/dist/core/types.d.ts +27 -0
  20. package/dist/daemon/daemon.js +44 -5
  21. package/dist/daemon/daemon.js.map +1 -1
  22. package/dist/daemon/extension-api.d.ts +8 -5
  23. package/dist/daemon-api.d.ts +2 -1
  24. package/dist/daemon-api.js +1 -0
  25. package/dist/daemon-api.js.map +1 -1
  26. package/dist/dispatch/offline.js +1 -0
  27. package/dist/dispatch/offline.js.map +1 -1
  28. package/dist/editor/dialog-guard.d.ts +12 -2
  29. package/dist/editor/dialog-guard.js +68 -2
  30. package/dist/editor/dialog-guard.js.map +1 -1
  31. package/dist/editor/editor-control.js +1 -1
  32. package/dist/editor/editor-control.js.map +1 -1
  33. package/dist/flow/write-methods.js +1 -1
  34. package/dist/flow/write-methods.js.map +1 -1
  35. package/dist/machine/projects.d.ts +85 -0
  36. package/dist/machine/projects.js +286 -0
  37. package/dist/machine/projects.js.map +1 -0
  38. package/dist/pie/script-events.d.ts +4 -1
  39. package/dist/pie/script-events.js.map +1 -1
  40. package/dist/surface/context/instructions.js +20 -0
  41. package/dist/surface/context/instructions.js.map +1 -1
  42. package/dist/tool-counts.json +12 -12
  43. package/dist/tools/asset.js +2 -1
  44. package/dist/tools/asset.js.map +1 -1
  45. package/dist/tools/editor.js +1 -1
  46. package/dist/tools/editor.js.map +1 -1
  47. package/dist/tools/epic/effects.js +11 -0
  48. package/dist/tools/epic/effects.js.map +1 -1
  49. package/dist/tools/epic/fab.generated.d.ts +6 -0
  50. package/dist/tools/epic/fab.generated.js +67 -0
  51. package/dist/tools/epic/fab.generated.js.map +1 -0
  52. package/dist/tools/epic/index.d.ts +2 -0
  53. package/dist/tools/epic/index.js +2 -0
  54. package/dist/tools/epic/index.js.map +1 -1
  55. package/dist/tools/epic/toolset-routes.js +2 -0
  56. package/dist/tools/epic/toolset-routes.js.map +1 -1
  57. package/dist/tools/epic.js +4 -4
  58. package/dist/tools/epic.js.map +1 -1
  59. package/dist/tools/fab-epic.d.ts +23 -0
  60. package/dist/tools/fab-epic.js +109 -0
  61. package/dist/tools/fab-epic.js.map +1 -0
  62. package/dist/tools/fab.js +27 -18
  63. package/dist/tools/fab.js.map +1 -1
  64. package/dist/tools/level.js +9 -2
  65. package/dist/tools/level.js.map +1 -1
  66. package/dist/tools/material.js +1 -1
  67. package/dist/tools/material.js.map +1 -1
  68. package/dist/tools/pie.js +1 -1
  69. package/dist/tools/pie.js.map +1 -1
  70. package/dist/tools/specs/asset.generated.js +92 -3
  71. package/dist/tools/specs/asset.generated.js.map +1 -1
  72. package/dist/tools/specs/fab.generated.js +143 -3
  73. package/dist/tools/specs/fab.generated.js.map +1 -1
  74. package/dist/tools/specs/level.generated.js +183 -9
  75. package/dist/tools/specs/level.generated.js.map +1 -1
  76. package/dist/tools/specs/pie.generated.js +28 -8
  77. package/dist/tools/specs/pie.generated.js.map +1 -1
  78. package/dist/tools/specs/widget.generated.js +8 -1
  79. package/dist/tools/specs/widget.generated.js.map +1 -1
  80. package/dist/ue-mcp.default.yml +522 -76
  81. package/package.json +2 -2
  82. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeServer.cpp +26 -0
  83. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.cpp +24 -0
  84. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.h +7 -0
  85. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_Mesh.cpp +483 -10
  86. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Dialog/DialogHandlers.cpp +345 -1
  87. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_AIAssistant.cpp +34 -6
  88. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabDownloads.cpp +766 -0
  89. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabDownloads.h +26 -0
  90. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabHandlers.cpp +159 -55
  91. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabHandlers.h +23 -12
  92. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabLibrary.cpp +306 -0
  93. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Fab/FabLibrary.h +55 -0
  94. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.cpp +34 -2
  95. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.h +9 -0
  96. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Blockout.cpp +12 -8
  97. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_PerfAudit.cpp +3 -1
  98. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Refresh.cpp +479 -0
  99. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_ReplaceActors.cpp +2 -0
  100. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_WorldPartition.cpp +824 -12
  101. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Material/MaterialHandlers.cpp +95 -1
  102. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers.cpp +13 -0
  103. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/MCPPIETestScript.h +8 -3
  104. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers.cpp +2 -0
  105. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Record.cpp +6 -0
  106. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Replay.cpp +1 -0
  107. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEHandlers_Script.cpp +2 -2
  108. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputRecorder.cpp +52 -1
  109. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputRecorder.h +16 -0
  110. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputReplayer.cpp +65 -1
  111. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEInputReplayer.h +15 -0
  112. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEReplayInputLock.cpp +146 -0
  113. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEReplayInputLock.h +53 -0
  114. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptRunner.cpp +351 -14
  115. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptRunner.h +55 -6
  116. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEScriptValidation.cpp +8 -1
  117. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIESequenceFormat.cpp +59 -0
  118. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIESequenceFormat.h +15 -2
  119. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEUIPointer.cpp +567 -0
  120. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/PIEUIPointer.h +173 -0
  121. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PIE/SMCPPIEStudioPanel.cpp +41 -6
  122. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers.cpp +92 -32
  123. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabDownloadTests.cpp +140 -0
  124. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabEndToEndTests.cpp +365 -0
  125. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/FabLibraryTests.cpp +52 -0
  126. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PCGGraphAuthoringTests.cpp +5 -2
  127. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEReplayInputLockTests.cpp +77 -0
  128. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEScriptTests.cpp +256 -0
  129. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEScriptValidationTests.cpp +18 -0
  130. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/PIEUIPointerTests.cpp +246 -0
  131. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/UE_MCP_Bridge.cpp +4 -0
  132. package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/UE_MCP_Bridge.Build.cs +85 -13
  133. package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Private/MCPPIEActionTrigger.cpp +48 -0
  134. package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Private/MCPPIERemoteControl.cpp +93 -0
  135. package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Public/MCPPIEActionTrigger.h +52 -0
  136. package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeRuntime/Public/MCPPIERemoteControl.h +54 -0
  137. package/plugin/ue_mcp_bridge/UE_MCP_Bridge.uplugin +2 -2
@@ -7,6 +7,8 @@
7
7
  #include "Serialization/JsonReader.h"
8
8
  #include "Serialization/JsonSerializer.h"
9
9
  #include "MaterialDomain.h"
10
+ #include "MaterialShared.h"
11
+ #include "UObject/UObjectIterator.h"
10
12
  #include "Materials/Material.h"
11
13
  #include "Materials/MaterialInstance.h"
12
14
  #include "Materials/MaterialInstanceConstant.h"
@@ -3610,6 +3612,53 @@ TSharedPtr<FJsonValue> FMaterialHandlers::SetMaterialStaticSwitch(const TSharedP
3610
3612
  return MCPResult(Result);
3611
3613
  }
3612
3614
 
3615
+ namespace
3616
+ {
3617
+ // #1441: what the renderer will draw for a material and its loaded instances
3618
+ // that compile their own shader maps. A finished resource without a valid
3619
+ // shader map renders as the default material. Read without blocking: a
3620
+ // resource still compiling is reported as such, not waited on.
3621
+ TSharedPtr<FJsonObject> DescribeMaterialShaderState(UMaterial* Material)
3622
+ {
3623
+ TSharedPtr<FJsonObject> State = MakeShared<FJsonObject>();
3624
+ const FMaterialResource* Resource = Material ? Material->GetMaterialResource(GMaxRHIShaderPlatform) : nullptr;
3625
+ const bool bFinished = Resource && Resource->IsCompilationFinished();
3626
+ State->SetBoolField(TEXT("compiling"), Resource && !bFinished);
3627
+ if (bFinished)
3628
+ {
3629
+ State->SetBoolField(TEXT("validShaderMap"), Resource->HasValidGameThreadShaderMap());
3630
+ TArray<TSharedPtr<FJsonValue>> Errors;
3631
+ for (const FString& Error : Resource->GetCompileErrors()) Errors.Add(MakeShared<FJsonValueString>(Error));
3632
+ State->SetArrayField(TEXT("resourceCompileErrors"), Errors);
3633
+ }
3634
+
3635
+ TArray<TSharedPtr<FJsonValue>> Fallbacks;
3636
+ int32 PermutationChildren = 0;
3637
+ int32 ChildrenCompiling = 0;
3638
+ for (TObjectIterator<UMaterialInstance> It; It; ++It)
3639
+ {
3640
+ UMaterialInstance* Instance = *It;
3641
+ if (!Instance || !Instance->bHasStaticPermutationResource || !Instance->IsChildOf(Material)) continue;
3642
+ ++PermutationChildren;
3643
+ const FMaterialResource* ChildResource = Instance->GetMaterialResource(GMaxRHIShaderPlatform);
3644
+ if (!ChildResource) continue;
3645
+ if (!ChildResource->IsCompilationFinished()) { ++ChildrenCompiling; continue; }
3646
+ if (!ChildResource->HasValidGameThreadShaderMap())
3647
+ {
3648
+ Fallbacks.Add(MakeShared<FJsonValueString>(Instance->GetPathName()));
3649
+ }
3650
+ }
3651
+ State->SetNumberField(TEXT("staticPermutationChildren"), PermutationChildren);
3652
+ State->SetNumberField(TEXT("childrenCompiling"), ChildrenCompiling);
3653
+ State->SetArrayField(TEXT("childrenWithoutShaderMap"), Fallbacks);
3654
+ if (!bFinished || ChildrenCompiling > 0)
3655
+ {
3656
+ State->SetStringField(TEXT("note"), TEXT("Shaders were still compiling when this call returned. editor(get_shader_compile_status, waitUntilIdle=true) waits for them."));
3657
+ }
3658
+ return State;
3659
+ }
3660
+ }
3661
+
3613
3662
  TSharedPtr<FJsonValue> FMaterialHandlers::SetExpressionValue(const TSharedPtr<FJsonObject>& Params)
3614
3663
  {
3615
3664
  // Read by the branch the node's class selects, after the graph load. x and y
@@ -3646,6 +3695,7 @@ TSharedPtr<FJsonValue> FMaterialHandlers::SetExpressionValue(const TSharedPtr<FJ
3646
3695
 
3647
3696
  FString ExpressionClass = Expression->GetClass()->GetName();
3648
3697
  bool bValueSet = false;
3698
+ bool bTextureChanged = false;
3649
3699
 
3650
3700
  auto Result = MCPSuccess();
3651
3701
 
@@ -3800,9 +3850,22 @@ TSharedPtr<FJsonValue> FMaterialHandlers::SetExpressionValue(const TSharedPtr<FJ
3800
3850
  {
3801
3851
  RollbackBlockedReason = TEXT("The TextureSample had no texture before this call, and set_expression_value cannot clear one: an empty texturePath is rejected as an unloadable asset.");
3802
3852
  }
3853
+ // #1441: the property-edit path a native texture swap takes. The
3854
+ // node's PostEditChangeProperty re-derives the sampler type and
3855
+ // texture-reference state that a bare field write leaves stale.
3856
+ FProperty* TextureProp = TexSampleExpr->GetClass()->FindPropertyByName(TEXT("Texture"));
3857
+ TexSampleExpr->Modify();
3858
+ TexSampleExpr->PreEditChange(TextureProp);
3803
3859
  TexSampleExpr->Texture = Texture;
3860
+ FPropertyChangedEvent TextureChanged(TextureProp, EPropertyChangeType::ValueSet);
3861
+ TexSampleExpr->PostEditChangeProperty(TextureChanged);
3804
3862
  bValueSet = true;
3863
+ bTextureChanged = true;
3805
3864
  Result->SetStringField(TEXT("texturePath"), Texture->GetPathName());
3865
+ if (const UEnum* SamplerEnum = StaticEnum<EMaterialSamplerType>())
3866
+ {
3867
+ Result->SetStringField(TEXT("samplerType"), SamplerEnum->GetNameStringByValue(static_cast<int64>(TexSampleExpr->SamplerType.GetValue())));
3868
+ }
3806
3869
  }
3807
3870
  else
3808
3871
  {
@@ -3906,7 +3969,18 @@ TSharedPtr<FJsonValue> FMaterialHandlers::SetExpressionValue(const TSharedPtr<FJ
3906
3969
  FString PreviousValueText;
3907
3970
  Prop->ExportText_Direct(PreviousValueText, ValuePtr, ValuePtr, Expression, PPF_None);
3908
3971
 
3972
+ // Wrapped in the node's own edit notifications, as a details-panel
3973
+ // edit is, so nodes that derive state from a property (a texture
3974
+ // node's sampler type, a Noise node's outputs) rebuild it.
3975
+ Expression->Modify();
3976
+ Expression->PreEditChange(Prop);
3909
3977
  const TCHAR* ImportResult = Prop->ImportText_Direct(*ValueStr, ValuePtr, Expression, PPF_None);
3978
+ FPropertyChangedEvent PropertyChanged(Prop, EPropertyChangeType::ValueSet);
3979
+ Expression->PostEditChangeProperty(PropertyChanged);
3980
+ if (ImportResult && CastField<FObjectPropertyBase>(Prop) && Cast<UTexture>(CastField<FObjectPropertyBase>(Prop)->GetObjectPropertyValue(ValuePtr)))
3981
+ {
3982
+ bTextureChanged = true;
3983
+ }
3910
3984
  if (ImportResult)
3911
3985
  {
3912
3986
  bValueSet = true;
@@ -3959,7 +4033,27 @@ TSharedPtr<FJsonValue> FMaterialHandlers::SetExpressionValue(const TSharedPtr<FJ
3959
4033
  return MCPError(FString::Printf(TEXT("Could not set value on expression of type '%s'. For known types provide standard value params; for arbitrary expressions pass 'propertyName' + 'value'."), *ExpressionClass));
3960
4034
  }
3961
4035
 
3962
- Target.PostEdit();
4036
+ // #1441: a texture write recompiles through the editor's RecompileMaterial,
4037
+ // which also re-caches child instances with static permutations. It balances
4038
+ // the PreEditChange taken above.
4039
+ if (bTextureChanged && Target.Material)
4040
+ {
4041
+ #if UE_MCP_HAS_5_8_API
4042
+ const TArray<FString> CompileErrors = UMaterialEditingLibrary::RecompileMaterial(Target.Material);
4043
+ TArray<TSharedPtr<FJsonValue>> ErrorValues;
4044
+ for (const FString& Error : CompileErrors) ErrorValues.Add(MakeShared<FJsonValueString>(Error));
4045
+ Result->SetArrayField(TEXT("compileErrors"), ErrorValues);
4046
+ #else
4047
+ UMaterialEditingLibrary::RecompileMaterial(Target.Material);
4048
+ Result->SetStringField(TEXT("compileErrorsNote"),
4049
+ TEXT("compileErrors is not reported on this engine: UMaterialEditingLibrary::RecompileMaterial returns void before UE 5.8. Read the editor log for its errors."));
4050
+ #endif
4051
+ Result->SetObjectField(TEXT("shaderState"), DescribeMaterialShaderState(Target.Material));
4052
+ }
4053
+ else
4054
+ {
4055
+ Target.PostEdit();
4056
+ }
3963
4057
 
3964
4058
  // #979: the value was written in memory and the package only marked dirty,
3965
4059
  // so a caller who then asked something else to save it could be told the
@@ -3346,12 +3346,25 @@ TSharedPtr<FJsonValue> FPCGHandlers::ImportGraph(const TSharedPtr<FJsonObject>&
3346
3346
 
3347
3347
  SrcNode->Modify();
3348
3348
  DstNode->Modify();
3349
+ #if UE_MCP_HAS_5_9_API
3350
+ // 5.9's TryAddEdge says why an edge is refused, as pcg(connect_nodes) reports it (#1828).
3351
+ FText RefusedBecause;
3352
+ const EPCGGraphConnectionResult Added = Graph->TryAddEdge(SrcNode, SrcPinName, DstNode, DstPinName, RefusedBecause);
3353
+ if (Added != EPCGGraphConnectionResult::Success)
3354
+ {
3355
+ ++ImportFailures;
3356
+ Warnings.Add(MakeShared<FJsonValueString>(FString::Printf(TEXT("connection %s.%s -> %s.%s: %s (%s)"), *From, *SrcPinName.ToString(), *To, *DstPinName.ToString(),
3357
+ *StaticEnum<EPCGGraphConnectionResult>()->GetNameStringByValue(static_cast<int64>(Added)), *RefusedBecause.ToString())));
3358
+ continue;
3359
+ }
3360
+ #else
3349
3361
  if (!Graph->AddEdge(SrcNode, SrcPinName, DstNode, DstPinName))
3350
3362
  {
3351
3363
  ++ImportFailures;
3352
3364
  Warnings.Add(MakeShared<FJsonValueString>(FString::Printf(TEXT("connection %s.%s -> %s.%s: AddEdge failed (incompatible or duplicate?)"), *From, *SrcPinName.ToString(), *To, *DstPinName.ToString())));
3353
3365
  continue;
3354
3366
  }
3367
+ #endif
3355
3368
  // #304: verify the UPCGEdge object was actually instantiated. Some
3356
3369
  // pin/label combinations return success from AddEdge while leaving
3357
3370
  // no edge in either pin's Edges array; those phantom connections
@@ -20,7 +20,8 @@ enum class EMCPPIEExpectOp : uint8
20
20
  Gt UMETA(DisplayName="Greater Than", ToolTip="Value is greater than Target."),
21
21
  Lt UMETA(DisplayName="Less Than", ToolTip="Value is less than Target."),
22
22
  Visible UMETA(ToolTip="Widget is on screen. Target 0 means not visible."),
23
- Exists UMETA(ToolTip="Actor resolves in the PIE world. Target 0 means gone.")
23
+ Exists UMETA(ToolTip="Actor resolves in the PIE world. Target 0 means gone."),
24
+ Triggered UMETA(ToolTip="The person playing fires the Input Action named by Value on player Client, after the step's act ends. WithinMs 0 waits with no timeout.")
24
25
  };
25
26
 
26
27
  USTRUCT(BlueprintType)
@@ -29,7 +30,7 @@ struct FMCPPIEStepExpect
29
30
  GENERATED_BODY()
30
31
 
31
32
  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Expect",
32
- meta=(ToolTip="Tracked value path (or its last segment), actor id for Exists, widget class or name for Visible."))
33
+ meta=(ToolTip="Tracked value path (or its last segment), actor id for Exists, widget class or name for Visible, Input Action object path for Triggered."))
33
34
  FString Value;
34
35
 
35
36
  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Expect",
@@ -45,8 +46,12 @@ struct FMCPPIEStepExpect
45
46
  double Target = 0.0;
46
47
 
47
48
  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Expect",
48
- meta=(ClampMin="0", ToolTip="Milliseconds of game time the condition has to hold within. 0 uses the script default."))
49
+ meta=(ClampMin="0", ToolTip="Milliseconds of game time the condition has to hold within. 0 uses the script default, except on Triggered, where 0 waits with no timeout."))
49
50
  int32 WithinMs = 0;
51
+
52
+ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Expect",
53
+ meta=(ClampMin="0", EditCondition="Op == EMCPPIEExpectOp::Triggered", ToolTip="Triggered only: the player whose input is watched. 0 is the editor's own player, 1..N a remote player in join order, as act's client."))
54
+ int32 Client = 0;
50
55
  };
51
56
 
52
57
  USTRUCT(BlueprintType)
@@ -275,6 +275,7 @@ void FPIEHandlers::RegisterHandlers(FMCPHandlerRegistry& Registry)
275
275
  MCPParam::Optional(TEXT("pie_instance"), EType::Integer, PieInstanceDoc).Min(0),
276
276
  MCPParam::Optional(TEXT("rng_seed"), EType::Number, TEXT("Seed the stream RNG for reproducible runs")),
277
277
  MCPParam::Optional(TEXT("run_gap_frames"), EType::Integer, TEXT("Idle frames that split input runs (default 6)")),
278
+ MCPParam::Optional(TEXT("capture_ui_pointer"), EType::Boolean, TEXT("Also record the mouse through Slate (cursor, UMG hover, click, drag, wheel) while the cursor is shown, as ui_input steps (default false)")),
278
279
  MCPParam::Optional(TEXT("recording_dir"), EType::String, TEXT("Recordings root (default Saved/MCPRecordings)")),
279
280
  MCPParam::Optional(TEXT("id"), EType::String, TEXT("Recording id (default: a timestamp)")),
280
281
  }, MCPSpec::ContractExempt(TEXT("Arms the recorder, which starts on the next PIE session")));
@@ -319,6 +320,7 @@ void FPIEHandlers::RegisterHandlers(FMCPHandlerRegistry& Registry)
319
320
  MCPParam::Optional(TEXT("record_drift"), EType::Boolean, TEXT("Record drift against the source (default true)")),
320
321
  MCPParam::Optional(TEXT("auto_stop_pie"), EType::Boolean, TEXT("End PIE when the replay completes (replay_arm default false, replay_run default true)")),
321
322
  MCPParam::Optional(TEXT("eject"), EType::Boolean, TEXT("Eject to a spectator camera during replay")),
323
+ MCPParam::Optional(TEXT("lock_input"), EType::Boolean, TEXT("Block the user's keyboard, mouse and gamepad from the PIE game while the replay runs, so only the recording drives the player; Esc, Shift+F1 and F8 still work, and monitor mode ignores it (default false)")),
322
324
  MCPParam::Optional(TEXT("time_scale"), EType::Number, TEXT("Playback speed multiplier (default 1)")),
323
325
  MCPParam::Optional(TEXT("mode"), EType::String, TEXT("replay drives input; monitor only samples (default replay)")).Enum({ TEXT("replay"), TEXT("monitor") }),
324
326
  MCPParam::Optional(TEXT("capture_frame_every"), EType::Integer, TEXT("Capture a viewport JPEG every N steps and build a contact sheet")).Min(0),
@@ -45,6 +45,10 @@ namespace
45
45
  R->SetNumberField(TEXT("elapsed_seconds"), S.ElapsedSeconds);
46
46
  R->SetNumberField(TEXT("tracked_action_count"), S.TrackedActionCount);
47
47
  R->SetBoolField(TEXT("pie_active"), S.bPIEActive);
48
+ if (S.bCaptureUIPointer)
49
+ {
50
+ R->SetNumberField(TEXT("ui_pointer_events"), S.UIPointerEvents);
51
+ }
48
52
  if (S.PIEInstance != INDEX_NONE)
49
53
  {
50
54
  R->SetNumberField(TEXT("pie_instance"), S.PIEInstance);
@@ -71,6 +75,7 @@ namespace
71
75
  R->SetStringField(TEXT("sequence_path"), F.SequencePath);
72
76
  R->SetNumberField(TEXT("total_frames"), F.TotalFrames);
73
77
  R->SetNumberField(TEXT("duration_seconds"), F.DurationSeconds);
78
+ R->SetNumberField(TEXT("ui_pointer_steps"), F.UIPointerSteps);
74
79
  if (F.bTakeRecordAttempted)
75
80
  {
76
81
  R->SetStringField(TEXT("take_recorder_status"), F.TakeRecorderStatus);
@@ -152,6 +157,7 @@ TSharedPtr<FJsonValue> FPIEHandlers::PieRecordArm(const TSharedPtr<FJsonObject>&
152
157
  if (TryGetBoolParam(Params, TEXT("capture_pawn_state"), BV)) Cfg.bCapturePawnState = BV;
153
158
  if (TryGetBoolParam(Params, TEXT("capture_montage"), BV)) Cfg.bCaptureMontage = BV;
154
159
  if (TryGetBoolParam(Params, TEXT("take_record"), BV)) Cfg.bTakeRecord = BV;
160
+ if (TryGetBoolParam(Params, TEXT("capture_ui_pointer"), BV)) Cfg.bCaptureUIPointer = BV;
155
161
 
156
162
  int32 ClientId = 0;
157
163
  if (TryGetNumberParam(Params, TEXT("client_id"), ClientId))
@@ -167,6 +167,7 @@ namespace
167
167
  Cfg.bEncodeGif = OptionalBool(Params, TEXT("encode_gif"), false);
168
168
  Cfg.bFixedTimestep = OptionalBool(Params, TEXT("fixed_timestep"), false);
169
169
  Cfg.bEject = OptionalBool(Params, TEXT("eject"), false);
170
+ Cfg.bLockInput = OptionalBool(Params, TEXT("lock_input"), false);
170
171
  Cfg.TimeScale = static_cast<float>(OptionalNumber(Params, TEXT("time_scale"), 1.0));
171
172
  const FString Mode = OptionalString(Params, TEXT("mode"), TEXT("replay")).ToLower();
172
173
  Cfg.bMonitor = (Mode == TEXT("monitor"));
@@ -281,9 +281,9 @@ void FPIEHandlers::RegisterScriptHandlers(FMCPHandlerRegistry& Registry)
281
281
  const TCHAR* const PieInstanceDoc = TEXT("FWorldContext PIEInstance to observe (default the active PIE world)");
282
282
  const TCHAR* const ClientIdDoc = TEXT("Local-player index inside the selected PIE world (default 0)");
283
283
 
284
- // One step: {instruction, judge auto|manual, agent_judgeable, resolve_in_pie, arrange, act, expect {value, op, target, within_ms}}.
284
+ // One step: {instruction, judge auto|manual, agent_judgeable, resolve_in_pie, arrange, act, expect {value, op, target, within_ms, client}}.
285
285
  // The shape is validated in the handler, so the replay actions' inline steps and these share one key type.
286
- const TCHAR* const StepsShape = TEXT("{instruction, judge: auto|manual (default auto), agent_judgeable (manual steps: false means only a person gives the verdict, default true), resolve_in_pie (true: expect.value and the actors arrange and act name only resolve once PIE runs, so script_create and script_update do not check them), arrange: [{kind: spawn, class, at?, rotation?, scale?} | {kind: set, target, path, value} | {kind: call, target, func, args?}] (run when the step starts), act: [{client?, place: {at, offset?, face?} | {location, yaw?}} | {client?, press: {action, frames?}} | {client?, inject: {action, value}} | {client?, hold: {action, value, ms}} | {client?, tape: {action, values, hz?}} | {client?, console} | {client?, capture} | {wait_ms}] (run after arrange, as uat_run runs a step's do; within_ms counts from its end), expect: {value (tracked value path or last segment, actor id for exists, widget for visible), op: decreasing|increasing|eq|gt|lt|visible|exists, target (number for eq/gt/lt, boolean for visible/exists, default true, optional least change for decreasing/increasing), within_ms}}");
286
+ const TCHAR* const StepsShape = TEXT("{instruction, judge: auto|manual (default auto), agent_judgeable (manual steps: false means only a person gives the verdict, default true), resolve_in_pie (true: expect.value and the actors arrange and act name only resolve once PIE runs, so script_create and script_update do not check them), arrange: [{kind: spawn, class, at?, rotation?, scale?} | {kind: set, target, path, value} | {kind: call, target, func, args?}] (run when the step starts), act: [{client?, place: {at, offset?, face?} | {location, yaw?}} | {client?, press: {action, frames?}} | {client?, inject: {action, value}} | {client?, hold: {action, value, ms}} | {client?, tape: {action, values, hz?}} | {client?, console} | {client?, capture} | {wait_ms}] (run after arrange, as uat_run runs a step's do; within_ms counts from its end), expect: {value (tracked value path or last segment, actor id for exists, widget for visible, Input Action asset path for triggered), op: decreasing|increasing|eq|gt|lt|visible|exists|triggered, target (number for eq/gt/lt, boolean for visible/exists, default true, optional least change for decreasing/increasing; none for triggered), within_ms (triggered: 0 or absent waits with no timeout), client (triggered only: the player whose input is watched, 0 the editor's own player (default), 1..N a remote player, as act counts them)}}. triggered passes on the first fresh trigger of the action after act ends (input still held when the window opens does not count) and records triggered_at_ms and action_value as evidence");
287
287
  const TCHAR* const MapDoc = TEXT("Level the script plays in, as a package or object path such as /Game/Maps/L_Arena. A run opens it before PIE and refuses when the open level has unsaved changes; empty plays whatever level is open");
288
288
  const TCHAR* const ManualOnlyDoc = TEXT("Every step is judged by a verdict: allows a script with no auto step that has an expect (default false)");
289
289
 
@@ -6,6 +6,7 @@
6
6
  #include "Engine/World.h"
7
7
  #include "EngineUtils.h"
8
8
  #include "GameFramework/Actor.h"
9
+ #include "GameFramework/PlayerController.h"
9
10
  #include "HAL/FileManager.h"
10
11
  #include "HAL/PlatformFileManager.h"
11
12
  #include "HAL/PlatformTime.h"
@@ -85,9 +86,12 @@ namespace MCPPIE
85
86
  OnEndFrameHandle.Reset();
86
87
  bEndFrameBound = false;
87
88
  FPSPin.Restore();
89
+ StopUICapture();
90
+ UICapture.Reset();
88
91
  State = ERecorderState::Idle;
89
92
  bArmed = false;
90
93
  TargetWorld.Reset();
94
+ TargetPlayerController.Reset();
91
95
  ResolvedPIEInstance = INDEX_NONE;
92
96
  bTargetResolved = false;
93
97
  TargetResolveStartSeconds = 0.0;
@@ -149,6 +153,10 @@ namespace MCPPIE
149
153
  if (!bArmed) return;
150
154
  bArmed = false;
151
155
  TargetWorld.Reset();
156
+ TargetPlayerController.Reset();
157
+ StopUICapture();
158
+ UICapture.Reset();
159
+ FirstRowRealTime = -1.0;
152
160
  ResolvedPIEInstance = INDEX_NONE;
153
161
  bTargetResolved = false;
154
162
  TargetResolveStartSeconds = FPlatformTime::Seconds();
@@ -201,6 +209,16 @@ namespace MCPPIE
201
209
  }
202
210
  }
203
211
 
212
+ void FPIEInputRecorder::StopUICapture()
213
+ {
214
+ // Unregisters from Slate but keeps the samples, which the sequence
215
+ // is built from after the recording stops.
216
+ if (UICapture.IsValid())
217
+ {
218
+ FPIEUIPointerCapture::Stop(UICapture);
219
+ }
220
+ }
221
+
204
222
  void FPIEInputRecorder::OnEndFrame()
205
223
  {
206
224
  if (State == ERecorderState::Idle) return;
@@ -221,6 +239,7 @@ namespace MCPPIE
221
239
  return;
222
240
  }
223
241
  TargetWorld = Target.World;
242
+ TargetPlayerController = Target.PlayerController;
224
243
  ResolvedPIEInstance = Target.PIEInstance;
225
244
  bTargetResolved = true;
226
245
  TargetResolveError.Reset();
@@ -246,6 +265,13 @@ namespace MCPPIE
246
265
  CSVHeader = BuildCSVHeader(CSVHdr);
247
266
  CSVBody.Reset();
248
267
 
268
+ if (Pending.bCaptureUIPointer)
269
+ {
270
+ UICapture = FPIEUIPointerCapture::Start(PIEWorld, TargetPlayerController.Get());
271
+ UE_LOG(LogMCPPIE, Log, TEXT("[PIE-REC] ui pointer capture %s"),
272
+ UICapture.IsValid() ? TEXT("on") : TEXT("unavailable (Slate not initialised)"));
273
+ }
274
+
249
275
  State = ERecorderState::Recording;
250
276
  }
251
277
  return;
@@ -256,6 +282,10 @@ namespace MCPPIE
256
282
  const double GameTime = PIEWorld->GetTimeSeconds();
257
283
  const double Dt = PIEWorld->GetDeltaSeconds();
258
284
  const uint64 FrameNum = static_cast<uint64>(Rows.Num());
285
+ if (FrameNum == 0)
286
+ {
287
+ FirstRowRealTime = PIEWorld->GetRealTimeSeconds();
288
+ }
259
289
  FCSVRow Row = Sampler.SampleFrame(PIEWorld, FrameNum, GameTime, Dt);
260
290
 
261
291
  // Lift mark:* edge events into the manifest markers list.
@@ -422,7 +452,15 @@ namespace MCPPIE
422
452
  Out.Steps.Add(S);
423
453
  }
424
454
 
425
- Out.Steps.Sort([](const FStep& A, const FStep& B) { return A.DelayMs < B.DelayMs; });
455
+ // Cursor / UMG pointer events, on the real-time clock from the first row.
456
+ if (UICapture.IsValid() && FirstRowRealTime >= 0.0)
457
+ {
458
+ BuildUIPointerSteps(UICapture->GetSamples(), FirstRowRealTime, Out.Steps);
459
+ }
460
+
461
+ // Stable: a press and its release, or a move and the click after it,
462
+ // can land on the same millisecond and must keep their order.
463
+ Out.Steps.StableSort([](const FStep& A, const FStep& B) { return A.DelayMs < B.DelayMs; });
426
464
  }
427
465
 
428
466
  FRecorderFinishResult FPIEInputRecorder::FinaliseCurrent()
@@ -435,6 +473,7 @@ namespace MCPPIE
435
473
  }
436
474
  const bool bHadData = Rows.Num() > 0 && Sampler.IsAttached();
437
475
  FPSPin.Restore();
476
+ StopUICapture();
438
477
  R.Id = CurrentId;
439
478
  R.RecordingDir = CurrentDir;
440
479
 
@@ -480,6 +519,9 @@ namespace MCPPIE
480
519
  TrackedActorCache.Reset();
481
520
  Markers.Reset();
482
521
  TargetWorld.Reset();
522
+ TargetPlayerController.Reset();
523
+ UICapture.Reset();
524
+ FirstRowRealTime = -1.0;
483
525
  ResolvedPIEInstance = INDEX_NONE;
484
526
  bTargetResolved = false;
485
527
  TargetResolveStartSeconds = 0.0;
@@ -505,6 +547,10 @@ namespace MCPPIE
505
547
 
506
548
  FSequence Seq;
507
549
  BuildSequenceSteps(Seq);
550
+ for (const FStep& Step : Seq.Steps)
551
+ {
552
+ if (Step.Type == EStepType::UIInput) ++R.UIPointerSteps;
553
+ }
508
554
  if (!SaveSequence(SeqPath, Seq, WriteErr))
509
555
  {
510
556
  R.Error = WriteErr;
@@ -599,6 +645,9 @@ namespace MCPPIE
599
645
  TrackedActorCache.Reset();
600
646
  Markers.Reset();
601
647
  TargetWorld.Reset();
648
+ TargetPlayerController.Reset();
649
+ UICapture.Reset();
650
+ FirstRowRealTime = -1.0;
602
651
  ResolvedPIEInstance = INDEX_NONE;
603
652
  bTargetResolved = false;
604
653
  TargetResolveStartSeconds = 0.0;
@@ -623,6 +672,8 @@ namespace MCPPIE
623
672
  S.LastError = LastError;
624
673
  S.Warnings = Sampler.GetWarnings();
625
674
  S.PIEInstance = ResolvedPIEInstance;
675
+ S.bCaptureUIPointer = State != ERecorderState::Idle && Pending.bCaptureUIPointer;
676
+ S.UIPointerEvents = UICapture.IsValid() ? UICapture->GetSamples().Num() : 0;
626
677
  if (State == ERecorderState::WaitingForPawn)
627
678
  {
628
679
  S.WaitingFor = !bTargetResolved
@@ -4,10 +4,12 @@
4
4
  #include "Handlers/PIE/PIEFrameSampler.h"
5
5
  #include "Handlers/PIE/PIESequenceFormat.h"
6
6
  #include "Handlers/PIE/PIEMaxFPSPin.h"
7
+ #include "Handlers/PIE/PIEUIPointer.h"
7
8
  #include "UObject/WeakObjectPtrTemplates.h"
8
9
 
9
10
  class UWorld;
10
11
  class AActor;
12
+ class APlayerController;
11
13
 
12
14
  /**
13
15
  * PIE input recorder: opt-in arm-then-record. Module-owned singleton, hooked
@@ -65,6 +67,11 @@ namespace MCPPIE
65
67
  int64 RngSeed = 0; // 0 = auto-generate
66
68
  bool bUserSuppliedSeed = false;
67
69
  int32 RunGapFrames = 6; // sequence run-extraction gap tolerance
70
+ // Also record the mouse at the Slate layer (cursor moves, UMG hover,
71
+ // clicks, drag-and-drop, wheel) as ui_input steps while the player
72
+ // shows its cursor (#1822). Off by default: a click that is also
73
+ // bound to an Enhanced Input action would replay twice.
74
+ bool bCaptureUIPointer = false;
68
75
  };
69
76
 
70
77
  struct FRecorderStatus
@@ -83,6 +90,8 @@ namespace MCPPIE
83
90
  FString WaitingFor;
84
91
  int32 PIEInstance = INDEX_NONE;
85
92
  bool bPIEActive = false;
93
+ bool bCaptureUIPointer = false;
94
+ int32 UIPointerEvents = 0;
86
95
  };
87
96
 
88
97
  struct FRecorderFinishResult
@@ -101,6 +110,8 @@ namespace MCPPIE
101
110
  bool bTakeRecordAttempted = false;
102
111
  FString TakeRecorderStatus;
103
112
  TArray<FString> Warnings;
113
+ // ui_input steps written to sequence.json (0 when not captured).
114
+ int32 UIPointerSteps = 0;
104
115
  };
105
116
 
106
117
  class FPIEInputRecorder
@@ -138,6 +149,7 @@ namespace MCPPIE
138
149
 
139
150
  FRecorderFinishResult FinaliseCurrent();
140
151
  void ApplyFPSPin(UWorld* PIEWorld);
152
+ void StopUICapture();
141
153
 
142
154
  // Run-extraction encoder: builds sequence.json steps from the row buffer.
143
155
  void BuildSequenceSteps(FSequence& OutSequence) const;
@@ -148,6 +160,10 @@ namespace MCPPIE
148
160
  FPIEFrameSampler Sampler;
149
161
  FPIEMaxFPSPin FPSPin;
150
162
  TWeakObjectPtr<UWorld> TargetWorld;
163
+ TWeakObjectPtr<APlayerController> TargetPlayerController;
164
+ TSharedPtr<FPIEUIPointerCapture> UICapture;
165
+ // Real time of the first row, the zero point of ui_input delays.
166
+ double FirstRowRealTime = -1.0;
151
167
  int32 ResolvedPIEInstance = INDEX_NONE;
152
168
  bool bTargetResolved = false;
153
169
  double TargetResolveStartSeconds = 0.0;
@@ -1,4 +1,5 @@
1
1
  #include "Handlers/PIE/PIEInputReplayer.h"
2
+ #include "Handlers/PIE/PIEReplayInputLock.h"
2
3
  #include "MCPPIEViewportCapture.h"
3
4
  #include "Handlers/PIE/PIEGifEncoder.h"
4
5
  #include "Handlers/PIE/PIEContactSheet.h"
@@ -145,6 +146,7 @@ namespace MCPPIE
145
146
  bEndFrameBound = false;
146
147
  FPSPin.Restore();
147
148
  RestoreFixedTimestep();
149
+ ReplayInputLock::Stop();
148
150
  State = EReplayerState::Idle;
149
151
  bArmed = false;
150
152
  TargetWorld.Reset();
@@ -164,6 +166,9 @@ namespace MCPPIE
164
166
  }
165
167
  ActiveHolds.Reset();
166
168
  ActiveTapes.Reset();
169
+ UIPlayer.ReleaseAll(nullptr);
170
+ UIPlayer.Reset();
171
+ ReplayInputLock::Stop();
167
172
  }
168
173
 
169
174
  bool FPIEInputReplayer::LoadSourceFrames(const FString& CSVPath, FString& OutError)
@@ -354,6 +359,12 @@ namespace MCPPIE
354
359
  CaptureDir.Reset();
355
360
  NextStepIndex = 0;
356
361
  ExecutedSteps = 0;
362
+ UIPlayer.Reset();
363
+ NextUIStepIndex = 0;
364
+ UIStepErrors = 0;
365
+ AttachRealTime = 0.0;
366
+ UIClockStartRealMs = 0.0;
367
+ UIClockStartStepMs = 0.0;
357
368
  SourceCursor = 0;
358
369
  bSourceExhausted = false;
359
370
  ReplayFrameIndex = 0;
@@ -673,6 +684,12 @@ namespace MCPPIE
673
684
  while (NextStepIndex < ActiveSequence.Steps.Num())
674
685
  {
675
686
  const FStep& S = ActiveSequence.Steps[NextStepIndex];
687
+ if (S.Type == EStepType::UIInput)
688
+ {
689
+ // Played by ExecutePendingUISteps on the real-time clock.
690
+ NextStepIndex++;
691
+ continue;
692
+ }
676
693
  if (S.DelayMs > ElapsedMs) break;
677
694
 
678
695
  const bool bInputStep = S.Type == EStepType::Input || S.Type == EStepType::Hold || S.Type == EStepType::InputTape;
@@ -790,6 +807,32 @@ namespace MCPPIE
790
807
  }
791
808
  }
792
809
 
810
+ void FPIEInputReplayer::ExecutePendingUISteps(double UIElapsedMs)
811
+ {
812
+ UWorld* PIEWorld = TargetWorld.Get();
813
+ while (NextUIStepIndex < ActiveSequence.Steps.Num())
814
+ {
815
+ const FStep& S = ActiveSequence.Steps[NextUIStepIndex];
816
+ if (S.Type != EStepType::UIInput)
817
+ {
818
+ NextUIStepIndex++;
819
+ continue;
820
+ }
821
+ if (S.DelayMs > UIElapsedMs) break;
822
+ FString Err;
823
+ if (!UIPlayer.Play(S, PIEWorld, Err))
824
+ {
825
+ // Log the first few; a missing viewport fails every step.
826
+ if (UIStepErrors++ < 5)
827
+ {
828
+ UE_LOG(LogMCPPIE, Warning, TEXT("[PIE-REP] %s"), *Err);
829
+ }
830
+ }
831
+ NextUIStepIndex++;
832
+ ExecutedSteps++;
833
+ }
834
+ }
835
+
793
836
  void FPIEInputReplayer::OnEndFrame()
794
837
  {
795
838
  if (State == EReplayerState::Idle || State == EReplayerState::Completed) return;
@@ -852,6 +895,11 @@ namespace MCPPIE
852
895
  }
853
896
  }
854
897
 
898
+ if (Pending.bLockInput && !Pending.bMonitor)
899
+ {
900
+ ReplayInputLock::Start(PIEWorld);
901
+ }
902
+
855
903
  if (Pending.bEject)
856
904
  {
857
905
  EjectPlayer(PIEWorld);
@@ -870,6 +918,7 @@ namespace MCPPIE
870
918
  }
871
919
 
872
920
  AttachTime = PIEWorld->GetTimeSeconds();
921
+ AttachRealTime = PIEWorld->GetRealTimeSeconds();
873
922
  State = EReplayerState::Replaying;
874
923
  }
875
924
  return;
@@ -890,6 +939,8 @@ namespace MCPPIE
890
939
  {
891
940
  bStepClockStarted = true;
892
941
  StepOffsetMs = Settle;
942
+ UIClockStartRealMs = (PIEWorld->GetRealTimeSeconds() - AttachRealTime) * 1000.0;
943
+ UIClockStartStepMs = ElapsedMs - StepOffsetMs;
893
944
  }
894
945
  }
895
946
  else if (UpdateStartGate(PIEWorld, Now, GateBlocker))
@@ -897,6 +948,8 @@ namespace MCPPIE
897
948
  bStepClockStarted = true;
898
949
  StepOffsetMs = ElapsedMs - SourceGateMs;
899
950
  GateOpenedMs = ElapsedMs;
951
+ UIClockStartRealMs = (PIEWorld->GetRealTimeSeconds() - AttachRealTime) * 1000.0;
952
+ UIClockStartStepMs = ElapsedMs - StepOffsetMs;
900
953
  GateBlocker.Reset();
901
954
  UE_LOG(LogMCPPIE, Log, TEXT("[PIE-REP] start_when open at %.0f ms; resuming at source %.0f ms (%s)"),
902
955
  ElapsedMs, SourceGateMs, *GateAnchor);
@@ -912,6 +965,11 @@ namespace MCPPIE
912
965
  if (bStepClockStarted && !Pending.bMonitor)
913
966
  {
914
967
  ExecutePendingSteps(ElapsedMs - StepOffsetMs);
968
+ // Real time is undilated, so time_scale is applied to it here
969
+ // to keep the menu input in step with a slowed replay.
970
+ const double RealMs = (PIEWorld->GetRealTimeSeconds() - AttachRealTime) * 1000.0;
971
+ const double Scale = Pending.TimeScale > 0.f ? static_cast<double>(Pending.TimeScale) : 1.0;
972
+ ExecutePendingUISteps(UIClockStartStepMs + (RealMs - UIClockStartRealMs) * Scale);
915
973
  }
916
974
 
917
975
  // Per-frame viewport capture (off by default). Counted off the
@@ -1136,7 +1194,8 @@ namespace MCPPIE
1136
1194
  // Auto-stop when all steps consumed and all holds released. In
1137
1195
  // monitor mode the steps were never executed so we drive completion
1138
1196
  // purely off frame count against the source recording.
1139
- const bool bStepsDone = Pending.bMonitor ? true : (NextStepIndex >= ActiveSequence.Steps.Num() && ActiveHolds.Num() == 0 && ActiveTapes.Num() == 0);
1197
+ const bool bStepsDone = Pending.bMonitor ? true : (NextStepIndex >= ActiveSequence.Steps.Num() && NextUIStepIndex >= ActiveSequence.Steps.Num()
1198
+ && ActiveHolds.Num() == 0 && ActiveTapes.Num() == 0);
1140
1199
  if (bStepsDone)
1141
1200
  {
1142
1201
  // Stay in Replaying for one more sample frame to let drift catch
@@ -1144,6 +1203,8 @@ namespace MCPPIE
1144
1203
  if (SourceFrames.Num() == 0 || bSourceExhausted)
1145
1204
  {
1146
1205
  State = EReplayerState::Completed;
1206
+ // Hand the player back as soon as the recording is done, not when PIE ends.
1207
+ ReplayInputLock::Stop();
1147
1208
  }
1148
1209
  }
1149
1210
  }
@@ -1189,6 +1250,8 @@ namespace MCPPIE
1189
1250
  FPIEInputInjector::StopAny(Id);
1190
1251
  }
1191
1252
  ActiveTapes.Reset();
1253
+ // A replay stopped mid-drag must not leave a mouse button down.
1254
+ UIPlayer.ReleaseAll(TargetWorld.Get());
1192
1255
 
1193
1256
  const bool bTargetFailed = !bTargetResolved && !TargetResolveError.IsEmpty();
1194
1257
  R.bSuccess = !bTargetFailed && GateError.IsEmpty();
@@ -1316,6 +1379,7 @@ namespace MCPPIE
1316
1379
  }
1317
1380
  }
1318
1381
 
1382
+ ReplayInputLock::Stop();
1319
1383
  RepossessPlayer();
1320
1384
  RestoreFixedTimestep();
1321
1385
  FPSPin.Restore();