ue-mcp 1.4.12 → 1.4.13
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 +4 -5
- package/dist/bridge/bridge-timeouts.js +16 -0
- package/dist/bridge/bridge-timeouts.js.map +1 -1
- package/dist/bridge/bridge.d.ts +58 -3
- package/dist/bridge/bridge.js +149 -8
- package/dist/bridge/bridge.js.map +1 -1
- package/dist/cli/cli-commands.js +7 -1
- package/dist/cli/cli-commands.js.map +1 -1
- package/dist/cli/doctor.d.ts +9 -0
- package/dist/cli/doctor.js +63 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/editor-flag.js +5 -1
- package/dist/cli/editor-flag.js.map +1 -1
- package/dist/cli/extension-cli.d.ts +3 -0
- package/dist/cli/extension-cli.js +83 -16
- package/dist/cli/extension-cli.js.map +1 -1
- package/dist/cli/flow-cli.js +3 -1
- package/dist/cli/flow-cli.js.map +1 -1
- package/dist/cli/init-core.d.ts +74 -1
- package/dist/cli/init-core.js +231 -38
- package/dist/cli/init-core.js.map +1 -1
- package/dist/cli/init.js +86 -22
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/login-cli.d.ts +27 -1
- package/dist/cli/login-cli.js +130 -17
- package/dist/cli/login-cli.js.map +1 -1
- package/dist/cli/plugin-cli.js +1 -1
- package/dist/cli/plugin-cli.js.map +1 -1
- package/dist/cli/tools-cli.d.ts +14 -0
- package/dist/cli/tools-cli.js +270 -0
- package/dist/cli/tools-cli.js.map +1 -0
- package/dist/cli/ui/ansi.d.ts +2 -0
- package/dist/cli/ui/ansi.js +8 -0
- package/dist/cli/ui/ansi.js.map +1 -1
- package/dist/codeintel/config-hierarchy.d.ts +73 -0
- package/dist/codeintel/config-hierarchy.js +165 -0
- package/dist/codeintel/config-hierarchy.js.map +1 -0
- package/dist/config/project.d.ts +12 -4
- package/dist/config/project.js.map +1 -1
- package/dist/core/archive.d.ts +8 -0
- package/dist/core/archive.js +40 -0
- package/dist/core/archive.js.map +1 -0
- package/dist/core/env.d.ts +4 -0
- package/dist/core/env.js +4 -0
- package/dist/core/env.js.map +1 -1
- package/dist/core/errors.d.ts +9 -1
- package/dist/core/errors.js +8 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/png.d.ts +31 -0
- package/dist/core/png.js +308 -0
- package/dist/core/png.js.map +1 -0
- package/dist/core/types.d.ts +31 -0
- package/dist/daemon/daemon.js +16 -2
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/extension-install.d.ts +14 -0
- package/dist/daemon/extension-install.js +25 -29
- package/dist/daemon/extension-install.js.map +1 -1
- package/dist/daemon/install-names.d.ts +10 -0
- package/dist/daemon/install-names.js +39 -0
- package/dist/daemon/install-names.js.map +1 -0
- package/dist/daemon/tools-routes.d.ts +23 -0
- package/dist/daemon/tools-routes.js +46 -0
- package/dist/daemon/tools-routes.js.map +1 -0
- package/dist/diagram/action.d.ts +25 -0
- package/dist/diagram/action.js +141 -0
- package/dist/diagram/action.js.map +1 -0
- package/dist/diagram/adapters.d.ts +48 -0
- package/dist/diagram/adapters.js +569 -0
- package/dist/diagram/adapters.js.map +1 -0
- package/dist/diagram/mermaid.d.ts +22 -0
- package/dist/diagram/mermaid.js +164 -0
- package/dist/diagram/mermaid.js.map +1 -0
- package/dist/diagram/model.d.ts +59 -0
- package/dist/diagram/model.js +17 -0
- package/dist/diagram/model.js.map +1 -0
- package/dist/diagram/png.d.ts +17 -0
- package/dist/diagram/png.js +48 -0
- package/dist/diagram/png.js.map +1 -0
- package/dist/diagram/select.d.ts +26 -0
- package/dist/diagram/select.js +146 -0
- package/dist/diagram/select.js.map +1 -0
- package/dist/diagram/svg.d.ts +10 -0
- package/dist/diagram/svg.js +254 -0
- package/dist/diagram/svg.js.map +1 -0
- package/dist/diagram/theme.d.ts +33 -0
- package/dist/diagram/theme.js +37 -0
- package/dist/diagram/theme.js.map +1 -0
- package/dist/dispatch/call-pipeline.d.ts +8 -0
- package/dist/dispatch/call-pipeline.js +19 -2
- package/dist/dispatch/call-pipeline.js.map +1 -1
- package/dist/dispatch/inline-image.d.ts +70 -0
- package/dist/dispatch/inline-image.js +198 -0
- package/dist/dispatch/inline-image.js.map +1 -0
- package/dist/dispatch/lease-paths.d.ts +16 -0
- package/dist/dispatch/lease-paths.js +42 -0
- package/dist/dispatch/lease-paths.js.map +1 -0
- package/dist/dispatch/leases.d.ts +71 -0
- package/dist/dispatch/leases.js +191 -0
- package/dist/dispatch/leases.js.map +1 -0
- package/dist/dispatch/offline.js +17 -0
- package/dist/dispatch/offline.js.map +1 -1
- package/dist/dispatch/server-dispatch.d.ts +32 -1
- package/dist/dispatch/server-dispatch.js +70 -2
- package/dist/dispatch/server-dispatch.js.map +1 -1
- package/dist/editor/bridge-binaries.d.ts +2 -0
- package/dist/editor/bridge-binaries.js +12 -22
- package/dist/editor/bridge-binaries.js.map +1 -1
- package/dist/editor/dialog-guard.d.ts +10 -0
- package/dist/editor/dialog-guard.js +26 -4
- package/dist/editor/dialog-guard.js.map +1 -1
- package/dist/editor/editor-plugin.d.ts +16 -0
- package/dist/editor/editor-plugin.js +98 -0
- package/dist/editor/editor-plugin.js.map +1 -0
- package/dist/editor/engine-root.d.ts +2 -0
- package/dist/editor/engine-root.js +2 -2
- package/dist/editor/engine-root.js.map +1 -1
- package/dist/editor/install-marker.d.ts +2 -0
- package/dist/editor/install-marker.js +13 -6
- package/dist/editor/install-marker.js.map +1 -1
- package/dist/extensions/registry-auth.d.ts +60 -1
- package/dist/extensions/registry-auth.js +202 -5
- package/dist/extensions/registry-auth.js.map +1 -1
- package/dist/extensions/skill-catalog.d.ts +20 -0
- package/dist/extensions/skill-catalog.js +56 -0
- package/dist/extensions/skill-catalog.js.map +1 -0
- package/dist/flow/flow-tool.js +10 -2
- package/dist/flow/flow-tool.js.map +1 -1
- package/dist/flow/guarded-bridge.d.ts +6 -4
- package/dist/flow/guarded-bridge.js +11 -5
- package/dist/flow/guarded-bridge.js.map +1 -1
- package/dist/flow/loader.js +19 -0
- package/dist/flow/loader.js.map +1 -1
- package/dist/flow/run-action.js +37 -5
- package/dist/flow/run-action.js.map +1 -1
- package/dist/flow/write-methods.js +4 -0
- package/dist/flow/write-methods.js.map +1 -1
- package/dist/integrations/agent-guides.d.ts +29 -0
- package/dist/integrations/agent-guides.js +125 -0
- package/dist/integrations/agent-guides.js.map +1 -0
- package/dist/integrations/claude-code/mcp-client-config.d.ts +16 -4
- package/dist/integrations/claude-code/mcp-client-config.js +57 -10
- package/dist/integrations/claude-code/mcp-client-config.js.map +1 -1
- package/dist/integrations/claude-code/unreal-mcp-entries.d.ts +33 -0
- package/dist/integrations/claude-code/unreal-mcp-entries.js +159 -0
- package/dist/integrations/claude-code/unreal-mcp-entries.js.map +1 -0
- package/dist/integrations/epic/project-status.d.ts +25 -0
- package/dist/integrations/epic/project-status.js +35 -0
- package/dist/integrations/epic/project-status.js.map +1 -0
- package/dist/integrations/epic/toolset-settings.d.ts +28 -0
- package/dist/integrations/epic/toolset-settings.js +136 -0
- package/dist/integrations/epic/toolset-settings.js.map +1 -0
- package/dist/integrations/epic/unreal-assistant.d.ts +64 -0
- package/dist/integrations/epic/unreal-assistant.js +209 -0
- package/dist/integrations/epic/unreal-assistant.js.map +1 -0
- package/dist/integrations/epic/unreal-canvas.d.ts +48 -0
- package/dist/integrations/epic/unreal-canvas.js +126 -0
- package/dist/integrations/epic/unreal-canvas.js.map +1 -0
- package/dist/integrations/epic/unreal-mcp-server.d.ts +74 -0
- package/dist/integrations/epic/unreal-mcp-server.js +231 -0
- package/dist/integrations/epic/unreal-mcp-server.js.map +1 -0
- package/dist/server/context-projection.js +5 -3
- package/dist/server/context-projection.js.map +1 -1
- package/dist/server/editor-resources.d.ts +39 -0
- package/dist/server/editor-resources.js +94 -0
- package/dist/server/editor-resources.js.map +1 -0
- package/dist/server/mcp-server.d.ts +7 -0
- package/dist/server/mcp-server.js +49 -13
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/runtime.js +21 -1
- package/dist/server/runtime.js.map +1 -1
- package/dist/server/skill-prompts.d.ts +16 -0
- package/dist/server/skill-prompts.js +22 -0
- package/dist/server/skill-prompts.js.map +1 -0
- package/dist/sessions/session-load.d.ts +16 -0
- package/dist/sessions/session-load.js +64 -20
- package/dist/sessions/session-load.js.map +1 -1
- package/dist/sessions/session.d.ts +9 -0
- package/dist/sessions/session.js +8 -0
- package/dist/sessions/session.js.map +1 -1
- package/dist/surface/action-signature.js +9 -0
- package/dist/surface/action-signature.js.map +1 -1
- package/dist/surface/category-state.d.ts +119 -0
- package/dist/surface/category-state.js +232 -0
- package/dist/surface/category-state.js.map +1 -0
- package/dist/surface/context/call-envelope.d.ts +7 -0
- package/dist/surface/context/call-envelope.js +11 -0
- package/dist/surface/context/call-envelope.js.map +1 -1
- package/dist/surface/context/instructions.d.ts +2 -0
- package/dist/surface/context/instructions.js +20 -10
- package/dist/surface/context/instructions.js.map +1 -1
- package/dist/surface/context/micro-context.d.ts +7 -0
- package/dist/surface/context/micro-context.js +70 -14
- package/dist/surface/context/micro-context.js.map +1 -1
- package/dist/surface/context/tool-search.js +6 -2
- package/dist/surface/context/tool-search.js.map +1 -1
- package/dist/surface/epic-engines.d.ts +24 -0
- package/dist/surface/epic-engines.js +32 -0
- package/dist/surface/epic-engines.js.map +1 -0
- package/dist/surface/epic-input.d.ts +27 -2
- package/dist/surface/epic-input.js +39 -2
- package/dist/surface/epic-input.js.map +1 -1
- package/dist/surface/epic-surface.d.ts +15 -17
- package/dist/surface/epic-surface.js +13 -57
- package/dist/surface/epic-surface.js.map +1 -1
- package/dist/surface/registered-surface.d.ts +21 -4
- package/dist/surface/registered-surface.js +67 -23
- package/dist/surface/registered-surface.js.map +1 -1
- package/dist/surface/schemas.d.ts +8 -0
- package/dist/surface/schemas.js +14 -3
- package/dist/surface/schemas.js.map +1 -1
- package/dist/tool-counts.json +38 -31
- package/dist/tools/ai-assistant-wait.d.ts +17 -0
- package/dist/tools/ai-assistant-wait.js +45 -0
- package/dist/tools/ai-assistant-wait.js.map +1 -0
- package/dist/tools/animation.js +14 -8
- package/dist/tools/animation.js.map +1 -1
- package/dist/tools/asset.js +18 -5
- package/dist/tools/asset.js.map +1 -1
- package/dist/tools/audio.js +3 -0
- package/dist/tools/audio.js.map +1 -1
- package/dist/tools/blueprint.js +7 -0
- package/dist/tools/blueprint.js.map +1 -1
- package/dist/tools/canvas-results.d.ts +32 -0
- package/dist/tools/canvas-results.js +137 -0
- package/dist/tools/canvas-results.js.map +1 -0
- package/dist/tools/canvas.d.ts +19 -0
- package/dist/tools/canvas.js +254 -0
- package/dist/tools/canvas.js.map +1 -0
- package/dist/tools/chooser.js +42 -6
- package/dist/tools/chooser.js.map +1 -1
- package/dist/tools/demo.js +2 -2
- package/dist/tools/demo.js.map +1 -1
- package/dist/tools/editor/batch.js +1 -1
- package/dist/tools/editor/batch.js.map +1 -1
- package/dist/tools/editor-csv-profile.d.ts +62 -0
- package/dist/tools/editor-csv-profile.js +266 -0
- package/dist/tools/editor-csv-profile.js.map +1 -0
- package/dist/tools/editor.js +41 -12
- package/dist/tools/editor.js.map +1 -1
- package/dist/tools/epic/animation.generated.d.ts +1 -1
- package/dist/tools/epic/animation.generated.js +5051 -695
- package/dist/tools/epic/animation.generated.js.map +1 -1
- package/dist/tools/epic/asset.generated.d.ts +1 -1
- package/dist/tools/epic/asset.generated.js +848 -156
- package/dist/tools/epic/asset.generated.js.map +1 -1
- package/dist/tools/epic/audio.generated.d.ts +6 -0
- package/dist/tools/epic/audio.generated.js +323 -0
- package/dist/tools/epic/audio.generated.js.map +1 -0
- package/dist/tools/epic/blueprint.generated.d.ts +1 -1
- package/dist/tools/epic/blueprint.generated.js +467 -118
- package/dist/tools/epic/blueprint.generated.js.map +1 -1
- package/dist/tools/epic/catalog-engines.d.ts +2 -0
- package/dist/tools/epic/catalog-engines.js +4 -0
- package/dist/tools/epic/catalog-engines.js.map +1 -0
- package/dist/tools/epic/conversation.generated.js +11 -11
- package/dist/tools/epic/conversation.generated.js.map +1 -1
- package/dist/tools/epic/dataflow.generated.d.ts +1 -1
- package/dist/tools/epic/dataflow.generated.js +349 -29
- package/dist/tools/epic/dataflow.generated.js.map +1 -1
- package/dist/tools/epic/editor.generated.d.ts +1 -1
- package/dist/tools/epic/editor.generated.js +575 -41
- package/dist/tools/epic/editor.generated.js.map +1 -1
- package/dist/tools/epic/effects.d.ts +9 -3
- package/dist/tools/epic/effects.js +3384 -33
- package/dist/tools/epic/effects.js.map +1 -1
- package/dist/tools/epic/epic.generated.d.ts +1 -1
- package/dist/tools/epic/epic.generated.js +68 -10
- package/dist/tools/epic/epic.generated.js.map +1 -1
- package/dist/tools/epic/gameplay.generated.d.ts +1 -1
- package/dist/tools/epic/gameplay.generated.js +502 -45
- package/dist/tools/epic/gameplay.generated.js.map +1 -1
- package/dist/tools/epic/gas.generated.d.ts +1 -1
- package/dist/tools/epic/gas.generated.js +29 -21
- package/dist/tools/epic/gas.generated.js.map +1 -1
- package/dist/tools/epic/index.d.ts +4 -0
- package/dist/tools/epic/index.js +4 -0
- package/dist/tools/epic/index.js.map +1 -1
- package/dist/tools/epic/level.generated.d.ts +1 -1
- package/dist/tools/epic/level.generated.js +524 -95
- package/dist/tools/epic/level.generated.js.map +1 -1
- package/dist/tools/epic/material.generated.d.ts +1 -1
- package/dist/tools/epic/material.generated.js +152 -76
- package/dist/tools/epic/material.generated.js.map +1 -1
- package/dist/tools/epic/niagara.generated.d.ts +1 -1
- package/dist/tools/epic/niagara.generated.js +124 -115
- package/dist/tools/epic/niagara.generated.js.map +1 -1
- package/dist/tools/epic/pcg.generated.d.ts +1 -1
- package/dist/tools/epic/pcg.generated.js +322 -47
- package/dist/tools/epic/pcg.generated.js.map +1 -1
- package/dist/tools/epic/plugins.generated.d.ts +1 -1
- package/dist/tools/epic/plugins.generated.js +143 -36
- package/dist/tools/epic/plugins.generated.js.map +1 -1
- package/dist/tools/epic/project.generated.d.ts +1 -1
- package/dist/tools/epic/project.generated.js +144 -31
- package/dist/tools/epic/project.generated.js.map +1 -1
- package/dist/tools/epic/reflection.generated.d.ts +1 -1
- package/dist/tools/epic/reflection.generated.js +33 -16
- package/dist/tools/epic/reflection.generated.js.map +1 -1
- package/dist/tools/epic/source_control.generated.d.ts +6 -0
- package/dist/tools/epic/source_control.generated.js +260 -0
- package/dist/tools/epic/source_control.generated.js.map +1 -0
- package/dist/tools/epic/statetree.generated.d.ts +1 -1
- package/dist/tools/epic/statetree.generated.js +292 -20
- package/dist/tools/epic/statetree.generated.js.map +1 -1
- package/dist/tools/epic/toolset-routes.d.ts +6 -0
- package/dist/tools/epic/toolset-routes.js +74 -0
- package/dist/tools/epic/toolset-routes.js.map +1 -0
- package/dist/tools/epic/widget.generated.d.ts +1 -1
- package/dist/tools/epic/widget.generated.js +797 -85
- package/dist/tools/epic/widget.generated.js.map +1 -1
- package/dist/tools/epic.js +22 -4
- package/dist/tools/epic.js.map +1 -1
- package/dist/tools/gameplay.js +10 -0
- package/dist/tools/gameplay.js.map +1 -1
- package/dist/tools/graph-diagrams.d.ts +15 -0
- package/dist/tools/graph-diagrams.js +153 -0
- package/dist/tools/graph-diagrams.js.map +1 -0
- package/dist/tools/landscape.js +12 -1
- package/dist/tools/landscape.js.map +1 -1
- package/dist/tools/level.js +35 -1
- package/dist/tools/level.js.map +1 -1
- package/dist/tools/material.js +7 -1
- package/dist/tools/material.js.map +1 -1
- package/dist/tools/networking.js +1 -0
- package/dist/tools/networking.js.map +1 -1
- package/dist/tools/pcg.js +8 -1
- package/dist/tools/pcg.js.map +1 -1
- package/dist/tools/project/categories.d.ts +74 -0
- package/dist/tools/project/categories.js +405 -0
- package/dist/tools/project/categories.js.map +1 -0
- package/dist/tools/project/config.js +93 -0
- package/dist/tools/project/config.js.map +1 -1
- package/dist/tools/project/leases.d.ts +8 -0
- package/dist/tools/project/leases.js +107 -0
- package/dist/tools/project/leases.js.map +1 -0
- package/dist/tools/project/localization.d.ts +7 -0
- package/dist/tools/project/localization.js +21 -0
- package/dist/tools/project/localization.js.map +1 -0
- package/dist/tools/project/sessions.js +29 -1
- package/dist/tools/project/sessions.js.map +1 -1
- package/dist/tools/project.js +25 -4
- package/dist/tools/project.js.map +1 -1
- package/dist/tools/source_control.js +3 -0
- package/dist/tools/source_control.js.map +1 -1
- package/dist/tools/specs/animation.generated.js +3 -3
- package/dist/tools/specs/animation.generated.js.map +1 -1
- package/dist/tools/specs/asset.generated.js +223 -12
- package/dist/tools/specs/asset.generated.js.map +1 -1
- package/dist/tools/specs/chooser.generated.js +1039 -63
- package/dist/tools/specs/chooser.generated.js.map +1 -1
- package/dist/tools/specs/demo.generated.js +11 -3
- package/dist/tools/specs/demo.generated.js.map +1 -1
- package/dist/tools/specs/editor.generated.js +444 -15
- package/dist/tools/specs/editor.generated.js.map +1 -1
- package/dist/tools/specs/epic.generated.js +215 -3
- package/dist/tools/specs/epic.generated.js.map +1 -1
- package/dist/tools/specs/gameplay.generated.js +175 -4
- package/dist/tools/specs/gameplay.generated.js.map +1 -1
- package/dist/tools/specs/landscape.generated.js +483 -7
- package/dist/tools/specs/landscape.generated.js.map +1 -1
- package/dist/tools/specs/level.generated.js +1218 -68
- package/dist/tools/specs/level.generated.js.map +1 -1
- package/dist/tools/specs/networking.generated.js +83 -0
- package/dist/tools/specs/networking.generated.js.map +1 -1
- package/dist/tools/specs/pcg.generated.js +125 -5
- package/dist/tools/specs/pcg.generated.js.map +1 -1
- package/dist/tools/specs/project.generated.js +134 -0
- package/dist/tools/specs/project.generated.js.map +1 -1
- package/dist/tools/specs/statetree.generated.js +245 -9
- package/dist/tools/specs/statetree.generated.js.map +1 -1
- package/dist/tools/specs/widget.generated.js +362 -3
- package/dist/tools/specs/widget.generated.js.map +1 -1
- package/dist/tools/statetree.js +12 -1
- package/dist/tools/statetree.js.map +1 -1
- package/dist/tools/widget.js +12 -0
- package/dist/tools/widget.js.map +1 -1
- package/dist/tools.js +2 -0
- package/dist/tools.js.map +1 -1
- package/dist/ue-mcp.default.yml +14785 -983
- package/package.json +4 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgePortConfig.cpp +56 -4
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeRequestContext.h +54 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeServer.cpp +203 -18
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/BridgeServer.h +42 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/HandlerCatalog.cpp +6 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/HandlerDeferred.cpp +225 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/HandlerLevelSwitch.h +123 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/HandlerScriptErrors.h +44 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Animation/AnimationHandlers.cpp +7 -7
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.cpp +15 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers.h +9 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_Import.cpp +147 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_Redirectors.cpp +11 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Asset/AssetHandlers_SemanticSearch.cpp +435 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Chooser/ChooserHandlers.cpp +363 -331
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Chooser/ChooserHandlers.h +30 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Chooser/ChooserHandlers_Authoring.cpp +2178 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Chooser/HandlerChooserShared.h +1005 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Demo/DemoHandlers.cpp +104 -11
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Demo/DemoHandlers.h +19 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Dialog/DialogHandlers.cpp +54 -2
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Dialog/DialogHandlers.h +9 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers.cpp +31 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers.h +15 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_CsvProfile.cpp +272 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_MapCheck.cpp +197 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_Profiling.cpp +11 -16
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_PythonPaths.cpp +237 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Editor/EditorHandlers_TraceAnalysis.cpp +790 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers.cpp +201 -56
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers.h +30 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_AIAssistant.cpp +510 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_MCP.cpp +394 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/EpicHandlers_Toolsets.cpp +542 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Epic/MCPAIAssistantListener.h +19 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Gas/GasHandlers_Runtime.cpp +10 -7
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers.cpp +9 -23
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers.h +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers_Sculpt.cpp +7 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers_Splines.cpp +1253 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Landscape/LandscapeHandlers_Splines.h +39 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelGeneratorRecords.h +84 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.cpp +57 -12
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers.h +33 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Blockout.cpp +987 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_Blockout.h +23 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_PerfAudit.cpp +925 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_ReplaceActors.cpp +387 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_SplineGen.cpp +813 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_SplineGen.h +22 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Level/LevelHandlers_WorldPartitionSubsystem.cpp +1238 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Localization/LocalizationHandlers.cpp +982 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Localization/LocalizationHandlers.h +32 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/MachineLearning/MachineLearningHandlers.cpp +44 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/MachineLearning/MachineLearningHandlers.h +29 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/MachineLearning/MachineLearningHandlers_LearningAgents.cpp +491 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/MachineLearning/MachineLearningHandlers_NNE.cpp +532 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Networking/NetworkingHandlers.cpp +14 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Networking/NetworkingHandlers.h +2 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Networking/NetworkingHandlers_Audit.cpp +496 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGEdgeValidation.h +150 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers.cpp +26 -1
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers.h +5 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers_CustomHLSL.cpp +290 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/PCG/PCGHandlers_LevelToAsset.cpp +34 -3
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Sequencer/MovieRenderQueueHandlers.cpp +1215 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Sequencer/MovieRenderQueueHandlers.h +27 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/StateTree/StateTreeHandlers.cpp +72 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/StateTree/StateTreeHandlers.h +11 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/StateTree/StateTreeHandlers_NodesAndBindings.cpp +1172 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers.cpp +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers_MVVM.cpp +396 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Handlers/Widget/WidgetHandlers_MVVM.h +32 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/DialogBlockingWindowTests.cpp +74 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Private/Tests/HandlerSpecContractTests.cpp +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Public/HandlerDeferred.h +76 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Public/HandlerEngineVersion.h +4 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Public/HandlerMVVMBackend.h +92 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/Public/HandlerStaticInvoke.h +96 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_Bridge/UE_MCP_Bridge.Build.cs +75 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeMVVM/Private/UE_MCP_BridgeMVVMModule.cpp +1277 -0
- package/plugin/ue_mcp_bridge/Source/UE_MCP_BridgeMVVM/UE_MCP_BridgeMVVM.Build.cs +58 -0
- package/plugin/ue_mcp_bridge/UE_MCP_Bridge.uplugin +7 -2
- package/skills/ue-mcp-animation/SKILL.md +4 -4
- package/skills/ue-mcp-epic-routing/SKILL.md +4 -0
|
@@ -0,0 +1,982 @@
|
|
|
1
|
+
// Localization targets, cultures, gather/compile and FText keys. See
|
|
2
|
+
// LocalizationHandlers.h.
|
|
3
|
+
//
|
|
4
|
+
// A gather and a compile run the GatherText commandlet in a separate process
|
|
5
|
+
// through FLocalizationCommandletProcess, with the config the Localization
|
|
6
|
+
// Dashboard generates for the target, exactly as the dashboard's Gather Text
|
|
7
|
+
// and Compile Text buttons do. The dashboard shows a modal window while it
|
|
8
|
+
// waits; these answer the bridge request when the process exits instead.
|
|
9
|
+
|
|
10
|
+
#include "LocalizationHandlers.h"
|
|
11
|
+
#include "HandlerRegistry.h"
|
|
12
|
+
#include "HandlerUtils.h"
|
|
13
|
+
#include "HandlerDeferred.h"
|
|
14
|
+
#include "Handlers/Widget/WidgetGuidMap.h"
|
|
15
|
+
#include "Blueprint/WidgetTree.h"
|
|
16
|
+
#include "Components/Widget.h"
|
|
17
|
+
#include "Containers/Ticker.h"
|
|
18
|
+
#include "HAL/FileManager.h"
|
|
19
|
+
#include "HAL/PlatformProcess.h"
|
|
20
|
+
#include "Internationalization/Culture.h"
|
|
21
|
+
#include "Internationalization/Internationalization.h"
|
|
22
|
+
#include "Internationalization/StringTable.h"
|
|
23
|
+
#include "Internationalization/StringTableCore.h"
|
|
24
|
+
#include "Internationalization/TextLocalizationManager.h"
|
|
25
|
+
#include "Internationalization/TextNamespaceUtil.h"
|
|
26
|
+
#include "Internationalization/TextPackageNamespaceUtil.h"
|
|
27
|
+
#include "Kismet2/BlueprintEditorUtils.h"
|
|
28
|
+
#include "LocalizationCommandletExecution.h"
|
|
29
|
+
#include "LocalizationConfigurationScript.h"
|
|
30
|
+
#include "LocalizationDelegates.h"
|
|
31
|
+
#include "LocalizationSettings.h"
|
|
32
|
+
#include "LocalizationTargetTypes.h"
|
|
33
|
+
#include "Misc/ConfigCacheIni.h"
|
|
34
|
+
#include "Misc/Paths.h"
|
|
35
|
+
#include "WidgetBlueprint.h"
|
|
36
|
+
|
|
37
|
+
// ── Targets ──────────────────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
/** A target by name, game targets first. Engine targets only when asked. */
|
|
40
|
+
static ULocalizationTarget* MCPLocFindTarget(const FString& Name, bool bIncludeEngine)
|
|
41
|
+
{
|
|
42
|
+
TArray<ULocalizationTargetSet*> Sets = { ULocalizationSettings::GetGameTargetSet() };
|
|
43
|
+
if (bIncludeEngine) Sets.Add(ULocalizationSettings::GetEngineTargetSet());
|
|
44
|
+
for (ULocalizationTargetSet* Set : Sets)
|
|
45
|
+
{
|
|
46
|
+
if (!Set) continue;
|
|
47
|
+
for (ULocalizationTarget* Target : Set->TargetObjects)
|
|
48
|
+
{
|
|
49
|
+
if (Target && Target->Settings.Name.Equals(Name, ESearchCase::IgnoreCase)) return Target;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return nullptr;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static TArray<TSharedPtr<FJsonValue>> MCPLocStrings(const TArray<FString>& Values)
|
|
56
|
+
{
|
|
57
|
+
TArray<TSharedPtr<FJsonValue>> Out;
|
|
58
|
+
for (const FString& Value : Values) Out.Add(MakeShared<FJsonValueString>(Value));
|
|
59
|
+
return Out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static FString MCPLocNativeCulture(const FLocalizationTargetSettings& Settings)
|
|
63
|
+
{
|
|
64
|
+
return Settings.SupportedCulturesStatistics.IsValidIndex(Settings.NativeCultureIndex)
|
|
65
|
+
? Settings.SupportedCulturesStatistics[Settings.NativeCultureIndex].CultureName
|
|
66
|
+
: FString();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static TSharedPtr<FJsonObject> MCPLocFileEntry(const FString& Path)
|
|
70
|
+
{
|
|
71
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
72
|
+
const FString Full = FPaths::ConvertRelativePathToFull(Path);
|
|
73
|
+
Out->SetStringField(TEXT("path"), Full);
|
|
74
|
+
const int64 Size = IFileManager::Get().FileSize(*Full);
|
|
75
|
+
Out->SetBoolField(TEXT("exists"), Size >= 0);
|
|
76
|
+
if (Size >= 0)
|
|
77
|
+
{
|
|
78
|
+
Out->SetNumberField(TEXT("bytes"), static_cast<double>(Size));
|
|
79
|
+
Out->SetStringField(TEXT("modified"), IFileManager::Get().GetTimeStamp(*Full).ToIso8601());
|
|
80
|
+
}
|
|
81
|
+
return Out;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The parameters set_localization_target takes to put a target back to Settings. */
|
|
85
|
+
static TSharedPtr<FJsonObject> MCPLocTargetToSetParams(const FLocalizationTargetSettings& Settings)
|
|
86
|
+
{
|
|
87
|
+
TSharedPtr<FJsonObject> Out = MakeShared<FJsonObject>();
|
|
88
|
+
Out->SetStringField(TEXT("target"), Settings.Name);
|
|
89
|
+
TArray<FString> Cultures;
|
|
90
|
+
for (const FCultureStatistics& Culture : Settings.SupportedCulturesStatistics) Cultures.Add(Culture.CultureName);
|
|
91
|
+
Out->SetArrayField(TEXT("cultures"), MCPLocStrings(Cultures));
|
|
92
|
+
Out->SetStringField(TEXT("nativeCulture"), MCPLocNativeCulture(Settings));
|
|
93
|
+
Out->SetBoolField(TEXT("gatherFromPackages"), Settings.GatherFromPackages.IsEnabled);
|
|
94
|
+
TArray<FString> Include;
|
|
95
|
+
for (const FGatherTextIncludePath& Path : Settings.GatherFromPackages.IncludePathWildcards) Include.Add(Path.Pattern);
|
|
96
|
+
Out->SetArrayField(TEXT("includePaths"), MCPLocStrings(Include));
|
|
97
|
+
TArray<FString> Exclude;
|
|
98
|
+
for (const FGatherTextExcludePath& Path : Settings.GatherFromPackages.ExcludePathWildcards) Exclude.Add(Path.Pattern);
|
|
99
|
+
Out->SetArrayField(TEXT("excludePaths"), MCPLocStrings(Exclude));
|
|
100
|
+
Out->SetBoolField(TEXT("gatherFromTextFiles"), Settings.GatherFromTextFiles.IsEnabled);
|
|
101
|
+
TArray<FString> Directories;
|
|
102
|
+
for (const FGatherTextSearchDirectory& Directory : Settings.GatherFromTextFiles.SearchDirectories) Directories.Add(Directory.Path);
|
|
103
|
+
Out->SetArrayField(TEXT("searchDirectories"), MCPLocStrings(Directories));
|
|
104
|
+
return Out;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static TSharedPtr<FJsonObject> MCPLocDescribeTarget(const ULocalizationTarget* Target)
|
|
108
|
+
{
|
|
109
|
+
const FLocalizationTargetSettings& Settings = Target->Settings;
|
|
110
|
+
TSharedPtr<FJsonObject> Out = MCPLocTargetToSetParams(Settings);
|
|
111
|
+
Out->SetStringField(TEXT("guid"), Settings.Guid.ToString(EGuidFormats::DigitsWithHyphens));
|
|
112
|
+
Out->SetBoolField(TEXT("engineTarget"), Target->IsMemberOfEngineTargetSet());
|
|
113
|
+
Out->SetBoolField(TEXT("gatherFromMetaData"), Settings.GatherFromMetaData.IsEnabled);
|
|
114
|
+
Out->SetStringField(TEXT("conflictStatus"), StaticEnum<ELocalizationTargetConflictStatus>()->GetNameStringByValue(static_cast<int64>(Settings.ConflictStatus)));
|
|
115
|
+
|
|
116
|
+
TArray<TSharedPtr<FJsonValue>> Cultures;
|
|
117
|
+
TArray<TSharedPtr<FJsonValue>> Archives;
|
|
118
|
+
TArray<TSharedPtr<FJsonValue>> LocRes;
|
|
119
|
+
for (const FCultureStatistics& Culture : Settings.SupportedCulturesStatistics)
|
|
120
|
+
{
|
|
121
|
+
TSharedPtr<FJsonObject> Row = MakeShared<FJsonObject>();
|
|
122
|
+
Row->SetStringField(TEXT("culture"), Culture.CultureName);
|
|
123
|
+
Row->SetNumberField(TEXT("wordCount"), Culture.WordCount);
|
|
124
|
+
Cultures.Add(MakeShared<FJsonValueObject>(Row));
|
|
125
|
+
|
|
126
|
+
TSharedPtr<FJsonObject> Archive = MCPLocFileEntry(LocalizationConfigurationScript::GetArchivePath(Target, Culture.CultureName));
|
|
127
|
+
Archive->SetStringField(TEXT("culture"), Culture.CultureName);
|
|
128
|
+
Archives.Add(MakeShared<FJsonValueObject>(Archive));
|
|
129
|
+
TSharedPtr<FJsonObject> Resource = MCPLocFileEntry(LocalizationConfigurationScript::GetLocResPath(Target, Culture.CultureName));
|
|
130
|
+
Resource->SetStringField(TEXT("culture"), Culture.CultureName);
|
|
131
|
+
LocRes.Add(MakeShared<FJsonValueObject>(Resource));
|
|
132
|
+
}
|
|
133
|
+
Out->SetArrayField(TEXT("cultureStatistics"), Cultures);
|
|
134
|
+
|
|
135
|
+
TSharedPtr<FJsonObject> Files = MakeShared<FJsonObject>();
|
|
136
|
+
Files->SetStringField(TEXT("gatherConfig"), FPaths::ConvertRelativePathToFull(LocalizationConfigurationScript::GetGatherTextConfigPath(Target)));
|
|
137
|
+
Files->SetStringField(TEXT("compileConfig"), FPaths::ConvertRelativePathToFull(LocalizationConfigurationScript::GetCompileTextConfigPath(Target)));
|
|
138
|
+
Files->SetObjectField(TEXT("manifest"), MCPLocFileEntry(LocalizationConfigurationScript::GetManifestPath(Target)));
|
|
139
|
+
Files->SetArrayField(TEXT("archives"), Archives);
|
|
140
|
+
Files->SetArrayField(TEXT("locres"), LocRes);
|
|
141
|
+
Out->SetObjectField(TEXT("files"), Files);
|
|
142
|
+
return Out;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static bool MCPLocValidTargetName(const FString& Name)
|
|
146
|
+
{
|
|
147
|
+
if (Name.IsEmpty() || Name.Len() > 64) return false;
|
|
148
|
+
for (const TCHAR Ch : Name)
|
|
149
|
+
{
|
|
150
|
+
if (!FChar::IsAlnum(Ch) && Ch != TEXT('_') && Ch != TEXT('-')) return false;
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static bool MCPLocReadStringArray(const TSharedPtr<FJsonObject>& Params, const TCHAR* Key, bool& bOutGiven, TArray<FString>& Out, FString& OutError)
|
|
156
|
+
{
|
|
157
|
+
const TArray<TSharedPtr<FJsonValue>>* Values = nullptr;
|
|
158
|
+
bOutGiven = TryGetArrayParam(Params, Key, Values) && Values;
|
|
159
|
+
if (!bOutGiven) return true;
|
|
160
|
+
for (const TSharedPtr<FJsonValue>& Value : *Values)
|
|
161
|
+
{
|
|
162
|
+
FString Text;
|
|
163
|
+
if (!Value.IsValid() || !Value->TryGetString(Text))
|
|
164
|
+
{
|
|
165
|
+
OutError = FString::Printf(TEXT("%s has to be an array of strings."), Key);
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
Out.Add(Text);
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
static void MCPLocPersistTargets()
|
|
174
|
+
{
|
|
175
|
+
// The target set copies its objects back into the config-backed settings
|
|
176
|
+
// and writes DefaultEditor.ini, the way an edit in Project Settings does.
|
|
177
|
+
if (ULocalizationTargetSet* GameSet = ULocalizationSettings::GetGameTargetSet())
|
|
178
|
+
{
|
|
179
|
+
GameSet->PostEditChange();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ── Commandlet runs ──────────────────────────────────────────────────────────
|
|
184
|
+
|
|
185
|
+
struct FMCPLocRunState
|
|
186
|
+
{
|
|
187
|
+
TSharedPtr<FLocalizationCommandletProcess> Process;
|
|
188
|
+
TWeakObjectPtr<ULocalizationTarget> Target;
|
|
189
|
+
FString TargetName;
|
|
190
|
+
FString Step;
|
|
191
|
+
FString Culture;
|
|
192
|
+
FString ConfigPath;
|
|
193
|
+
FString Log;
|
|
194
|
+
double StartSeconds = 0.0;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
static bool& MCPLocRunActive()
|
|
198
|
+
{
|
|
199
|
+
static bool bActive = false;
|
|
200
|
+
return bActive;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Drain the pipe. True while the process is running or still has output. */
|
|
204
|
+
static bool MCPLocPump(FMCPLocRunState& State)
|
|
205
|
+
{
|
|
206
|
+
const FString Chunk = FPlatformProcess::ReadPipe(State.Process->GetReadPipe());
|
|
207
|
+
if (!Chunk.IsEmpty())
|
|
208
|
+
{
|
|
209
|
+
State.Log += Chunk;
|
|
210
|
+
// The tail is what is reported; keep memory bounded on a long gather.
|
|
211
|
+
constexpr int32 MaxLog = 512 * 1024;
|
|
212
|
+
if (State.Log.Len() > MaxLog) State.Log.RightChopInline(State.Log.Len() - MaxLog);
|
|
213
|
+
}
|
|
214
|
+
return FPlatformProcess::IsProcRunning(State.Process->GetHandle()) || !Chunk.IsEmpty();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Write the target's config for Step, start the commandlet, and answer when it
|
|
219
|
+
* exits. Step is "gather" or "compile"; Culture narrows a compile to one culture.
|
|
220
|
+
*/
|
|
221
|
+
static TSharedPtr<FJsonValue> MCPLocRunCommandlet(ULocalizationTarget* Target, const FString& Step, const FString& Culture)
|
|
222
|
+
{
|
|
223
|
+
if (MCPLocRunActive())
|
|
224
|
+
{
|
|
225
|
+
return MCPError(TEXT("A localization gather or compile is already running. Wait for it to answer, then run this one."));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
FString ConfigPath;
|
|
229
|
+
bool bWritten = false;
|
|
230
|
+
if (Step == TEXT("gather"))
|
|
231
|
+
{
|
|
232
|
+
ConfigPath = LocalizationConfigurationScript::GetGatherTextConfigPath(Target);
|
|
233
|
+
bWritten = LocalizationConfigurationScript::GenerateGatherTextConfigFile(Target).WriteWithSCC(ConfigPath);
|
|
234
|
+
}
|
|
235
|
+
else
|
|
236
|
+
{
|
|
237
|
+
const TOptional<FString> CultureName = Culture.IsEmpty() ? TOptional<FString>() : TOptional<FString>(Culture);
|
|
238
|
+
ConfigPath = LocalizationConfigurationScript::GetCompileTextConfigPath(Target, CultureName);
|
|
239
|
+
bWritten = LocalizationConfigurationScript::GenerateCompileTextConfigFile(Target, CultureName).WriteWithSCC(ConfigPath);
|
|
240
|
+
}
|
|
241
|
+
if (!bWritten)
|
|
242
|
+
{
|
|
243
|
+
return MCPError(FString::Printf(TEXT("Could not write the %s config for target '%s' to %s. Check the file is writable (or checked out)."),
|
|
244
|
+
*Step, *Target->Settings.Name, *FPaths::ConvertRelativePathToFull(ConfigPath)));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
TSharedPtr<FMCPLocRunState> State = MakeShared<FMCPLocRunState>();
|
|
248
|
+
State->Process = FLocalizationCommandletProcess::Execute(ConfigPath, !Target->IsMemberOfEngineTargetSet());
|
|
249
|
+
if (!State->Process.IsValid())
|
|
250
|
+
{
|
|
251
|
+
return MCPError(FString::Printf(TEXT("Could not start the GatherText commandlet for target '%s'."), *Target->Settings.Name));
|
|
252
|
+
}
|
|
253
|
+
State->Target = Target;
|
|
254
|
+
State->TargetName = Target->Settings.Name;
|
|
255
|
+
State->Step = Step;
|
|
256
|
+
State->Culture = Culture;
|
|
257
|
+
State->ConfigPath = ConfigPath;
|
|
258
|
+
State->StartSeconds = FPlatformTime::Seconds();
|
|
259
|
+
MCPLocRunActive() = true;
|
|
260
|
+
|
|
261
|
+
// Runs on the game thread once the process has exited and the pipe is empty.
|
|
262
|
+
auto Finish = [](FMCPLocRunState& Run) -> TSharedPtr<FJsonValue>
|
|
263
|
+
{
|
|
264
|
+
MCPLocRunActive() = false;
|
|
265
|
+
int32 ExitCode = -1;
|
|
266
|
+
FPlatformProcess::GetProcReturnCode(Run.Process->GetHandle(), &ExitCode);
|
|
267
|
+
|
|
268
|
+
TArray<FString> Lines;
|
|
269
|
+
Run.Log.ParseIntoArrayLines(Lines);
|
|
270
|
+
TArray<FString> Errors;
|
|
271
|
+
int32 Warnings = 0;
|
|
272
|
+
for (const FString& Line : Lines)
|
|
273
|
+
{
|
|
274
|
+
if (Line.Contains(TEXT("Error:"))) Errors.Add(Line.TrimStartAndEnd());
|
|
275
|
+
else if (Line.Contains(TEXT("Warning:"))) ++Warnings;
|
|
276
|
+
}
|
|
277
|
+
TArray<FString> Tail;
|
|
278
|
+
for (int32 Index = FMath::Max(0, Lines.Num() - 40); Index < Lines.Num(); ++Index) Tail.Add(Lines[Index]);
|
|
279
|
+
|
|
280
|
+
const bool bSucceeded = ExitCode == 0;
|
|
281
|
+
TSharedPtr<FJsonObject> Result = bSucceeded
|
|
282
|
+
? MCPSuccess()
|
|
283
|
+
: MCPErrorObject(FString::Printf(TEXT("GatherText (%s) for target '%s' exited with code %d%s"),
|
|
284
|
+
*Run.Step, *Run.TargetName, ExitCode, Errors.Num() ? *FString::Printf(TEXT(": %s"), *Errors[0]) : TEXT("; see logTail")));
|
|
285
|
+
Result->SetStringField(TEXT("target"), Run.TargetName);
|
|
286
|
+
Result->SetStringField(TEXT("step"), Run.Step);
|
|
287
|
+
if (!Run.Culture.IsEmpty()) Result->SetStringField(TEXT("culture"), Run.Culture);
|
|
288
|
+
Result->SetNumberField(TEXT("exitCode"), ExitCode);
|
|
289
|
+
Result->SetNumberField(TEXT("durationSeconds"), FPlatformTime::Seconds() - Run.StartSeconds);
|
|
290
|
+
Result->SetStringField(TEXT("configPath"), FPaths::ConvertRelativePathToFull(Run.ConfigPath));
|
|
291
|
+
Result->SetStringField(TEXT("commandletArguments"), Run.Process->GetProcessArguments());
|
|
292
|
+
Result->SetArrayField(TEXT("errors"), MCPLocStrings(Errors));
|
|
293
|
+
Result->SetNumberField(TEXT("warningCount"), Warnings);
|
|
294
|
+
Result->SetArrayField(TEXT("logTail"), MCPLocStrings(Tail));
|
|
295
|
+
|
|
296
|
+
if (ULocalizationTarget* Target = Run.Target.Get())
|
|
297
|
+
{
|
|
298
|
+
if (Run.Step == TEXT("gather"))
|
|
299
|
+
{
|
|
300
|
+
Target->UpdateWordCountsFromCSV();
|
|
301
|
+
Target->UpdateStatusFromConflictReport();
|
|
302
|
+
}
|
|
303
|
+
else
|
|
304
|
+
{
|
|
305
|
+
// Pick the new LocRes up in this editor session.
|
|
306
|
+
FTextLocalizationManager::Get().RefreshResources();
|
|
307
|
+
}
|
|
308
|
+
const FString ContentPath = FPaths::Combine(Target->IsMemberOfEngineTargetSet() ? FPaths::EngineContentDir() : FPaths::ProjectContentDir(), TEXT("Localization"), Target->Settings.Name);
|
|
309
|
+
LocalizationDelegates::OnLocalizationTargetDataUpdated.Broadcast(ContentPath);
|
|
310
|
+
Result->SetObjectField(TEXT("targetState"), MCPLocDescribeTarget(Target));
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
Result->SetBoolField(TEXT("changed"), bSucceeded);
|
|
314
|
+
MCPSetNoRollback(Result, Run.Step == TEXT("gather")
|
|
315
|
+
? TEXT("A gather rewrites the target's manifest, archives and word-count report in place. The previous files are not kept, so no call restores them; recover them from source control.")
|
|
316
|
+
: TEXT("A compile rewrites the target's LocRes files from its archives. The previous files are not kept; compiling again from unchanged archives reproduces them."));
|
|
317
|
+
return MCPResult(Result);
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const FMCPDeferredCallPtr Deferred = MCPDeferRequest();
|
|
321
|
+
if (!Deferred)
|
|
322
|
+
{
|
|
323
|
+
// Called in-process: wait here.
|
|
324
|
+
while (MCPLocPump(*State))
|
|
325
|
+
{
|
|
326
|
+
FPlatformProcess::Sleep(0.05f);
|
|
327
|
+
}
|
|
328
|
+
return Finish(*State);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
Deferred->SetCancelNote(TEXT("The commandlet process was terminated. Files it had already written stay as they are."));
|
|
332
|
+
Deferred->OnCancel([State](const FString&)
|
|
333
|
+
{
|
|
334
|
+
if (State->Process.IsValid() && FPlatformProcess::IsProcRunning(State->Process->GetHandle()))
|
|
335
|
+
{
|
|
336
|
+
FPlatformProcess::TerminateProc(State->Process->GetHandle(), true);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
FTSTicker::GetCoreTicker().AddTicker(FTickerDelegate::CreateLambda([State, Deferred, Finish](float) -> bool
|
|
340
|
+
{
|
|
341
|
+
if (MCPLocPump(*State)) return true;
|
|
342
|
+
TSharedPtr<FJsonValue> Answer = Finish(*State);
|
|
343
|
+
if (!Deferred->IsCancelled()) Deferred->Complete(Answer);
|
|
344
|
+
return false;
|
|
345
|
+
}), 0.1f);
|
|
346
|
+
return MCPDeferredMarker();
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// ── FText properties ─────────────────────────────────────────────────────────
|
|
350
|
+
|
|
351
|
+
/** The object whose property is edited: a widget in a Widget Blueprint's tree, a Blueprint's CDO, or the asset. */
|
|
352
|
+
static UObject* MCPLocResolveTextOwner(UObject* Asset, const FString& WidgetName, FString& OutError)
|
|
353
|
+
{
|
|
354
|
+
if (!WidgetName.IsEmpty())
|
|
355
|
+
{
|
|
356
|
+
UWidgetBlueprint* WidgetBP = Cast<UWidgetBlueprint>(Asset);
|
|
357
|
+
if (!WidgetBP)
|
|
358
|
+
{
|
|
359
|
+
OutError = FString::Printf(TEXT("widgetName needs a Widget Blueprint; %s is a %s."), *Asset->GetPathName(), *Asset->GetClass()->GetName());
|
|
360
|
+
return nullptr;
|
|
361
|
+
}
|
|
362
|
+
UWidget* Widget = WidgetBP->WidgetTree ? WidgetBP->WidgetTree->FindWidget(FName(*WidgetName)) : nullptr;
|
|
363
|
+
if (!Widget)
|
|
364
|
+
{
|
|
365
|
+
OutError = FString::Printf(TEXT("No widget named '%s' in %s."), *WidgetName, *Asset->GetPathName());
|
|
366
|
+
}
|
|
367
|
+
return Widget;
|
|
368
|
+
}
|
|
369
|
+
if (UBlueprint* Blueprint = Cast<UBlueprint>(Asset))
|
|
370
|
+
{
|
|
371
|
+
UObject* Defaults = Blueprint->GeneratedClass ? Blueprint->GeneratedClass->GetDefaultObject() : nullptr;
|
|
372
|
+
if (!Defaults)
|
|
373
|
+
{
|
|
374
|
+
OutError = FString::Printf(TEXT("Blueprint %s has no generated class yet; compile it first."), *Asset->GetPathName());
|
|
375
|
+
}
|
|
376
|
+
return Defaults;
|
|
377
|
+
}
|
|
378
|
+
return Asset;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** Walk PropertyPath (dots through structs and object references) to an FText. */
|
|
382
|
+
static FText* MCPLocResolveText(UObject* Owner, const FString& PropertyPath, FString& OutError)
|
|
383
|
+
{
|
|
384
|
+
TArray<FString> Parts;
|
|
385
|
+
PropertyPath.ParseIntoArray(Parts, TEXT("."), true);
|
|
386
|
+
if (Parts.Num() == 0)
|
|
387
|
+
{
|
|
388
|
+
OutError = TEXT("propertyName is empty.");
|
|
389
|
+
return nullptr;
|
|
390
|
+
}
|
|
391
|
+
const UStruct* Struct = Owner->GetClass();
|
|
392
|
+
void* Container = Owner;
|
|
393
|
+
for (int32 Index = 0; Index < Parts.Num(); ++Index)
|
|
394
|
+
{
|
|
395
|
+
FProperty* Property = FindFProperty<FProperty>(Struct, FName(*Parts[Index]));
|
|
396
|
+
if (!Property)
|
|
397
|
+
{
|
|
398
|
+
OutError = FString::Printf(TEXT("%s has no property '%s'."), *Struct->GetName(), *Parts[Index]);
|
|
399
|
+
return nullptr;
|
|
400
|
+
}
|
|
401
|
+
void* Value = Property->ContainerPtrToValuePtr<void>(Container);
|
|
402
|
+
if (Index == Parts.Num() - 1)
|
|
403
|
+
{
|
|
404
|
+
if (!CastField<FTextProperty>(Property))
|
|
405
|
+
{
|
|
406
|
+
OutError = FString::Printf(TEXT("'%s' is a %s, not a Text property."), *PropertyPath, *Property->GetCPPType());
|
|
407
|
+
return nullptr;
|
|
408
|
+
}
|
|
409
|
+
return static_cast<FText*>(Value);
|
|
410
|
+
}
|
|
411
|
+
if (const FStructProperty* AsStruct = CastField<FStructProperty>(Property))
|
|
412
|
+
{
|
|
413
|
+
Struct = AsStruct->Struct;
|
|
414
|
+
Container = Value;
|
|
415
|
+
}
|
|
416
|
+
else if (const FObjectPropertyBase* AsObject = CastField<FObjectPropertyBase>(Property))
|
|
417
|
+
{
|
|
418
|
+
UObject* Inner = AsObject->GetObjectPropertyValue(Value);
|
|
419
|
+
if (!Inner)
|
|
420
|
+
{
|
|
421
|
+
OutError = FString::Printf(TEXT("'%s' is empty, so '%s' cannot be reached."), *Parts[Index], *PropertyPath);
|
|
422
|
+
return nullptr;
|
|
423
|
+
}
|
|
424
|
+
Struct = Inner->GetClass();
|
|
425
|
+
Container = Inner;
|
|
426
|
+
}
|
|
427
|
+
else
|
|
428
|
+
{
|
|
429
|
+
OutError = FString::Printf(TEXT("'%s' is neither a struct nor an object, so '%s' cannot be reached."), *Parts[Index], *PropertyPath);
|
|
430
|
+
return nullptr;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return nullptr;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
static void MCPLocDescribeText(const TSharedPtr<FJsonObject>& Out, const FText& Text)
|
|
437
|
+
{
|
|
438
|
+
Out->SetStringField(TEXT("text"), Text.ToString());
|
|
439
|
+
const FString* Source = FTextInspector::GetSourceString(Text);
|
|
440
|
+
Out->SetStringField(TEXT("sourceString"), Source ? *Source : Text.ToString());
|
|
441
|
+
FName TableId;
|
|
442
|
+
FString TableKey;
|
|
443
|
+
const bool bFromTable = FTextInspector::GetTableIdAndKey(Text, TableId, TableKey);
|
|
444
|
+
Out->SetBoolField(TEXT("isFromStringTable"), bFromTable);
|
|
445
|
+
Out->SetStringField(TEXT("stringTableId"), bFromTable ? TableId.ToString() : FString());
|
|
446
|
+
Out->SetStringField(TEXT("stringTableKey"), bFromTable ? TableKey : FString());
|
|
447
|
+
const TOptional<FString> Namespace = FTextInspector::GetNamespace(Text);
|
|
448
|
+
const TOptional<FString> Key = FTextInspector::GetKey(Text);
|
|
449
|
+
const FString FullNamespace = Namespace.IsSet() ? Namespace.GetValue() : FString();
|
|
450
|
+
Out->SetStringField(TEXT("namespace"), TextNamespaceUtil::StripPackageNamespace(FullNamespace));
|
|
451
|
+
Out->SetStringField(TEXT("packageNamespace"), TextNamespaceUtil::ExtractPackageNamespace(FullNamespace));
|
|
452
|
+
Out->SetStringField(TEXT("fullNamespace"), FullNamespace);
|
|
453
|
+
Out->SetStringField(TEXT("key"), Key.IsSet() ? Key.GetValue() : FString());
|
|
454
|
+
Out->SetBoolField(TEXT("isCultureInvariant"), Text.IsCultureInvariant());
|
|
455
|
+
Out->SetBoolField(TEXT("isLocalizable"), FTextInspector::ShouldGatherForLocalization(Text));
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// ── Registration ─────────────────────────────────────────────────────────────
|
|
459
|
+
|
|
460
|
+
void FLocalizationHandlers::RegisterHandlers(FMCPHandlerRegistry& Registry)
|
|
461
|
+
{
|
|
462
|
+
using EType = EMCPParamType;
|
|
463
|
+
{
|
|
464
|
+
FMCPHandlerRegistry::FCategoryScope CategoryScope(Registry, TEXT("project"));
|
|
465
|
+
Registry.RegisterHandler(TEXT("list_localization_cultures"), &ListCultures, {});
|
|
466
|
+
Registry.RegisterHandler(TEXT("list_localization_targets"), &ListTargets, {
|
|
467
|
+
MCPParam::Optional(TEXT("includeEngineTargets"), EType::Boolean, TEXT("Also list the engine's own targets (default false)")),
|
|
468
|
+
});
|
|
469
|
+
Registry.RegisterHandler(TEXT("set_localization_target"), &SetTarget, {
|
|
470
|
+
MCPParam::Required(TEXT("target"), EType::String, TEXT("Localization target name (letters, digits, _ and -); created when the project has none of that name")),
|
|
471
|
+
MCPParam::Optional(TEXT("cultures"), EType::Array, TEXT("Culture codes the target supports, e.g. [\"en\", \"fr\"]; replaces the list")).Items(EType::String),
|
|
472
|
+
MCPParam::Optional(TEXT("nativeCulture"), EType::String, TEXT("The culture source text is written in; one of cultures (default the first)")),
|
|
473
|
+
MCPParam::Optional(TEXT("gatherFromPackages"), EType::Boolean, TEXT("Gather text from assets and maps")),
|
|
474
|
+
MCPParam::Optional(TEXT("includePaths"), EType::Array, TEXT("Package path wildcards to gather from, relative to the project root, e.g. Content/UI/*; replaces the list")).Items(EType::String),
|
|
475
|
+
MCPParam::Optional(TEXT("excludePaths"), EType::Array, TEXT("Package path wildcards to skip; replaces the list")).Items(EType::String),
|
|
476
|
+
MCPParam::Optional(TEXT("gatherFromTextFiles"), EType::Boolean, TEXT("Gather LOCTEXT and NSLOCTEXT from source files")),
|
|
477
|
+
MCPParam::Optional(TEXT("searchDirectories"), EType::Array, TEXT("Source directories to gather from, relative to the project root, e.g. Source; replaces the list")).Items(EType::String),
|
|
478
|
+
});
|
|
479
|
+
Registry.RegisterHandler(TEXT("remove_localization_target"), &RemoveTarget, {
|
|
480
|
+
MCPParam::Required(TEXT("target"), EType::String, TEXT("Localization target name")),
|
|
481
|
+
MCPParam::Optional(TEXT("deleteFiles"), EType::Boolean, TEXT("Also delete its config, manifest, archives and LocRes files (default false)")),
|
|
482
|
+
});
|
|
483
|
+
Registry.RegisterHandlerWithTimeout(TEXT("gather_localization_target"), &GatherTarget, 1800.0f, {
|
|
484
|
+
MCPParam::Required(TEXT("target"), EType::String, TEXT("Localization target name")),
|
|
485
|
+
});
|
|
486
|
+
Registry.RegisterHandlerWithTimeout(TEXT("compile_localization_target"), &CompileTarget, 1800.0f, {
|
|
487
|
+
MCPParam::Required(TEXT("target"), EType::String, TEXT("Localization target name")),
|
|
488
|
+
MCPParam::Optional(TEXT("culture"), EType::String, TEXT("Compile only this culture (default every culture of the target)")),
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
{
|
|
492
|
+
FMCPHandlerRegistry::FCategoryScope CategoryScope(Registry, TEXT("asset"));
|
|
493
|
+
Registry.RegisterHandler(TEXT("get_text_localization"), &GetTextLocalization, {
|
|
494
|
+
MCPParam::Required(TEXT("assetPath"), EType::String, TEXT("Asset holding the Text property; a Blueprint means its class defaults")).Alias(TEXT("path")),
|
|
495
|
+
MCPParam::Required(TEXT("propertyName"), EType::String, TEXT("Text property, dotted through structs and object references")),
|
|
496
|
+
MCPParam::Optional(TEXT("widgetName"), EType::String, TEXT("A widget in a Widget Blueprint's tree that owns the property")),
|
|
497
|
+
});
|
|
498
|
+
Registry.RegisterHandler(TEXT("set_text_localization"), &SetTextLocalization, {
|
|
499
|
+
MCPParam::Required(TEXT("assetPath"), EType::String, TEXT("Asset holding the Text property; a Blueprint means its class defaults")).Alias(TEXT("path")),
|
|
500
|
+
MCPParam::Required(TEXT("propertyName"), EType::String, TEXT("Text property, dotted through structs and object references")),
|
|
501
|
+
MCPParam::Optional(TEXT("widgetName"), EType::String, TEXT("A widget in a Widget Blueprint's tree that owns the property")),
|
|
502
|
+
MCPParam::Optional(TEXT("namespace"), EType::String, TEXT("Text namespace, without the package marker (default the current one)")),
|
|
503
|
+
MCPParam::Optional(TEXT("key"), EType::String, TEXT("Text key (default the current one)")),
|
|
504
|
+
MCPParam::Optional(TEXT("sourceString"), EType::String, TEXT("Source string (default the current one)")),
|
|
505
|
+
MCPParam::Optional(TEXT("stringTableId"), EType::String, TEXT("Reference a string table entry instead: the table's asset path or id, with stringTableKey")),
|
|
506
|
+
MCPParam::Optional(TEXT("stringTableKey"), EType::String, TEXT("Entry key in stringTableId")),
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// ── Handlers ─────────────────────────────────────────────────────────────────
|
|
512
|
+
|
|
513
|
+
TSharedPtr<FJsonValue> FLocalizationHandlers::ListCultures(const TSharedPtr<FJsonObject>& Params)
|
|
514
|
+
{
|
|
515
|
+
FInternationalization& I18N = FInternationalization::Get();
|
|
516
|
+
auto Result = MCPSuccess();
|
|
517
|
+
Result->SetStringField(TEXT("currentCulture"), I18N.GetCurrentCulture()->GetName());
|
|
518
|
+
Result->SetStringField(TEXT("currentLanguage"), I18N.GetCurrentLanguage()->GetName());
|
|
519
|
+
Result->SetStringField(TEXT("currentLocale"), I18N.GetCurrentLocale()->GetName());
|
|
520
|
+
|
|
521
|
+
FTextLocalizationManager& Manager = FTextLocalizationManager::Get();
|
|
522
|
+
Result->SetStringField(TEXT("gameNativeCulture"), Manager.GetNativeCultureName(ELocalizedTextSourceCategory::Game));
|
|
523
|
+
Result->SetStringField(TEXT("editorNativeCulture"), Manager.GetNativeCultureName(ELocalizedTextSourceCategory::Editor));
|
|
524
|
+
Result->SetArrayField(TEXT("gameLocalizedCultures"), MCPLocStrings(Manager.GetLocalizedCultureNames(ELocalizationLoadFlags::Game)));
|
|
525
|
+
|
|
526
|
+
TArray<FString> CulturesToStage;
|
|
527
|
+
GConfig->GetArray(TEXT("/Script/UnrealEd.ProjectPackagingSettings"), TEXT("CulturesToStage"), CulturesToStage, GGameIni);
|
|
528
|
+
Result->SetArrayField(TEXT("culturesToStage"), MCPLocStrings(CulturesToStage));
|
|
529
|
+
|
|
530
|
+
TArray<FString> TargetCultures;
|
|
531
|
+
TArray<TSharedPtr<FJsonValue>> PerTarget;
|
|
532
|
+
if (const ULocalizationTargetSet* GameSet = ULocalizationSettings::GetGameTargetSet())
|
|
533
|
+
{
|
|
534
|
+
for (const ULocalizationTarget* Target : GameSet->TargetObjects)
|
|
535
|
+
{
|
|
536
|
+
if (!Target) continue;
|
|
537
|
+
TArray<FString> Cultures;
|
|
538
|
+
for (const FCultureStatistics& Culture : Target->Settings.SupportedCulturesStatistics)
|
|
539
|
+
{
|
|
540
|
+
Cultures.Add(Culture.CultureName);
|
|
541
|
+
TargetCultures.AddUnique(Culture.CultureName);
|
|
542
|
+
}
|
|
543
|
+
TSharedPtr<FJsonObject> Row = MakeShared<FJsonObject>();
|
|
544
|
+
Row->SetStringField(TEXT("target"), Target->Settings.Name);
|
|
545
|
+
Row->SetStringField(TEXT("nativeCulture"), MCPLocNativeCulture(Target->Settings));
|
|
546
|
+
Row->SetArrayField(TEXT("cultures"), MCPLocStrings(Cultures));
|
|
547
|
+
PerTarget.Add(MakeShared<FJsonValueObject>(Row));
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
TargetCultures.Sort();
|
|
551
|
+
Result->SetArrayField(TEXT("targetCultures"), MCPLocStrings(TargetCultures));
|
|
552
|
+
Result->SetArrayField(TEXT("targets"), PerTarget);
|
|
553
|
+
return MCPResult(Result);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
TSharedPtr<FJsonValue> FLocalizationHandlers::ListTargets(const TSharedPtr<FJsonObject>& Params)
|
|
557
|
+
{
|
|
558
|
+
const bool bIncludeEngine = OptionalBool(Params, TEXT("includeEngineTargets"), false);
|
|
559
|
+
TArray<TSharedPtr<FJsonValue>> Rows;
|
|
560
|
+
TArray<const ULocalizationTargetSet*> Sets = { ULocalizationSettings::GetGameTargetSet() };
|
|
561
|
+
if (bIncludeEngine) Sets.Add(ULocalizationSettings::GetEngineTargetSet());
|
|
562
|
+
for (const ULocalizationTargetSet* Set : Sets)
|
|
563
|
+
{
|
|
564
|
+
if (!Set) continue;
|
|
565
|
+
for (const ULocalizationTarget* Target : Set->TargetObjects)
|
|
566
|
+
{
|
|
567
|
+
if (Target) Rows.Add(MakeShared<FJsonValueObject>(MCPLocDescribeTarget(Target)));
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
auto Result = MCPSuccess();
|
|
571
|
+
Result->SetArrayField(TEXT("targets"), Rows);
|
|
572
|
+
Result->SetNumberField(TEXT("count"), Rows.Num());
|
|
573
|
+
return MCPResult(Result);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
TSharedPtr<FJsonValue> FLocalizationHandlers::SetTarget(const TSharedPtr<FJsonObject>& Params)
|
|
577
|
+
{
|
|
578
|
+
FString Name;
|
|
579
|
+
const TSharedPtr<FJsonValue> MissingName = RequireString(Params, TEXT("target"), Name);
|
|
580
|
+
FString ArrayError;
|
|
581
|
+
bool bCulturesGiven = false, bIncludeGiven = false, bExcludeGiven = false, bDirectoriesGiven = false;
|
|
582
|
+
TArray<FString> Cultures, Include, Exclude, Directories;
|
|
583
|
+
const bool bArraysOk =
|
|
584
|
+
MCPLocReadStringArray(Params, TEXT("cultures"), bCulturesGiven, Cultures, ArrayError)
|
|
585
|
+
&& MCPLocReadStringArray(Params, TEXT("includePaths"), bIncludeGiven, Include, ArrayError)
|
|
586
|
+
&& MCPLocReadStringArray(Params, TEXT("excludePaths"), bExcludeGiven, Exclude, ArrayError)
|
|
587
|
+
&& MCPLocReadStringArray(Params, TEXT("searchDirectories"), bDirectoriesGiven, Directories, ArrayError);
|
|
588
|
+
MCPReadParamsAhead(Params, { TEXT("cultures"), TEXT("includePaths"), TEXT("excludePaths"), TEXT("searchDirectories") });
|
|
589
|
+
FString NativeCulture;
|
|
590
|
+
const bool bNativeGiven = TryGetStringParam(Params, TEXT("nativeCulture"), NativeCulture) && !NativeCulture.IsEmpty();
|
|
591
|
+
bool bPackages = false, bTextFiles = false;
|
|
592
|
+
const bool bPackagesGiven = TryGetBoolParam(Params, TEXT("gatherFromPackages"), bPackages);
|
|
593
|
+
const bool bTextFilesGiven = TryGetBoolParam(Params, TEXT("gatherFromTextFiles"), bTextFiles);
|
|
594
|
+
|
|
595
|
+
if (MissingName) return MissingName;
|
|
596
|
+
if (!bArraysOk) return MCPError(ArrayError);
|
|
597
|
+
if (!MCPLocValidTargetName(Name))
|
|
598
|
+
{
|
|
599
|
+
return MCPError(FString::Printf(TEXT("target '%s' is not a valid localization target name: use letters, digits, _ and -, at most 64 characters."), *Name));
|
|
600
|
+
}
|
|
601
|
+
for (const FString& Culture : Cultures)
|
|
602
|
+
{
|
|
603
|
+
if (!FInternationalization::Get().GetCulture(Culture).IsValid())
|
|
604
|
+
{
|
|
605
|
+
return MCPError(FString::Printf(TEXT("'%s' is not a culture this engine knows (try en, fr, de, ja, zh-Hans)."), *Culture));
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
ULocalizationTargetSet* GameSet = ULocalizationSettings::GetGameTargetSet();
|
|
610
|
+
if (!GameSet)
|
|
611
|
+
{
|
|
612
|
+
return MCPError(TEXT("The project's localization target set is not available."));
|
|
613
|
+
}
|
|
614
|
+
if (ULocalizationTarget* EngineTarget = MCPLocFindTarget(Name, true))
|
|
615
|
+
{
|
|
616
|
+
if (EngineTarget->IsMemberOfEngineTargetSet())
|
|
617
|
+
{
|
|
618
|
+
return MCPError(FString::Printf(TEXT("'%s' is an engine localization target; only project targets can be changed."), *Name));
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
ULocalizationTarget* Target = MCPLocFindTarget(Name, false);
|
|
623
|
+
const bool bCreated = Target == nullptr;
|
|
624
|
+
TSharedPtr<FJsonObject> Before;
|
|
625
|
+
FLocalizationTargetSettings Settings;
|
|
626
|
+
if (Target)
|
|
627
|
+
{
|
|
628
|
+
Before = MCPLocTargetToSetParams(Target->Settings);
|
|
629
|
+
Settings = Target->Settings;
|
|
630
|
+
}
|
|
631
|
+
else
|
|
632
|
+
{
|
|
633
|
+
Settings.Name = Name;
|
|
634
|
+
// A new target gathers nothing until told what to gather from.
|
|
635
|
+
Settings.GatherFromTextFiles.IsEnabled = false;
|
|
636
|
+
Settings.GatherFromPackages.IsEnabled = false;
|
|
637
|
+
Settings.GatherFromMetaData.IsEnabled = false;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
const FString PreviousNative = MCPLocNativeCulture(Settings);
|
|
641
|
+
if (bCulturesGiven)
|
|
642
|
+
{
|
|
643
|
+
TArray<FCultureStatistics> Statistics;
|
|
644
|
+
for (const FString& Culture : Cultures)
|
|
645
|
+
{
|
|
646
|
+
const FCultureStatistics* Existing = Settings.SupportedCulturesStatistics.FindByPredicate(
|
|
647
|
+
[&Culture](const FCultureStatistics& Row) { return Row.CultureName == Culture; });
|
|
648
|
+
Statistics.Add(Existing ? *Existing : FCultureStatistics(Culture));
|
|
649
|
+
}
|
|
650
|
+
Settings.SupportedCulturesStatistics = Statistics;
|
|
651
|
+
}
|
|
652
|
+
const FString WantNative = bNativeGiven ? NativeCulture : PreviousNative;
|
|
653
|
+
Settings.NativeCultureIndex = Settings.SupportedCulturesStatistics.IndexOfByPredicate(
|
|
654
|
+
[&WantNative](const FCultureStatistics& Row) { return Row.CultureName == WantNative; });
|
|
655
|
+
if (Settings.NativeCultureIndex == INDEX_NONE)
|
|
656
|
+
{
|
|
657
|
+
if (bNativeGiven)
|
|
658
|
+
{
|
|
659
|
+
return MCPError(FString::Printf(TEXT("nativeCulture '%s' is not one of the target's cultures."), *NativeCulture));
|
|
660
|
+
}
|
|
661
|
+
Settings.NativeCultureIndex = Settings.SupportedCulturesStatistics.Num() > 0 ? 0 : INDEX_NONE;
|
|
662
|
+
}
|
|
663
|
+
if (bPackagesGiven) Settings.GatherFromPackages.IsEnabled = bPackages;
|
|
664
|
+
if (bIncludeGiven)
|
|
665
|
+
{
|
|
666
|
+
Settings.GatherFromPackages.IncludePathWildcards.Reset();
|
|
667
|
+
for (const FString& Pattern : Include)
|
|
668
|
+
{
|
|
669
|
+
FGatherTextIncludePath Path;
|
|
670
|
+
Path.Pattern = Pattern;
|
|
671
|
+
Settings.GatherFromPackages.IncludePathWildcards.Add(Path);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
if (bExcludeGiven)
|
|
675
|
+
{
|
|
676
|
+
Settings.GatherFromPackages.ExcludePathWildcards.Reset();
|
|
677
|
+
for (const FString& Pattern : Exclude)
|
|
678
|
+
{
|
|
679
|
+
FGatherTextExcludePath Path;
|
|
680
|
+
Path.Pattern = Pattern;
|
|
681
|
+
Settings.GatherFromPackages.ExcludePathWildcards.Add(Path);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (bTextFilesGiven) Settings.GatherFromTextFiles.IsEnabled = bTextFiles;
|
|
685
|
+
if (bDirectoriesGiven)
|
|
686
|
+
{
|
|
687
|
+
Settings.GatherFromTextFiles.SearchDirectories.Reset();
|
|
688
|
+
for (const FString& Directory : Directories)
|
|
689
|
+
{
|
|
690
|
+
FGatherTextSearchDirectory Path;
|
|
691
|
+
Path.Path = Directory;
|
|
692
|
+
Settings.GatherFromTextFiles.SearchDirectories.Add(Path);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if (!bCreated)
|
|
697
|
+
{
|
|
698
|
+
const TSharedPtr<FJsonObject> After = MCPLocTargetToSetParams(Settings);
|
|
699
|
+
const TSharedRef<FJsonValueObject> AV = MakeShared<FJsonValueObject>(After);
|
|
700
|
+
const TSharedRef<FJsonValueObject> BV = MakeShared<FJsonValueObject>(Before);
|
|
701
|
+
if (FJsonValue::CompareEqual(*AV, *BV))
|
|
702
|
+
{
|
|
703
|
+
auto Result = MCPSuccess();
|
|
704
|
+
MCPSetExisted(Result);
|
|
705
|
+
Result->SetBoolField(TEXT("unchanged"), true);
|
|
706
|
+
Result->SetObjectField(TEXT("targetState"), MCPLocDescribeTarget(Target));
|
|
707
|
+
return MCPResult(Result);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
GameSet->Modify();
|
|
712
|
+
if (bCreated)
|
|
713
|
+
{
|
|
714
|
+
Target = NewObject<ULocalizationTarget>(GameSet);
|
|
715
|
+
GameSet->TargetObjects.Add(Target);
|
|
716
|
+
}
|
|
717
|
+
Target->Modify();
|
|
718
|
+
Target->Settings = Settings;
|
|
719
|
+
MCPLocPersistTargets();
|
|
720
|
+
|
|
721
|
+
auto Result = MCPSuccess();
|
|
722
|
+
if (bCreated) MCPSetCreated(Result); else MCPSetUpdated(Result);
|
|
723
|
+
Result->SetObjectField(TEXT("targetState"), MCPLocDescribeTarget(Target));
|
|
724
|
+
if (bCreated)
|
|
725
|
+
{
|
|
726
|
+
TSharedPtr<FJsonObject> Payload = MakeShared<FJsonObject>();
|
|
727
|
+
Payload->SetStringField(TEXT("target"), Name);
|
|
728
|
+
MCPSetRollback(Result, TEXT("remove_localization_target"), Payload);
|
|
729
|
+
}
|
|
730
|
+
else
|
|
731
|
+
{
|
|
732
|
+
Result->SetObjectField(TEXT("previous"), Before);
|
|
733
|
+
MCPSetRollback(Result, TEXT("set_localization_target"), Before);
|
|
734
|
+
}
|
|
735
|
+
return MCPResult(Result);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
TSharedPtr<FJsonValue> FLocalizationHandlers::RemoveTarget(const TSharedPtr<FJsonObject>& Params)
|
|
739
|
+
{
|
|
740
|
+
FString Name;
|
|
741
|
+
const TSharedPtr<FJsonValue> MissingName = RequireString(Params, TEXT("target"), Name);
|
|
742
|
+
const bool bDeleteFiles = OptionalBool(Params, TEXT("deleteFiles"), false);
|
|
743
|
+
if (MissingName) return MissingName;
|
|
744
|
+
|
|
745
|
+
ULocalizationTarget* Target = MCPLocFindTarget(Name, true);
|
|
746
|
+
if (Target && Target->IsMemberOfEngineTargetSet())
|
|
747
|
+
{
|
|
748
|
+
return MCPError(FString::Printf(TEXT("'%s' is an engine localization target; only project targets can be removed."), *Name));
|
|
749
|
+
}
|
|
750
|
+
auto Result = MCPSuccess();
|
|
751
|
+
Result->SetStringField(TEXT("target"), Name);
|
|
752
|
+
if (!Target)
|
|
753
|
+
{
|
|
754
|
+
Result->SetBoolField(TEXT("alreadyRemoved"), true);
|
|
755
|
+
return MCPResult(Result);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
const TSharedPtr<FJsonObject> Restore = MCPLocTargetToSetParams(Target->Settings);
|
|
759
|
+
bool bFilesDeleted = false;
|
|
760
|
+
if (bDeleteFiles)
|
|
761
|
+
{
|
|
762
|
+
bFilesDeleted = Target->DeleteFiles();
|
|
763
|
+
Result->SetBoolField(TEXT("filesDeleted"), bFilesDeleted);
|
|
764
|
+
}
|
|
765
|
+
ULocalizationTargetSet* GameSet = ULocalizationSettings::GetGameTargetSet();
|
|
766
|
+
GameSet->Modify();
|
|
767
|
+
GameSet->TargetObjects.Remove(Target);
|
|
768
|
+
MCPLocPersistTargets();
|
|
769
|
+
|
|
770
|
+
Result->SetBoolField(TEXT("deleted"), true);
|
|
771
|
+
MCPSetRollback(Result, TEXT("set_localization_target"), Restore);
|
|
772
|
+
if (bDeleteFiles)
|
|
773
|
+
{
|
|
774
|
+
Result->SetStringField(TEXT("rollbackNote"), TEXT("The rollback recreates the target's settings under a new GUID. The deleted manifest, archives and LocRes files are not restored; gather and compile again to regenerate them."));
|
|
775
|
+
}
|
|
776
|
+
return MCPResult(Result);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
TSharedPtr<FJsonValue> FLocalizationHandlers::GatherTarget(const TSharedPtr<FJsonObject>& Params)
|
|
780
|
+
{
|
|
781
|
+
FString Name;
|
|
782
|
+
if (auto Missing = RequireString(Params, TEXT("target"), Name)) return Missing;
|
|
783
|
+
ULocalizationTarget* Target = MCPLocFindTarget(Name, true);
|
|
784
|
+
if (!Target)
|
|
785
|
+
{
|
|
786
|
+
return MCPError(FString::Printf(TEXT("No localization target named '%s'. project(list_localization_targets) lists them."), *Name));
|
|
787
|
+
}
|
|
788
|
+
return MCPLocRunCommandlet(Target, TEXT("gather"), FString());
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
TSharedPtr<FJsonValue> FLocalizationHandlers::CompileTarget(const TSharedPtr<FJsonObject>& Params)
|
|
792
|
+
{
|
|
793
|
+
FString Name;
|
|
794
|
+
const TSharedPtr<FJsonValue> Missing = RequireString(Params, TEXT("target"), Name);
|
|
795
|
+
const FString Culture = OptionalString(Params, TEXT("culture"));
|
|
796
|
+
if (Missing) return Missing;
|
|
797
|
+
ULocalizationTarget* Target = MCPLocFindTarget(Name, true);
|
|
798
|
+
if (!Target)
|
|
799
|
+
{
|
|
800
|
+
return MCPError(FString::Printf(TEXT("No localization target named '%s'. project(list_localization_targets) lists them."), *Name));
|
|
801
|
+
}
|
|
802
|
+
if (!Culture.IsEmpty() && !Target->Settings.SupportedCulturesStatistics.ContainsByPredicate(
|
|
803
|
+
[&Culture](const FCultureStatistics& Row) { return Row.CultureName == Culture; }))
|
|
804
|
+
{
|
|
805
|
+
return MCPError(FString::Printf(TEXT("Target '%s' does not support culture '%s'."), *Name, *Culture));
|
|
806
|
+
}
|
|
807
|
+
return MCPLocRunCommandlet(Target, TEXT("compile"), Culture);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
TSharedPtr<FJsonValue> FLocalizationHandlers::GetTextLocalization(const TSharedPtr<FJsonObject>& Params)
|
|
811
|
+
{
|
|
812
|
+
FString AssetPath;
|
|
813
|
+
const TSharedPtr<FJsonValue> MissingAsset = RequireString(Params, TEXT("assetPath"), AssetPath);
|
|
814
|
+
FString PropertyName;
|
|
815
|
+
const TSharedPtr<FJsonValue> MissingProperty = RequireString(Params, TEXT("propertyName"), PropertyName);
|
|
816
|
+
const FString WidgetName = OptionalString(Params, TEXT("widgetName"));
|
|
817
|
+
if (MissingAsset) return MissingAsset;
|
|
818
|
+
if (MissingProperty) return MissingProperty;
|
|
819
|
+
|
|
820
|
+
TSharedPtr<FJsonValue> LoadError;
|
|
821
|
+
UObject* Asset = MCPRequireAssetObject(AssetPath, LoadError);
|
|
822
|
+
if (!Asset) return LoadError;
|
|
823
|
+
FString Error;
|
|
824
|
+
UObject* Owner = MCPLocResolveTextOwner(Asset, WidgetName, Error);
|
|
825
|
+
if (!Owner) return MCPError(Error);
|
|
826
|
+
const FText* Text = MCPLocResolveText(Owner, PropertyName, Error);
|
|
827
|
+
if (!Text) return MCPError(Error);
|
|
828
|
+
|
|
829
|
+
auto Result = MCPSuccess();
|
|
830
|
+
Result->SetStringField(TEXT("assetPath"), AssetPath);
|
|
831
|
+
Result->SetStringField(TEXT("propertyName"), PropertyName);
|
|
832
|
+
if (!WidgetName.IsEmpty()) Result->SetStringField(TEXT("widgetName"), WidgetName);
|
|
833
|
+
MCPLocDescribeText(Result, *Text);
|
|
834
|
+
return MCPResult(Result);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
TSharedPtr<FJsonValue> FLocalizationHandlers::SetTextLocalization(const TSharedPtr<FJsonObject>& Params)
|
|
838
|
+
{
|
|
839
|
+
FString AssetPath;
|
|
840
|
+
const TSharedPtr<FJsonValue> MissingAsset = RequireString(Params, TEXT("assetPath"), AssetPath);
|
|
841
|
+
FString PropertyName;
|
|
842
|
+
const TSharedPtr<FJsonValue> MissingProperty = RequireString(Params, TEXT("propertyName"), PropertyName);
|
|
843
|
+
const FString WidgetName = OptionalString(Params, TEXT("widgetName"));
|
|
844
|
+
FString Namespace, Key, SourceString, TableId, TableKey;
|
|
845
|
+
const bool bNamespaceGiven = TryGetStringParam(Params, TEXT("namespace"), Namespace);
|
|
846
|
+
const bool bKeyGiven = TryGetStringParam(Params, TEXT("key"), Key) && !Key.IsEmpty();
|
|
847
|
+
const bool bSourceGiven = TryGetStringParam(Params, TEXT("sourceString"), SourceString);
|
|
848
|
+
const bool bTableGiven = TryGetStringParam(Params, TEXT("stringTableId"), TableId) && !TableId.IsEmpty();
|
|
849
|
+
const bool bTableKeyGiven = TryGetStringParam(Params, TEXT("stringTableKey"), TableKey) && !TableKey.IsEmpty();
|
|
850
|
+
if (MissingAsset) return MissingAsset;
|
|
851
|
+
if (MissingProperty) return MissingProperty;
|
|
852
|
+
|
|
853
|
+
if (bTableGiven != bTableKeyGiven)
|
|
854
|
+
{
|
|
855
|
+
return MCPError(TEXT("stringTableId and stringTableKey go together."));
|
|
856
|
+
}
|
|
857
|
+
if (bTableGiven && (bNamespaceGiven || bKeyGiven || bSourceGiven))
|
|
858
|
+
{
|
|
859
|
+
return MCPError(TEXT("A string table reference takes its namespace, key and source from the table: pass stringTableId and stringTableKey, or namespace/key/sourceString, not both."));
|
|
860
|
+
}
|
|
861
|
+
if (!bTableGiven && !bNamespaceGiven && !bKeyGiven && !bSourceGiven)
|
|
862
|
+
{
|
|
863
|
+
return MCPError(TEXT("Nothing to set: pass namespace, key or sourceString, or stringTableId with stringTableKey."));
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
TSharedPtr<FJsonValue> LoadError;
|
|
867
|
+
UObject* Asset = MCPRequireAssetObject(AssetPath, LoadError);
|
|
868
|
+
if (!Asset) return LoadError;
|
|
869
|
+
FString Error;
|
|
870
|
+
UObject* Owner = MCPLocResolveTextOwner(Asset, WidgetName, Error);
|
|
871
|
+
if (!Owner) return MCPError(Error);
|
|
872
|
+
FText* Text = MCPLocResolveText(Owner, PropertyName, Error);
|
|
873
|
+
if (!Text) return MCPError(Error);
|
|
874
|
+
|
|
875
|
+
const FText Previous = *Text;
|
|
876
|
+
TSharedPtr<FJsonObject> PreviousState = MakeShared<FJsonObject>();
|
|
877
|
+
MCPLocDescribeText(PreviousState, Previous);
|
|
878
|
+
|
|
879
|
+
FText Updated;
|
|
880
|
+
if (bTableGiven)
|
|
881
|
+
{
|
|
882
|
+
FName ResolvedId(*TableId);
|
|
883
|
+
if (UStringTable* Table = LoadAssetByPath<UStringTable>(TableId))
|
|
884
|
+
{
|
|
885
|
+
ResolvedId = Table->GetStringTableId();
|
|
886
|
+
FString Unused;
|
|
887
|
+
if (!Table->GetStringTable()->GetSourceString(FTextKey(TableKey), Unused))
|
|
888
|
+
{
|
|
889
|
+
return MCPError(FString::Printf(TEXT("String table %s has no entry '%s'."), *TableId, *TableKey));
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
Updated = FText::FromStringTable(ResolvedId, FTextKey(TableKey));
|
|
893
|
+
}
|
|
894
|
+
else
|
|
895
|
+
{
|
|
896
|
+
const TOptional<FString> CurrentNamespace = FTextInspector::GetNamespace(Previous);
|
|
897
|
+
const TOptional<FString> CurrentKey = FTextInspector::GetKey(Previous);
|
|
898
|
+
const FString* CurrentSource = FTextInspector::GetSourceString(Previous);
|
|
899
|
+
const FString UseNamespace = bNamespaceGiven ? Namespace : TextNamespaceUtil::StripPackageNamespace(CurrentNamespace.IsSet() ? CurrentNamespace.GetValue() : FString());
|
|
900
|
+
const FString UseKey = bKeyGiven ? Key : (CurrentKey.IsSet() && !CurrentKey.GetValue().IsEmpty() ? CurrentKey.GetValue() : FGuid::NewGuid().ToString());
|
|
901
|
+
const FString UseSource = bSourceGiven ? SourceString : (CurrentSource ? *CurrentSource : Previous.ToString());
|
|
902
|
+
#if USE_STABLE_LOCALIZATION_KEYS
|
|
903
|
+
// Text in an asset carries its package's namespace, as an edit in the details panel would give it.
|
|
904
|
+
const FString FullNamespace = TextNamespaceUtil::BuildFullNamespace(UseNamespace, TextNamespaceUtil::EnsurePackageNamespace(Owner), true);
|
|
905
|
+
#else
|
|
906
|
+
const FString FullNamespace = UseNamespace;
|
|
907
|
+
#endif
|
|
908
|
+
Updated = FText::ChangeKey(FTextKey(FullNamespace), FTextKey(UseKey), FText::FromString(UseSource));
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
TSharedPtr<FJsonObject> UpdatedState = MakeShared<FJsonObject>();
|
|
912
|
+
MCPLocDescribeText(UpdatedState, Updated);
|
|
913
|
+
auto Result = MCPSuccess();
|
|
914
|
+
Result->SetStringField(TEXT("assetPath"), AssetPath);
|
|
915
|
+
Result->SetStringField(TEXT("propertyName"), PropertyName);
|
|
916
|
+
if (!WidgetName.IsEmpty()) Result->SetStringField(TEXT("widgetName"), WidgetName);
|
|
917
|
+
|
|
918
|
+
const TSharedRef<FJsonValueObject> BeforeValue = MakeShared<FJsonValueObject>(PreviousState);
|
|
919
|
+
const TSharedRef<FJsonValueObject> AfterValue = MakeShared<FJsonValueObject>(UpdatedState);
|
|
920
|
+
if (FJsonValue::CompareEqual(*BeforeValue, *AfterValue))
|
|
921
|
+
{
|
|
922
|
+
MCPSetExisted(Result);
|
|
923
|
+
Result->SetBoolField(TEXT("unchanged"), true);
|
|
924
|
+
MCPLocDescribeText(Result, Previous);
|
|
925
|
+
return MCPResult(Result);
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
Owner->Modify();
|
|
929
|
+
*Text = Updated;
|
|
930
|
+
Owner->PostEditChange();
|
|
931
|
+
|
|
932
|
+
FString SaveError;
|
|
933
|
+
bool bSaved = false;
|
|
934
|
+
if (UWidgetBlueprint* WidgetBP = Cast<UWidgetBlueprint>(Asset))
|
|
935
|
+
{
|
|
936
|
+
// The designer tree is the template; a compile carries the text into the generated class.
|
|
937
|
+
FBlueprintEditorUtils::MarkBlueprintAsModified(WidgetBP);
|
|
938
|
+
const MCPWidgetGuidMap::FSyncReport Report = MCPWidgetGuidMap::CompileChecked(WidgetBP);
|
|
939
|
+
bSaved = Report.WasRefused() ? SaveAssetPackageChecked(WidgetBP, SaveError) : MCPWidgetGuidMap::SaveIfCompiled(WidgetBP, Report, SaveError);
|
|
940
|
+
Result->SetStringField(TEXT("compileStatus"), WidgetCompileStatusString(WidgetBP));
|
|
941
|
+
}
|
|
942
|
+
else
|
|
943
|
+
{
|
|
944
|
+
if (UBlueprint* Blueprint = Cast<UBlueprint>(Asset))
|
|
945
|
+
{
|
|
946
|
+
FBlueprintEditorUtils::MarkBlueprintAsModified(Blueprint);
|
|
947
|
+
}
|
|
948
|
+
bSaved = SaveAssetPackageChecked(Asset, SaveError);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
MCPSetUpdated(Result);
|
|
952
|
+
MCPNoteSaveOutcome(Result, AssetPath, bSaved, SaveError);
|
|
953
|
+
MCPLocDescribeText(Result, *Text);
|
|
954
|
+
Result->SetObjectField(TEXT("previous"), PreviousState);
|
|
955
|
+
|
|
956
|
+
TSharedPtr<FJsonObject> Payload = MakeShared<FJsonObject>();
|
|
957
|
+
Payload->SetStringField(TEXT("assetPath"), AssetPath);
|
|
958
|
+
Payload->SetStringField(TEXT("propertyName"), PropertyName);
|
|
959
|
+
if (!WidgetName.IsEmpty()) Payload->SetStringField(TEXT("widgetName"), WidgetName);
|
|
960
|
+
bool bPreviousFromTable = false;
|
|
961
|
+
PreviousState->TryGetBoolField(TEXT("isFromStringTable"), bPreviousFromTable);
|
|
962
|
+
FString PreviousKey;
|
|
963
|
+
PreviousState->TryGetStringField(TEXT("key"), PreviousKey);
|
|
964
|
+
if (bPreviousFromTable)
|
|
965
|
+
{
|
|
966
|
+
Payload->SetStringField(TEXT("stringTableId"), PreviousState->GetStringField(TEXT("stringTableId")));
|
|
967
|
+
Payload->SetStringField(TEXT("stringTableKey"), PreviousState->GetStringField(TEXT("stringTableKey")));
|
|
968
|
+
MCPSetRollback(Result, TEXT("set_text_localization"), Payload);
|
|
969
|
+
}
|
|
970
|
+
else if (!PreviousKey.IsEmpty())
|
|
971
|
+
{
|
|
972
|
+
Payload->SetStringField(TEXT("namespace"), PreviousState->GetStringField(TEXT("namespace")));
|
|
973
|
+
Payload->SetStringField(TEXT("key"), PreviousKey);
|
|
974
|
+
Payload->SetStringField(TEXT("sourceString"), PreviousState->GetStringField(TEXT("sourceString")));
|
|
975
|
+
MCPSetRollback(Result, TEXT("set_text_localization"), Payload);
|
|
976
|
+
}
|
|
977
|
+
else
|
|
978
|
+
{
|
|
979
|
+
MCPSetNoRollback(Result, TEXT("The previous value was culture-invariant text with no namespace or key, which set_text_localization cannot recreate. Set the old string again with asset or widget property actions."));
|
|
980
|
+
}
|
|
981
|
+
return MCPResult(Result);
|
|
982
|
+
}
|