Add identifiers to the settings window
This commit is contained in:
parent
6d995cee9b
commit
b74b007186
5 changed files with 144 additions and 28 deletions
|
@ -1351,9 +1351,9 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_ProjectFiles">
|
<widget class="QWidget" name="tab_Files">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Project Files</string>
|
<string>Files</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
<item>
|
<item>
|
||||||
|
@ -1372,9 +1372,9 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_ProjectFiles">
|
<widget class="QLabel" name="label_ProjectFilesHelp">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string> <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></string>
|
<string> <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></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
<property name="textFormat">
|
||||||
<enum>Qt::RichText</enum>
|
<enum>Qt::RichText</enum>
|
||||||
|
@ -1445,6 +1445,100 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_Identifiers">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Identifiers</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_21">
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollArea" name="scrollArea_IdentifiersTab">
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents_IdentifiersTab">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>559</width>
|
||||||
|
<height>490</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_19">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_IdentifiersHelp">
|
||||||
|
<property name="text">
|
||||||
|
<string> <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></string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>Qt::RichText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget_Identifiers" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_20">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollArea" name="scrollArea_Identifiers">
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaContents_Identifiers">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>533</width>
|
||||||
|
<height>440</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="layout_Identifiers">
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -309,7 +309,7 @@ public:
|
||||||
this->readKeys.clear();
|
this->readKeys.clear();
|
||||||
}
|
}
|
||||||
static const QMap<ProjectIdentifier, QPair<QString, QString>> defaultIdentifiers;
|
static const QMap<ProjectIdentifier, QPair<QString, QString>> defaultIdentifiers;
|
||||||
static const QMap<ProjectFilePath, std::pair<QString, QString>> defaultPaths;
|
static const QMap<ProjectFilePath, QPair<QString, QString>> defaultPaths;
|
||||||
static const QStringList versionStrings;
|
static const QStringList versionStrings;
|
||||||
void reset(BaseGameVersion baseGameVersion);
|
void reset(BaseGameVersion baseGameVersion);
|
||||||
void setBaseGameVersion(BaseGameVersion baseGameVersion);
|
void setBaseGameVersion(BaseGameVersion baseGameVersion);
|
||||||
|
|
|
@ -52,7 +52,9 @@ private:
|
||||||
void setBorderMetatileIds(bool customSize, QList<uint16_t> metatileIds);
|
void setBorderMetatileIds(bool customSize, QList<uint16_t> metatileIds);
|
||||||
QList<uint16_t> getBorderMetatileIds(bool customSize);
|
QList<uint16_t> getBorderMetatileIds(bool customSize);
|
||||||
|
|
||||||
|
void createConfigTextTable(const QList<QPair<QString, QString>> configPairs, bool filesTab);
|
||||||
void createProjectPathsTable();
|
void createProjectPathsTable();
|
||||||
|
void createProjectIdentifiersTable();
|
||||||
QString chooseProjectFile(const QString &defaultFilepath);
|
QString chooseProjectFile(const QString &defaultFilepath);
|
||||||
void choosePrefabsFile();
|
void choosePrefabsFile();
|
||||||
void chooseImageFile(QLineEdit * filepathEdit);
|
void chooseImageFile(QLineEdit * filepathEdit);
|
||||||
|
|
|
@ -106,7 +106,7 @@ const QMap<ProjectIdentifier, QPair<QString, QString>> ProjectConfig::defaultIde
|
||||||
{ProjectIdentifier::regex_species, {"regex_species", "\\bSPECIES_"}},
|
{ProjectIdentifier::regex_species, {"regex_species", "\\bSPECIES_"}},
|
||||||
};
|
};
|
||||||
|
|
||||||
const QMap<ProjectFilePath, std::pair<QString, QString>> ProjectConfig::defaultPaths = {
|
const QMap<ProjectFilePath, QPair<QString, QString>> ProjectConfig::defaultPaths = {
|
||||||
{ProjectFilePath::data_map_folders, { "data_map_folders", "data/maps/"}},
|
{ProjectFilePath::data_map_folders, { "data_map_folders", "data/maps/"}},
|
||||||
{ProjectFilePath::data_scripts_folders, { "data_scripts_folders", "data/scripts/"}},
|
{ProjectFilePath::data_scripts_folders, { "data_scripts_folders", "data/scripts/"}},
|
||||||
{ProjectFilePath::data_layouts_folders, { "data_layouts_folders", "data/layouts/"}},
|
{ProjectFilePath::data_layouts_folders, { "data_layouts_folders", "data/layouts/"}},
|
||||||
|
|
|
@ -22,6 +22,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(QWidget *parent, Project *project)
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
this->initUi();
|
this->initUi();
|
||||||
this->createProjectPathsTable();
|
this->createProjectPathsTable();
|
||||||
|
this->createProjectIdentifiersTable();
|
||||||
this->connectSignals();
|
this->connectSignals();
|
||||||
this->refresh();
|
this->refresh();
|
||||||
this->restoreWindowState();
|
this->restoreWindowState();
|
||||||
|
@ -326,20 +327,27 @@ void ProjectSettingsEditor::updateWarpBehaviorsList(bool adding) {
|
||||||
this->hasUnsavedChanges = true;
|
this->hasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::createProjectPathsTable() {
|
// Dynamically populate the tabs for project files and identifiers
|
||||||
auto pathPairs = ProjectConfig::defaultPaths.values();
|
void ProjectSettingsEditor::createConfigTextTable(const QList<QPair<QString, QString>> configPairs, bool filesTab) {
|
||||||
for (auto pathPair : pathPairs) {
|
for (auto pair : configPairs) {
|
||||||
// Name of the path
|
const QString idName = pair.first;
|
||||||
|
const QString defaultText = pair.second;
|
||||||
|
|
||||||
auto name = new QLabel();
|
auto name = new QLabel();
|
||||||
name->setAlignment(Qt::AlignBottom);
|
name->setAlignment(Qt::AlignBottom);
|
||||||
name->setText(pathPair.first);
|
name->setText(idName);
|
||||||
|
|
||||||
// Filepath line edit
|
|
||||||
auto lineEdit = new QLineEdit();
|
auto lineEdit = new QLineEdit();
|
||||||
lineEdit->setObjectName(pathPair.first); // Used when saving the paths
|
lineEdit->setObjectName(idName); // Used when saving
|
||||||
lineEdit->setPlaceholderText(pathPair.second);
|
lineEdit->setPlaceholderText(defaultText);
|
||||||
lineEdit->setClearButtonEnabled(true);
|
lineEdit->setClearButtonEnabled(true);
|
||||||
|
|
||||||
|
// Add to list
|
||||||
|
auto editArea = new QWidget();
|
||||||
|
auto layout = new QHBoxLayout(editArea);
|
||||||
|
layout->addWidget(lineEdit);
|
||||||
|
|
||||||
|
if (filesTab) {
|
||||||
// "Choose file" button
|
// "Choose file" button
|
||||||
auto button = new QToolButton();
|
auto button = new QToolButton();
|
||||||
button->setIcon(QIcon(":/icons/folder.ico"));
|
button->setIcon(QIcon(":/icons/folder.ico"));
|
||||||
|
@ -350,15 +358,24 @@ void ProjectSettingsEditor::createProjectPathsTable() {
|
||||||
this->markEdited();
|
this->markEdited();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add to list
|
|
||||||
auto editArea = new QWidget();
|
|
||||||
auto layout = new QHBoxLayout(editArea);
|
|
||||||
layout->addWidget(lineEdit);
|
|
||||||
layout->addWidget(button);
|
layout->addWidget(button);
|
||||||
|
|
||||||
ui->layout_ProjectPaths->addRow(name, editArea);
|
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) {
|
QString ProjectSettingsEditor::chooseProjectFile(const QString &defaultFilepath) {
|
||||||
const QString startDir = this->baseDir + defaultFilepath;
|
const QString startDir = this->baseDir + defaultFilepath;
|
||||||
|
@ -451,6 +468,8 @@ void ProjectSettingsEditor::refresh() {
|
||||||
ui->lineEdit_HealspotsIcon->setText(projectConfig.getEventIconPath(Event::Group::Heal));
|
ui->lineEdit_HealspotsIcon->setText(projectConfig.getEventIconPath(Event::Group::Heal));
|
||||||
for (auto lineEdit : ui->scrollAreaContents_ProjectPaths->findChildren<QLineEdit*>())
|
for (auto lineEdit : ui->scrollAreaContents_ProjectPaths->findChildren<QLineEdit*>())
|
||||||
lineEdit->setText(projectConfig.getCustomFilePath(lineEdit->objectName()));
|
lineEdit->setText(projectConfig.getCustomFilePath(lineEdit->objectName()));
|
||||||
|
for (auto lineEdit : ui->scrollAreaContents_Identifiers->findChildren<QLineEdit*>())
|
||||||
|
lineEdit->setText(projectConfig.getCustomIdentifier(lineEdit->objectName()));
|
||||||
this->setWarpBehaviorsList(projectConfig.getWarpBehaviors());
|
this->setWarpBehaviorsList(projectConfig.getWarpBehaviors());
|
||||||
|
|
||||||
this->refreshing = false; // Allow signals
|
this->refreshing = false; // Allow signals
|
||||||
|
@ -511,7 +530,8 @@ void ProjectSettingsEditor::save() {
|
||||||
projectConfig.setEventIconPath(Event::Group::Heal, ui->lineEdit_HealspotsIcon->text());
|
projectConfig.setEventIconPath(Event::Group::Heal, ui->lineEdit_HealspotsIcon->text());
|
||||||
for (auto lineEdit : ui->scrollAreaContents_ProjectPaths->findChildren<QLineEdit*>())
|
for (auto lineEdit : ui->scrollAreaContents_ProjectPaths->findChildren<QLineEdit*>())
|
||||||
projectConfig.setFilePath(lineEdit->objectName(), lineEdit->text());
|
projectConfig.setFilePath(lineEdit->objectName(), lineEdit->text());
|
||||||
|
for (auto lineEdit : ui->scrollAreaContents_Identifiers->findChildren<QLineEdit*>())
|
||||||
|
projectConfig.setIdentifier(lineEdit->objectName(), lineEdit->text());
|
||||||
projectConfig.setWarpBehaviors(this->getWarpBehaviorsList());
|
projectConfig.setWarpBehaviors(this->getWarpBehaviorsList());
|
||||||
|
|
||||||
// Save border metatile IDs
|
// Save border metatile IDs
|
||||||
|
|
Loading…
Reference in a new issue