Add metatile swap

This commit is contained in:
GriffinR
2025-07-29 16:45:31 -04:00
parent f6f07ca5fc
commit d0337a7ae3
19 changed files with 504 additions and 177 deletions

View File

@@ -25,6 +25,7 @@ public:
if (head > 0) {
return history.at(--head);
}
head = -1;
return NULL;
}
@@ -37,9 +38,7 @@ public:
void push(T commit) {
while (head + 1 < history.length()) {
T item = history.last();
history.removeLast();
delete item;
delete history.takeLast();
}
if (saved > head) {
saved = -1;
@@ -48,7 +47,7 @@ public:
head++;
}
T current() {
T current() const {
if (head < 0 || history.length() == 0) {
return NULL;
}
@@ -59,10 +58,30 @@ public:
saved = head;
}
bool isSaved() {
bool isSaved() const {
return saved == head;
}
int length() const {
return history.length();
}
bool isEmpty() const {
return history.isEmpty();
}
int index() const {
return head;
}
bool canUndo() const {
return head >= 0;
}
bool canRedo() const {
return (head + 1) < history.length();
}
private:
QList<T> history;
int head = -1;

View File

@@ -124,10 +124,13 @@ public:
bool isWithinBounds(const QRect &rect) const;
bool isWithinBorderBounds(int x, int y) const;
bool getBlock(int x, int y, Block *out);
bool getBlock(int x, int y, Block *out) const;
void setBlock(int x, int y, Block block, bool enableScriptCallback = false);
void setBlockdata(Blockdata blockdata, bool enableScriptCallback = false);
uint16_t getMetatileId(int x, int y) const;
bool setMetatileId(int x, int y, uint16_t metatileId, bool enableScriptCallback = false);
void adjustDimensions(const QMargins &margins, bool setNewBlockdata = true);
void setDimensions(int newWidth, int newHeight, bool setNewBlockdata = true);
void setBorderDimensions(int newWidth, int newHeight, bool setNewBlockdata = true, bool enableScriptCallback = false);