载入中...
搜索中...
未找到
AnimationEditorModule.cpp
浏览该文件的文档.
2
6#include "common/Capability.h"
9
10#include <simplesquirrel/simplesquirrel.hpp>
11
12#include <stdexcept>
13#include <string_view>
14#include <utility>
15#include <vector>
16
17namespace eve::animation_editor {
18namespace {
19
21 const auto found = request.find(key);
22 return found == request.end() ? nullptr : &found->second;
23}
24
25} // namespace
26
28public:
29 std::vector<std::string_view> types() const override { return {"animation-clip", "animation-clip-document"}; }
30
32 const editor::TargetId& target, std::string_view, const editor::EditorValue::Object& request) override {
33 auto clip = std::make_unique<animation_editing::AnimationClipDocumentTarget>(target.value());
34 if (const editor::EditorValue* snapshot = field(request, "snapshot")) {
35 auto loaded = clip->loadSnapshot(*snapshot);
36 if (!loaded.ok())
38 }
40 owned.target = std::move(clip);
41 return eve::editing::applied<editor::AutomationOwnedTarget>(std::move(owned));
42 }
43};
44
46
48 auto* registry = eve::cap::query<editing::IEditingCommandRegistry>();
49 if (!registry || !animation_editing::registerEditingCommands(*registry).ok())
50 throw std::runtime_error("Failed to register animation editing commands");
51 eve::cap::addListener<editor::IEditorAutomationTargetFactory>(factory_.get());
52}
53
55 eve::cap::removeListener<editor::IEditorAutomationTargetFactory>(factory_.get());
56 if (auto* registry = eve::cap::query<editing::IEditingCommandRegistry>())
57 registry->unregisterOwner("animation_editing").ignore("animation editor adapter shutdown");
58}
59
60void AnimationEditorModule::expose(ssq::Table& table) {
61 auto module = table.addClass(name, AnimationEditorModule::create, false);
63}
64void AnimationEditorModule::expose(ssq::Class&) {}
65
66} // namespace eve::animation_editor
LogicalId target
Squirrel adapter for the animation clip editor.
ActiveSource owned
const GltfImportRequest & request
std::uint32_t key
glm::vec4 clip
#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
editor::Result< editor::AutomationOwnedTarget > create(const editor::TargetId &target, std::string_view, const editor::EditorValue::Object &request) override
Create a domain target from an automation request. @ownership Success transfers the target and any su...
std::vector< std::string_view > types() const override
Stable target type names this factory accepts.
Composition adapter that contributes animation editing commands and automation targets.
~AnimationEditorModule() override
Animation editor module.
Deterministic owning value tree shared by authoring hosts.
std::map< std::string, Value > Object
Multi-provider extension point for domain-specific automation target creation.
editing::Result< void > registerEditingCommands(editing::IEditingCommandRegistry &registry)
Register animation-clip commands with a generic editing host.
void exposeAnimationClipEditorScriptBindings(ssq::Table &table, ssq::Class &moduleClass)
Expose the script-owned AnimationClipEditor factory on AnimationEditorModule.
eve::editing::Value EditorValue
Compatibility alias for the UI-independent authoring value tree.
Definition EditorValue.h:8
const EditorValue * field(const EditorValue &value, const char *name)
Target plus optional borrowed-dependency owner returned by an automation factory.
std::unique_ptr< IEditableTarget > target