|
@@ -257,6 +257,8 @@ void Editor::onConnectionItemSelected(ConnectionPixmapItem* connectionItem) {
|
257
|
257
|
current_connection_edit_item->setZValue(0);
|
258
|
258
|
setConnectionEditControlsEnabled(true);
|
259
|
259
|
setConnectionEditControlValues(current_connection_edit_item->connection);
|
|
260
|
+ ui->spinBox_ConnectionOffset->setMaximum(current_connection_edit_item->getMaxOffset());
|
|
261
|
+ ui->spinBox_ConnectionOffset->setMinimum(current_connection_edit_item->getMinOffset());
|
260
|
262
|
}
|
261
|
263
|
|
262
|
264
|
void Editor::onConnectionDirectionChanged(QString newDirection) {
|
|
@@ -451,7 +453,7 @@ void Editor::createConnectionItem(Connection* connection, bool hide) {
|
451
|
453
|
map->connection_items.append(item);
|
452
|
454
|
item->setVisible(!hide);
|
453
|
455
|
|
454
|
|
- ConnectionPixmapItem *connection_edit_item = new ConnectionPixmapItem(pixmap, connection, x, y);
|
|
456
|
+ ConnectionPixmapItem *connection_edit_item = new ConnectionPixmapItem(pixmap, connection, x, y, map->getWidth(), map->getHeight());
|
455
|
457
|
connection_edit_item->setX(x);
|
456
|
458
|
connection_edit_item->setY(y);
|
457
|
459
|
connection_edit_item->setZValue(-1);
|
|
@@ -496,6 +498,8 @@ void Editor::updateConnectionOffset(int offset) {
|
496
|
498
|
return;
|
497
|
499
|
|
498
|
500
|
current_connection_edit_item->blockSignals(true);
|
|
501
|
+ offset = qMin(offset, current_connection_edit_item->getMaxOffset());
|
|
502
|
+ offset = qMax(offset, current_connection_edit_item->getMinOffset());
|
499
|
503
|
current_connection_edit_item->connection->offset = QString::number(offset);
|
500
|
504
|
if (current_connection_edit_item->connection->direction == "up" || current_connection_edit_item->connection->direction == "down") {
|
501
|
505
|
current_connection_edit_item->setX(current_connection_edit_item->initialX + (offset - current_connection_edit_item->initialOffset) * 16);
|
|
@@ -690,6 +694,18 @@ void CollisionMetatilesPixmapItem::updateCurHoveredMetatile(QPointF pos) {
|
690
|
694
|
}
|
691
|
695
|
}
|
692
|
696
|
|
|
697
|
+int ConnectionPixmapItem::getMinOffset() {
|
|
698
|
+ if (connection->direction == "up" || connection->direction == "down")
|
|
699
|
+ return 1 - (this->pixmap().width() / 16);
|
|
700
|
+ else
|
|
701
|
+ return 1 - (this->pixmap().height() / 16);
|
|
702
|
+}
|
|
703
|
+int ConnectionPixmapItem::getMaxOffset() {
|
|
704
|
+ if (connection->direction == "up" || connection->direction == "down")
|
|
705
|
+ return baseMapWidth - 1;
|
|
706
|
+ else
|
|
707
|
+ return baseMapHeight - 1;
|
|
708
|
+}
|
693
|
709
|
QVariant ConnectionPixmapItem::itemChange(GraphicsItemChange change, const QVariant &value)
|
694
|
710
|
{
|
695
|
711
|
if (change == ItemPositionChange) {
|
|
@@ -700,6 +716,9 @@ QVariant ConnectionPixmapItem::itemChange(GraphicsItemChange change, const QVari
|
700
|
716
|
if (connection->direction == "up" || connection->direction == "down") {
|
701
|
717
|
x = round(newPos.x() / 16) * 16;
|
702
|
718
|
newOffset += (x - initialX) / 16;
|
|
719
|
+ newOffset = qMin(newOffset, this->getMaxOffset());
|
|
720
|
+ newOffset = qMax(newOffset, this->getMinOffset());
|
|
721
|
+ x = newOffset * 16;
|
703
|
722
|
}
|
704
|
723
|
else {
|
705
|
724
|
x = initialX;
|
|
@@ -708,6 +727,9 @@ QVariant ConnectionPixmapItem::itemChange(GraphicsItemChange change, const QVari
|
708
|
727
|
if (connection->direction == "right" || connection->direction == "left") {
|
709
|
728
|
y = round(newPos.y() / 16) * 16;
|
710
|
729
|
newOffset += (y - initialY) / 16;
|
|
730
|
+ newOffset = qMin(newOffset, this->getMaxOffset());
|
|
731
|
+ newOffset = qMax(newOffset, this->getMinOffset());
|
|
732
|
+ y = newOffset * 16;
|
711
|
733
|
}
|
712
|
734
|
else {
|
713
|
735
|
y = initialY;
|