ue-mcp 1.0.39 → 1.0.41
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/dist/tool-counts.json +2 -2
- package/package.json +1 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/PIE/PIEFrameSampler.cpp +51 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/PIE/PIEFrameSampler.h +1 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/PIE/PIEInputRecorder.cpp +14 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/UE_MCP_Bridge.cpp +3 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/UI/SMCPPIEPanel.cpp +489 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/UI/SMCPPIEPanel.h +47 -0
package/dist/tool-counts.json
CHANGED
package/package.json
CHANGED
|
@@ -146,6 +146,7 @@ namespace UEMCPPIE
|
|
|
146
146
|
TrackedValues.Reset();
|
|
147
147
|
Tracked.Reset();
|
|
148
148
|
PendingMarkerLabels.Reset();
|
|
149
|
+
PrevPawnLocation = FVector::ZeroVector;
|
|
149
150
|
// Re-seed TrackedValues from config in case the caller calls AttachToPIE again.
|
|
150
151
|
for (const FString& P : Config.TrackedValuePaths)
|
|
151
152
|
{
|
|
@@ -218,6 +219,41 @@ namespace UEMCPPIE
|
|
|
218
219
|
APawn* Pawn = PC->GetPawn();
|
|
219
220
|
if (!Pawn) return Row;
|
|
220
221
|
|
|
222
|
+
// Rescan for late-bound actions (IMCs added after initial attach).
|
|
223
|
+
if (UEnhancedInputComponent* EIC = Cast<UEnhancedInputComponent>(Pawn->InputComponent))
|
|
224
|
+
{
|
|
225
|
+
TSet<FString> Known;
|
|
226
|
+
for (const FTrackedAction& T : Tracked) Known.Add(T.Path);
|
|
227
|
+
|
|
228
|
+
TSet<FString> Whitelist;
|
|
229
|
+
for (const FString& P : Config.ActionPaths) Whitelist.Add(P);
|
|
230
|
+
|
|
231
|
+
for (const TUniquePtr<FEnhancedInputActionEventBinding>& Bind : EIC->GetActionEventBindings())
|
|
232
|
+
{
|
|
233
|
+
const UInputAction* Action = Bind->GetAction();
|
|
234
|
+
if (!Action) continue;
|
|
235
|
+
const FString Path = Action->GetPathName();
|
|
236
|
+
if (Known.Contains(Path)) continue;
|
|
237
|
+
if (!Whitelist.IsEmpty() && !Whitelist.Contains(Path)) continue;
|
|
238
|
+
Known.Add(Path);
|
|
239
|
+
|
|
240
|
+
FTrackedAction T;
|
|
241
|
+
T.Action = Action;
|
|
242
|
+
T.Name = Action->GetName();
|
|
243
|
+
T.Path = Path;
|
|
244
|
+
T.ValueType = ConvertValueType(Action->ValueType);
|
|
245
|
+
Tracked.Add(T);
|
|
246
|
+
|
|
247
|
+
FActionSpec Spec;
|
|
248
|
+
Spec.Name = T.Name;
|
|
249
|
+
Spec.Path = Path;
|
|
250
|
+
Spec.ValueType = T.ValueType;
|
|
251
|
+
Actions.Add(Spec);
|
|
252
|
+
UE_LOG(LogMCPBridge, Log, TEXT("[PIE-SAMPLER] Late-discovered action: %s (%s)"),
|
|
253
|
+
*T.Name, *Path);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
221
257
|
if (Config.bCapturePawnState)
|
|
222
258
|
{
|
|
223
259
|
Row.PawnLocation = Pawn->GetActorLocation();
|
|
@@ -232,8 +268,21 @@ namespace UEMCPPIE
|
|
|
232
268
|
}
|
|
233
269
|
else
|
|
234
270
|
{
|
|
235
|
-
|
|
236
|
-
|
|
271
|
+
FVector Vel = Pawn->GetVelocity();
|
|
272
|
+
if (Vel.IsNearlyZero())
|
|
273
|
+
{
|
|
274
|
+
if (UPrimitiveComponent* Root = Cast<UPrimitiveComponent>(Pawn->GetRootComponent()))
|
|
275
|
+
{
|
|
276
|
+
Vel = Root->GetPhysicsLinearVelocity();
|
|
277
|
+
}
|
|
278
|
+
if (Vel.IsNearlyZero() && FrameNumber > 0)
|
|
279
|
+
{
|
|
280
|
+
Vel = (Pawn->GetActorLocation() - PrevPawnLocation) / FMath::Max(DeltaTime, 0.001);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
PrevPawnLocation = Pawn->GetActorLocation();
|
|
284
|
+
Row.PawnVelocity = Vel;
|
|
285
|
+
Row.Speed2D = Vel.Size2D();
|
|
237
286
|
}
|
|
238
287
|
}
|
|
239
288
|
|
|
@@ -242,6 +242,20 @@ namespace UEMCPPIE
|
|
|
242
242
|
ActorRows.Add(MoveTemp(AR));
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
+
// Detect late-discovered actions and rebuild CSV header.
|
|
246
|
+
const TArray<FActionSpec>& CurrentActions = Sampler.GetActions();
|
|
247
|
+
if (CurrentActions.Num() != CSVHdr.Actions.Num())
|
|
248
|
+
{
|
|
249
|
+
CSVHdr.Actions = CurrentActions;
|
|
250
|
+
CSVHdr.TrackedValues = Sampler.GetTrackedValues();
|
|
251
|
+
CSVHeader = BuildCSVHeader(CSVHdr);
|
|
252
|
+
CSVBody.Reset();
|
|
253
|
+
for (const FCSVRow& Prev : Rows)
|
|
254
|
+
{
|
|
255
|
+
AppendCSVRow(CSVBody, Prev, CSVHdr);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
245
259
|
AppendCSVRow(CSVBody, Row, CSVHdr);
|
|
246
260
|
Rows.Add(MoveTemp(Row));
|
|
247
261
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#include "PIE/PIEInputRecorder.h"
|
|
7
7
|
#include "PIE/PIEInputReplayer.h"
|
|
8
8
|
#include "PIE/PIEObserver.h"
|
|
9
|
+
#include "UI/SMCPPIEPanel.h"
|
|
9
10
|
#include "Editor.h"
|
|
10
11
|
#include "Editor/EditorEngine.h"
|
|
11
12
|
#include "Misc/ConfigCacheIni.h"
|
|
@@ -26,6 +27,7 @@ void FUE_MCP_BridgeModule::StartupModule()
|
|
|
26
27
|
UEMCPPIE::FPIEInputRecorder::Get().Init();
|
|
27
28
|
UEMCPPIE::FPIEInputReplayer::Get().Init();
|
|
28
29
|
UEMCPPIE::FPIEObserver::Get().Init();
|
|
30
|
+
SMCPPIEPanel::RegisterTab();
|
|
29
31
|
// Clear any leftover injections from a previous PIE session so a fresh
|
|
30
32
|
// EndPIE-BeginPIE pair starts with no ghost holds in the queue.
|
|
31
33
|
FEditorDelegates::EndPIE.AddLambda([](bool /*bIsSimulating*/)
|
|
@@ -114,6 +116,7 @@ void FUE_MCP_BridgeModule::StartupModule()
|
|
|
114
116
|
|
|
115
117
|
void FUE_MCP_BridgeModule::ShutdownModule()
|
|
116
118
|
{
|
|
119
|
+
SMCPPIEPanel::UnregisterTab();
|
|
117
120
|
// Stop bridge server
|
|
118
121
|
FDialogHandlers::RemoveDialogHook();
|
|
119
122
|
UEMCPPIE::FPIEObserver::Get().Shutdown();
|
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
#include "SMCPPIEPanel.h"
|
|
2
|
+
#include "UE_MCP_BridgeModule.h"
|
|
3
|
+
#include "PIE/PIEInputRecorder.h"
|
|
4
|
+
#include "PIE/PIEInputReplayer.h"
|
|
5
|
+
#include "PIE/PIEObserver.h"
|
|
6
|
+
#include "PIE/MCPObservationProfile.h"
|
|
7
|
+
#include "PIE/PIESequenceFormat.h"
|
|
8
|
+
#include "Widgets/Layout/SScrollBox.h"
|
|
9
|
+
#include "Widgets/Layout/SSeparator.h"
|
|
10
|
+
#include "Widgets/Layout/SExpandableArea.h"
|
|
11
|
+
#include "Widgets/Input/SButton.h"
|
|
12
|
+
#include "Widgets/Text/STextBlock.h"
|
|
13
|
+
#include "Framework/Docking/TabManager.h"
|
|
14
|
+
#include "WorkspaceMenuStructure.h"
|
|
15
|
+
#include "WorkspaceMenuStructureModule.h"
|
|
16
|
+
#include "Styling/AppStyle.h"
|
|
17
|
+
#include "AssetRegistry/AssetRegistryModule.h"
|
|
18
|
+
#include "HAL/FileManager.h"
|
|
19
|
+
#include "Misc/Paths.h"
|
|
20
|
+
|
|
21
|
+
const FName SMCPPIEPanel::TabId(TEXT("MCPPIEPanel"));
|
|
22
|
+
|
|
23
|
+
namespace
|
|
24
|
+
{
|
|
25
|
+
FString RecorderStateStr(UEMCPPIE::ERecorderState S)
|
|
26
|
+
{
|
|
27
|
+
switch (S)
|
|
28
|
+
{
|
|
29
|
+
case UEMCPPIE::ERecorderState::Idle: return TEXT("Idle");
|
|
30
|
+
case UEMCPPIE::ERecorderState::Armed: return TEXT("Armed");
|
|
31
|
+
case UEMCPPIE::ERecorderState::WaitingForPawn: return TEXT("Waiting for Pawn");
|
|
32
|
+
case UEMCPPIE::ERecorderState::Recording: return TEXT("Recording");
|
|
33
|
+
}
|
|
34
|
+
return TEXT("?");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
FString ReplayerStateStr(UEMCPPIE::EReplayerState S)
|
|
38
|
+
{
|
|
39
|
+
switch (S)
|
|
40
|
+
{
|
|
41
|
+
case UEMCPPIE::EReplayerState::Idle: return TEXT("Idle");
|
|
42
|
+
case UEMCPPIE::EReplayerState::Armed: return TEXT("Armed");
|
|
43
|
+
case UEMCPPIE::EReplayerState::WaitingForPawn: return TEXT("Waiting for Pawn");
|
|
44
|
+
case UEMCPPIE::EReplayerState::Replaying: return TEXT("Replaying");
|
|
45
|
+
case UEMCPPIE::EReplayerState::Completed: return TEXT("Completed");
|
|
46
|
+
}
|
|
47
|
+
return TEXT("?");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
FString ObserverStateStr(UEMCPPIE::EObserverState S)
|
|
51
|
+
{
|
|
52
|
+
switch (S)
|
|
53
|
+
{
|
|
54
|
+
case UEMCPPIE::EObserverState::Idle: return TEXT("Idle");
|
|
55
|
+
case UEMCPPIE::EObserverState::Armed: return TEXT("Armed");
|
|
56
|
+
case UEMCPPIE::EObserverState::WaitingForPawn: return TEXT("Waiting for Pawn");
|
|
57
|
+
case UEMCPPIE::EObserverState::Observing: return TEXT("Observing");
|
|
58
|
+
case UEMCPPIE::EObserverState::Completed: return TEXT("Completed");
|
|
59
|
+
}
|
|
60
|
+
return TEXT("?");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
FSlateColor StateColor(bool bActive)
|
|
64
|
+
{
|
|
65
|
+
return bActive ? FSlateColor(FLinearColor::Green) : FSlateColor(FSlateColor::UseForeground());
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
void SMCPPIEPanel::RegisterTab()
|
|
70
|
+
{
|
|
71
|
+
FGlobalTabmanager::Get()->RegisterNomadTabSpawner(TabId,
|
|
72
|
+
FOnSpawnTab::CreateLambda([](const FSpawnTabArgs&) -> TSharedRef<SDockTab>
|
|
73
|
+
{
|
|
74
|
+
return SNew(SDockTab)
|
|
75
|
+
.TabRole(NomadTab)
|
|
76
|
+
.Label(FText::FromString(TEXT("MCP PIE")))
|
|
77
|
+
[
|
|
78
|
+
SNew(SMCPPIEPanel)
|
|
79
|
+
];
|
|
80
|
+
}))
|
|
81
|
+
.SetDisplayName(FText::FromString(TEXT("MCP PIE")))
|
|
82
|
+
.SetTooltipText(FText::FromString(TEXT("PIE Record / Replay / Observe")))
|
|
83
|
+
.SetGroup(WorkspaceMenu::GetMenuStructure().GetToolsCategory());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
void SMCPPIEPanel::UnregisterTab()
|
|
87
|
+
{
|
|
88
|
+
FGlobalTabmanager::Get()->UnregisterNomadTabSpawner(TabId);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
void SMCPPIEPanel::OpenTab()
|
|
92
|
+
{
|
|
93
|
+
FGlobalTabmanager::Get()->TryInvokeTab(TabId);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void SMCPPIEPanel::Construct(const FArguments& InArgs)
|
|
97
|
+
{
|
|
98
|
+
ChildSlot
|
|
99
|
+
[
|
|
100
|
+
SNew(SScrollBox)
|
|
101
|
+
+ SScrollBox::Slot().Padding(8)
|
|
102
|
+
[
|
|
103
|
+
SNew(SVerticalBox)
|
|
104
|
+
|
|
105
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 0, 0, 4)
|
|
106
|
+
[ BuildRecorderSection() ]
|
|
107
|
+
|
|
108
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4)
|
|
109
|
+
[ SNew(SSeparator) ]
|
|
110
|
+
|
|
111
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4, 0, 4)
|
|
112
|
+
[ BuildReplayerSection() ]
|
|
113
|
+
|
|
114
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4)
|
|
115
|
+
[ SNew(SSeparator) ]
|
|
116
|
+
|
|
117
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4, 0, 4)
|
|
118
|
+
[ BuildObserverSection() ]
|
|
119
|
+
|
|
120
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4)
|
|
121
|
+
[ SNew(SSeparator) ]
|
|
122
|
+
|
|
123
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4, 0, 4)
|
|
124
|
+
[ BuildRecordingsSection() ]
|
|
125
|
+
|
|
126
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4)
|
|
127
|
+
[ SNew(SSeparator) ]
|
|
128
|
+
|
|
129
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4, 0, 4)
|
|
130
|
+
[ BuildProfilesSection() ]
|
|
131
|
+
]
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
TSharedRef<SWidget> SMCPPIEPanel::BuildRecorderSection()
|
|
136
|
+
{
|
|
137
|
+
return SNew(SVerticalBox)
|
|
138
|
+
+ SVerticalBox::Slot().AutoHeight()
|
|
139
|
+
[
|
|
140
|
+
SNew(SHorizontalBox)
|
|
141
|
+
+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center)
|
|
142
|
+
[
|
|
143
|
+
SNew(STextBlock)
|
|
144
|
+
.Font(FAppStyle::GetFontStyle("BoldFont"))
|
|
145
|
+
.Text(FText::FromString(TEXT("Recorder")))
|
|
146
|
+
]
|
|
147
|
+
+ SHorizontalBox::Slot().FillWidth(1.f)
|
|
148
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(4, 0)
|
|
149
|
+
[
|
|
150
|
+
SAssignNew(RecorderStateText, STextBlock)
|
|
151
|
+
.Text(FText::FromString(TEXT("Idle")))
|
|
152
|
+
]
|
|
153
|
+
]
|
|
154
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4)
|
|
155
|
+
[
|
|
156
|
+
SNew(SHorizontalBox)
|
|
157
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(0, 0, 4, 0)
|
|
158
|
+
[
|
|
159
|
+
SNew(SButton)
|
|
160
|
+
.Text(FText::FromString(TEXT("Arm")))
|
|
161
|
+
.OnClicked_Lambda([]()
|
|
162
|
+
{
|
|
163
|
+
UEMCPPIE::FRecorderArmConfig Cfg;
|
|
164
|
+
FString Err, Msg;
|
|
165
|
+
UEMCPPIE::FPIEInputRecorder::Get().Arm(Cfg, Err, Msg);
|
|
166
|
+
return FReply::Handled();
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(0, 0, 4, 0)
|
|
170
|
+
[
|
|
171
|
+
SNew(SButton)
|
|
172
|
+
.Text(FText::FromString(TEXT("Disarm")))
|
|
173
|
+
.OnClicked_Lambda([]()
|
|
174
|
+
{
|
|
175
|
+
FString Err;
|
|
176
|
+
UEMCPPIE::FPIEInputRecorder::Get().Disarm(Err);
|
|
177
|
+
return FReply::Handled();
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
+ SHorizontalBox::Slot().AutoWidth()
|
|
181
|
+
[
|
|
182
|
+
SNew(SButton)
|
|
183
|
+
.Text(FText::FromString(TEXT("Stop")))
|
|
184
|
+
.OnClicked_Lambda([]()
|
|
185
|
+
{
|
|
186
|
+
UEMCPPIE::FPIEInputRecorder::Get().ForceStop();
|
|
187
|
+
return FReply::Handled();
|
|
188
|
+
})
|
|
189
|
+
]
|
|
190
|
+
];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
TSharedRef<SWidget> SMCPPIEPanel::BuildReplayerSection()
|
|
194
|
+
{
|
|
195
|
+
return SNew(SVerticalBox)
|
|
196
|
+
+ SVerticalBox::Slot().AutoHeight()
|
|
197
|
+
[
|
|
198
|
+
SNew(SHorizontalBox)
|
|
199
|
+
+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center)
|
|
200
|
+
[
|
|
201
|
+
SNew(STextBlock)
|
|
202
|
+
.Font(FAppStyle::GetFontStyle("BoldFont"))
|
|
203
|
+
.Text(FText::FromString(TEXT("Replayer")))
|
|
204
|
+
]
|
|
205
|
+
+ SHorizontalBox::Slot().FillWidth(1.f)
|
|
206
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(4, 0)
|
|
207
|
+
[
|
|
208
|
+
SAssignNew(ReplayerStateText, STextBlock)
|
|
209
|
+
.Text(FText::FromString(TEXT("Idle")))
|
|
210
|
+
]
|
|
211
|
+
]
|
|
212
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4)
|
|
213
|
+
[
|
|
214
|
+
SNew(SHorizontalBox)
|
|
215
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(0, 0, 4, 0)
|
|
216
|
+
[
|
|
217
|
+
SNew(SButton)
|
|
218
|
+
.Text(FText::FromString(TEXT("Disarm")))
|
|
219
|
+
.OnClicked_Lambda([]()
|
|
220
|
+
{
|
|
221
|
+
FString Err;
|
|
222
|
+
UEMCPPIE::FPIEInputReplayer::Get().Disarm(Err);
|
|
223
|
+
return FReply::Handled();
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
+ SHorizontalBox::Slot().AutoWidth()
|
|
227
|
+
[
|
|
228
|
+
SNew(SButton)
|
|
229
|
+
.Text(FText::FromString(TEXT("Stop")))
|
|
230
|
+
.OnClicked_Lambda([]()
|
|
231
|
+
{
|
|
232
|
+
UEMCPPIE::FPIEInputReplayer::Get().ForceStop();
|
|
233
|
+
return FReply::Handled();
|
|
234
|
+
})
|
|
235
|
+
]
|
|
236
|
+
];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
TSharedRef<SWidget> SMCPPIEPanel::BuildObserverSection()
|
|
240
|
+
{
|
|
241
|
+
return SNew(SVerticalBox)
|
|
242
|
+
+ SVerticalBox::Slot().AutoHeight()
|
|
243
|
+
[
|
|
244
|
+
SNew(SHorizontalBox)
|
|
245
|
+
+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center)
|
|
246
|
+
[
|
|
247
|
+
SNew(STextBlock)
|
|
248
|
+
.Font(FAppStyle::GetFontStyle("BoldFont"))
|
|
249
|
+
.Text(FText::FromString(TEXT("Observer")))
|
|
250
|
+
]
|
|
251
|
+
+ SHorizontalBox::Slot().FillWidth(1.f)
|
|
252
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(4, 0)
|
|
253
|
+
[
|
|
254
|
+
SAssignNew(ObserverStateText, STextBlock)
|
|
255
|
+
.Text(FText::FromString(TEXT("Idle")))
|
|
256
|
+
]
|
|
257
|
+
]
|
|
258
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4)
|
|
259
|
+
[
|
|
260
|
+
SNew(SHorizontalBox)
|
|
261
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(0, 0, 4, 0)
|
|
262
|
+
[
|
|
263
|
+
SNew(SButton)
|
|
264
|
+
.Text(FText::FromString(TEXT("Disarm")))
|
|
265
|
+
.OnClicked_Lambda([]()
|
|
266
|
+
{
|
|
267
|
+
FString Err;
|
|
268
|
+
UEMCPPIE::FPIEObserver::Get().Disarm(Err);
|
|
269
|
+
return FReply::Handled();
|
|
270
|
+
})
|
|
271
|
+
]
|
|
272
|
+
+ SHorizontalBox::Slot().AutoWidth()
|
|
273
|
+
[
|
|
274
|
+
SNew(SButton)
|
|
275
|
+
.Text(FText::FromString(TEXT("Stop")))
|
|
276
|
+
.OnClicked_Lambda([]()
|
|
277
|
+
{
|
|
278
|
+
UEMCPPIE::FPIEObserver::Get().ForceStop();
|
|
279
|
+
return FReply::Handled();
|
|
280
|
+
})
|
|
281
|
+
]
|
|
282
|
+
];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
TSharedRef<SWidget> SMCPPIEPanel::BuildRecordingsSection()
|
|
286
|
+
{
|
|
287
|
+
return SNew(SVerticalBox)
|
|
288
|
+
+ SVerticalBox::Slot().AutoHeight()
|
|
289
|
+
[
|
|
290
|
+
SNew(SHorizontalBox)
|
|
291
|
+
+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center)
|
|
292
|
+
[
|
|
293
|
+
SNew(STextBlock)
|
|
294
|
+
.Font(FAppStyle::GetFontStyle("BoldFont"))
|
|
295
|
+
.Text(FText::FromString(TEXT("Recordings")))
|
|
296
|
+
]
|
|
297
|
+
+ SHorizontalBox::Slot().FillWidth(1.f)
|
|
298
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(4, 0)
|
|
299
|
+
[
|
|
300
|
+
SNew(SButton)
|
|
301
|
+
.Text(FText::FromString(TEXT("Refresh")))
|
|
302
|
+
.OnClicked_Lambda([this]()
|
|
303
|
+
{
|
|
304
|
+
RefreshRecordings();
|
|
305
|
+
return FReply::Handled();
|
|
306
|
+
})
|
|
307
|
+
]
|
|
308
|
+
]
|
|
309
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4)
|
|
310
|
+
[
|
|
311
|
+
SAssignNew(RecordingsListBox, SVerticalBox)
|
|
312
|
+
];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
TSharedRef<SWidget> SMCPPIEPanel::BuildProfilesSection()
|
|
316
|
+
{
|
|
317
|
+
return SNew(SVerticalBox)
|
|
318
|
+
+ SVerticalBox::Slot().AutoHeight()
|
|
319
|
+
[
|
|
320
|
+
SNew(SHorizontalBox)
|
|
321
|
+
+ SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center)
|
|
322
|
+
[
|
|
323
|
+
SNew(STextBlock)
|
|
324
|
+
.Font(FAppStyle::GetFontStyle("BoldFont"))
|
|
325
|
+
.Text(FText::FromString(TEXT("Observation Profiles")))
|
|
326
|
+
]
|
|
327
|
+
+ SHorizontalBox::Slot().FillWidth(1.f)
|
|
328
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(4, 0)
|
|
329
|
+
[
|
|
330
|
+
SNew(SButton)
|
|
331
|
+
.Text(FText::FromString(TEXT("Refresh")))
|
|
332
|
+
.OnClicked_Lambda([this]()
|
|
333
|
+
{
|
|
334
|
+
RefreshProfiles();
|
|
335
|
+
return FReply::Handled();
|
|
336
|
+
})
|
|
337
|
+
]
|
|
338
|
+
]
|
|
339
|
+
+ SVerticalBox::Slot().AutoHeight().Padding(0, 4)
|
|
340
|
+
[
|
|
341
|
+
SAssignNew(ProfilesListBox, SVerticalBox)
|
|
342
|
+
];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
void SMCPPIEPanel::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
|
|
346
|
+
{
|
|
347
|
+
SCompoundWidget::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);
|
|
348
|
+
|
|
349
|
+
// Update state labels
|
|
350
|
+
{
|
|
351
|
+
const auto RS = UEMCPPIE::FPIEInputRecorder::Get().GetStatus();
|
|
352
|
+
const FString RecText = FString::Printf(TEXT("%s %s F:%d %.1fs"),
|
|
353
|
+
*RecorderStateStr(RS.State), *RS.Id, RS.CurrentFrame, RS.ElapsedSeconds);
|
|
354
|
+
const bool bRecActive = RS.State == UEMCPPIE::ERecorderState::Recording;
|
|
355
|
+
RecorderStateText->SetText(FText::FromString(RecText));
|
|
356
|
+
RecorderStateText->SetColorAndOpacity(StateColor(bRecActive));
|
|
357
|
+
}
|
|
358
|
+
{
|
|
359
|
+
const auto RS = UEMCPPIE::FPIEInputReplayer::Get().GetStatus();
|
|
360
|
+
const FString RepText = FString::Printf(TEXT("%s %s %d/%d %.1fs"),
|
|
361
|
+
*ReplayerStateStr(RS.State), *RS.SourceRecordingId,
|
|
362
|
+
RS.CurrentStep, RS.TotalSteps, RS.ElapsedSeconds);
|
|
363
|
+
const bool bRepActive = RS.State == UEMCPPIE::EReplayerState::Replaying;
|
|
364
|
+
ReplayerStateText->SetText(FText::FromString(RepText));
|
|
365
|
+
ReplayerStateText->SetColorAndOpacity(StateColor(bRepActive));
|
|
366
|
+
}
|
|
367
|
+
{
|
|
368
|
+
const auto OS = UEMCPPIE::FPIEObserver::Get().GetStatus();
|
|
369
|
+
const FString ObsText = FString::Printf(TEXT("%s %s F:%d %.1fs"),
|
|
370
|
+
*ObserverStateStr(OS.State),
|
|
371
|
+
*FPaths::GetBaseFilename(OS.ProfilePath),
|
|
372
|
+
OS.FramesSampled, OS.ElapsedSeconds);
|
|
373
|
+
const bool bObsActive = OS.State == UEMCPPIE::EObserverState::Observing;
|
|
374
|
+
ObserverStateText->SetText(FText::FromString(ObsText));
|
|
375
|
+
ObserverStateText->SetColorAndOpacity(StateColor(bObsActive));
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Auto-refresh lists every 5 seconds
|
|
379
|
+
if (InCurrentTime - LastRecordingsRefresh > 5.0)
|
|
380
|
+
{
|
|
381
|
+
RefreshRecordings();
|
|
382
|
+
LastRecordingsRefresh = InCurrentTime;
|
|
383
|
+
}
|
|
384
|
+
if (InCurrentTime - LastProfilesRefresh > 5.0)
|
|
385
|
+
{
|
|
386
|
+
RefreshProfiles();
|
|
387
|
+
LastProfilesRefresh = InCurrentTime;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
void SMCPPIEPanel::RefreshRecordings()
|
|
392
|
+
{
|
|
393
|
+
if (!RecordingsListBox.IsValid()) return;
|
|
394
|
+
RecordingsListBox->ClearChildren();
|
|
395
|
+
CachedRecordingIds.Reset();
|
|
396
|
+
|
|
397
|
+
const FString Root = UEMCPPIE::DefaultRecordingsRoot();
|
|
398
|
+
TArray<FString> Dirs;
|
|
399
|
+
IFileManager::Get().FindFiles(Dirs, *(Root / TEXT("*")), false, true);
|
|
400
|
+
Dirs.Sort([](const FString& A, const FString& B) { return A > B; });
|
|
401
|
+
if (Dirs.Num() > 50) Dirs.SetNum(50);
|
|
402
|
+
|
|
403
|
+
for (const FString& D : Dirs)
|
|
404
|
+
{
|
|
405
|
+
CachedRecordingIds.Add(D);
|
|
406
|
+
const FString Id = D;
|
|
407
|
+
|
|
408
|
+
RecordingsListBox->AddSlot().AutoHeight().Padding(0, 2)
|
|
409
|
+
[
|
|
410
|
+
SNew(SHorizontalBox)
|
|
411
|
+
+ SHorizontalBox::Slot().FillWidth(1.f).VAlign(VAlign_Center)
|
|
412
|
+
[
|
|
413
|
+
SNew(STextBlock).Text(FText::FromString(Id))
|
|
414
|
+
]
|
|
415
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(4, 0)
|
|
416
|
+
[
|
|
417
|
+
SNew(SButton)
|
|
418
|
+
.Text(FText::FromString(TEXT("Replay")))
|
|
419
|
+
.OnClicked_Lambda([Id]()
|
|
420
|
+
{
|
|
421
|
+
UEMCPPIE::FReplayerArmConfig Cfg;
|
|
422
|
+
Cfg.SourceRecordingId = Id;
|
|
423
|
+
FString Err, Msg;
|
|
424
|
+
UEMCPPIE::FPIEInputReplayer::Get().Arm(Cfg, Err, Msg);
|
|
425
|
+
return FReply::Handled();
|
|
426
|
+
})
|
|
427
|
+
]
|
|
428
|
+
];
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (Dirs.Num() == 0)
|
|
432
|
+
{
|
|
433
|
+
RecordingsListBox->AddSlot().AutoHeight()
|
|
434
|
+
[
|
|
435
|
+
SNew(STextBlock)
|
|
436
|
+
.Text(FText::FromString(TEXT("No recordings found")))
|
|
437
|
+
.ColorAndOpacity(FSlateColor(FLinearColor::Gray))
|
|
438
|
+
];
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
void SMCPPIEPanel::RefreshProfiles()
|
|
443
|
+
{
|
|
444
|
+
if (!ProfilesListBox.IsValid()) return;
|
|
445
|
+
ProfilesListBox->ClearChildren();
|
|
446
|
+
CachedProfilePaths.Reset();
|
|
447
|
+
|
|
448
|
+
FAssetRegistryModule& ARM = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
|
|
449
|
+
TArray<FAssetData> Assets;
|
|
450
|
+
ARM.Get().GetAssetsByClass(UMCPObservationProfile::StaticClass()->GetClassPathName(), Assets, true);
|
|
451
|
+
|
|
452
|
+
for (const FAssetData& A : Assets)
|
|
453
|
+
{
|
|
454
|
+
const FString Path = A.GetObjectPathString();
|
|
455
|
+
CachedProfilePaths.Add(Path);
|
|
456
|
+
|
|
457
|
+
ProfilesListBox->AddSlot().AutoHeight().Padding(0, 2)
|
|
458
|
+
[
|
|
459
|
+
SNew(SHorizontalBox)
|
|
460
|
+
+ SHorizontalBox::Slot().FillWidth(1.f).VAlign(VAlign_Center)
|
|
461
|
+
[
|
|
462
|
+
SNew(STextBlock).Text(FText::FromString(A.AssetName.ToString()))
|
|
463
|
+
]
|
|
464
|
+
+ SHorizontalBox::Slot().AutoWidth().Padding(4, 0)
|
|
465
|
+
[
|
|
466
|
+
SNew(SButton)
|
|
467
|
+
.Text(FText::FromString(TEXT("Observe")))
|
|
468
|
+
.OnClicked_Lambda([Path]()
|
|
469
|
+
{
|
|
470
|
+
UEMCPPIE::FObserverArmConfig Cfg;
|
|
471
|
+
Cfg.ProfilePath = Path;
|
|
472
|
+
FString Err, Msg;
|
|
473
|
+
UEMCPPIE::FPIEObserver::Get().Arm(Cfg, Err, Msg);
|
|
474
|
+
return FReply::Handled();
|
|
475
|
+
})
|
|
476
|
+
]
|
|
477
|
+
];
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (Assets.Num() == 0)
|
|
481
|
+
{
|
|
482
|
+
ProfilesListBox->AddSlot().AutoHeight()
|
|
483
|
+
[
|
|
484
|
+
SNew(STextBlock)
|
|
485
|
+
.Text(FText::FromString(TEXT("No profiles found")))
|
|
486
|
+
.ColorAndOpacity(FSlateColor(FLinearColor::Gray))
|
|
487
|
+
];
|
|
488
|
+
}
|
|
489
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "CoreMinimal.h"
|
|
4
|
+
#include "Widgets/SCompoundWidget.h"
|
|
5
|
+
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
6
|
+
|
|
7
|
+
class SMCPPIEPanel : public SCompoundWidget
|
|
8
|
+
{
|
|
9
|
+
public:
|
|
10
|
+
SLATE_BEGIN_ARGS(SMCPPIEPanel) {}
|
|
11
|
+
SLATE_END_ARGS()
|
|
12
|
+
|
|
13
|
+
void Construct(const FArguments& InArgs);
|
|
14
|
+
|
|
15
|
+
static void RegisterTab();
|
|
16
|
+
static void UnregisterTab();
|
|
17
|
+
static void OpenTab();
|
|
18
|
+
|
|
19
|
+
static const FName TabId;
|
|
20
|
+
|
|
21
|
+
private:
|
|
22
|
+
virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
|
|
23
|
+
|
|
24
|
+
TSharedRef<SWidget> BuildRecorderSection();
|
|
25
|
+
TSharedRef<SWidget> BuildReplayerSection();
|
|
26
|
+
TSharedRef<SWidget> BuildObserverSection();
|
|
27
|
+
TSharedRef<SWidget> BuildRecordingsSection();
|
|
28
|
+
TSharedRef<SWidget> BuildProfilesSection();
|
|
29
|
+
|
|
30
|
+
void RefreshRecordings();
|
|
31
|
+
void RefreshProfiles();
|
|
32
|
+
|
|
33
|
+
// State text blocks updated per tick
|
|
34
|
+
TSharedPtr<STextBlock> RecorderStateText;
|
|
35
|
+
TSharedPtr<STextBlock> ReplayerStateText;
|
|
36
|
+
TSharedPtr<STextBlock> ObserverStateText;
|
|
37
|
+
|
|
38
|
+
// Recordings list
|
|
39
|
+
TSharedPtr<SVerticalBox> RecordingsListBox;
|
|
40
|
+
TArray<FString> CachedRecordingIds;
|
|
41
|
+
double LastRecordingsRefresh = 0.0;
|
|
42
|
+
|
|
43
|
+
// Profiles list
|
|
44
|
+
TSharedPtr<SVerticalBox> ProfilesListBox;
|
|
45
|
+
TArray<FString> CachedProfilePaths;
|
|
46
|
+
double LastProfilesRefresh = 0.0;
|
|
47
|
+
};
|