载入中...
搜索中...
未找到
PixelWorldEditorModule.cpp
浏览该文件的文档.
2
3#include <simplesquirrel/simplesquirrel.hpp>
4
5#include <stdexcept>
6
8
10
12 if (!panel_) panel_ = std::make_unique<PixelWorldCatalogPanel>(PixelWorldCatalogPanel::builtIn());
13 auto opened = panel_->open();
14 if (!opened) return eve::Result<void>::failure(opened.status());
16}
17
19 if (panel_) panel_->close();
20}
21
23 return panel_ && panel_->isOpen();
24}
25
26void PixelWorldEditorModule::expose(ssq::Table& table) {
27 auto module = table.addClass(name, PixelWorldEditorModule::create, false);
28 expose(module);
29}
30
31void PixelWorldEditorModule::expose(ssq::Class& cls) {
32 cls.addFunc("openCatalog", [](PixelWorldEditorModule* self) {
33 auto result = self->openCatalog();
34 if (!result) throw std::runtime_error(result.status().describe());
35 });
36 cls.addFunc("closeCatalog", [](PixelWorldEditorModule* self) { self->closeCatalog(); });
37 cls.addFunc("isCatalogOpen", [](PixelWorldEditorModule* self) {
38 return self->isCatalogOpen();
39 });
40}
41
42} // namespace eve::pixelworld_editor
HSQOBJECT cls
Definition ECS.cpp:21
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:26
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static PixelWorldCatalogPanel builtIn()
Create a panel over the canonical built-in Catalog.
Script-facing owner for the dedicated PixelWorld Catalog panel.
bool isCatalogOpen() const
Report whether the Catalog panel is currently visible.
void closeCatalog()
Hide the Catalog panel while preserving its draft.
eve::Result< void > openCatalog()
Open the built-in Catalog draft panel, creating it on first use.