载入中...
搜索中...
未找到
ActionEditorModule.cpp
浏览该文件的文档.
2
6#include "common/Capability.h"
9
10#include <simplesquirrel/simplesquirrel.hpp>
11
12#include <stdexcept>
13#include <string>
14#include <string_view>
15#include <utility>
16#include <vector>
17
18namespace eve::action_editor {
19namespace {
20
21std::string stringField(const editor::EditorValue::Object& request, const char* key) {
22 const auto found = request.find(key);
23 if (found == request.end()) return {};
24 const auto* value = found->second.getIf<std::string>();
25 return value ? *value : std::string{};
26}
27
28} // namespace
29
31public:
32 std::vector<std::string_view> types() const override { return {"action", "action-timeline"}; }
33
35 const editor::TargetId& target, std::string_view type, const editor::EditorValue::Object& request) override {
36 (void)type;
37 auto document = std::make_unique<editor::ActionTimelineTarget>(target.value());
38 const auto found = request.find("timeline");
39 if (found != request.end()) {
40 auto loaded = document->loadSnapshot(found->second);
41 if (!loaded.ok())
43 }
44 const std::string animationUri = stringField(request, "animationUri");
45 if (!animationUri.empty()) {
47 selection.channel = "asset";
49 item.domain = editor::SelectionDomain::Asset;
50 item.target = editor::TargetId(document->targetId());
51 item.item = editor::StableId(document->targetId().value());
52 item.type = "action.timeline";
53 selection.items.push_back(item);
54 selection.primary = item;
55 auto operation = document->makeSet(selection, editor::PropertyPath("timeline.animationUri"),
56 animationUri, editor::PropertySetMode::Absolute);
57 if (!operation.ok())
59 auto applied = document->applyDomainOperation(operation.value());
60 if (!applied.ok())
62 }
64 owned.target = std::move(document);
65 return eve::editing::applied<editor::AutomationOwnedTarget>(std::move(owned));
66 }
67};
68
70
72 auto* registry = eve::cap::query<editing::IEditingCommandRegistry>();
73 if (!registry || !registerEditingCommands(*registry).ok())
74 throw std::runtime_error("Failed to register action editing commands");
75 eve::cap::addListener<editor::IEditorAutomationTargetFactory>(factory_.get());
76}
77
79 eve::cap::removeListener<editor::IEditorAutomationTargetFactory>(factory_.get());
80 if (auto* registry = eve::cap::query<editing::IEditingCommandRegistry>())
81 registry->unregisterOwner("action_editor").ignore("action editor adapter shutdown");
82}
83
84void ActionEditorModule::expose(ssq::Table& table) {
85 auto module = table.addClass(name, ActionEditorModule::create, false);
87}
88
89void ActionEditorModule::expose(ssq::Class&) {}
90
91} // namespace eve::action_editor
LogicalId target
ActionParameterOperation operation
double value
UI-neutral transactional action timeline editor and preview model.
Squirrel adapter for the canonical action timeline editor.
ActiveSource owned
const GltfImportRequest & request
std::uint32_t key
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:26
bool found
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
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.
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