载入中...
搜索中...
未找到
ProcgenScriptEditor.cpp
浏览该文件的文档.
2#include <algorithm>
3#include <cstdint>
4#include <simplesquirrel/simplesquirrel.hpp>
5#include <string>
6#include <utility>
12#include "procgen/PointSet.h"
16
17// ProcgenScriptEditor.cpp
18namespace eve::procgen_editor {
19namespace {
20
21template <class T = void>
22procgen_editing::Result<T> editorError(procgen_editing::EditorStatus status, std::string rule, std::string message) {
23 return eve::editing::failed<T>(status, eve::editing::RuleId(std::move(rule)), std::move(message));
24}
25
26} // namespace
27
29 : target_(std::move(targetId)), authority_(&target_), transactions_(&authority_) {}
30
32 editor::EditorWorkspace candidate = workspace;
33 struct Panel {
34 const char* id;
35 const char* title;
36 const char* region;
37 const char* context;
38 int order;
39 };
40 constexpr Panel panels[] = {
41 {"procgen.modules", "Modules", "left", "list", 100},
42 {"procgen.preview", "World Preview", "center", "preview", 100},
43 {"procgen.inspector", "Generator Inspector", "right", "inspector", 100},
44 {"procgen.stages", "Debug Stages", "bottom", "stages", 100},
45 };
46 for (const auto& panel : panels) {
47 if (!candidate.registerPanel(panel.id, panel.title, panel.region, panel.order) ||
48 !candidate.setPanelCapability(panel.id, "procgen.script") ||
49 !candidate.setPanelContext(panel.id, panel.context))
50 return editorError(procgen_editing::EditorStatus::Rejected, "editor.procgen.workspace-conflict",
51 "Could not install the procgen script workspace composition");
52 }
53 if (!candidate.activatePanel("procgen.preview"))
54 return editorError(procgen_editing::EditorStatus::Rejected, "editor.procgen.workspace-activate",
55 "Could not activate the procgen preview panel");
56 workspace = std::move(candidate);
57 return eve::editing::applied<void>();
58}
59
60editor::SelectionSnapshot ProcgenScriptEditor::selection() const {
62 snapshot.channel = "procgen";
64 item.domain = editor::SelectionDomain::Asset;
65 item.target = editor::TargetId(target_.targetId());
66 item.item = editor::StableId(target_.moduleId().empty() ? target_.targetId().value() : target_.moduleId());
67 item.type = "procgen-script";
68 snapshot.items.push_back(item);
69 snapshot.primary = item;
70 return snapshot;
71}
72
74 std::string label) {
77 spec.id = editor::TransactionId("procgen.script.tx." + std::to_string(++txSequence_));
78 spec.label = std::move(label);
79 spec.target = editor::TargetId(target_.targetId());
80 spec.baseRevision = target_.revision();
81 auto begun = transactions_.begin(std::move(spec));
82 if (!begun.ok())
83 return editorError(begun.code(), "editor.procgen.begin", "Could not begin the generator transaction");
84 auto appended = transactions_.append(std::move(operation).takeValue());
85 if (!appended.ok()) {
86 auto discarded = transactions_.discard();
87 if (!discarded.ok()) discarded.ignore("pending procgen script transaction already inactive");
88 return procgen_editing::Result<void>::failure(appended.status());
89 }
90 auto committed = transactions_.commit();
92 dirty_ = true;
93 previewFailureSummary_.clear();
94 return eve::editing::applied<void>();
95}
96
98 return commit(target_.makeLoadModule(std::move(spec)), "Load generator module");
99}
100
101procgen_editing::Result<void> ProcgenScriptEditor::loadModule(std::string uri, std::string id, std::string displayName,
102 std::string kind,
103 const procgen_editing::EditorValue& schema) {
105 std::move(uri), std::move(id), std::move(displayName), std::move(kind), schema);
106 if (!parsed.ok()) return procgen_editing::Result<void>::failure(parsed.status());
107 return loadModule(std::move(parsed).takeValue());
108}
109
111 return commit(target_.makeSet(selection(), editing::PropertyPath("param." + key), std::move(value),
113 "Set generator parameter");
114}
115
119
123
127
129 return setParam(std::move(key), procgen_editing::EditorValue(std::move(value)));
130}
131
133 const procgen::PointSet* points) const {
134 if (!points)
135 return editorError<std::vector<PreviewPoint>>(procgen_editing::EditorStatus::Rejected, "editor.procgen.preview",
136 "Preview PointSet must not be null");
137 if (pointBudget_ > 0 && points->getCount() > pointBudget_)
138 return editorError<std::vector<PreviewPoint>>(procgen_editing::EditorStatus::Rejected,
139 "editor.procgen.point-budget",
140 "Preview exceeded the point budget");
141 std::vector<PreviewPoint> next;
142 next.reserve(static_cast<std::size_t>(points->getCount()));
143 for (int i = 0; i < points->getCount(); ++i) {
144 PreviewPoint point;
145 point.x = points->getX(i);
146 point.z = points->getZ(i);
147 point.seed = points->getPointSeed(i);
148 next.push_back(point);
149 }
150 return eve::editing::applied(std::move(next));
151}
152
154 std::uint64_t expectedRevision) {
155 if (expectedRevision != target_.revision())
156 return editorError(procgen_editing::EditorStatus::Conflict, "editor.procgen.stale-preview",
157 "Preview revision does not match the generator document");
158 auto copied = copyPoints(points);
159 if (!copied.ok()) return procgen_editing::Result<void>::failure(copied.status());
160 if (stage.empty()) stage = "output";
161 if (std::find(stageOrder_.begin(), stageOrder_.end(), stage) == stageOrder_.end()) stageOrder_.push_back(stage);
162 stages_[stage] = std::move(copied).takeValue();
163 selectedStage_ = stage;
164 previewRevision_ = target_.revision();
165 dirty_ = false;
166 previewFailureSummary_.clear();
167 return eve::editing::applied<void>();
168}
169
171 if (stage.empty())
172 return editorError(procgen_editing::EditorStatus::Rejected, "editor.procgen.stage",
173 "Debug stage name must not be empty");
174 auto copied = copyPoints(points);
175 if (!copied.ok()) return procgen_editing::Result<void>::failure(copied.status());
176 if (std::find(stageOrder_.begin(), stageOrder_.end(), stage) == stageOrder_.end()) stageOrder_.push_back(stage);
177 stages_[stage] = std::move(copied).takeValue();
178 return eve::editing::applied<void>();
179}
180
181procgen_editing::Result<void> ProcgenScriptEditor::failPreview(std::string message, std::uint64_t expectedRevision) {
182 if (expectedRevision != target_.revision())
183 return editorError(procgen_editing::EditorStatus::Conflict, "editor.procgen.stale-preview",
184 "Failed preview revision does not match the generator document");
185 dirty_ = false;
186 previewFailureSummary_ = std::move(message);
187 return eve::editing::applied<void>();
188}
189
191 if (stages_.find(stage) == stages_.end())
192 return editorError(procgen_editing::EditorStatus::NotFound, "editor.procgen.stage",
193 "Debug stage was not found");
194 selectedStage_ = std::move(stage);
195 return eve::editing::applied<void>();
196}
197
199 if (budget < 0)
200 return editorError(procgen_editing::EditorStatus::Rejected, "editor.procgen.point-budget",
201 "Point budget must not be negative");
202 pointBudget_ = budget;
203 return eve::editing::applied<void>();
204}
205
207 continuousRebuild_ = enabled;
208 return eve::editing::applied<void>();
209}
210
212 auto result = transactions_.undo();
213 if (!result.ok()) return result;
214 dirty_ = true;
215 previewFailureSummary_.clear();
216 return result;
217}
218
220 auto result = transactions_.redo();
221 if (!result.ok()) return result;
222 dirty_ = true;
223 previewFailureSummary_.clear();
224 return result;
225}
226
227const procgen::ParamDescriptor* ProcgenScriptEditor::paramAt(int index) const {
228 if (index < 0 || static_cast<std::size_t>(index) >= target_.params().size()) return nullptr;
229 return &target_.params()[static_cast<std::size_t>(index)];
230}
231
232std::string ProcgenScriptEditor::paramKey(int index) const {
233 const auto* param = paramAt(index);
234 return param ? param->key : std::string{};
235}
237 const auto* param = paramAt(index);
238 return param ? (param->displayName.empty() ? param->key : param->displayName) : std::string{};
239}
240std::string ProcgenScriptEditor::paramKind(int index) const {
241 const auto* param = paramAt(index);
242 if (!param) return {};
243 switch (param->kind) {
244 case procgen::ParamKind::Integer: return "int";
245 case procgen::ParamKind::Float: return "float";
246 case procgen::ParamKind::Boolean: return "bool";
247 case procgen::ParamKind::Choice: return "choice";
248 case procgen::ParamKind::String: return "string";
249 }
250 return {};
251}
253 const auto* param = paramAt(index);
254 return param ? static_cast<float>(param->minimum) : 0.0f;
255}
257 const auto* param = paramAt(index);
258 return param ? static_cast<float>(param->maximum) : 0.0f;
259}
261 const auto* param = paramAt(index);
262 return param ? static_cast<float>(param->step) : 0.0f;
263}
265 const auto* param = paramAt(index);
266 return param ? static_cast<int>(param->choices.size()) : 0;
267}
268std::string ProcgenScriptEditor::paramChoice(int paramIndex, int choiceIndex) const {
269 const auto* param = paramAt(paramIndex);
270 if (!param || choiceIndex < 0 || static_cast<std::size_t>(choiceIndex) >= param->choices.size()) return {};
271 return param->choices[static_cast<std::size_t>(choiceIndex)];
272}
273
274int ProcgenScriptEditor::getInt(const std::string& key) const {
275 const auto found = target_.values().find(key);
276 if (found == target_.values().end()) return 0;
277 if (const auto* integer = found->second.getIf<std::int64_t>()) return static_cast<int>(*integer);
278 if (const auto* real = found->second.getIf<double>()) return static_cast<int>(*real);
279 return 0;
280}
281float ProcgenScriptEditor::getFloat(const std::string& key) const {
282 const auto found = target_.values().find(key);
283 if (found == target_.values().end()) return 0.0f;
284 if (const auto* real = found->second.getIf<double>()) return static_cast<float>(*real);
285 if (const auto* integer = found->second.getIf<std::int64_t>()) return static_cast<float>(*integer);
286 return 0.0f;
287}
288bool ProcgenScriptEditor::getBool(const std::string& key) const {
289 const auto found = target_.values().find(key);
290 if (found == target_.values().end()) return false;
291 if (const auto* flag = found->second.getIf<bool>()) return *flag;
292 if (const auto* integer = found->second.getIf<std::int64_t>()) return *integer != 0;
293 return false;
294}
295std::string ProcgenScriptEditor::getString(const std::string& key) const {
296 const auto found = target_.values().find(key);
297 if (found == target_.values().end()) return {};
298 if (const auto* text = found->second.getIf<std::string>()) return *text;
299 return {};
300}
301
302const std::vector<ProcgenScriptEditor::PreviewPoint>& ProcgenScriptEditor::displayedPoints() const {
303 static const std::vector<PreviewPoint> empty;
304 const auto found = stages_.find(selectedStage_);
305 return found == stages_.end() ? empty : found->second;
306}
307
308std::string ProcgenScriptEditor::stageName(int index) const {
309 if (index < 0 || static_cast<std::size_t>(index) >= stageOrder_.size()) return {};
310 return stageOrder_[static_cast<std::size_t>(index)];
311}
312
313int ProcgenScriptEditor::pointCount() const { return static_cast<int>(displayedPoints().size()); }
314
316 const auto& points = displayedPoints();
317 if (index < 0 || static_cast<std::size_t>(index) >= points.size()) return 0.0f;
318 return points[static_cast<std::size_t>(index)].x;
319}
321 const auto& points = displayedPoints();
322 if (index < 0 || static_cast<std::size_t>(index) >= points.size()) return 0.0f;
323 return points[static_cast<std::size_t>(index)].z;
324}
325std::uint32_t ProcgenScriptEditor::pointSeed(int index) const {
326 const auto& points = displayedPoints();
327 if (index < 0 || static_cast<std::size_t>(index) >= points.size()) return 0;
328 return points[static_cast<std::size_t>(index)].seed;
329}
330
331} // namespace eve::procgen_editor
332
333// ProcgenScriptEditorScriptBindings.cpp
334namespace eve::procgen_editor {
335namespace {
336
337constexpr const char* kBindingSource = "editor.procgen.script.squirrel";
338
339class ScriptProcgenScriptEditor {
340public:
341 explicit ScriptProcgenScriptEditor(std::string targetId) : editor_(std::move(targetId)) {}
342
343 ProcgenScriptEditor& editor() noexcept { return editor_; }
344 const ProcgenScriptEditor& editor() const noexcept { return editor_; }
345
346private:
347 ProcgenScriptEditor editor_;
348};
349
350ssq::Table loadModuleFromScript(const editor::ScriptBind& bind, ScriptProcgenScriptEditor* self, const std::string& uri,
351 const std::string& id, const std::string& displayName, const std::string& kind,
352 const ssq::Object& schema) {
353 if (!self) return bind.fail(DiagnosticCode::InvalidArgument, "procgen editor must not be null");
354 auto converted = script::valueFromSquirrel(schema);
355 if (!converted.ok()) return script::projectStatusResult(bind.vm(), converted.status());
356 return editor::project(
357 bind.vm(), self->editor().loadModule(uri, id, displayName, kind, editor::toEditorValue(converted.value())));
358}
359
360} // namespace
361
362void exposeProcgenScriptEditorScriptBindings(ssq::Table& table, ssq::Class& moduleClass) {
363 const editor::ScriptBind bind{table.getHandle(), kBindingSource};
364 auto procgenEditor = editor::addScriptClass<ScriptProcgenScriptEditor>(table, "ProcgenScriptEditor");
365 auto meshEditor = editor::addScriptClass<MeshModifierEditor>(table, "MeshModifierEditor");
366 editor::registerDirectEditorWorkspace<MeshModifierEditor>(meshEditor, bind,
367 "mesh modifier editor and workspace required");
368 meshEditor.addFunc("activateTool",
369 [bind](MeshModifierEditor* self, editor::EditorWorkspace* workspace, const std::string& tool) {
370 return bind.checked(self && workspace, "mesh modifier editor and workspace required",
371 [&] { return self->activateTool(*workspace, tool); });
372 });
373 meshEditor.addFunc("observeRevision", [bind](MeshModifierEditor* self, const std::string& document, int revision) {
374 return bind.checked(self && revision >= 0, "valid editor and revision required",
375 [&] { return self->observeRevision(document, static_cast<std::uint64_t>(revision)); });
376 });
377 meshEditor.addFunc("getTargetId", [](MeshModifierEditor* self) { return self ? self->targetId() : std::string{}; });
378 meshEditor.addFunc("getActiveTool",
379 [](MeshModifierEditor* self) { return self ? self->activeTool() : std::string{}; });
380 editor::registerEditorWorkspace<ScriptProcgenScriptEditor>(procgenEditor, bind,
381 "procgen editor and workspace must not be null");
382 procgenEditor.addFunc("loadModule",
383 [bind](ScriptProcgenScriptEditor* self, const std::string& uri, const std::string& id,
384 const std::string& displayName, const std::string& kind, const ssq::Object& schema) {
385 return loadModuleFromScript(bind, self, uri, id, displayName, kind, schema);
386 });
387 procgenEditor.addFunc("setInt", [bind](ScriptProcgenScriptEditor* self, const std::string& key, int value) {
388 return bind.checked(self, "procgen editor must not be null", [&] { return self->editor().setInt(key, value); });
389 });
390 procgenEditor.addFunc("setFloat", [bind](ScriptProcgenScriptEditor* self, const std::string& key, float value) {
391 return bind.checked(self, "procgen editor must not be null",
392 [&] { return self->editor().setFloat(key, static_cast<double>(value)); });
393 });
394 procgenEditor.addFunc("setBool", [bind](ScriptProcgenScriptEditor* self, const std::string& key, bool value) {
395 return bind.checked(self, "procgen editor must not be null",
396 [&] { return self->editor().setBool(key, value); });
397 });
398 procgenEditor.addFunc("setString",
399 [bind](ScriptProcgenScriptEditor* self, const std::string& key, const std::string& value) {
400 return bind.checked(self, "procgen editor must not be null",
401 [&] { return self->editor().setString(key, value); });
402 });
403 procgenEditor.addFunc("publishPreview", [bind](ScriptProcgenScriptEditor* self, procgen::PointSet* points,
404 const std::string& stage, int expectedRevision) {
405 return bind.checked(self, "procgen editor must not be null", [&] {
406 return self->editor().publishPreview(points, stage, static_cast<std::uint64_t>(expectedRevision));
407 });
408 });
409 procgenEditor.addFunc("publishStage",
410 [bind](ScriptProcgenScriptEditor* self, procgen::PointSet* points, const std::string& stage) {
411 return bind.checked(self, "procgen editor must not be null",
412 [&] { return self->editor().publishStage(points, stage); });
413 });
414 procgenEditor.addFunc(
415 "failPreview", [bind](ScriptProcgenScriptEditor* self, const std::string& message, int expectedRevision) {
416 return bind.checked(self, "procgen editor must not be null", [&] {
417 return self->editor().failPreview(message, static_cast<std::uint64_t>(expectedRevision));
418 });
419 });
420 procgenEditor.addFunc("selectStage", [bind](ScriptProcgenScriptEditor* self, const std::string& stage) {
421 return bind.checked(self, "procgen editor must not be null", [&] { return self->editor().selectStage(stage); });
422 });
423 procgenEditor.addFunc("setPointBudget", [bind](ScriptProcgenScriptEditor* self, int budget) {
424 return bind.checked(self, "procgen editor must not be null",
425 [&] { return self->editor().setPointBudget(budget); });
426 });
427 procgenEditor.addFunc("setLive", [bind](ScriptProcgenScriptEditor* self, bool enabled) {
428 return bind.checked(self, "procgen editor must not be null", [&] { return self->editor().setLive(enabled); });
429 });
430 editor::registerEditorHistory<ScriptProcgenScriptEditor>(procgenEditor, bind, "procgen editor must not be null");
431 procgenEditor.addFunc("isDirty", [](ScriptProcgenScriptEditor* self) { return self && self->editor().isDirty(); });
432 procgenEditor.addFunc("isLive",
433 [](ScriptProcgenScriptEditor* self) { return self && self->editor().isContinuousRebuild(); });
434 procgenEditor.addFunc("getPreviewRevision", [](ScriptProcgenScriptEditor* self) {
435 return self ? static_cast<int>(self->editor().previewRevision()) : 0;
436 });
437 procgenEditor.addFunc("getModuleId", [](ScriptProcgenScriptEditor* self) {
438 return self ? self->editor().moduleId() : std::string{};
439 });
440 procgenEditor.addFunc("getModuleUri", [](ScriptProcgenScriptEditor* self) {
441 return self ? self->editor().moduleUri() : std::string{};
442 });
443 procgenEditor.addFunc("getDisplayName", [](ScriptProcgenScriptEditor* self) {
444 return self ? self->editor().displayName() : std::string{};
445 });
446 procgenEditor.addFunc("getKind",
447 [](ScriptProcgenScriptEditor* self) { return self ? self->editor().kind() : std::string{}; });
448 procgenEditor.addFunc("getSelectedStage", [](ScriptProcgenScriptEditor* self) {
449 return self ? self->editor().selectedStage() : std::string{};
450 });
451 procgenEditor.addFunc("getPreviewFailureSummary", [](ScriptProcgenScriptEditor* self) {
452 return self ? self->editor().previewFailureSummary() : std::string{};
453 });
454 procgenEditor.addFunc("getParamCount",
455 [](ScriptProcgenScriptEditor* self) { return self ? self->editor().paramCount() : 0; });
456 procgenEditor.addFunc("getParamKey", [](ScriptProcgenScriptEditor* self, int index) {
457 return self ? self->editor().paramKey(index) : std::string{};
458 });
459 procgenEditor.addFunc("getParamLabel", [](ScriptProcgenScriptEditor* self, int index) {
460 return self ? self->editor().paramLabel(index) : std::string{};
461 });
462 procgenEditor.addFunc("getParamKind", [](ScriptProcgenScriptEditor* self, int index) {
463 return self ? self->editor().paramKind(index) : std::string{};
464 });
465 procgenEditor.addFunc("getParamMinimum", [](ScriptProcgenScriptEditor* self, int index) {
466 return self ? self->editor().paramMinimum(index) : 0.0f;
467 });
468 procgenEditor.addFunc("getParamMaximum", [](ScriptProcgenScriptEditor* self, int index) {
469 return self ? self->editor().paramMaximum(index) : 0.0f;
470 });
471 procgenEditor.addFunc("getParamStep", [](ScriptProcgenScriptEditor* self, int index) {
472 return self ? self->editor().paramStep(index) : 0.0f;
473 });
474 procgenEditor.addFunc("getParamChoiceCount", [](ScriptProcgenScriptEditor* self, int index) {
475 return self ? self->editor().paramChoiceCount(index) : 0;
476 });
477 procgenEditor.addFunc("getParamChoice", [](ScriptProcgenScriptEditor* self, int paramIndex, int choiceIndex) {
478 return self ? self->editor().paramChoice(paramIndex, choiceIndex) : std::string{};
479 });
480 procgenEditor.addFunc("getInt", [](ScriptProcgenScriptEditor* self, const std::string& key) {
481 return self ? self->editor().getInt(key) : 0;
482 });
483 procgenEditor.addFunc("getFloat", [](ScriptProcgenScriptEditor* self, const std::string& key) {
484 return self ? self->editor().getFloat(key) : 0.0f;
485 });
486 procgenEditor.addFunc("getBool", [](ScriptProcgenScriptEditor* self, const std::string& key) {
487 return self && self->editor().getBool(key);
488 });
489 procgenEditor.addFunc("getString", [](ScriptProcgenScriptEditor* self, const std::string& key) {
490 return self ? self->editor().getString(key) : std::string{};
491 });
492 procgenEditor.addFunc("getStageCount",
493 [](ScriptProcgenScriptEditor* self) { return self ? self->editor().stageCount() : 0; });
494 procgenEditor.addFunc("getStageName", [](ScriptProcgenScriptEditor* self, int index) {
495 return self ? self->editor().stageName(index) : std::string{};
496 });
497 procgenEditor.addFunc("getPointCount",
498 [](ScriptProcgenScriptEditor* self) { return self ? self->editor().pointCount() : 0; });
499 procgenEditor.addFunc("getPointX", [](ScriptProcgenScriptEditor* self, int index) {
500 return self ? self->editor().pointX(index) : 0.0f;
501 });
502 procgenEditor.addFunc("getPointZ", [](ScriptProcgenScriptEditor* self, int index) {
503 return self ? self->editor().pointZ(index) : 0.0f;
504 });
505 procgenEditor.addFunc("getPointSeed", [](ScriptProcgenScriptEditor* self, int index) {
506 return self ? static_cast<int>(self->editor().pointSeed(index)) : 0;
507 });
508
509 editor::registerEditorOwnedCreate<ScriptProcgenScriptEditor, ProcgenEditorModule>(
510 moduleClass, bind, "procgen target id must not be empty");
511 moduleClass.addFunc("createMeshModifier", [bind](ProcgenEditorModule*, const std::string& targetId) {
512 return bind.ownedCreate<MeshModifierEditor>("mesh target id must not be empty", targetId);
513 });
514}
515
516} // namespace eve::procgen_editor
double z
double x
ActionParameterOperation operation
std::uint64_t revision
std::string title
bool committed
SQObjectPtr key
Definition ECS.cpp:155
ScriptFieldRegion region
std::string message
wgpu::PopErrorScopeStatus status
std::string label
std::string id
Poco::JSON::Object::Ptr result
Snapshot snapshot
std::vector< std::int32_t > order
std::string uri
std::uint32_t targetId
std::shared_ptr< const std::vector< glm::vec2 > > points
Squirrel adapter for the procgen script editor.
UI-neutral host for a script generator: schema params, undo, PointSet preview.
Object::Ptr value
bool found
std::string text
std::string kind
uint32_t seed
Definition TreeMesh.cpp:276
uint32_t index
const VegetationPresetContext & context
glm::vec3 point
void ignore(std::string_view reason={}) const noexcept
Explicitly discard this result after documenting the reason.
Definition Result.h:571
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
const std::string & value() const noexcept
Returns the exact legacy or canonical compatibility spelling.
Definition Identity.h:365
Dotted property path (layout.size) compared and persisted as text.
Definition EditingIds.h:78
Deterministic owning value tree shared by authoring hosts.
Composition model shared by project-specific developer and runtime editors.
bool setPanelContext(const std::string &id, const std::string &context)
Attach a semantic input context such as scene, graph, or timeline.
Result< WorkspacePanelDescriptor > registerPanel(WorkspacePanelDescriptor descriptor)
Register a checked owning panel descriptor.
Result< WorkspacePanelDescriptor > activatePanel(const StableId &id)
Activate a visible panel with structured not-found/rejected results.
bool setPanelCapability(const std::string &id, const std::string &capability)
Attach a capability requirement used by the host when filtering panels.
Result< TransactionReceipt > commit() override
Preflight and commit all active operations through the authority.
Result< TransactionId > begin(TransactionSpec specification) override
Begin a transaction with a stable id and base revision.
Result< TransactionReceipt > undo() override
Compensate the most recent committed transaction.
Result< void > discard() override
Discard the active, not-yet-committed operation list.
Result< TransactionReceipt > redo() override
Reapply the most recently compensated transaction.
Result< void > append(DomainOperation operation) override
Append an operation to the active transaction without applying it.
Editor facade binder: common script::BindContext plus history/owned-create helpers.
Script-friendly collection of attributed 3D samples.
Definition PointSet.h:59
Result< editing::DomainOperation > makeSet(const editing::SelectionSnapshot &, const editing::PropertyPath &, const EditorValue &, editing::PropertySetMode) const override
Make set.
Result< editing::DomainOperation > makeLoadModule(ProcgenScriptModuleSpec spec) const
Replace module identity and schema, remapping values (drop unknown, fill defaults).
const std::string & moduleId() const
Module id.
editing::TargetId targetId() const override
Target id.
std::uint64_t revision() const override
Revision.
const EditorValue::Object & values() const
Values.
const std::vector< procgen::ParamDescriptor > & params() const
Params.
static Result< ProcgenScriptModuleSpec > parseSpec(std::string uri, std::string id, std::string displayName, std::string kind, const EditorValue &schema)
Parse a schema array into a module spec.
UI-neutral composition controller for modifier graph, spline, sculpt, UV-paint, merge,...
const std::string & activeTool() const noexcept
Active tool.
const std::string & targetId() const noexcept
procgen_editing::Result< void > observeRevision(std::string document, std::uint64_t revision)
Observe an externally owned document revision without copying its state.
procgen_editing::Result< void > activateTool(editor::EditorWorkspace &workspace, std::string tool)
Activate graph, spline, sculpt, uvPaint, merge, or adhere and update semantic focus.
Composition adapter for the script-hosted procgen generator editor.
float paramStep(int index) const
Param step.
int getInt(const std::string &key) const
Returns the int.
procgen_editing::Result< void > setPointBudget(int budget)
Sets the point budget.
procgen_editing::Result< editor::TransactionReceipt > redo()
std::string getString(const std::string &key) const
Returns the string.
procgen_editing::Result< void > configureWorkspace(editor::EditorWorkspace &workspace) const
Install Modules / Preview / Inspector / Debug Stages panels.
procgen_editing::Result< void > publishStage(const procgen::PointSet *points, std::string stage)
Copy an intermediate debug stage without changing the displayed output unless it is selected.
std::string stageName(int index) const
Stage name.
std::string displayName() const
Display name.
procgen_editing::Result< void > setLive(bool enabled)
Choose whether the presenter should rebuild on every parameter commit.
std::string paramKey(int index) const
Param key.
float paramMaximum(int index) const
Param maximum.
std::string paramChoice(int paramIndex, int choiceIndex) const
Param choice.
procgen_editing::Result< void > setBool(std::string key, bool value)
Sets the bool.
procgen_editing::Result< void > setParam(std::string key, procgen_editing::EditorValue value)
Sets the param.
procgen_editing::Result< void > setString(std::string key, std::string value)
Sets the string.
float getFloat(const std::string &key) const
Returns the float.
procgen_editing::Result< void > setFloat(std::string key, double value)
Sets the float.
procgen_editing::Result< void > setInt(std::string key, int value)
Sets the int.
std::uint32_t pointSeed(int index) const
Point seed.
float paramMinimum(int index) const
Param minimum.
procgen_editing::Result< void > selectStage(std::string stage)
Select stage.
procgen_editing::Result< void > publishPreview(const procgen::PointSet *points, std::string stage, std::uint64_t expectedRevision)
Copy a successful generation into the preview cache.
procgen_editing::Result< void > failPreview(std::string message, std::uint64_t expectedRevision)
procgen_editing::Result< editor::TransactionReceipt > undo()
std::string paramLabel(int index) const
Param label.
bool getBool(const std::string &key) const
Returns the bool.
std::string paramKind(int index) const
Param kind.
ProcgenScriptEditor(std::string targetId)
Construct an empty generator host.
int paramChoiceCount(int index) const
Param choice count.
procgen_editing::Result< void > loadModule(procgen_editing::ProcgenScriptModuleSpec spec)
Result< T > applied(T value, std::vector< Diagnostic > diagnostics={})
Construct an Applied result with an owning payload and optional diagnostics.
eve::editing::StableId StableId
Definition EditorIds.h:36
EditorValue toEditorValue(const eve::Value &value)
Compatibility spelling for conversion into the authoring value tree.
eve::editing::TargetId TargetId
Definition EditorIds.h:29
eve::editing::TransactionId TransactionId
Definition EditorIds.h:34
ssq::Table project(HSQUIRRELVM vm, const eve::Result< void > &result)
Project a completed editing result that has no payload.
void exposeProcgenScriptEditorScriptBindings(ssq::Table &table, ssq::Class &moduleClass)
Expose the script-owned ProcgenScriptEditor factory on ProcgenEditorModule.
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
Result< Value > valueFromSquirrel(HSQUIRRELVM vm, SQInteger index, const SquirrelValueOptions &options)
Convert one Squirrel value into the canonical owning Value tree.
bool enabled
SelectionItem public API.
SelectionSnapshot public API.
TransactionSpec public API.
UI-independent metadata for one procedural recipe parameter.
Definition ParamSchema.h:14
Authored identity and reflected parameter schema for one script generator.