remember edit mode in map tab

This commit is contained in:
garakmon 2020-04-21 15:12:20 -04:00
parent 7e039121bb
commit 9e883a8a2f
3 changed files with 24 additions and 0 deletions

View file

@ -211,6 +211,7 @@ private:
void displayMapProperties();
void checkToolButtons();
void clickToolButtonFromEditMode(QString editMode);
void initWindow();
void initCustomUI();

View file

@ -1868,6 +1868,10 @@ void Editor::deleteEvent(Event *event) {
// variable "selectingEvent" so that we can detect whether or not the user
// is clicking on the background instead of an event.
void Editor::objectsView_onMousePress(QMouseEvent *event) {
// make sure we are in object editing mode
if (map_item && map_item->paintingMode != MapPixmapItem::PaintMode::EventObjects) {
return;
}
if (this->map_edit_mode == "paint" && event->buttons() & Qt::RightButton) {
this->map_edit_mode = "select";
this->settings->mapCursor = QCursor();

View file

@ -1214,9 +1214,12 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index)
if (index == 0) {
ui->stackedWidget_MapEvents->setCurrentIndex(0);
on_tabWidget_2_currentChanged(ui->tabWidget_2->currentIndex());
clickToolButtonFromEditMode(editor->prev_edit_mode);
} else if (index == 1) {
ui->stackedWidget_MapEvents->setCurrentIndex(1);
editor->prev_edit_mode = editor->map_edit_mode;
editor->setEditingObjects();
clickToolButtonFromEditMode("select");
} else if (index == 3) {
editor->setEditingConnections();
}
@ -2115,6 +2118,22 @@ void MainWindow::checkToolButtons() {
ui->toolButton_Shift->setChecked(editor->map_edit_mode == "shift");
}
void MainWindow::clickToolButtonFromEditMode(QString editMode) {
if (editMode == "paint") {
on_toolButton_Paint_clicked();
} else if (editMode == "select") {
on_toolButton_Select_clicked();
} else if (editMode == "fill") {
on_toolButton_Fill_clicked();
} else if (editMode == "pick") {
on_toolButton_Dropper_clicked();
} else if (editMode == "move") {
on_toolButton_Move_clicked();
} else if (editMode == "shift") {
on_toolButton_Shift_clicked();
}
}
void MainWindow::onLoadMapRequested(QString mapName, QString fromMapName) {
if (!setMap(mapName, true)) {
QMessageBox msgBox(this);