diff --git a/include/config.h b/include/config.h index 4f9b2dbe..7f63871f 100644 --- a/include/config.h +++ b/include/config.h @@ -33,6 +33,7 @@ public: this->mapSortOrder = MapSortOrder::Group; this->prettyCursors = true; this->collisionOpacity = 50; + this->metatilesZoom = 30; this->showPlayerView = false; this->showCursorTile = true; } @@ -42,6 +43,7 @@ public: void setPrettyCursors(bool enabled); void setGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray); void setCollisionOpacity(int opacity); + void setMetatilesZoom(int zoom); void setShowPlayerView(bool enabled); void setShowCursorTile(bool enabled); QString getRecentProject(); @@ -50,6 +52,7 @@ public: bool getPrettyCursors(); QMap getGeometry(); int getCollisionOpacity(); + int getMetatilesZoom(); bool getShowPlayerView(); bool getShowCursorTile(); protected: @@ -70,6 +73,7 @@ private: QByteArray eventsSlpitterState; QByteArray mainSplitterState; int collisionOpacity; + int metatilesZoom; bool showPlayerView; bool showCursorTile; }; diff --git a/src/config.cpp b/src/config.cpp index 1eef943f..aa21a1af 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -137,6 +137,13 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { logWarn(QString("Invalid config value for collision_opacity: '%1'. Must be an integer.").arg(value)); this->collisionOpacity = 50; } + } else if (key == "metatiles_zoom") { + bool ok; + this->metatilesZoom = qMax(10, qMin(100, value.toInt(&ok))); + if (!ok) { + logWarn(QString("Invalid config value for metatiles_zoom: '%1'. Must be an integer.").arg(value)); + this->metatilesZoom = 30; + } } else if (key == "show_player_view") { bool ok; this->showPlayerView = value.toInt(&ok); @@ -166,6 +173,7 @@ QMap PorymapConfig::getKeyValueMap() { map.insert("events_splitter_state", stringFromByteArray(this->eventsSlpitterState)); map.insert("main_splitter_state", stringFromByteArray(this->mainSplitterState)); map.insert("collision_opacity", QString("%1").arg(this->collisionOpacity)); + 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"); return map; @@ -223,6 +231,11 @@ void PorymapConfig::setCollisionOpacity(int opacity) { // don't auto-save here because this can be called very frequently. } +void PorymapConfig::setMetatilesZoom(int zoom) { + this->metatilesZoom = zoom; + // don't auto-save here because this can be called very frequently. +} + void PorymapConfig::setShowPlayerView(bool enabled) { this->showPlayerView = enabled; this->save(); @@ -265,6 +278,10 @@ int PorymapConfig::getCollisionOpacity() { return this->collisionOpacity; } +int PorymapConfig::getMetatilesZoom() { + return this->metatilesZoom; +} + bool PorymapConfig::getShowPlayerView() { return this->showPlayerView; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7228b5d9..982f3be8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -216,6 +216,9 @@ void MainWindow::loadUserSettings() { this->editor->collisionOpacity = static_cast(porymapConfig.getCollisionOpacity()) / 100; ui->horizontalSlider_CollisionTransparency->setValue(porymapConfig.getCollisionOpacity()); ui->horizontalSlider_CollisionTransparency->blockSignals(false); + ui->horizontalSlider_MetatileZoom->blockSignals(true); + ui->horizontalSlider_MetatileZoom->setValue(porymapConfig.getMetatilesZoom()); + ui->horizontalSlider_MetatileZoom->blockSignals(false); } void MainWindow::restoreWindowState() { @@ -397,6 +400,8 @@ void MainWindow::redrawMapScene() ui->graphicsView_Collision->setScene(editor->scene_collision_metatiles); //ui->graphicsView_Collision->setSceneRect(editor->scene_collision_metatiles->sceneRect()); ui->graphicsView_Collision->setFixedSize(editor->movement_permissions_selector_item->pixmap().width() + 2, editor->movement_permissions_selector_item->pixmap().height() + 2); + + on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value()); } void MainWindow::openWarpMap(QString map_name, QString warp_num) { @@ -1960,6 +1965,7 @@ void MainWindow::on_tableWidget_CustomHeaderFields_cellChanged(int row, int colu } void MainWindow::on_horizontalSlider_MetatileZoom_valueChanged(int value) { + porymapConfig.setMetatilesZoom(value); double scale = pow(3.0, static_cast(value - 30) / 30.0); QMatrix matrix;