载入中...
搜索中...
未找到
EditorHistory.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
7
8#include <string>
9#include <vector>
10
11namespace eve::level_editing {
12
18public:
20 void clear();
21
23 void push(const std::string &name, const std::string &payload);
24
26 void beginGroup(const std::string &name);
28 void recordTile(int x, int y, int oldGid, int newGid);
30 void endGroup();
32 bool isGrouping() const { return grouping_; }
33
35 bool canUndo() const;
37 bool canRedo() const;
39 int getUndoCount() const;
41 int getRedoCount() const;
42
44 [[nodiscard]] editing::Result<std::string> undoAction();
46 [[nodiscard]] editing::Result<std::string> redoAction();
48 bool undo();
50 bool redo();
51
54 [[nodiscard]] editing::Result<void> applyLastToBufferChecked(TileBuffer& buffer);
56 bool applyLastToBuffer(TileBuffer *buffer);
57
59 std::string getLastActionName() const;
61 std::string getLastActionKind() const; // "opaque" | "tiles"
63 std::string getLastPayload() const;
65 int getLastTileCount() const;
67 int getLastTileX(int index) const;
69 int getLastTileY(int index) const;
71 int getLastTileOldGid(int index) const;
73 int getLastTileNewGid(int index) const;
74
75private:
76 struct TileChange {
77 int x = 0, y = 0, oldGid = 0, newGid = 0;
78 };
79 struct Action {
80 std::string kind; // opaque | tiles
81 std::string name;
82 std::string payload;
83 std::vector<TileChange> tiles;
84 };
85
86 void trimRedo();
87 bool validLastTile(int index) const;
88
89 std::vector<Action> undoStack_;
90 std::vector<Action> redoStack_;
91 Action pending_;
92 bool grouping_ = false;
93 Action lastApplied_;
94 bool hasLast_ = false;
95 bool lastWasUndo_ = false;
96};
97
98} // namespace eve::level_editing
Value::Object payload
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
#define EVENGINE_API_DOMAINS
Definition Export.h:110
TokenKind kind
std::string name
std::unique_ptr< gpgpu::GpuBuffer > buffer
Definition OnnxGpgpu.cpp:26
uint32_t index
std::vector< WfcTile > tiles
Definition WfcSimple.cpp:22
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Undo/redo stack: opaque string actions + optional tile change groups that can apply directly to a Til...
bool isGrouping() const
True when grouping.
Independent GID grid for map brushes (no hard dependency on map.TileLayer).
Definition TileBuffer.h:11