载入中...
搜索中...
未找到
EditorHistory.h
浏览该文件的文档.
1#pragma once
2
3#include "editor/TileBuffer.h"
4
5#include <string>
6#include <vector>
7
8namespace eve::editor {
9
15public:
16 void clear();
17
18 void push(const std::string &name, const std::string &payload);
19
20 void beginGroup(const std::string &name);
21 void recordTile(int x, int y, int oldGid, int newGid);
22 void endGroup();
23 bool isGrouping() const { return grouping_; }
24
25 bool canUndo() const;
26 bool canRedo() const;
27 int getUndoCount() const;
28 int getRedoCount() const;
29
30 bool undo();
31 bool redo();
32
34 bool applyLastToBuffer(TileBuffer *buffer);
35
36 std::string getLastActionName() const;
37 std::string getLastActionKind() const; // "opaque" | "tiles"
38 std::string getLastPayload() const;
39 int getLastTileCount() const;
40 int getLastTileX(int index) const;
41 int getLastTileY(int index) const;
42 int getLastTileOldGid(int index) const;
43 int getLastTileNewGid(int index) const;
44
45private:
46 struct TileChange {
47 int x = 0, y = 0, oldGid = 0, newGid = 0;
48 };
49 struct Action {
50 std::string kind; // opaque | tiles
51 std::string name;
52 std::string payload;
53 std::vector<TileChange> tiles;
54 };
55
56 void trimRedo();
57 bool validLastTile(int index) const;
58
59 std::vector<Action> undoStack_;
60 std::vector<Action> redoStack_;
61 Action pending_;
62 bool grouping_ = false;
63 Action lastApplied_;
64 bool hasLast_ = false;
65 bool lastWasUndo_ = false;
66};
67
68} // namespace eve::editor
Tok kind
int y
Definition Grass.cpp:135
int x
Definition Grass.cpp:135
const char * name
Definition RockMesh.cpp:21
std::vector< WfcTile > tiles
Definition WfcSimple.cpp:22
Undo/redo stack: opaque string actions + optional tile change groups that can apply directly to a Til...
std::string getLastActionName() const
int getLastTileY(int index) const
int getLastTileOldGid(int index) const
int getLastTileX(int index) const
int getLastTileNewGid(int index) const
void recordTile(int x, int y, int oldGid, int newGid)
std::string getLastActionKind() const
void push(const std::string &name, const std::string &payload)
bool applyLastToBuffer(TileBuffer *buffer)
Apply last undone/redone tile group to buffer (no-op for opaque actions).
std::string getLastPayload() const
void beginGroup(const std::string &name)
Independent GID grid for map brushes (no hard dependency on map.TileLayer).
Definition TileBuffer.h:9