diff --git a/include/config.h b/include/config.h index e9264d15..ed5403a2 100644 --- a/include/config.h +++ b/include/config.h @@ -38,7 +38,6 @@ public: } virtual void reset() override { this->recentProject = ""; - this->recentMap = ""; this->mapSortOrder = MapSortOrder::Group; this->prettyCursors = true; this->collisionOpacity = 50; @@ -52,7 +51,6 @@ public: this->textEditorGotoLine = ""; } void setRecentProject(QString project); - void setRecentMap(QString map); void setMapSortOrder(MapSortOrder order); void setPrettyCursors(bool enabled); void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray); @@ -69,7 +67,6 @@ public: void setTextEditorOpenFolder(const QString &command); void setTextEditorGotoLine(const QString &command); QString getRecentProject(); - QString getRecentMap(); MapSortOrder getMapSortOrder(); bool getPrettyCursors(); QMap getMainGeometry(); @@ -93,7 +90,6 @@ protected: virtual void setUnreadKeys() override {}; private: QString recentProject; - QString recentMap; QString stringFromByteArray(QByteArray); QByteArray bytesFromString(QString); MapSortOrder mapSortOrder; @@ -136,6 +132,7 @@ public: } virtual void reset() override { this->baseGameVersion = BaseGameVersion::pokeemerald; + this->recentMap = QString(); this->useEncounterJson = true; this->useCustomBorderSize = false; this->enableEventWeatherTrigger = true; @@ -151,6 +148,8 @@ public: } void setBaseGameVersion(BaseGameVersion baseGameVersion); BaseGameVersion getBaseGameVersion(); + void setRecentMap(const QString &map); + QString getRecentMap(); void setEncounterJsonActive(bool active); bool getEncounterJsonActive(); void setUsePoryScript(bool usePoryScript); @@ -186,6 +185,7 @@ protected: private: BaseGameVersion baseGameVersion; QString projectDir; + QString recentMap; bool useEncounterJson; bool usePoryScript; bool useCustomBorderSize; diff --git a/src/config.cpp b/src/config.cpp index 5ef3723f..daf53067 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -109,8 +109,6 @@ QString PorymapConfig::getConfigFilepath() { void PorymapConfig::parseConfigKeyValue(QString key, QString value) { if (key == "recent_project") { this->recentProject = value; - } else if (key == "recent_map") { - this->recentMap = value; } else if (key == "pretty_cursors") { bool ok; this->prettyCursors = value.toInt(&ok); @@ -202,7 +200,6 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) { QMap PorymapConfig::getKeyValueMap() { QMap map; map.insert("recent_project", this->recentProject); - map.insert("recent_map", this->recentMap); map.insert("pretty_cursors", this->prettyCursors ? "1" : "0"); map.insert("map_sort_order", mapSortOrderMap.value(this->mapSortOrder)); map.insert("main_window_geometry", stringFromByteArray(this->mainWindowGeometry)); @@ -250,11 +247,6 @@ void PorymapConfig::setRecentProject(QString project) { this->save(); } -void PorymapConfig::setRecentMap(QString map) { - this->recentMap = map; - this->save(); -} - void PorymapConfig::setMapSortOrder(MapSortOrder order) { this->mapSortOrder = order; this->save(); @@ -339,10 +331,6 @@ QString PorymapConfig::getRecentProject() { return this->recentProject; } -QString PorymapConfig::getRecentMap() { - return this->recentMap; -} - MapSortOrder PorymapConfig::getMapSortOrder() { return this->mapSortOrder; } @@ -453,6 +441,8 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) { this->baseGameVersion = BaseGameVersion::pokeemerald; logWarn(QString("Invalid config value for base_game_version: '%1'. Must be 'pokeruby', 'pokefirered' or 'pokeemerald'.").arg(value)); } + } else if (key == "recent_map") { + this->recentMap = value; } else if (key == "use_encounter_json") { bool ok; this->useEncounterJson = value.toInt(&ok); @@ -550,6 +540,7 @@ void ProjectConfig::setUnreadKeys() { QMap ProjectConfig::getKeyValueMap() { QMap map; map.insert("base_game_version", baseGameVersionMap.value(this->baseGameVersion)); + map.insert("recent_map", this->recentMap); map.insert("use_encounter_json", QString::number(this->useEncounterJson)); map.insert("use_poryscript", QString::number(this->usePoryScript)); map.insert("use_custom_border_size", QString::number(this->useCustomBorderSize)); @@ -623,6 +614,15 @@ BaseGameVersion ProjectConfig::getBaseGameVersion() { return this->baseGameVersion; } +void ProjectConfig::setRecentMap(const QString &map) { + this->recentMap = map; + this->save(); +} + +QString ProjectConfig::getRecentMap() { + return this->recentMap; +} + void ProjectConfig::setEncounterJsonActive(bool active) { this->useEncounterJson = active; this->save(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 14a8fc3d..836eafbd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -541,7 +541,7 @@ QString MainWindow::getDefaultMap() { if (editor && editor->project) { QList names = editor->project->groupedMapNames; if (!names.isEmpty()) { - QString recentMap = porymapConfig.getRecentMap(); + QString recentMap = projectConfig.getRecentMap(); if (!recentMap.isNull() && recentMap.length() > 0) { for (int i = 0; i < names.length(); i++) { if (names.value(i).contains(recentMap)) { @@ -568,8 +568,8 @@ QString MainWindow::getExistingDirectory(QString dir) { void MainWindow::on_action_Open_Project_triggered() { QString recent = "."; - if (!porymapConfig.getRecentMap().isNull() && porymapConfig.getRecentMap().length() > 0) { - recent = porymapConfig.getRecentMap(); + if (!projectConfig.getRecentMap().isEmpty()) { + recent = projectConfig.getRecentMap(); } QString dir = getExistingDirectory(recent); if (!dir.isEmpty()) { @@ -711,7 +711,7 @@ void MainWindow::openWarpMap(QString map_name, QString warp_num) { } void MainWindow::setRecentMap(QString mapName) { - porymapConfig.setRecentMap(mapName); + projectConfig.setRecentMap(mapName); } void MainWindow::displayMapProperties() {