diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e4ef2e..582fbf51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Porymap is now compatible with Qt6. - Add tool to count the times each metatile or tile is used in the tileset editor. - Events, current metatile selections, and map images can now be copied and pasted, including between windows. +- The grid and map border visibility are now saved as config options. ### Changed - New events will be placed in the center of the current view of the map. diff --git a/include/config.h b/include/config.h index a0841a53..b49d56dc 100644 --- a/include/config.h +++ b/include/config.h @@ -44,6 +44,8 @@ public: this->metatilesZoom = 30; this->showPlayerView = false; this->showCursorTile = true; + this->showBorder = true; + this->showGrid = false; this->monitorFiles = true; this->regionMapDimensions = QSize(32, 20); this->theme = "default"; @@ -61,6 +63,8 @@ public: void setMetatilesZoom(int zoom); void setShowPlayerView(bool enabled); void setShowCursorTile(bool enabled); + void setShowBorder(bool enabled); + void setShowGrid(bool enabled); void setMonitorFiles(bool monitor); void setRegionMapDimensions(int width, int height); void setTheme(QString theme); @@ -77,6 +81,8 @@ public: int getMetatilesZoom(); bool getShowPlayerView(); bool getShowCursorTile(); + bool getShowBorder(); + bool getShowGrid(); bool getMonitorFiles(); QSize getRegionMapDimensions(); QString getTheme(); @@ -109,6 +115,8 @@ private: int metatilesZoom; bool showPlayerView; bool showCursorTile; + bool showBorder; + bool showGrid; bool monitorFiles; QSize regionMapDimensions; QString theme; diff --git a/include/editor.h b/include/editor.h index 7e466688..c57b87c8 100644 --- a/include/editor.h +++ b/include/editor.h @@ -201,6 +201,7 @@ private slots: void onHoveredMapMovementPermissionCleared(); void onSelectedMetatilesChanged(); void onWheelZoom(int); + void onToggleGridClicked(bool); signals: void objectsChanged(); diff --git a/src/config.cpp b/src/config.cpp index 35c1507f..2bfd5439 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -168,6 +168,18 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { if (!ok) { logWarn(QString("Invalid config value for show_cursor_tile: '%1'. Must be 0 or 1.").arg(value)); } + } else if (key == "show_border") { + bool ok; + this->showBorder = value.toInt(&ok); + if (!ok) { + logWarn(QString("Invalid config value for show_border: '%1'. Must be 0 or 1.").arg(value)); + } + } else if (key == "show_grid") { + bool ok; + this->showGrid = value.toInt(&ok); + if (!ok) { + logWarn(QString("Invalid config value for show_grid: '%1'. Must be 0 or 1.").arg(value)); + } } else if (key == "monitor_files") { bool ok; this->monitorFiles = value.toInt(&ok); @@ -215,6 +227,8 @@ QMap PorymapConfig::getKeyValueMap() { map.insert("metatiles_zoom", QString("%1").arg(this->metatilesZoom)); map.insert("show_player_view", this->showPlayerView ? "1" : "0"); map.insert("show_cursor_tile", this->showCursorTile ? "1" : "0"); + map.insert("show_border", this->showBorder ? "1" : "0"); + map.insert("show_grid", this->showGrid ? "1" : "0"); map.insert("monitor_files", this->monitorFiles ? "1" : "0"); map.insert("region_map_dimensions", QString("%1x%2").arg(this->regionMapDimensions.width()) .arg(this->regionMapDimensions.height())); @@ -308,6 +322,16 @@ void PorymapConfig::setShowCursorTile(bool enabled) { this->save(); } +void PorymapConfig::setShowBorder(bool enabled) { + this->showBorder = enabled; + this->save(); +} + +void PorymapConfig::setShowGrid(bool enabled) { + this->showGrid = enabled; + this->save(); +} + void PorymapConfig::setRegionMapDimensions(int width, int height) { this->regionMapDimensions = QSize(width, height); } @@ -392,6 +416,14 @@ bool PorymapConfig::getShowCursorTile() { return this->showCursorTile; } +bool PorymapConfig::getShowBorder() { + return this->showBorder; +} + +bool PorymapConfig::getShowGrid() { + return this->showGrid; +} + bool PorymapConfig::getMonitorFiles() { return this->monitorFiles; } diff --git a/src/editor.cpp b/src/editor.cpp index 74f44a3b..4a4d26d4 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -1663,6 +1663,10 @@ int Editor::getBorderDrawDistance(int dimension) { } } +void Editor::onToggleGridClicked(bool checked) { + porymapConfig.setShowGrid(checked); +} + void Editor::displayMapGrid() { for (QGraphicsLineItem* item : gridLines) { if (item && item->scene()) { @@ -1689,6 +1693,7 @@ void Editor::displayMapGrid() { gridLines.append(line); connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, [=](bool checked){line->setVisible(checked);}); } + connect(ui->checkBox_ToggleGrid, &QCheckBox::toggled, this, &Editor::onToggleGridClicked); } void Editor::updateConnectionOffset(int offset) { @@ -1915,6 +1920,7 @@ void Editor::toggleBorderVisibility(bool visible) { this->setBorderItemsVisible(visible); this->setConnectionsVisibility(visible); + porymapConfig.setShowBorder(visible); } void Editor::updateCustomMapHeaderValues(QTableWidget *table) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7a1bc40f..d0004cca 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -456,6 +456,8 @@ void MainWindow::loadUserSettings() { this->editor->settings->playerViewRectEnabled = porymapConfig.getShowPlayerView(); ui->actionCursor_Tile_Outline->setChecked(porymapConfig.getShowCursorTile()); this->editor->settings->cursorTileRectEnabled = porymapConfig.getShowCursorTile(); + ui->checkBox_ToggleBorder->setChecked(porymapConfig.getShowBorder()); + ui->checkBox_ToggleGrid->setChecked(porymapConfig.getShowGrid()); mapSortOrder = porymapConfig.getMapSortOrder(); ui->horizontalSlider_CollisionTransparency->blockSignals(true); this->editor->collisionOpacity = static_cast(porymapConfig.getCollisionOpacity()) / 100;