Add setBlock overload, handle collision values of 2 or 3
This commit is contained in:
parent
0fa71dc4c8
commit
4feb913fe8
5 changed files with 15 additions and 6 deletions
|
@ -46,7 +46,8 @@ public:
|
|||
Q_INVOKABLE QJSValue getBlock(int x, int y);
|
||||
void tryRedrawMapArea(bool forceRedraw);
|
||||
void tryCommitMapChanges(bool commitChanges);
|
||||
Q_INVOKABLE void setBlock(int x, int y, int tile, int collision, int elevation, bool forceRedraw = true, bool commitChanges = true);
|
||||
Q_INVOKABLE void setBlock(int x, int y, int metatileId, int collision, int elevation, bool forceRedraw = true, bool commitChanges = true);
|
||||
Q_INVOKABLE void setBlock(int x, int y, int rawValue, bool forceRedraw = true, bool commitChanges = true);
|
||||
Q_INVOKABLE void setBlocksFromSelection(int x, int y, bool forceRedraw = true, bool commitChanges = true);
|
||||
Q_INVOKABLE int getMetatileId(int x, int y);
|
||||
Q_INVOKABLE void setMetatileId(int x, int y, int metatileId, bool forceRedraw = true, bool commitChanges = true);
|
||||
|
|
|
@ -1075,7 +1075,7 @@ QString Editor::getMovementPermissionText(uint16_t collision, uint16_t elevation
|
|||
} else if (collision == 0) {
|
||||
message = QString("Collision: Passable, Elevation: %1").arg(elevation);
|
||||
} else {
|
||||
message = QString("Collision: Impassable, Elevation: %1").arg(elevation);
|
||||
message = QString("Collision: Impassable (%1), Elevation: %2").arg(collision).arg(elevation);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -50,10 +50,18 @@ void MainWindow::tryCommitMapChanges(bool commitChanges) {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::setBlock(int x, int y, int tile, int collision, int elevation, bool forceRedraw, bool commitChanges) {
|
||||
void MainWindow::setBlock(int x, int y, int metatileId, int collision, int elevation, bool forceRedraw, bool commitChanges) {
|
||||
if (!this->editor || !this->editor->map)
|
||||
return;
|
||||
this->editor->map->setBlock(x, y, Block(tile, collision, elevation));
|
||||
this->editor->map->setBlock(x, y, Block(metatileId, collision, elevation));
|
||||
this->tryCommitMapChanges(commitChanges);
|
||||
this->tryRedrawMapArea(forceRedraw);
|
||||
}
|
||||
|
||||
void MainWindow::setBlock(int x, int y, int rawValue, bool forceRedraw, bool commitChanges) {
|
||||
if (!this->editor || !this->editor->map)
|
||||
return;
|
||||
this->editor->map->setBlock(x, y, Block(static_cast<uint16_t>(rawValue)));
|
||||
this->tryCommitMapChanges(commitChanges);
|
||||
this->tryRedrawMapArea(forceRedraw);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ QImage getCollisionMetatileImage(Block block) {
|
|||
}
|
||||
|
||||
QImage getCollisionMetatileImage(int collision, int elevation) {
|
||||
int x = collision * 16;
|
||||
int x = (collision != 0) * 16;
|
||||
int y = elevation * 16;
|
||||
QPixmap collisionImage = QPixmap(":/images/collisions.png").copy(x, y, 16, 16);
|
||||
return collisionImage.toImage();
|
||||
|
|
|
@ -16,7 +16,7 @@ uint16_t MovementPermissionsSelector::getSelectedElevation() {
|
|||
}
|
||||
|
||||
void MovementPermissionsSelector::select(uint16_t collision, uint16_t elevation) {
|
||||
SelectablePixmapItem::select(collision, elevation, 0, 0);
|
||||
SelectablePixmapItem::select(collision != 0, elevation, 0, 0);
|
||||
}
|
||||
|
||||
void MovementPermissionsSelector::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
|
||||
|
|
Loading…
Reference in a new issue