From 238a9d186572a5599f382812edc9cc549c60e63d Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 6 May 2025 15:30:45 -0400 Subject: [PATCH] Fix regression to cursor single tile mode --- include/ui/cursortilerect.h | 16 ++++++++++------ src/editor.cpp | 25 ++++++------------------- src/mainwindow.cpp | 12 ++++++------ src/ui/cursortilerect.cpp | 20 -------------------- 4 files changed, 22 insertions(+), 51 deletions(-) diff --git a/include/ui/cursortilerect.h b/include/ui/cursortilerect.h index 26b4d929..f53ae5aa 100644 --- a/include/ui/cursortilerect.h +++ b/include/ui/cursortilerect.h @@ -50,12 +50,16 @@ public: void stopAnchor(); void initRightClickSelectionAnchor(int coordX, int coordY); void stopRightClickSelectionAnchor(); - void setSmartPathMode(bool enable); - bool getSmartPathMode() { return this->smartPathMode; } - void setStraightPathMode(bool enable); - bool getStraightPathMode() { return this->straightPathMode; } - void setSingleTileMode(); - void stopSingleTileMode(); + + void setSmartPathMode(bool enable) { this->smartPathMode = enable; } + bool getSmartPathMode() const { return this->smartPathMode; } + + void setStraightPathMode(bool enable) { this->straightPathMode = enable; } + bool getStraightPathMode() const { return this->straightPathMode; } + + void setSingleTileMode(bool enable) { this->singleTileMode = enable; } + bool getSingleTileMode() const { return this->singleTileMode; } + void updateLocation(int x, int y); void updateSelectionSize(int width, int height); void setActive(bool active); diff --git a/src/editor.cpp b/src/editor.cpp index 058173da..f5759e35 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -168,11 +168,15 @@ void Editor::setEditMode(EditMode editMode) { if (editingLayout && this->layout) { editStack = &this->layout->editHistory; } - this->cursorMapTileRect->setSingleTileMode(); + + this->cursorMapTileRect->setSingleTileMode(editMode == EditMode::Collision); this->cursorMapTileRect->setActive(editingLayout); this->playerViewRect->setActive(editingLayout); this->editGroup.setActiveStack(editStack); - setMapEditingButtonsEnabled(editingLayout); + this->ui->toolButton_Fill->setEnabled(editingLayout); + this->ui->toolButton_Dropper->setEnabled(editingLayout); + this->ui->pushButton_ChangeDimensions->setEnabled(editingLayout); + this->ui->checkBox_smartPaths->setEnabled(editingLayout); if (this->editMode == EditMode::Events || oldEditMode == EditMode::Events) { // When switching to or from the Events tab the opacity of the events changes. Redraw the events to reflect that change. @@ -183,22 +187,6 @@ void Editor::setEditMode(EditMode editMode) { } } -void Editor::setMapEditingButtonsEnabled(bool enabled) { - this->ui->toolButton_Fill->setEnabled(enabled); - this->ui->toolButton_Dropper->setEnabled(enabled); - this->ui->pushButton_ChangeDimensions->setEnabled(enabled); - // If the fill button is pressed, unpress it and select the pointer. - if (!enabled && (this->ui->toolButton_Fill->isChecked() || this->ui->toolButton_Dropper->isChecked())) { - this->mapEditAction = EditAction::Select; - this->settings->mapCursor = QCursor(); - this->cursorMapTileRect->setSingleTileMode(); - this->ui->toolButton_Fill->setChecked(false); - this->ui->toolButton_Dropper->setChecked(false); - this->ui->toolButton_Select->setChecked(true); - } - this->ui->checkBox_smartPaths->setEnabled(enabled); -} - void Editor::clearWildMonTables() { QStackedWidget *stack = ui->stackedWidget_WildMons; const QSignalBlocker blocker(stack); @@ -1406,7 +1394,6 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *i if (event->buttons() & Qt::RightButton) { this->eventEditAction = EditAction::Select; this->settings->mapCursor = QCursor(); - this->cursorMapTileRect->setSingleTileMode(); this->ui->toolButton_Paint->setChecked(false); this->ui->toolButton_Select->setChecked(true); } else { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6a54bce1..eb38989b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2454,7 +2454,7 @@ void MainWindow::on_toolButton_Paint_clicked() editor->settings->mapCursor = QCursor(QPixmap(":/icons/pencil_cursor.ico"), 10, 10); if (ui->mapViewTab->currentIndex() != MapViewTab::Collision) - editor->cursorMapTileRect->stopSingleTileMode(); + editor->cursorMapTileRect->setSingleTileMode(false); ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); @@ -2473,7 +2473,7 @@ void MainWindow::on_toolButton_Select_clicked() editor->eventEditAction = Editor::EditAction::Select; editor->settings->mapCursor = QCursor(); - editor->cursorMapTileRect->setSingleTileMode(); + editor->cursorMapTileRect->setSingleTileMode(true); ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); @@ -2492,7 +2492,7 @@ void MainWindow::on_toolButton_Fill_clicked() editor->eventEditAction = Editor::EditAction::Fill; editor->settings->mapCursor = QCursor(QPixmap(":/icons/fill_color_cursor.ico"), 10, 10); - editor->cursorMapTileRect->setSingleTileMode(); + editor->cursorMapTileRect->setSingleTileMode(true); ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); @@ -2511,7 +2511,7 @@ void MainWindow::on_toolButton_Dropper_clicked() editor->eventEditAction = Editor::EditAction::Pick; editor->settings->mapCursor = QCursor(QPixmap(":/icons/pipette_cursor.ico"), 10, 10); - editor->cursorMapTileRect->setSingleTileMode(); + editor->cursorMapTileRect->setSingleTileMode(true); ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); @@ -2530,7 +2530,7 @@ void MainWindow::on_toolButton_Move_clicked() editor->eventEditAction = Editor::EditAction::Move; editor->settings->mapCursor = QCursor(QPixmap(":/icons/move.ico"), 7, 7); - editor->cursorMapTileRect->setSingleTileMode(); + editor->cursorMapTileRect->setSingleTileMode(true); ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -2549,7 +2549,7 @@ void MainWindow::on_toolButton_Shift_clicked() editor->eventEditAction = Editor::EditAction::Shift; editor->settings->mapCursor = QCursor(QPixmap(":/icons/shift_cursor.ico"), 10, 10); - editor->cursorMapTileRect->setSingleTileMode(); + editor->cursorMapTileRect->setSingleTileMode(true); ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->graphicsView_Map->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); diff --git a/src/ui/cursortilerect.cpp b/src/ui/cursortilerect.cpp index 4eed7c94..511f0fda 100644 --- a/src/ui/cursortilerect.cpp +++ b/src/ui/cursortilerect.cpp @@ -63,26 +63,6 @@ void CursorTileRect::updateSelectionSize(int width, int height) this->update(); } -void CursorTileRect::setSmartPathMode(bool enable) -{ - this->smartPathMode = enable; -} - -void CursorTileRect::setStraightPathMode(bool enable) -{ - this->straightPathMode = enable; -} - -void CursorTileRect::setSingleTileMode() -{ - this->singleTileMode = true; -} - -void CursorTileRect::stopSingleTileMode() -{ - this->singleTileMode = false; -} - bool CursorTileRect::smartPathInEffect() { return !this->rightClickSelectionAnchored && this->smartPathMode && this->selectionHeight == 3 && this->selectionWidth == 3;