载入中...
搜索中...
未找到
ActionEditorModule.cpp
浏览该文件的文档.
2
7#include "common/Capability.h"
11
12#include <simplesquirrel/simplesquirrel.hpp>
13
14#include <stdexcept>
15#include <string>
16#include <string_view>
17#include <utility>
18#include <vector>
19
20namespace eve::action_editor {
21namespace {
22
23std::string stringField(const editor::EditorValue::Object& request, const char* key) {
24 const auto found = request.find(key);
25 if (found == request.end()) return {};
26 const auto* value = found->second.getIf<std::string>();
27 return value ? *value : std::string{};
28}
29
30} // namespace
31
33public:
34 std::vector<std::string_view> types() const override { return {"action", "action-timeline"}; }
35
37 const editor::TargetId& target, std::string_view type, const editor::EditorValue::Object& request) override {
38 (void)type;
39 auto document = std::make_unique<editor::ActionTimelineTarget>(target.value());
40 const auto found = request.find("timeline");
41 if (found != request.end()) {
42 auto loaded = document->loadSnapshot(found->second);
43 if (!loaded.ok())
45 }
46 const std::string animationUri = stringField(request, "animationUri");
47 if (!animationUri.empty()) {
49 selection.channel = "asset";
51 item.domain = editor::SelectionDomain::Asset;
52 item.target = editor::TargetId(document->targetId());
53 item.item = editor::StableId(document->targetId().value());
54 item.type = "action.timeline";
55 selection.items.push_back(item);
56 selection.primary = item;
57 auto operation = document->makeSet(selection, editor::PropertyPath("timeline.animationUri"),
58 animationUri, editor::PropertySetMode::Absolute);
59 if (!operation.ok())
61 auto applied = document->applyDomainOperation(operation.value());
62 if (!applied.ok())
64 }
66 owned.target = std::move(document);
67 return eve::editing::applied<editor::AutomationOwnedTarget>(std::move(owned));
68 }
69};
70
72
74 : factory_(std::make_unique<TargetFactory>()), packageProvider_(std::make_unique<ActionEditorPackageProvider>()) {
75 auto* registry = eve::cap::query<editing::IEditingCommandRegistry>();
76 if (!registry || !registerEditingCommands(*registry).ok())
77 throw std::runtime_error("Failed to register action editing commands");
78 eve::cap::addListener<editor::IEditorAutomationTargetFactory>(factory_.get());
79 eve::cap::addListener<editing::IEditorPackageProvider>(packageProvider_.get());
80}
81
83 eve::cap::removeListener<editing::IEditorPackageProvider>(packageProvider_.get());
84 eve::cap::removeListener<editor::IEditorAutomationTargetFactory>(factory_.get());
85 if (auto* registry = eve::cap::query<editing::IEditingCommandRegistry>())
86 registry->unregisterOwner("action_editor").ignore("action editor adapter shutdown");
87}
88
89void ActionEditorModule::expose(ssq::Table& table) {
90 auto module = table.addClass(name, ActionEditorModule::create, false);
92}
93
94void ActionEditorModule::expose(ssq::Class&) {}
95
96} // namespace eve::action_editor
LogicalId target
ActionParameterOperation operation
UI-neutral transactional action timeline editor and preview model.
Squirrel adapter for the canonical action timeline editor.
ActiveSource owned
bool applied
SQObjectPtr key
Definition ECS.cpp:155
const GltfImportRequest & request
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:27
std::unordered_set< std::string > loaded
Definition Plugins.cpp:24
const eve::script::BindingContractRegistry & registry
Object::Ptr value
bool found
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
std::vector< std::string_view > types() const override
Stable target type names this factory accepts.
editor::Result< editor::AutomationOwnedTarget > create(const editor::TargetId &target, std::string_view type, const editor::EditorValue::Object &request) override
Create a domain target from an automation request. @ownership Success transfers the target and any su...
Composition adapter that contributes action-timeline commands, automation targets,...
~ActionEditorModule() override
Action editor module.
Capability provider advertising makeActionEditorPackage().
Dotted property path (layout.size) compared and persisted as text.
Definition EditingIds.h:78
std::map< std::string, Value > Object
Multi-provider extension point for domain-specific automation target creation.
editing::Result< void > registerEditingCommands(editing::IEditingCommandRegistry &registry)
Register Action-owned property commands with a generic editing host.
eve::editing::StableId StableId
Definition EditorIds.h:36
eve::editing::TargetId TargetId
Definition EditorIds.h:29
void exposeActionTimelineScriptBindings(ssq::Table &table, ssq::Class &moduleClass)
Expose the script-owned action timeline editor adapter.
SelectionItem public API.
SelectionSnapshot public API.
std::vector< SelectionItem > items
std::optional< SelectionItem > primary
Target plus optional borrowed-dependency owner returned by an automation factory.
std::unique_ptr< IEditableTarget > target