Simplify some usages of Blockdata
This commit is contained in:
parent
f09e28f06c
commit
a3326a764b
5 changed files with 27 additions and 48 deletions
|
@ -75,8 +75,8 @@ public:
|
|||
int getBorderHeight();
|
||||
QPixmap render(bool ignoreCache, MapLayout * fromLayout = nullptr);
|
||||
QPixmap renderCollision(qreal opacity, bool ignoreCache);
|
||||
bool mapBlockChanged(int i, Blockdata cache);
|
||||
bool borderBlockChanged(int i, Blockdata cache);
|
||||
bool mapBlockChanged(int i, const Blockdata &cache);
|
||||
bool borderBlockChanged(int i, const Blockdata &cache);
|
||||
void cacheBlockdata();
|
||||
void cacheCollision();
|
||||
bool getBlock(int x, int y, Block *out);
|
||||
|
|
|
@ -78,7 +78,7 @@ int Map::getBorderHeight() {
|
|||
return layout->border_height.toInt(nullptr, 0);
|
||||
}
|
||||
|
||||
bool Map::mapBlockChanged(int i, Blockdata cache) {
|
||||
bool Map::mapBlockChanged(int i, const Blockdata &cache) {
|
||||
if (cache.length() <= i)
|
||||
return true;
|
||||
if (layout->blockdata.length() <= i)
|
||||
|
@ -87,7 +87,7 @@ bool Map::mapBlockChanged(int i, Blockdata cache) {
|
|||
return layout->blockdata.at(i) != cache.at(i);
|
||||
}
|
||||
|
||||
bool Map::borderBlockChanged(int i, Blockdata cache) {
|
||||
bool Map::borderBlockChanged(int i, const Blockdata &cache) {
|
||||
if (cache.length() <= i)
|
||||
return true;
|
||||
if (layout->border.length() <= i)
|
||||
|
|
|
@ -21,9 +21,8 @@ void BorderMetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
Blockdata newBorder = map->layout->border;
|
||||
if (newBorder != oldBorder) {
|
||||
map->editHistory.push(new PaintBorder(map, oldBorder, newBorder, 0));
|
||||
if (map->layout->border != oldBorder) {
|
||||
map->editHistory.push(new PaintBorder(map, oldBorder, map->layout->border, 0));
|
||||
}
|
||||
|
||||
emit borderMetatilesChanged();
|
||||
|
|
|
@ -65,9 +65,8 @@ void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
|||
map->setBlock(pos.x(), pos.y(), block, true);
|
||||
}
|
||||
|
||||
Blockdata newCollision = map->layout->blockdata;
|
||||
if (newCollision != oldCollision) {
|
||||
map->editHistory.push(new PaintCollision(map, oldCollision, newCollision, actionId_));
|
||||
if (map->layout->blockdata != oldCollision) {
|
||||
map->editHistory.push(new PaintCollision(map, oldCollision, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,9 +82,8 @@ void CollisionPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
|||
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
|
||||
map->floodFillCollisionElevation(pos.x(), pos.y(), collision, elevation);
|
||||
|
||||
Blockdata newCollision = map->layout->blockdata;
|
||||
if (newCollision != oldCollision) {
|
||||
map->editHistory.push(new BucketFillCollision(map, oldCollision, newCollision));
|
||||
if (map->layout->blockdata != oldCollision) {
|
||||
map->editHistory.push(new BucketFillCollision(map, oldCollision, map->layout->blockdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,9 +98,8 @@ void CollisionPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
|
|||
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
|
||||
map->magicFillCollisionElevation(pos.x(), pos.y(), collision, elevation);
|
||||
|
||||
Blockdata newCollision = map->layout->blockdata;
|
||||
if (newCollision != oldCollision) {
|
||||
map->editHistory.push(new MagicFillCollision(map, oldCollision, newCollision));
|
||||
if (map->layout->blockdata != oldCollision) {
|
||||
map->editHistory.push(new MagicFillCollision(map, oldCollision, map->layout->blockdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,8 @@ void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) {
|
|||
}
|
||||
|
||||
void MapPixmapItem::shift(int xDelta, int yDelta, bool fromScriptCall) {
|
||||
Blockdata backupBlockdata = map->layout->blockdata;
|
||||
Blockdata oldMetatiles = !fromScriptCall ? map->layout->blockdata : Blockdata();
|
||||
|
||||
for (int i = 0; i < map->getWidth(); i++)
|
||||
for (int j = 0; j < map->getHeight(); j++) {
|
||||
int destX = i + xDelta;
|
||||
|
@ -89,15 +90,12 @@ void MapPixmapItem::shift(int xDelta, int yDelta, bool fromScriptCall) {
|
|||
destY %= map->getHeight();
|
||||
|
||||
int blockIndex = j * map->getWidth() + i;
|
||||
Block srcBlock = backupBlockdata.at(blockIndex);
|
||||
Block srcBlock = oldMetatiles.at(blockIndex);
|
||||
map->setBlock(destX, destY, srcBlock);
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata newMetatiles = map->layout->blockdata;
|
||||
if (newMetatiles != backupBlockdata) {
|
||||
map->editHistory.push(new ShiftMetatiles(map, backupBlockdata, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new ShiftMetatiles(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,11 +135,8 @@ void MapPixmapItem::paintNormal(int x, int y, bool fromScriptCall) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata newMetatiles = map->layout->blockdata;
|
||||
if (newMetatiles != oldMetatiles) {
|
||||
map->editHistory.push(new PaintMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new PaintMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,11 +248,8 @@ void MapPixmapItem::paintSmartPath(int x, int y, bool fromScriptCall) {
|
|||
map->setBlock(actualX, actualY, block, !fromScriptCall);
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata newMetatiles = map->layout->blockdata;
|
||||
if (newMetatiles != oldMetatiles) {
|
||||
map->editHistory.push(new PaintMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new PaintMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -432,11 +424,8 @@ void MapPixmapItem::magicFill(
|
|||
}
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata newMetatiles = map->layout->blockdata;
|
||||
if (newMetatiles != oldMetatiles) {
|
||||
map->editHistory.push(new MagicFillMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new MagicFillMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -513,11 +502,8 @@ void MapPixmapItem::floodFill(
|
|||
}
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata newMetatiles = map->layout->blockdata;
|
||||
if (newMetatiles != oldMetatiles) {
|
||||
map->editHistory.push(new BucketFillMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new BucketFillMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -635,11 +621,8 @@ void MapPixmapItem::floodFillSmartPath(int initialX, int initialY, bool fromScri
|
|||
}
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata newMetatiles = map->layout->blockdata;
|
||||
if (newMetatiles != oldMetatiles) {
|
||||
map->editHistory.push(new BucketFillMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new BucketFillMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue