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
package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Dialog/DialogHandlers.cpp
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
#include "Widgets/Text/SRichTextBlock.h"
|
|
53
53
|
#include "Widgets/Input/SButton.h"
|
|
54
54
|
#include "Widgets/Input/SCheckBox.h"
|
|
55
|
+
#include "Widgets/Views/SHeaderRow.h"
|
|
55
56
|
|
|
56
57
|
// Static member definitions
|
|
57
58
|
TArray<FDialogHandlers::FDialogPolicy> FDialogHandlers::Policies;
|
|
@@ -1554,6 +1555,281 @@ EMCPPromptKind FDialogHandlers::ClassifyWindow(const TSharedRef<SWindow>& Window
|
|
|
1554
1555
|
return EMCPPromptKind::Parented;
|
|
1555
1556
|
}
|
|
1556
1557
|
|
|
1558
|
+
/**
|
|
1559
|
+
* A dialog's body as a person reads it, not one line per text widget (#1891).
|
|
1560
|
+
*
|
|
1561
|
+
* The flat message lists every STextBlock in walk order, so the Save Content
|
|
1562
|
+
* prompt came out as eleven lines in one column: the caption, the column
|
|
1563
|
+
* headings, each cell of each row, and the labels of the buttons that are
|
|
1564
|
+
* already reported as the dialog's choices. This walk keeps the same widgets
|
|
1565
|
+
* and returns them in reading order as blocks:
|
|
1566
|
+
*
|
|
1567
|
+
* paragraph shown text outside any table and any button. Texts laid side by
|
|
1568
|
+
* side in one SHorizontalBox are one line ("Label: value").
|
|
1569
|
+
* table an SListView or STreeView: the visible columns of its
|
|
1570
|
+
* SHeaderRow, one row per generated row widget with one cell per
|
|
1571
|
+
* column, and each row's checkbox state when it has one.
|
|
1572
|
+
*
|
|
1573
|
+
* Only what is shown is read: a collapsed warning box is not part of the
|
|
1574
|
+
* question. A list view generates rows only for what is on screen, so a very
|
|
1575
|
+
* long list reports the rows Slate has generated.
|
|
1576
|
+
*
|
|
1577
|
+
* Named namespace, for the unity build (see MCPDialogPolicy above).
|
|
1578
|
+
*/
|
|
1579
|
+
namespace MCPDialogStructure
|
|
1580
|
+
{
|
|
1581
|
+
struct FBlock
|
|
1582
|
+
{
|
|
1583
|
+
bool bTable = false;
|
|
1584
|
+
/** A paragraph's text. */
|
|
1585
|
+
FString Text;
|
|
1586
|
+
/** A table's visible column headings, in header order. */
|
|
1587
|
+
TArray<FString> Columns;
|
|
1588
|
+
TArray<TArray<FString>> Rows;
|
|
1589
|
+
/** Per row: 1 ticked, 0 not ticked, -1 the row has no checkbox. */
|
|
1590
|
+
TArray<int32> Checked;
|
|
1591
|
+
/** Per row: the row's checkbox, to pair the row with its list_dialogs item. */
|
|
1592
|
+
TArray<TSharedPtr<SCheckBox>> Boxes;
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
static bool IsShown(const TSharedRef<SWidget>& Widget)
|
|
1596
|
+
{
|
|
1597
|
+
return Widget->GetVisibility().IsVisible();
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
static bool IsTableView(const FName& Type)
|
|
1601
|
+
{
|
|
1602
|
+
const FString Name = Type.ToString();
|
|
1603
|
+
return Name.StartsWith(TEXT("SListView")) || Name.StartsWith(TEXT("STreeView"));
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
static FString TextOf(const TSharedRef<SWidget>& Widget)
|
|
1607
|
+
{
|
|
1608
|
+
return StaticCastSharedRef<STextBlock>(Widget)->GetText().ToString().TrimStartAndEnd();
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
/** Every shown, non-empty text under a widget, depth first. */
|
|
1612
|
+
static void GatherText(const TSharedRef<SWidget>& Widget, TArray<FString>& Out)
|
|
1613
|
+
{
|
|
1614
|
+
if (!IsShown(Widget)) return;
|
|
1615
|
+
if (Widget->GetType() == TEXT("STextBlock"))
|
|
1616
|
+
{
|
|
1617
|
+
const FString Text = TextOf(Widget);
|
|
1618
|
+
if (!Text.IsEmpty()) Out.Add(Text);
|
|
1619
|
+
}
|
|
1620
|
+
if (FChildren* Children = Widget->GetChildren())
|
|
1621
|
+
{
|
|
1622
|
+
for (int32 i = 0; i < Children->Num(); ++i)
|
|
1623
|
+
{
|
|
1624
|
+
GatherText(Children->GetChildAt(i), Out);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
/** The first descendant of this type, depth first, the widget itself excluded. */
|
|
1630
|
+
static TSharedPtr<SWidget> FindFirst(const TSharedRef<SWidget>& Widget, const FName& Type)
|
|
1631
|
+
{
|
|
1632
|
+
FChildren* Children = Widget->GetChildren();
|
|
1633
|
+
if (!Children) return nullptr;
|
|
1634
|
+
for (int32 i = 0; i < Children->Num(); ++i)
|
|
1635
|
+
{
|
|
1636
|
+
const TSharedRef<SWidget> Child = Children->GetChildAt(i);
|
|
1637
|
+
if (Child->GetType() == Type) return Child;
|
|
1638
|
+
if (TSharedPtr<SWidget> Found = FindFirst(Child, Type)) return Found;
|
|
1639
|
+
}
|
|
1640
|
+
return nullptr;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
/** Every shown descendant of this type, depth first, not looking inside a match. */
|
|
1644
|
+
static void CollectShown(const TSharedRef<SWidget>& Widget, const FName& Type, TArray<TSharedRef<SWidget>>& Out)
|
|
1645
|
+
{
|
|
1646
|
+
FChildren* Children = Widget->GetChildren();
|
|
1647
|
+
if (!Children) return;
|
|
1648
|
+
for (int32 i = 0; i < Children->Num(); ++i)
|
|
1649
|
+
{
|
|
1650
|
+
const TSharedRef<SWidget> Child = Children->GetChildAt(i);
|
|
1651
|
+
if (!IsShown(Child)) continue;
|
|
1652
|
+
if (Child->GetType() == Type)
|
|
1653
|
+
{
|
|
1654
|
+
Out.Add(Child);
|
|
1655
|
+
continue;
|
|
1656
|
+
}
|
|
1657
|
+
CollectShown(Child, Type, Out);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
static FBlock ReadTable(const TSharedRef<SWidget>& View)
|
|
1662
|
+
{
|
|
1663
|
+
FBlock Table;
|
|
1664
|
+
Table.bTable = true;
|
|
1665
|
+
|
|
1666
|
+
// The columns a row generates a cell for: SMultiColumnTableRow skips
|
|
1667
|
+
// the rest (SHeaderRow::ShouldGeneratedColumn, restated because older
|
|
1668
|
+
// engines do not export it).
|
|
1669
|
+
if (TSharedPtr<SWidget> Header = FindFirst(View, TEXT("SHeaderRow")))
|
|
1670
|
+
{
|
|
1671
|
+
for (const SHeaderRow::FColumn& Column : StaticCastSharedPtr<SHeaderRow>(Header)->GetColumns())
|
|
1672
|
+
{
|
|
1673
|
+
if (Column.ShouldGenerateWidget.Get(true) && Column.bIsVisible)
|
|
1674
|
+
{
|
|
1675
|
+
Table.Columns.Add(Column.DefaultText.Get().ToString().TrimStartAndEnd());
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
// Every shown SListPanel's rows, in order. A table view holds two: the
|
|
1681
|
+
// pinned-items panel first, collapsed and empty unless rows are pinned,
|
|
1682
|
+
// then the panel of ordinary rows.
|
|
1683
|
+
TArray<TSharedRef<SWidget>> Panels;
|
|
1684
|
+
CollectShown(View, TEXT("SListPanel"), Panels);
|
|
1685
|
+
TArray<TSharedRef<SWidget>> RowWidgets;
|
|
1686
|
+
for (const TSharedRef<SWidget>& Panel : Panels)
|
|
1687
|
+
{
|
|
1688
|
+
if (FChildren* Children = Panel->GetChildren())
|
|
1689
|
+
{
|
|
1690
|
+
for (int32 i = 0; i < Children->Num(); ++i)
|
|
1691
|
+
{
|
|
1692
|
+
RowWidgets.Add(Children->GetChildAt(i));
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
for (const TSharedRef<SWidget>& Row : RowWidgets)
|
|
1697
|
+
{
|
|
1698
|
+
if (!IsShown(Row)) continue;
|
|
1699
|
+
|
|
1700
|
+
// A multi-column row lays its cells out as the slots of one
|
|
1701
|
+
// SHorizontalBox, one per generated column. When the count agrees,
|
|
1702
|
+
// each slot is a cell; otherwise the row's texts are its cells.
|
|
1703
|
+
TArray<FString> Cells;
|
|
1704
|
+
const TSharedPtr<SWidget> Box = FindFirst(Row, TEXT("SHorizontalBox"));
|
|
1705
|
+
FChildren* Slots = Box.IsValid() ? Box->GetChildren() : nullptr;
|
|
1706
|
+
if (Slots && Table.Columns.Num() > 0 && Slots->Num() == Table.Columns.Num())
|
|
1707
|
+
{
|
|
1708
|
+
for (int32 c = 0; c < Slots->Num(); ++c)
|
|
1709
|
+
{
|
|
1710
|
+
TArray<FString> Texts;
|
|
1711
|
+
GatherText(Slots->GetChildAt(c), Texts);
|
|
1712
|
+
Cells.Add(FString::Join(Texts, TEXT(" ")));
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
else
|
|
1716
|
+
{
|
|
1717
|
+
GatherText(Row, Cells);
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
const TSharedPtr<SWidget> Check = FindFirst(Row, TEXT("SCheckBox"));
|
|
1721
|
+
const TSharedPtr<SCheckBox> CheckBox = Check.IsValid() ? StaticCastSharedPtr<SCheckBox>(Check) : nullptr;
|
|
1722
|
+
Table.Rows.Add(MoveTemp(Cells));
|
|
1723
|
+
Table.Checked.Add(CheckBox.IsValid() ? (CheckBox->IsChecked() ? 1 : 0) : -1);
|
|
1724
|
+
Table.Boxes.Add(CheckBox);
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
// A column with no heading and nothing in any cell is the checkbox or
|
|
1728
|
+
// icon column: its state is in Checked, and an empty column says nothing.
|
|
1729
|
+
bool bAligned = Table.Columns.Num() > 0;
|
|
1730
|
+
for (const TArray<FString>& Cells : Table.Rows)
|
|
1731
|
+
{
|
|
1732
|
+
bAligned &= Cells.Num() == Table.Columns.Num();
|
|
1733
|
+
}
|
|
1734
|
+
if (bAligned)
|
|
1735
|
+
{
|
|
1736
|
+
for (int32 c = Table.Columns.Num() - 1; c >= 0; --c)
|
|
1737
|
+
{
|
|
1738
|
+
bool bEmpty = Table.Columns[c].IsEmpty();
|
|
1739
|
+
for (const TArray<FString>& Cells : Table.Rows)
|
|
1740
|
+
{
|
|
1741
|
+
bEmpty &= Cells[c].IsEmpty();
|
|
1742
|
+
}
|
|
1743
|
+
if (!bEmpty) continue;
|
|
1744
|
+
Table.Columns.RemoveAt(c);
|
|
1745
|
+
for (TArray<FString>& Cells : Table.Rows)
|
|
1746
|
+
{
|
|
1747
|
+
Cells.RemoveAt(c);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
return Table;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
struct FWalker
|
|
1755
|
+
{
|
|
1756
|
+
/** The window title and the button labels: neither is part of the body. */
|
|
1757
|
+
TSet<FString> Excluded;
|
|
1758
|
+
TArray<FBlock>& Out;
|
|
1759
|
+
FString Line;
|
|
1760
|
+
bool bInLine = false;
|
|
1761
|
+
|
|
1762
|
+
explicit FWalker(TArray<FBlock>& InOut) : Out(InOut) {}
|
|
1763
|
+
|
|
1764
|
+
void Flush()
|
|
1765
|
+
{
|
|
1766
|
+
Line.TrimStartAndEndInline();
|
|
1767
|
+
if (!Line.IsEmpty() && !Excluded.Contains(Line))
|
|
1768
|
+
{
|
|
1769
|
+
FBlock Paragraph;
|
|
1770
|
+
Paragraph.Text = Line;
|
|
1771
|
+
Out.Add(MoveTemp(Paragraph));
|
|
1772
|
+
}
|
|
1773
|
+
Line.Reset();
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
void Walk(const TSharedRef<SWidget>& Widget)
|
|
1777
|
+
{
|
|
1778
|
+
if (!IsShown(Widget)) return;
|
|
1779
|
+
const FName Type = Widget->GetType();
|
|
1780
|
+
// A button's label is one of the dialog's choices, reported as such.
|
|
1781
|
+
if (Type == TEXT("SButton")) return;
|
|
1782
|
+
if (IsTableView(Type))
|
|
1783
|
+
{
|
|
1784
|
+
Flush();
|
|
1785
|
+
Out.Add(ReadTable(Widget));
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
if (Type == TEXT("STextBlock"))
|
|
1789
|
+
{
|
|
1790
|
+
const FString Text = TextOf(Widget);
|
|
1791
|
+
if (!Text.IsEmpty())
|
|
1792
|
+
{
|
|
1793
|
+
if (!Line.IsEmpty()) Line += TEXT(" ");
|
|
1794
|
+
Line += Text;
|
|
1795
|
+
if (!bInLine) Flush();
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
const bool bStartsLine = !bInLine && Type == TEXT("SHorizontalBox");
|
|
1800
|
+
if (bStartsLine)
|
|
1801
|
+
{
|
|
1802
|
+
Flush();
|
|
1803
|
+
bInLine = true;
|
|
1804
|
+
}
|
|
1805
|
+
if (FChildren* Children = Widget->GetChildren())
|
|
1806
|
+
{
|
|
1807
|
+
for (int32 i = 0; i < Children->Num(); ++i)
|
|
1808
|
+
{
|
|
1809
|
+
Walk(Children->GetChildAt(i));
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
if (bStartsLine)
|
|
1813
|
+
{
|
|
1814
|
+
Flush();
|
|
1815
|
+
bInLine = false;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
|
|
1820
|
+
static void Collect(const TSharedRef<SWidget>& Root, const FString& Title, const TArray<FString>& ButtonLabels, TArray<FBlock>& Out)
|
|
1821
|
+
{
|
|
1822
|
+
FWalker Walker(Out);
|
|
1823
|
+
Walker.Excluded.Add(Title.TrimStartAndEnd());
|
|
1824
|
+
for (const FString& Label : ButtonLabels)
|
|
1825
|
+
{
|
|
1826
|
+
Walker.Excluded.Add(Label.TrimStartAndEnd());
|
|
1827
|
+
}
|
|
1828
|
+
Walker.Walk(Root);
|
|
1829
|
+
Walker.Flush();
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1557
1833
|
TSharedPtr<SWindow> FDialogHandlers::CollectActiveModal(FString& OutTitle, FString& OutMessage, TArray<FModalButton>& OutButtons, TArray<FModalItem>* OutItems, EMCPPromptKind* OutKind)
|
|
1558
1834
|
{
|
|
1559
1835
|
OutTitle.Empty();
|
|
@@ -1716,7 +1992,8 @@ TSharedPtr<FJsonValue> FDialogHandlers::ListDialogs(const TSharedPtr<FJsonObject
|
|
|
1716
1992
|
TArray<FModalButton> Buttons;
|
|
1717
1993
|
TArray<FModalItem> Items;
|
|
1718
1994
|
EMCPPromptKind Kind = EMCPPromptKind::NotAPrompt;
|
|
1719
|
-
const
|
|
1995
|
+
const TSharedPtr<SWindow> Modal = CollectActiveModal(Title, Message, Buttons, &Items, &Kind);
|
|
1996
|
+
const bool bHasDialog = Modal.IsValid();
|
|
1720
1997
|
|
|
1721
1998
|
// Every open modal and floating window, as the ids the window actions take,
|
|
1722
1999
|
// read here too because this is the call a refused client can still make.
|
|
@@ -1791,6 +2068,73 @@ TSharedPtr<FJsonValue> FDialogHandlers::ListDialogs(const TSharedPtr<FJsonObject
|
|
|
1791
2068
|
ItemsJsonArray.Add(MakeShared<FJsonValueObject>(ItemObj));
|
|
1792
2069
|
}
|
|
1793
2070
|
DialogObj->SetArrayField(TEXT("items"), ItemsJsonArray);
|
|
2071
|
+
|
|
2072
|
+
// The same body as `message`, structured (#1891): paragraphs and tables
|
|
2073
|
+
// in reading order, with the title and the button labels left out.
|
|
2074
|
+
// `message` stays as it was for a client that reads only that.
|
|
2075
|
+
TArray<FString> ButtonLabels;
|
|
2076
|
+
for (const FModalButton& Button : Buttons)
|
|
2077
|
+
{
|
|
2078
|
+
ButtonLabels.Add(Button.Label);
|
|
2079
|
+
}
|
|
2080
|
+
TArray<MCPDialogStructure::FBlock> Blocks;
|
|
2081
|
+
MCPDialogStructure::Collect(Modal.ToSharedRef(), Title, ButtonLabels, Blocks);
|
|
2082
|
+
TArray<TSharedPtr<FJsonValue>> BlocksJson;
|
|
2083
|
+
for (const MCPDialogStructure::FBlock& Block : Blocks)
|
|
2084
|
+
{
|
|
2085
|
+
TSharedPtr<FJsonObject> BlockObj = MakeShared<FJsonObject>();
|
|
2086
|
+
if (!Block.bTable)
|
|
2087
|
+
{
|
|
2088
|
+
BlockObj->SetStringField(TEXT("type"), TEXT("paragraph"));
|
|
2089
|
+
BlockObj->SetStringField(TEXT("text"), Block.Text);
|
|
2090
|
+
BlocksJson.Add(MakeShared<FJsonValueObject>(BlockObj));
|
|
2091
|
+
continue;
|
|
2092
|
+
}
|
|
2093
|
+
BlockObj->SetStringField(TEXT("type"), TEXT("table"));
|
|
2094
|
+
TArray<TSharedPtr<FJsonValue>> ColumnsJson;
|
|
2095
|
+
for (const FString& Column : Block.Columns)
|
|
2096
|
+
{
|
|
2097
|
+
ColumnsJson.Add(MakeShared<FJsonValueString>(Column));
|
|
2098
|
+
}
|
|
2099
|
+
BlockObj->SetArrayField(TEXT("columns"), ColumnsJson);
|
|
2100
|
+
TArray<TSharedPtr<FJsonValue>> RowsJson;
|
|
2101
|
+
for (const TArray<FString>& Row : Block.Rows)
|
|
2102
|
+
{
|
|
2103
|
+
TArray<TSharedPtr<FJsonValue>> CellsJson;
|
|
2104
|
+
for (const FString& Cell : Row)
|
|
2105
|
+
{
|
|
2106
|
+
CellsJson.Add(MakeShared<FJsonValueString>(Cell));
|
|
2107
|
+
}
|
|
2108
|
+
RowsJson.Add(MakeShared<FJsonValueArray>(CellsJson));
|
|
2109
|
+
}
|
|
2110
|
+
BlockObj->SetArrayField(TEXT("rows"), RowsJson);
|
|
2111
|
+
// Per row, only when some row has a checkbox: its state, and the
|
|
2112
|
+
// index of the matching entry in `items`, which is what
|
|
2113
|
+
// respond_to_dialog's items parameter takes. null for a row
|
|
2114
|
+
// without one.
|
|
2115
|
+
if (Block.Checked.ContainsByPredicate([](int32 State) { return State >= 0; }))
|
|
2116
|
+
{
|
|
2117
|
+
TArray<TSharedPtr<FJsonValue>> CheckedJson;
|
|
2118
|
+
TArray<TSharedPtr<FJsonValue>> RowItemsJson;
|
|
2119
|
+
for (int32 r = 0; r < Block.Rows.Num(); ++r)
|
|
2120
|
+
{
|
|
2121
|
+
CheckedJson.Add(Block.Checked[r] < 0
|
|
2122
|
+
? StaticCastSharedRef<FJsonValue>(MakeShared<FJsonValueNull>())
|
|
2123
|
+
: StaticCastSharedRef<FJsonValue>(MakeShared<FJsonValueBoolean>(Block.Checked[r] == 1)));
|
|
2124
|
+
const int32 ItemIndex = Block.Boxes[r].IsValid()
|
|
2125
|
+
? Items.IndexOfByPredicate([&](const FModalItem& Item) { return Item.Box == Block.Boxes[r]; })
|
|
2126
|
+
: INDEX_NONE;
|
|
2127
|
+
RowItemsJson.Add(ItemIndex == INDEX_NONE
|
|
2128
|
+
? StaticCastSharedRef<FJsonValue>(MakeShared<FJsonValueNull>())
|
|
2129
|
+
: StaticCastSharedRef<FJsonValue>(MakeShared<FJsonValueNumber>(ItemIndex)));
|
|
2130
|
+
}
|
|
2131
|
+
BlockObj->SetArrayField(TEXT("checked"), CheckedJson);
|
|
2132
|
+
BlockObj->SetArrayField(TEXT("items"), RowItemsJson);
|
|
2133
|
+
}
|
|
2134
|
+
BlocksJson.Add(MakeShared<FJsonValueObject>(BlockObj));
|
|
2135
|
+
}
|
|
2136
|
+
DialogObj->SetArrayField(TEXT("blocks"), BlocksJson);
|
|
2137
|
+
|
|
1794
2138
|
DialogObj->SetArrayField(TEXT("buttons"), ButtonsJsonArray);
|
|
1795
2139
|
DialogObj->SetArrayField(TEXT("choices"), ChoicesJsonArray);
|
|
1796
2140
|
if (ChoicesJsonArray.Num() == 0)
|
package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_AIAssistant.cpp
CHANGED
|
@@ -9,9 +9,14 @@
|
|
|
9
9
|
#include "UObject/UObjectHash.h"
|
|
10
10
|
#include "UObject/WeakObjectPtrTemplates.h"
|
|
11
11
|
|
|
12
|
-
// ── Reflection bridge to
|
|
12
|
+
// ── Reflection bridge to UAIAssistantInstance (UE 5.9+) ───
|
|
13
13
|
//
|
|
14
|
-
//
|
|
14
|
+
// The class lives in the AIAssistantEditor module (/Script/AIAssistantEditor.AIAssistantInstance).
|
|
15
|
+
// Early 5.9 builds had it in AIAssistant; the plugin's ClassRedirects map the old path, but
|
|
16
|
+
// FindObject does not follow redirects, so both paths are tried.
|
|
17
|
+
//
|
|
18
|
+
// Static UFUNCTIONs, each returning an async string result (UAsyncFunctionResultString,
|
|
19
|
+
// UToolCallAsyncResultString on early builds; both expose bIsComplete, Error and Value):
|
|
15
20
|
// SendTextMessage(InConversationId, Message, HiddenContext) -> conversation id
|
|
16
21
|
// SendTextMessageAndGetReply(InConversationId, Message, HiddenContext) -> reply text
|
|
17
22
|
// GetConversationJson(InConversationId) -> conversation JSON
|
|
@@ -19,7 +24,8 @@
|
|
|
19
24
|
// requestId and the server polls epic_ai_assistant_get_request for it.
|
|
20
25
|
namespace UEMCPAIAssistant
|
|
21
26
|
{
|
|
22
|
-
static const TCHAR* const InstanceClassPath = TEXT("/Script/
|
|
27
|
+
static const TCHAR* const InstanceClassPath = TEXT("/Script/AIAssistantEditor.AIAssistantInstance");
|
|
28
|
+
static const TCHAR* const LegacyInstanceClassPath = TEXT("/Script/AIAssistant.AIAssistantInstance");
|
|
23
29
|
static const TCHAR* const Subject = TEXT("Epic's AI Assistant API (UAIAssistantInstance)");
|
|
24
30
|
static const TCHAR* const FnSend = TEXT("SendTextMessage");
|
|
25
31
|
static const TCHAR* const FnSendAndReply = TEXT("SendTextMessageAndGetReply");
|
|
@@ -56,7 +62,8 @@ namespace UEMCPAIAssistant
|
|
|
56
62
|
|
|
57
63
|
static UClass* InstanceClass()
|
|
58
64
|
{
|
|
59
|
-
|
|
65
|
+
if (UClass* Cls = FindObject<UClass>(nullptr, InstanceClassPath)) return Cls;
|
|
66
|
+
return FindObject<UClass>(nullptr, LegacyInstanceClassPath);
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
static FString EngineVersionString()
|
|
@@ -275,9 +282,30 @@ namespace UEMCPAIAssistant
|
|
|
275
282
|
}
|
|
276
283
|
else if (R.Function == FnSendAndReply)
|
|
277
284
|
{
|
|
278
|
-
|
|
285
|
+
// Current 5.9 builds resolve with FSendTextMessageReply serialized as
|
|
286
|
+
// {"conversationId", "reply"}; earlier ones with the bare reply text. The
|
|
287
|
+
// conversationId in it is the canonical one: the first update event can
|
|
288
|
+
// carry a provisional local id that the conversation is renamed from.
|
|
289
|
+
TSharedPtr<FJsonObject> Wrapped;
|
|
290
|
+
FString WrappedReply;
|
|
291
|
+
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(S.Value);
|
|
292
|
+
if (S.Value.StartsWith(TEXT("{")) && FJsonSerializer::Deserialize(Reader, Wrapped) && Wrapped.IsValid()
|
|
293
|
+
&& Wrapped->TryGetStringField(TEXT("reply"), WrappedReply))
|
|
294
|
+
{
|
|
295
|
+
Res->SetStringField(TEXT("reply"), WrappedReply);
|
|
296
|
+
FString WrappedConversation;
|
|
297
|
+
if (Wrapped->TryGetStringField(TEXT("conversationId"), WrappedConversation) && !WrappedConversation.IsEmpty())
|
|
298
|
+
{
|
|
299
|
+
Res->SetStringField(TEXT("conversationId"), WrappedConversation);
|
|
300
|
+
Res->SetStringField(TEXT("conversationIdSource"), TEXT("reply"));
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
else
|
|
304
|
+
{
|
|
305
|
+
Res->SetStringField(TEXT("reply"), S.Value);
|
|
306
|
+
}
|
|
279
307
|
FString Source;
|
|
280
|
-
const FString Conversation = ConversationOf(R, Source);
|
|
308
|
+
const FString Conversation = Res->HasField(TEXT("conversationId")) ? FString() : ConversationOf(R, Source);
|
|
281
309
|
if (!Conversation.IsEmpty())
|
|
282
310
|
{
|
|
283
311
|
Res->SetStringField(TEXT("conversationId"), Conversation);
|