From 1497f42ab0cbecf7b236440c5ee377cd9267834e Mon Sep 17 00:00:00 2001 From: garak Date: Sun, 5 Feb 2023 14:52:40 -0500 Subject: [PATCH] save progress --- include/editor.h | 19 ++++++++++++------- src/editor.cpp | 41 +++++++++++++++++++++++----------------- src/mainwindow.cpp | 10 +++++++++- src/ui/maplistmodels.cpp | 3 ++- 4 files changed, 47 insertions(+), 26 deletions(-) diff --git a/include/editor.h b/include/editor.h index b207b9d3..29709df8 100644 --- a/include/editor.h +++ b/include/editor.h @@ -84,12 +84,6 @@ public: void updateMapBorder(); void updateMapConnections(); - void setEditingMap(); - void setEditingCollision(); - void setEditingObjects(); - void setEditingConnections(); - void setMapEditingButtonsEnabled(bool enabled); - void setCurrentConnectionDirection(QString curDirection); void updateCurrentConnectionDirection(QString curDirection); void setConnectionsVisibility(bool visible); @@ -160,8 +154,19 @@ public: EditAction objectEditAction = EditAction::Select; /// !TODO this - enum class EditMode { None, Map, Layout }; + enum class EditMode { None, Disabled, Map, Layout, Objects, Connections, Encounters }; EditMode editMode = EditMode::Map; + void setEditMode(EditMode mode) { this->editMode = mode; } + EditMode getEditMode() { return this->editMode; } + + void setEditingMap(); + void setEditingCollision(); + void setEditingLayout(); + void setEditingObjects(); + void setEditingConnections(); + void setEditingEncounters(); + + void setMapEditingButtonsEnabled(bool enabled); int scaleIndex = 2; qreal collisionOpacity = 0.5; diff --git a/src/editor.cpp b/src/editor.cpp index ca6d3857..8a508bbf 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -81,7 +81,6 @@ void Editor::closeProject() { } void Editor::setEditingMap() { - qDebug() << "Editor::setEditingMap()"; current_view = map_item; if (map_item) { map_item->paintingMode = LayoutPixmapItem::PaintMode::Metatiles; @@ -104,6 +103,10 @@ void Editor::setEditingMap() { setMapEditingButtonsEnabled(true); } +void Editor::setEditingLayout() { + // +} + void Editor::setEditingCollision() { current_view = collision_item; if (collision_item) { @@ -152,22 +155,6 @@ void Editor::setEditingObjects() { setMapEditingButtonsEnabled(false); } -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::setEditingConnections() { current_view = map_item; if (map_item) { @@ -199,6 +186,26 @@ void Editor::setEditingConnections() { this->cursorMapTileRect->setActive(false); } +void Editor::setEditingEncounters() { + // +} + +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::displayWildMonTables() { QStackedWidget *stack = ui->stackedWidget_WildMons; QComboBox *labelCombo = ui->comboBox_EncounterGroupLabel; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3c39fbc7..9edf6262 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -335,6 +335,7 @@ void MainWindow::initMiscHeapObjects() { ui->tabWidget_EventType->clear(); } +// TODO void MainWindow::initMapSortOrder() { // QMenu *mapSortOrderMenu = new QMenu(this); // QActionGroup *mapSortOrderActionGroup = new QActionGroup(ui->toolButton_MapSortOrder); @@ -356,6 +357,7 @@ void MainWindow::initMapSortOrder() { } void MainWindow::showWindowTitle() { + // !TODO, check editor editmode if (editor->map) { setWindowTitle(QString("%1%2 - %3") .arg(editor->map->hasUnsavedChanges() ? "* " : "") @@ -363,6 +365,13 @@ void MainWindow::showWindowTitle() { .arg(editor->project->getProjectTitle()) ); } + else if (editor->layout) { + setWindowTitle(QString("%1%2 - %3") + .arg(editor->layout->hasUnsavedChanges() ? "* " : "") + .arg(editor->layout->id) + .arg(editor->project->getProjectTitle()) + ); + } } void MainWindow::markMapEdited() { @@ -1780,7 +1789,6 @@ void MainWindow::on_mapViewTab_tabBarClicked(int index) Scripting::cb_MapViewTabChanged(oldIndex, index); if (index == 0) { - //if () editor->setEditingMap(); } else if (index == 1) { editor->setEditingCollision(); diff --git a/src/ui/maplistmodels.cpp b/src/ui/maplistmodels.cpp index 1add584f..dcf23207 100644 --- a/src/ui/maplistmodels.cpp +++ b/src/ui/maplistmodels.cpp @@ -274,7 +274,8 @@ LayoutTreeModel::LayoutTreeModel(Project *project, QObject *parent) : QStandardI QStandardItem *LayoutTreeModel::createLayoutItem(QString layoutId) { QStandardItem *layout = new QStandardItem; - layout->setText(layoutId); + layout->setText(this->project->layoutIdsToNames[layoutId]); + //layout->setText(layoutId); layout->setEditable(false); layout->setData(layoutId, Qt::UserRole); layout->setData("map_layout", MapListRoles::TypeRole);