more undo commands
- add edit command for duplicating map events - add edit commands for painting map collision - edit commands that delete events now select the proper next event
This commit is contained in:
parent
98c3298805
commit
6c2d035dfa
7 changed files with 122 additions and 47 deletions
|
@ -25,7 +25,7 @@ enum CommandId {
|
||||||
ID_EventShift, // - done
|
ID_EventShift, // - done
|
||||||
ID_EventCreate, // - done
|
ID_EventCreate, // - done
|
||||||
ID_EventDelete, // - done
|
ID_EventDelete, // - done
|
||||||
ID_EventDuplicate, // -
|
ID_EventDuplicate, // - done
|
||||||
ID_EventSetData, // - ?
|
ID_EventSetData, // - ?
|
||||||
// Region map editor history commands
|
// Region map editor history commands
|
||||||
};
|
};
|
||||||
|
@ -38,8 +38,8 @@ class PaintMetatile : public QUndoCommand {
|
||||||
public:
|
public:
|
||||||
PaintMetatile(Map *map,
|
PaintMetatile(Map *map,
|
||||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||||
unsigned eventId, QUndoCommand *parent = nullptr);
|
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||||
~PaintMetatile();
|
virtual ~PaintMetatile();
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
void redo() override;
|
void redo() override;
|
||||||
|
@ -53,7 +53,23 @@ private:
|
||||||
Blockdata *newMetatiles;
|
Blockdata *newMetatiles;
|
||||||
Blockdata *oldMetatiles;
|
Blockdata *oldMetatiles;
|
||||||
|
|
||||||
unsigned eventId;
|
unsigned actionId;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Implements a command to commit paint actions
|
||||||
|
/// on the metatile collision and elevation.
|
||||||
|
class PaintCollision : public PaintMetatile {
|
||||||
|
public:
|
||||||
|
PaintCollision(Map *map,
|
||||||
|
Blockdata *oldCollision, Blockdata *newCollision,
|
||||||
|
unsigned actionId, QUndoCommand *parent = nullptr)
|
||||||
|
: PaintMetatile(map, oldCollision, newCollision, actionId, parent) {
|
||||||
|
setText("Paint Collision");
|
||||||
|
}
|
||||||
|
|
||||||
|
int id() const override { return CommandId::ID_PaintCollision; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +79,7 @@ class PaintBorder : public QUndoCommand {
|
||||||
public:
|
public:
|
||||||
PaintBorder(Map *map,
|
PaintBorder(Map *map,
|
||||||
Blockdata *oldBorder, Blockdata *newBorder,
|
Blockdata *oldBorder, Blockdata *newBorder,
|
||||||
unsigned eventId, QUndoCommand *parent = nullptr);
|
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||||
~PaintBorder();
|
~PaintBorder();
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
|
@ -78,7 +94,7 @@ private:
|
||||||
Blockdata *newBorder;
|
Blockdata *newBorder;
|
||||||
Blockdata *oldBorder;
|
Blockdata *oldBorder;
|
||||||
|
|
||||||
unsigned eventId;
|
unsigned actionId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +105,7 @@ class BucketFillMetatile : public PaintMetatile {
|
||||||
public:
|
public:
|
||||||
BucketFillMetatile(Map *map,
|
BucketFillMetatile(Map *map,
|
||||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||||
unsigned eventId, QUndoCommand *parent = nullptr);
|
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||||
~BucketFillMetatile();
|
~BucketFillMetatile();
|
||||||
|
|
||||||
bool mergeWith(const QUndoCommand *command) override { return false; }
|
bool mergeWith(const QUndoCommand *command) override { return false; }
|
||||||
|
@ -98,13 +114,30 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Implements a command to commit flood fill actions
|
||||||
|
/// on the metatile collision and elevation.
|
||||||
|
class BucketFillCollision : public PaintCollision {
|
||||||
|
public:
|
||||||
|
BucketFillCollision(Map *map,
|
||||||
|
Blockdata *oldCollision, Blockdata *newCollision,
|
||||||
|
QUndoCommand *parent = nullptr)
|
||||||
|
: PaintCollision(map, oldCollision, newCollision, -1, parent) {
|
||||||
|
setText("Flood Fill Collision");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mergeWith(const QUndoCommand *command) override { return false; }
|
||||||
|
int id() const override { return CommandId::ID_BucketFillCollision; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Implements a command to commit magic fill metatile actions
|
/// Implements a command to commit magic fill metatile actions
|
||||||
/// with the bucket or paint tool onto the map.
|
/// with the bucket or paint tool onto the map.
|
||||||
class MagicFillMetatile : public PaintMetatile {
|
class MagicFillMetatile : public PaintMetatile {
|
||||||
public:
|
public:
|
||||||
MagicFillMetatile(Map *map,
|
MagicFillMetatile(Map *map,
|
||||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||||
unsigned eventId, QUndoCommand *parent = nullptr);
|
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||||
~MagicFillMetatile();
|
~MagicFillMetatile();
|
||||||
|
|
||||||
bool mergeWith(const QUndoCommand *command) override { return false; }
|
bool mergeWith(const QUndoCommand *command) override { return false; }
|
||||||
|
@ -113,13 +146,28 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Implements a command to commit magic fill collision actions.
|
||||||
|
class MagicFillCollision : public PaintCollision {
|
||||||
|
public:
|
||||||
|
MagicFillCollision(Map *map,
|
||||||
|
Blockdata *oldCollision, Blockdata *newCollision,
|
||||||
|
QUndoCommand *parent = nullptr)
|
||||||
|
: PaintCollision(map, oldCollision, newCollision, -1, parent) {
|
||||||
|
setText("Magic Fill Collision");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool mergeWith(const QUndoCommand *command) override { return false; }
|
||||||
|
int id() const override { return CommandId::ID_MagicFillCollision; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Implements a command to commit metatile shift actions.
|
/// Implements a command to commit metatile shift actions.
|
||||||
class ShiftMetatiles : public QUndoCommand {
|
class ShiftMetatiles : public QUndoCommand {
|
||||||
public:
|
public:
|
||||||
ShiftMetatiles(Map *map,
|
ShiftMetatiles(Map *map,
|
||||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||||
unsigned eventId, QUndoCommand *parent = nullptr);
|
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||||
~ShiftMetatiles();
|
~ShiftMetatiles();
|
||||||
|
|
||||||
void undo() override;
|
void undo() override;
|
||||||
|
@ -134,8 +182,7 @@ private:
|
||||||
Blockdata *newMetatiles;
|
Blockdata *newMetatiles;
|
||||||
Blockdata *oldMetatiles;
|
Blockdata *oldMetatiles;
|
||||||
|
|
||||||
unsigned eventId;
|
unsigned actionId;
|
||||||
bool mergeable = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#define BORDER_DISTANCE 7
|
#define BORDER_DISTANCE 7
|
||||||
|
|
||||||
class MapPixmapItem;
|
class MapPixmapItem;
|
||||||
|
class CollisionPixmapItem;
|
||||||
class BorderMetatilesPixmapItem;
|
class BorderMetatilesPixmapItem;
|
||||||
|
|
||||||
class Map : public QObject
|
class Map : public QObject
|
||||||
|
@ -97,6 +98,9 @@ public:
|
||||||
MapPixmapItem *mapItem = nullptr;
|
MapPixmapItem *mapItem = nullptr;
|
||||||
void setMapItem(MapPixmapItem *item) { mapItem = item; }
|
void setMapItem(MapPixmapItem *item) { mapItem = item; }
|
||||||
|
|
||||||
|
CollisionPixmapItem *collisionItem = nullptr;
|
||||||
|
void setCollisionItem(CollisionPixmapItem *item) { collisionItem = item; }
|
||||||
|
|
||||||
BorderMetatilesPixmapItem *borderItem = nullptr;
|
BorderMetatilesPixmapItem *borderItem = nullptr;
|
||||||
void setBorderItem(BorderMetatilesPixmapItem *item) { borderItem = item; }
|
void setBorderItem(BorderMetatilesPixmapItem *item) { borderItem = item; }
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
: MapPixmapItem(map, metatileSelector, settings){
|
: MapPixmapItem(map, metatileSelector, settings){
|
||||||
this->movementPermissionsSelector = movementPermissionsSelector;
|
this->movementPermissionsSelector = movementPermissionsSelector;
|
||||||
this->opacity = opacity;
|
this->opacity = opacity;
|
||||||
|
map->setCollisionItem(this);
|
||||||
}
|
}
|
||||||
MovementPermissionsSelector *movementPermissionsSelector;
|
MovementPermissionsSelector *movementPermissionsSelector;
|
||||||
qreal *opacity;
|
qreal *opacity;
|
||||||
|
@ -24,6 +25,9 @@ public:
|
||||||
virtual void pick(QGraphicsSceneMouseEvent*);
|
virtual void pick(QGraphicsSceneMouseEvent*);
|
||||||
void draw(bool ignoreCache = false);
|
void draw(bool ignoreCache = false);
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned actionId_ = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *);
|
void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *);
|
||||||
void hoveredMapMovementPermissionChanged(int, int);
|
void hoveredMapMovementPermissionChanged(int, int);
|
||||||
|
|
|
@ -69,7 +69,7 @@ private:
|
||||||
void paintSmartPath(int x, int y, bool fromScriptCall = false);
|
void paintSmartPath(int x, int y, bool fromScriptCall = false);
|
||||||
static QList<int> smartPathTable;
|
static QList<int> smartPathTable;
|
||||||
|
|
||||||
unsigned eventId_ = 0;
|
unsigned actionId_ = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void startPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
void startPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
||||||
|
|
|
@ -8,16 +8,20 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void renderMapBlocks(Map *map, bool ignoreCache = false) {
|
||||||
|
map->mapItem->draw(ignoreCache);
|
||||||
|
map->collisionItem->draw(ignoreCache);
|
||||||
|
}
|
||||||
PaintMetatile::PaintMetatile(Map *map,
|
PaintMetatile::PaintMetatile(Map *map,
|
||||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||||
unsigned eventId, QUndoCommand *parent) : QUndoCommand(parent) {
|
unsigned actionId, QUndoCommand *parent) : QUndoCommand(parent) {
|
||||||
setText("Paint Metatiles");
|
setText("Paint Metatiles");
|
||||||
|
|
||||||
this->map = map;
|
this->map = map;
|
||||||
this->oldMetatiles = oldMetatiles;
|
this->oldMetatiles = oldMetatiles;
|
||||||
this->newMetatiles = newMetatiles;
|
this->newMetatiles = newMetatiles;
|
||||||
|
|
||||||
this->eventId = eventId;
|
this->actionId = actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintMetatile::~PaintMetatile() {
|
PaintMetatile::~PaintMetatile() {
|
||||||
|
@ -34,7 +38,7 @@ void PaintMetatile::redo() {
|
||||||
map->layout->blockdata->copyFrom(newMetatiles);
|
map->layout->blockdata->copyFrom(newMetatiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
map->mapItem->draw();
|
renderMapBlocks(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintMetatile::undo() {
|
void PaintMetatile::undo() {
|
||||||
|
@ -44,7 +48,7 @@ void PaintMetatile::undo() {
|
||||||
map->layout->blockdata->copyFrom(oldMetatiles);
|
map->layout->blockdata->copyFrom(oldMetatiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
map->mapItem->draw();
|
renderMapBlocks(map);
|
||||||
|
|
||||||
QUndoCommand::undo();
|
QUndoCommand::undo();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +59,7 @@ bool PaintMetatile::mergeWith(const QUndoCommand *command) {
|
||||||
if (this->map != other->map)
|
if (this->map != other->map)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (eventId != other->eventId)
|
if (actionId != other->actionId)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this->newMetatiles->copyFrom(other->newMetatiles);
|
this->newMetatiles->copyFrom(other->newMetatiles);
|
||||||
|
@ -69,14 +73,14 @@ bool PaintMetatile::mergeWith(const QUndoCommand *command) {
|
||||||
|
|
||||||
PaintBorder::PaintBorder(Map *map,
|
PaintBorder::PaintBorder(Map *map,
|
||||||
Blockdata *oldBorder, Blockdata *newBorder,
|
Blockdata *oldBorder, Blockdata *newBorder,
|
||||||
unsigned eventId, QUndoCommand *parent) : QUndoCommand(parent) {
|
unsigned actionId, QUndoCommand *parent) : QUndoCommand(parent) {
|
||||||
setText("Paint Border");
|
setText("Paint Border");
|
||||||
|
|
||||||
this->map = map;
|
this->map = map;
|
||||||
this->oldBorder = oldBorder;
|
this->oldBorder = oldBorder;
|
||||||
this->newBorder = newBorder;
|
this->newBorder = newBorder;
|
||||||
|
|
||||||
this->eventId = eventId;
|
this->actionId = actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintBorder::~PaintBorder() {
|
PaintBorder::~PaintBorder() {
|
||||||
|
@ -114,8 +118,8 @@ void PaintBorder::undo() {
|
||||||
|
|
||||||
BucketFillMetatile::BucketFillMetatile(Map *map,
|
BucketFillMetatile::BucketFillMetatile(Map *map,
|
||||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||||
unsigned eventId, QUndoCommand *parent)
|
unsigned actionId, QUndoCommand *parent)
|
||||||
: PaintMetatile(map, oldMetatiles, newMetatiles, eventId, parent) {
|
: PaintMetatile(map, oldMetatiles, newMetatiles, actionId, parent) {
|
||||||
setText("Bucket Fill Metatiles");
|
setText("Bucket Fill Metatiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,8 +133,8 @@ BucketFillMetatile::~BucketFillMetatile() {
|
||||||
|
|
||||||
MagicFillMetatile::MagicFillMetatile(Map *map,
|
MagicFillMetatile::MagicFillMetatile(Map *map,
|
||||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||||
unsigned eventId, QUndoCommand *parent)
|
unsigned actionId, QUndoCommand *parent)
|
||||||
: PaintMetatile(map, oldMetatiles, newMetatiles, eventId, parent) {
|
: PaintMetatile(map, oldMetatiles, newMetatiles, actionId, parent) {
|
||||||
setText("Magic Fill Metatiles");
|
setText("Magic Fill Metatiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,14 +148,14 @@ MagicFillMetatile::~MagicFillMetatile() {
|
||||||
|
|
||||||
ShiftMetatiles::ShiftMetatiles(Map *map,
|
ShiftMetatiles::ShiftMetatiles(Map *map,
|
||||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||||
unsigned eventId, QUndoCommand *parent) : QUndoCommand(parent) {
|
unsigned actionId, QUndoCommand *parent) : QUndoCommand(parent) {
|
||||||
setText("Shift Metatiles");
|
setText("Shift Metatiles");
|
||||||
|
|
||||||
this->map = map;
|
this->map = map;
|
||||||
this->oldMetatiles = oldMetatiles;
|
this->oldMetatiles = oldMetatiles;
|
||||||
this->newMetatiles = newMetatiles;
|
this->newMetatiles = newMetatiles;
|
||||||
|
|
||||||
this->eventId = eventId;
|
this->actionId = actionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShiftMetatiles::~ShiftMetatiles() {
|
ShiftMetatiles::~ShiftMetatiles() {
|
||||||
|
@ -168,7 +172,7 @@ void ShiftMetatiles::redo() {
|
||||||
map->layout->blockdata->copyFrom(newMetatiles);
|
map->layout->blockdata->copyFrom(newMetatiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
map->mapItem->draw(true);
|
renderMapBlocks(map, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShiftMetatiles::undo() {
|
void ShiftMetatiles::undo() {
|
||||||
|
@ -178,7 +182,7 @@ void ShiftMetatiles::undo() {
|
||||||
map->layout->blockdata->copyFrom(oldMetatiles);
|
map->layout->blockdata->copyFrom(oldMetatiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
map->mapItem->draw(true);
|
renderMapBlocks(map, true);
|
||||||
|
|
||||||
QUndoCommand::undo();
|
QUndoCommand::undo();
|
||||||
}
|
}
|
||||||
|
@ -189,7 +193,7 @@ bool ShiftMetatiles::mergeWith(const QUndoCommand *command) {
|
||||||
if (this->map != other->map)
|
if (this->map != other->map)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (eventId != other->eventId)
|
if (actionId != other->actionId)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this->newMetatiles->copyFrom(other->newMetatiles);
|
this->newMetatiles->copyFrom(other->newMetatiles);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "collisionpixmapitem.h"
|
#include "collisionpixmapitem.h"
|
||||||
|
#include "editcommands.h"
|
||||||
|
|
||||||
void CollisionPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
void CollisionPixmapItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||||
int x = static_cast<int>(event->pos().x()) / 16;
|
int x = static_cast<int>(event->pos().x()) / 16;
|
||||||
|
@ -26,12 +27,17 @@ void CollisionPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
|
|
||||||
void CollisionPixmapItem::draw(bool ignoreCache) {
|
void CollisionPixmapItem::draw(bool ignoreCache) {
|
||||||
if (map) {
|
if (map) {
|
||||||
|
map->setCollisionItem(this);
|
||||||
setPixmap(map->renderCollision(*this->opacity, ignoreCache));
|
setPixmap(map->renderCollision(*this->opacity, ignoreCache));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
||||||
if (map) {
|
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||||
|
actionId_++;
|
||||||
|
} else if (map) {
|
||||||
|
Blockdata *oldCollision = map->layout->blockdata->copy();
|
||||||
|
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = static_cast<int>(pos.x()) / 16;
|
int x = static_cast<int>(pos.x()) / 16;
|
||||||
int y = static_cast<int>(pos.y()) / 16;
|
int y = static_cast<int>(pos.y()) / 16;
|
||||||
|
@ -41,34 +47,44 @@ void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
||||||
block->elevation = this->movementPermissionsSelector->getSelectedElevation();
|
block->elevation = this->movementPermissionsSelector->getSelectedElevation();
|
||||||
map->setBlock(x, y, *block, true);
|
map->setBlock(x, y, *block, true);
|
||||||
}
|
}
|
||||||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
|
||||||
map->commit();
|
Blockdata *newCollision = map->layout->blockdata->copy();
|
||||||
}
|
map->editHistory.push(new PaintCollision(map, oldCollision, newCollision, actionId_));
|
||||||
draw();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollisionPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
void CollisionPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
||||||
if (map) {
|
if (event->type() != QEvent::GraphicsSceneMouseRelease) {
|
||||||
|
// do nothing
|
||||||
|
} else if (map) {
|
||||||
|
Blockdata *oldCollision = map->layout->blockdata->copy();
|
||||||
|
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = static_cast<int>(pos.x()) / 16;
|
int x = static_cast<int>(pos.x()) / 16;
|
||||||
int y = static_cast<int>(pos.y()) / 16;
|
int y = static_cast<int>(pos.y()) / 16;
|
||||||
uint16_t collision = this->movementPermissionsSelector->getSelectedCollision();
|
uint16_t collision = this->movementPermissionsSelector->getSelectedCollision();
|
||||||
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
|
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
|
||||||
map->floodFillCollisionElevation(x, y, collision, elevation);
|
map->floodFillCollisionElevation(x, y, collision, elevation);
|
||||||
draw();
|
|
||||||
|
Blockdata *newCollision = map->layout->blockdata->copy();
|
||||||
|
map->editHistory.push(new BucketFillCollision(map, oldCollision, newCollision));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollisionPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
|
void CollisionPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
|
||||||
if (map) {
|
if (event->type() != QEvent::GraphicsSceneMouseRelease) {
|
||||||
|
// do nothing
|
||||||
|
} else if (map) {
|
||||||
|
Blockdata *oldCollision = map->layout->blockdata->copy();
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = static_cast<int>(pos.x()) / 16;
|
int x = static_cast<int>(pos.x()) / 16;
|
||||||
int y = static_cast<int>(pos.y()) / 16;
|
int y = static_cast<int>(pos.y()) / 16;
|
||||||
uint16_t collision = this->movementPermissionsSelector->getSelectedCollision();
|
uint16_t collision = this->movementPermissionsSelector->getSelectedCollision();
|
||||||
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
|
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
|
||||||
map->magicFillCollisionElevation(x, y, collision, elevation);
|
map->magicFillCollisionElevation(x, y, collision, elevation);
|
||||||
draw();
|
|
||||||
|
Blockdata *newCollision = map->layout->blockdata->copy();
|
||||||
|
map->editHistory.push(new MagicFillCollision(map, oldCollision, newCollision));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
||||||
if (map) {
|
if (map) {
|
||||||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||||
eventId_++;
|
actionId_++;
|
||||||
} else {
|
} else {
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = static_cast<int>(pos.x()) / 16;
|
int x = static_cast<int>(pos.x()) / 16;
|
||||||
|
@ -29,7 +29,7 @@ void MapPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
||||||
void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) {
|
void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) {
|
||||||
if (map) {
|
if (map) {
|
||||||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||||
eventId_++;
|
actionId_++;
|
||||||
} else {
|
} else {
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = static_cast<int>(pos.x()) / 16;
|
int x = static_cast<int>(pos.x()) / 16;
|
||||||
|
@ -71,7 +71,7 @@ void MapPixmapItem::shift(int xDelta, int yDelta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||||
ShiftMetatiles *paintEvent = new ShiftMetatiles(map, backupBlockdata, newMetatiles, eventId_);
|
ShiftMetatiles *paintEvent = new ShiftMetatiles(map, backupBlockdata, newMetatiles, actionId_);
|
||||||
map->editHistory.push(paintEvent);
|
map->editHistory.push(paintEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ void MapPixmapItem::paintNormal(int x, int y, bool fromScriptCall) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||||
PaintMetatile *paintEvent = new PaintMetatile(map, oldMetatiles, newMetatiles, eventId_);
|
PaintMetatile *paintEvent = new PaintMetatile(map, oldMetatiles, newMetatiles, actionId_);
|
||||||
map->editHistory.push(paintEvent);
|
map->editHistory.push(paintEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ void MapPixmapItem::paintSmartPath(int x, int y, bool fromScriptCall) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||||
PaintMetatile *paintEvent = new PaintMetatile(map, oldMetatiles, newMetatiles, eventId_);
|
PaintMetatile *paintEvent = new PaintMetatile(map, oldMetatiles, newMetatiles, actionId_);
|
||||||
map->editHistory.push(paintEvent);
|
map->editHistory.push(paintEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ void MapPixmapItem::updateMetatileSelection(QGraphicsSceneMouseEvent *event) {
|
||||||
void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
||||||
if (map) {
|
if (map) {
|
||||||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||||
eventId_++;
|
actionId_++;
|
||||||
} else {
|
} else {
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int x = static_cast<int>(pos.x()) / 16;
|
int x = static_cast<int>(pos.x()) / 16;
|
||||||
|
@ -302,7 +302,7 @@ void MapPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
||||||
void MapPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
|
void MapPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
|
||||||
if (map) {
|
if (map) {
|
||||||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||||
eventId_++;
|
actionId_++;
|
||||||
} else {
|
} else {
|
||||||
QPointF pos = event->pos();
|
QPointF pos = event->pos();
|
||||||
int initialX = static_cast<int>(pos.x()) / 16;
|
int initialX = static_cast<int>(pos.x()) / 16;
|
||||||
|
@ -365,7 +365,7 @@ void MapPixmapItem::magicFill(
|
||||||
}
|
}
|
||||||
|
|
||||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||||
MagicFillMetatile *paintEvent = new MagicFillMetatile(map, oldMetatiles, newMetatiles, eventId_);
|
MagicFillMetatile *paintEvent = new MagicFillMetatile(map, oldMetatiles, newMetatiles, actionId_);
|
||||||
map->editHistory.push(paintEvent);
|
map->editHistory.push(paintEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ void MapPixmapItem::floodFill(
|
||||||
}
|
}
|
||||||
|
|
||||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||||
BucketFillMetatile *paintEvent = new BucketFillMetatile(map, oldMetatiles, newMetatiles, eventId_);
|
BucketFillMetatile *paintEvent = new BucketFillMetatile(map, oldMetatiles, newMetatiles, actionId_);
|
||||||
map->editHistory.push(paintEvent);
|
map->editHistory.push(paintEvent);
|
||||||
|
|
||||||
delete[] visited;
|
delete[] visited;
|
||||||
|
@ -575,7 +575,7 @@ void MapPixmapItem::floodFillSmartPath(int initialX, int initialY, bool fromScri
|
||||||
}
|
}
|
||||||
|
|
||||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||||
BucketFillMetatile *paintEvent = new BucketFillMetatile(map, oldMetatiles, newMetatiles, eventId_);
|
BucketFillMetatile *paintEvent = new BucketFillMetatile(map, oldMetatiles, newMetatiles, actionId_);
|
||||||
map->editHistory.push(paintEvent);
|
map->editHistory.push(paintEvent);
|
||||||
|
|
||||||
delete[] visited;
|
delete[] visited;
|
||||||
|
|
Loading…
Reference in a new issue