载入中...
搜索中...
未找到
PixelWorldCatalogPanel.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Result.h"
8#include "ui/Widget.h"
9
10#include <cstddef>
11#include <cstdint>
12#include <optional>
13#include <string>
14#include <string_view>
15#include <vector>
16
17namespace eve::pixelworld_editor {
18
29
32 std::uint64_t revisionBefore = 0;
33 std::uint64_t revisionAfter = 0;
34 std::uint64_t fingerprint = 0;
35};
36
48public:
57
59 [[nodiscard]] static eve::Result<PixelWorldCatalogPanel> create(std::string_view catalogJson);
61 static PixelWorldCatalogPanel builtIn();
62
64 const eve::pixelworld::MaterialCatalog& draft() const noexcept { return draft_; }
66 std::uint64_t revision() const noexcept { return revision_; }
68 std::size_t selectedMaterialIndex() const noexcept { return selectedMaterial_; }
70 std::optional<std::size_t> selectedReactionIndex() const noexcept { return selectedReaction_; }
72 std::optional<std::size_t> selectedPhaseIndex() const noexcept { return selectedPhase_; }
73
75 std::vector<MaterialCard> materialCards() const;
77 [[nodiscard]] eve::Result<void> selectMaterial(std::size_t index);
79 [[nodiscard]] eve::Result<void> selectReaction(std::size_t index);
81 [[nodiscard]] eve::Result<void> selectPhase(std::size_t index);
82
84 [[nodiscard]] eve::Result<CatalogDraftReceipt> replaceMaterial(
87 [[nodiscard]] eve::Result<CatalogDraftReceipt> replaceReaction(
90 [[nodiscard]] eve::Result<CatalogDraftReceipt> addReaction(
93 [[nodiscard]] eve::Result<CatalogDraftReceipt> removeReaction(std::size_t index);
95 [[nodiscard]] eve::Result<CatalogDraftReceipt> replacePhase(
98 [[nodiscard]] eve::Result<CatalogDraftReceipt> addPhase(
101 [[nodiscard]] eve::Result<CatalogDraftReceipt> removePhase(std::size_t index);
102
104 [[nodiscard]] eve::Result<std::string> document() const;
106 [[nodiscard]] eve::Result<CatalogDraftReceipt> loadDocument(std::string_view catalogJson);
109 eve::pixelworld::PixelWorldControlService& control, std::uint64_t worldId,
110 std::uint64_t expectedFingerprint) const;
111
113 [[nodiscard]] eve::Result<eve::ui::UIHostHandle> open();
115 void close();
117 bool isOpen() const;
119 [[nodiscard]] eve::Result<void> refresh();
121 eve::ui::UIHostHandle host() const noexcept { return host_; }
122
124 eve::ui::WidgetDesc buildWidgetTree();
126 const std::string& statusText() const noexcept { return statusText_; }
127
128private:
130 [[nodiscard]] eve::Result<CatalogDraftReceipt> commitCandidate(
131 std::vector<eve::pixelworld::MaterialDefinition> definitions,
132 std::vector<eve::pixelworld::MaterialReactionRule> reactions,
133 std::vector<eve::pixelworld::MaterialPhaseRule> phases);
134 void observe(eve::Result<CatalogDraftReceipt> result);
135 void observe(eve::Result<void> result);
136
138 std::uint64_t revision_ = 1;
139 std::size_t selectedMaterial_ = 0;
140 std::optional<std::size_t> selectedReaction_;
141 std::optional<std::size_t> selectedPhase_;
142 std::string statusText_ = "Catalog draft is valid";
143 eve::ui::UIHostHandle host_{};
144};
145
146} // namespace eve::pixelworld_editor
#define EVENGINE_API_ORCHESTRATION
Definition Export.h:111
Move-only, checked operation results for the common layer.
Battle::Reactions reactions
LogicalId definition
uint32_t index
const std::map< std::string, Value > & definitions
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Owning immutable material and reaction table used by one PixelWorld.
Main-thread-affine control surface shared by editor, CLI and MCP adapters.
Dedicated visual material/reaction Catalog editor with transactional draft admission.
const std::string & statusText() const noexcept
Last callback diagnostic rendered in the panel status bar.
std::size_t selectedMaterialIndex() const noexcept
Selected material index, always valid for the current nonempty draft.
PixelWorldCatalogPanel(const PixelWorldCatalogPanel &)=delete
std::optional< std::size_t > selectedReactionIndex() const noexcept
Selected reaction index when at least one binary rule exists.
std::optional< std::size_t > selectedPhaseIndex() const noexcept
Selected phase-rule index when at least one transition exists.
std::uint64_t revision() const noexcept
Monotonic local draft revision, advanced only by accepted mutations.
PixelWorldCatalogPanel & operator=(const PixelWorldCatalogPanel &)=delete
const eve::pixelworld::MaterialCatalog & draft() const noexcept
Current validated immutable draft.
eve::ui::UIHostHandle host() const noexcept
Mounted UI host handle, or an empty handle before open().
MaterialId
Compact stable material identifier stored in each authoritative cell.
MaterialState
Broad movement class for one pixel material.
ecs::EntityHandle UIHostHandle
Definition UIHost.h:16
Immutable validated properties for one catalog material.
Data-driven phase transition evaluated after heat diffusion.
Deterministically ordered binary material reaction.
Draft mutation receipt used for UI reconciliation and optimistic publication.
One renderer-neutral material card projected by the Catalog panel.
eve::pixelworld::MaterialState state
Declarative widget description (build once / on dirty → flatten into UIHost::Tree).
Definition Widget.h:15