From db9e9d6f65077b230d14df7bfc779a7489956fde Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 4 Apr 2025 13:09:14 -0400 Subject: [PATCH] Remove Project::topLevelMapFields --- include/project.h | 4 ++-- src/mainwindow.cpp | 2 +- src/project.cpp | 16 +++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/project.h b/include/project.h index bcc53ae7..c5aed0a3 100644 --- a/include/project.h +++ b/include/project.h @@ -71,7 +71,6 @@ public: QSet modifiedFiles; bool usingAsmTilesets; QSet disabledSettingsNames; - QSet topLevelMapFields; int pokemonMinLevel; int pokemonMaxLevel; int maxEncounterRate; @@ -161,7 +160,6 @@ public: bool hasUnsavedChanges(); bool hasUnsavedDataChanges = false; - void initTopLevelMapFields(); bool readMapJson(const QString &mapName, QJsonDocument * out); bool loadMapEvent(Map *map, QJsonObject json, Event::Type defaultType = Event::Type::None); bool loadMapData(Map*); @@ -241,6 +239,8 @@ public: void setRegionMapEntries(const QHash &entries); QHash getRegionMapEntries() const; + QSet getTopLevelMapFields() const; + static QString getEmptyMapDefineName(); static QString getDynamicMapDefineName(); static QString getDynamicMapName(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index af7eaabe..28d7f996 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1192,7 +1192,7 @@ bool MainWindow::setProjectUI() { ui->layoutList->setModel(layoutListProxyModel); ui->layoutList->sortByColumn(0, Qt::SortOrder::AscendingOrder); - ui->mapCustomAttributesFrame->table()->setRestrictedKeys(project->topLevelMapFields); + ui->mapCustomAttributesFrame->table()->setRestrictedKeys(project->getTopLevelMapFields()); return true; } diff --git a/src/project.cpp b/src/project.cpp index 871b8e2c..f5499730 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -177,8 +177,8 @@ Map* Project::loadMap(const QString &mapName) { return map; } -void Project::initTopLevelMapFields() { - static const QSet defaultTopLevelMapFields = { +QSet Project::getTopLevelMapFields() const { + QSet fields = { "id", "name", "layout", @@ -197,15 +197,15 @@ void Project::initTopLevelMapFields() { "shared_events_map", "shared_scripts_map", }; - this->topLevelMapFields = defaultTopLevelMapFields; if (projectConfig.mapAllowFlagsEnabled) { - this->topLevelMapFields.insert("allow_cycling"); - this->topLevelMapFields.insert("allow_escaping"); - this->topLevelMapFields.insert("allow_running"); + fields.insert("allow_cycling"); + fields.insert("allow_escaping"); + fields.insert("allow_running"); } if (projectConfig.floorNumberEnabled) { - this->topLevelMapFields.insert("floor_number"); + fields.insert("floor_number"); } + return fields; } bool Project::readMapJson(const QString &mapName, QJsonDocument * out) { @@ -1794,8 +1794,6 @@ bool Project::readMapGroups() { this->groupNameToMapNames.clear(); this->customMapGroupsData = QJsonObject(); - this->initTopLevelMapFields(); - const QString filepath = projectConfig.getFilePath(ProjectFilePath::json_map_groups); fileWatcher.addPath(root + "/" + filepath); QJsonDocument mapGroupsDoc;