diff --git a/forms/projectsettingseditor.ui b/forms/projectsettingseditor.ui index fe50edd7..bf2ede83 100644 --- a/forms/projectsettingseditor.ui +++ b/forms/projectsettingseditor.ui @@ -1351,9 +1351,9 @@ - + - Project Files + Files @@ -1372,9 +1372,9 @@ - + - <html><head/><body><p><a href="https://huderlem.github.io/porymap/manual/project-files.html"><span style=" text-decoration: underline;">What are Project Files?</span></a></p></body></html> + <html><head/><body><p><a href="https://huderlem.github.io/porymap/manual/project-files.html"><span style=" text-decoration: underline;">Help</span></a></p></body></html> Qt::RichText @@ -1445,6 +1445,100 @@ + + + Identifiers + + + + + + true + + + + + 0 + 0 + 559 + 490 + + + + + + + <html><head/><body><p><a href="https://huderlem.github.io/porymap/manual/project-files.html"><span style=" text-decoration: underline;">Help</span></a></p></body></html> + + + Qt::RichText + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + true + + + + + + + + 2 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 2 + + + true + + + + + 0 + 0 + 533 + 440 + + + + + 0 + + + 0 + + + 4 + + + + + + + + + + + + + + diff --git a/include/config.h b/include/config.h index cd2b6457..981e4c0f 100644 --- a/include/config.h +++ b/include/config.h @@ -309,7 +309,7 @@ public: this->readKeys.clear(); } static const QMap> defaultIdentifiers; - static const QMap> defaultPaths; + static const QMap> defaultPaths; static const QStringList versionStrings; void reset(BaseGameVersion baseGameVersion); void setBaseGameVersion(BaseGameVersion baseGameVersion); diff --git a/include/ui/projectsettingseditor.h b/include/ui/projectsettingseditor.h index d4fcea11..73d0ecd4 100644 --- a/include/ui/projectsettingseditor.h +++ b/include/ui/projectsettingseditor.h @@ -52,7 +52,9 @@ private: void setBorderMetatileIds(bool customSize, QList metatileIds); QList getBorderMetatileIds(bool customSize); + void createConfigTextTable(const QList> configPairs, bool filesTab); void createProjectPathsTable(); + void createProjectIdentifiersTable(); QString chooseProjectFile(const QString &defaultFilepath); void choosePrefabsFile(); void chooseImageFile(QLineEdit * filepathEdit); diff --git a/src/config.cpp b/src/config.cpp index bc4ba7ae..721d95a5 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -106,7 +106,7 @@ const QMap> ProjectConfig::defaultIde {ProjectIdentifier::regex_species, {"regex_species", "\\bSPECIES_"}}, }; -const QMap> ProjectConfig::defaultPaths = { +const QMap> ProjectConfig::defaultPaths = { {ProjectFilePath::data_map_folders, { "data_map_folders", "data/maps/"}}, {ProjectFilePath::data_scripts_folders, { "data_scripts_folders", "data/scripts/"}}, {ProjectFilePath::data_layouts_folders, { "data_layouts_folders", "data/layouts/"}}, diff --git a/src/ui/projectsettingseditor.cpp b/src/ui/projectsettingseditor.cpp index 89cce4c3..984d7e7d 100644 --- a/src/ui/projectsettingseditor.cpp +++ b/src/ui/projectsettingseditor.cpp @@ -22,6 +22,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(QWidget *parent, Project *project) setAttribute(Qt::WA_DeleteOnClose); this->initUi(); this->createProjectPathsTable(); + this->createProjectIdentifiersTable(); this->connectSignals(); this->refresh(); this->restoreWindowState(); @@ -326,40 +327,56 @@ void ProjectSettingsEditor::updateWarpBehaviorsList(bool adding) { this->hasUnsavedChanges = true; } -void ProjectSettingsEditor::createProjectPathsTable() { - auto pathPairs = ProjectConfig::defaultPaths.values(); - for (auto pathPair : pathPairs) { - // Name of the path +// Dynamically populate the tabs for project files and identifiers +void ProjectSettingsEditor::createConfigTextTable(const QList> configPairs, bool filesTab) { + for (auto pair : configPairs) { + const QString idName = pair.first; + const QString defaultText = pair.second; + auto name = new QLabel(); name->setAlignment(Qt::AlignBottom); - name->setText(pathPair.first); + name->setText(idName); - // Filepath line edit auto lineEdit = new QLineEdit(); - lineEdit->setObjectName(pathPair.first); // Used when saving the paths - lineEdit->setPlaceholderText(pathPair.second); + lineEdit->setObjectName(idName); // Used when saving + lineEdit->setPlaceholderText(defaultText); lineEdit->setClearButtonEnabled(true); - // "Choose file" button - auto button = new QToolButton(); - button->setIcon(QIcon(":/icons/folder.ico")); - connect(button, &QAbstractButton::clicked, [this, lineEdit](bool) { - const QString path = this->chooseProjectFile(lineEdit->placeholderText()); - if (!path.isEmpty()) { - lineEdit->setText(path); - this->markEdited(); - } - }); - // Add to list auto editArea = new QWidget(); auto layout = new QHBoxLayout(editArea); layout->addWidget(lineEdit); - layout->addWidget(button); - ui->layout_ProjectPaths->addRow(name, editArea); + + if (filesTab) { + // "Choose file" button + auto button = new QToolButton(); + button->setIcon(QIcon(":/icons/folder.ico")); + connect(button, &QAbstractButton::clicked, [this, lineEdit](bool) { + const QString path = this->chooseProjectFile(lineEdit->placeholderText()); + if (!path.isEmpty()) { + lineEdit->setText(path); + this->markEdited(); + } + }); + layout->addWidget(button); + + ui->layout_ProjectPaths->addRow(name, editArea); + } else { + ui->layout_Identifiers->addRow(name, editArea); + } } } +void ProjectSettingsEditor::createProjectPathsTable() { + auto pairs = ProjectConfig::defaultPaths.values(); + this->createConfigTextTable(pairs, true); +} + +void ProjectSettingsEditor::createProjectIdentifiersTable() { + auto pairs = ProjectConfig::defaultIdentifiers.values(); + this->createConfigTextTable(pairs, false); +} + QString ProjectSettingsEditor::chooseProjectFile(const QString &defaultFilepath) { const QString startDir = this->baseDir + defaultFilepath; @@ -451,6 +468,8 @@ void ProjectSettingsEditor::refresh() { ui->lineEdit_HealspotsIcon->setText(projectConfig.getEventIconPath(Event::Group::Heal)); for (auto lineEdit : ui->scrollAreaContents_ProjectPaths->findChildren()) lineEdit->setText(projectConfig.getCustomFilePath(lineEdit->objectName())); + for (auto lineEdit : ui->scrollAreaContents_Identifiers->findChildren()) + lineEdit->setText(projectConfig.getCustomIdentifier(lineEdit->objectName())); this->setWarpBehaviorsList(projectConfig.getWarpBehaviors()); this->refreshing = false; // Allow signals @@ -511,7 +530,8 @@ void ProjectSettingsEditor::save() { projectConfig.setEventIconPath(Event::Group::Heal, ui->lineEdit_HealspotsIcon->text()); for (auto lineEdit : ui->scrollAreaContents_ProjectPaths->findChildren()) projectConfig.setFilePath(lineEdit->objectName(), lineEdit->text()); - + for (auto lineEdit : ui->scrollAreaContents_Identifiers->findChildren()) + projectConfig.setIdentifier(lineEdit->objectName(), lineEdit->text()); projectConfig.setWarpBehaviors(this->getWarpBehaviorsList()); // Save border metatile IDs