diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui
index f23028b6..91dfc192 100644
--- a/forms/mainwindow.ui
+++ b/forms/mainwindow.ui
@@ -3015,9 +3015,9 @@
-
-
-
+
+
+
@@ -3272,9 +3272,9 @@
Export Map Stitch Image...
-
+
- Edit Preferences...
+ Preferences...
Ctrl+,
@@ -3285,9 +3285,9 @@
Open Project in Text Editor
-
+
- Edit Shortcuts...
+ Shortcuts...
@@ -3310,9 +3310,9 @@
Import Map from Advance Map 1.92...
-
+
- Edit Project Settings...
+ Project Settings...
diff --git a/forms/projectsettingseditor.ui b/forms/projectsettingseditor.ui
index 78f9e61a..bcc19418 100644
--- a/forms/projectsettingseditor.ui
+++ b/forms/projectsettingseditor.ui
@@ -6,8 +6,8 @@
0
0
- 570
- 1041
+ 563
+ 1129
@@ -28,8 +28,8 @@
0
0
- 544
- 1107
+ 537
+ 1427
@@ -132,7 +132,7 @@
-
-
+
The default elevation that will be used to fill new maps
@@ -153,7 +153,7 @@
-
-
+
The default metatile value that will be used to fill new maps
@@ -309,7 +309,7 @@
-
-
+
The mask used to read/write Terrain Type from the metatile's attributes data. If 0, this attribute is disabled.
@@ -366,7 +366,7 @@
-
-
+
The mask used to read/write Metatile Behavior from the metatile's attributes data. If 0, this attribute is disabled.
@@ -399,7 +399,7 @@
-
-
+
The mask used to read/write Encounter Type from the metatile's attributes data. If 0, this attribute is disabled.
@@ -426,7 +426,7 @@
-
-
+
The mask used to read/write Layer Type from the metatile's attributes data. If 0, this attribute is disabled.
@@ -441,6 +441,60 @@
+ -
+
+
+
+ 0
+ 320
+
+
+
+ Path Overrides
+
+
+
+ 1
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ QFrame::NoFrame
+
+
+ QFrame::Plain
+
+
+ true
+
+
+
+
+ 0
+ 0
+ 507
+ 295
+
+
+
+
+
+
+
+
+
-
@@ -577,6 +631,11 @@
QComboBox
+
+ NoScrollSpinBox
+ QSpinBox
+
+
diff --git a/include/config.h b/include/config.h
index 11d503a5..4ec23b52 100644
--- a/include/config.h
+++ b/include/config.h
@@ -227,6 +227,7 @@ public:
this->filePaths.clear();
this->readKeys.clear();
}
+ static const QMap> defaultPaths;
static const QStringList versionStrings;
void reset(BaseGameVersion baseGameVersion);
void setBaseGameVersion(BaseGameVersion baseGameVersion);
@@ -271,8 +272,10 @@ public:
QString getDefaultSecondaryTileset();
void setDefaultPrimaryTileset(QString tilesetName);
void setDefaultSecondaryTileset(QString tilesetName);
+ void setFilePath(QString pathId, QString path);
void setFilePath(ProjectFilePath pathId, QString path);
- QString getFilePath(ProjectFilePath pathId);
+ QString getFilePath(QString defaultPath, bool allowDefault = true);
+ QString getFilePath(ProjectFilePath pathId, bool allowDefault = true);
void setPrefabFilepath(QString filepath);
QString getPrefabFilepath();
void setPrefabImportPrompted(bool prompted);
diff --git a/include/mainwindow.h b/include/mainwindow.h
index 224b8c24..41c6c7f0 100644
--- a/include/mainwindow.h
+++ b/include/mainwindow.h
@@ -201,7 +201,7 @@ private slots:
void on_spinBox_FloorNumber_valueChanged(int offset);
void on_actionMonitor_Project_Files_triggered(bool checked);
void on_actionOpen_Recent_Project_On_Launch_triggered(bool checked);
- void on_actionEdit_Shortcuts_triggered();
+ void on_actionShortcuts_triggered();
void on_actionZoom_In_triggered();
void on_actionZoom_Out_triggered();
@@ -284,9 +284,9 @@ private slots:
void on_pushButton_CreatePrefab_clicked();
void on_actionRegion_Map_Editor_triggered();
- void on_actionEdit_Preferences_triggered();
+ void on_actionPreferences_triggered();
void togglePreferenceSpecificUi();
- void on_actionEdit_Project_Settings_triggered();
+ void on_actionProject_Settings_triggered();
void on_actionCustom_Scripts_triggered();
void reloadScriptEngine();
diff --git a/include/ui/projectsettingseditor.h b/include/ui/projectsettingseditor.h
index 03b3d14d..5f4fcd31 100644
--- a/include/ui/projectsettingseditor.h
+++ b/include/ui/projectsettingseditor.h
@@ -41,6 +41,8 @@ private:
bool promptSaveChanges();
bool promptRestoreDefaults();
+ void createProjectPathsTable();
+
private slots:
void dialogButtonClicked(QAbstractButton *button);
void choosePrefabsFileClicked(bool);
diff --git a/src/config.cpp b/src/config.cpp
index 6bfd50a9..9592ca63 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -16,7 +16,7 @@
#include
#include
-const QMap> 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/"}},
@@ -64,7 +64,7 @@ const QMap> defaultPaths = {
};
ProjectFilePath reverseDefaultPaths(QString str) {
- for (auto it = defaultPaths.constKeyValueBegin(); it != defaultPaths.constKeyValueEnd(); ++it) {
+ for (auto it = ProjectConfig::defaultPaths.constKeyValueBegin(); it != ProjectConfig::defaultPaths.constKeyValueEnd(); ++it) {
if ((*it).second.first == str) return (*it).first;
}
return static_cast(-1);
@@ -793,19 +793,31 @@ QString ProjectConfig::getProjectDir() {
void ProjectConfig::setFilePath(ProjectFilePath pathId, QString path) {
if (!defaultPaths.contains(pathId)) return;
- this->filePaths[pathId] = path;
+ if (path.isEmpty()) {
+ this->filePaths.remove(pathId);
+ } else {
+ this->filePaths[pathId] = path;
+ }
}
-QString ProjectConfig::getFilePath(ProjectFilePath pathId) {
+void ProjectConfig::setFilePath(QString defaultPath, QString newPath) {
+ this->setFilePath(reverseDefaultPaths(defaultPath), newPath);
+}
+
+QString ProjectConfig::getFilePath(ProjectFilePath pathId, bool allowDefault) {
if (this->filePaths.contains(pathId)) {
return this->filePaths[pathId];
- } else if (defaultPaths.contains(pathId)) {
+ } else if (allowDefault && defaultPaths.contains(pathId)) {
return defaultPaths[pathId].second;
} else {
return QString();
}
}
+QString ProjectConfig::getFilePath(QString defaultPath, bool allowDefault) {
+ return this->getFilePath(reverseDefaultPaths(defaultPath), allowDefault);
+}
+
void ProjectConfig::setBaseGameVersion(BaseGameVersion baseGameVersion) {
this->baseGameVersion = baseGameVersion;
this->save();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index c667151d..f568f505 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1780,7 +1780,7 @@ void MainWindow::on_actionOpen_Recent_Project_On_Launch_triggered(bool checked)
porymapConfig.setReopenOnLaunch(checked);
}
-void MainWindow::on_actionEdit_Shortcuts_triggered()
+void MainWindow::on_actionShortcuts_triggered()
{
if (!shortcutsEditor)
initShortcutsEditor();
@@ -2702,7 +2702,7 @@ void MainWindow::on_actionOpen_Config_Folder_triggered() {
QDesktopServices::openUrl(QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)));
}
-void MainWindow::on_actionEdit_Preferences_triggered() {
+void MainWindow::on_actionPreferences_triggered() {
if (!preferenceEditor) {
preferenceEditor = new PreferenceEditor(this);
connect(preferenceEditor, &PreferenceEditor::themeChanged,
@@ -2723,7 +2723,7 @@ void MainWindow::togglePreferenceSpecificUi() {
ui->actionOpen_Project_in_Text_Editor->setEnabled(true);
}
-void MainWindow::on_actionEdit_Project_Settings_triggered() {
+void MainWindow::on_actionProject_Settings_triggered() {
if (!this->projectSettingsEditor) {
this->projectSettingsEditor = new ProjectSettingsEditor(this, this->editor->project);
connect(this->projectSettingsEditor, &ProjectSettingsEditor::reloadProject,
diff --git a/src/ui/projectsettingseditor.cpp b/src/ui/projectsettingseditor.cpp
index 9318838c..e8d9af40 100644
--- a/src/ui/projectsettingseditor.cpp
+++ b/src/ui/projectsettingseditor.cpp
@@ -11,6 +11,8 @@
Editor for the settings in a user's porymap.project.cfg file (and 'use_encounter_json' in porymap.user.cfg).
*/
+// TODO: Better red outline around warning section
+
ProjectSettingsEditor::ProjectSettingsEditor(QWidget *parent, Project *project) :
QMainWindow(parent),
ui(new Ui::ProjectSettingsEditor),
@@ -19,6 +21,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(QWidget *parent, Project *project)
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
this->initUi();
+ this->createProjectPathsTable();
this->connectSignals();
this->refresh();
this->restoreWindowState();
@@ -40,7 +43,7 @@ void ProjectSettingsEditor::connectSignals() {
connect(combo, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::markEdited);
for (auto checkBox : ui->centralwidget->findChildren())
connect(checkBox, &QCheckBox::stateChanged, this, &ProjectSettingsEditor::markEdited);
- for (auto spinBox : ui->centralwidget->findChildren())
+ for (auto spinBox : ui->centralwidget->findChildren())
connect(spinBox, QOverload::of(&QSpinBox::valueChanged), [this](int) { this->markEdited(); });
for (auto lineEdit : ui->centralwidget->findChildren())
connect(lineEdit, &QLineEdit::textEdited, this, &ProjectSettingsEditor::markEdited);
@@ -75,6 +78,35 @@ void ProjectSettingsEditor::initUi() {
ui->spinBox_TerrainTypeMask->setMaximum(INT_MAX);
}
+// TODO: Reduce vertical space between entries
+// TODO: Fix vertical misalignment between label and edit area
+// TODO: Add description / manual link at top?
+void ProjectSettingsEditor::createProjectPathsTable() {
+ auto pathPairs = ProjectConfig::defaultPaths.values();
+ for (auto pathPair : pathPairs) {
+ // Name of the path
+ auto name = new QLabel();
+ name->setText(pathPair.first);
+
+ // Editable area of the path
+ auto path = new QLineEdit();
+ path->setObjectName(pathPair.first); // Used when saving the paths
+ path->setPlaceholderText(pathPair.second);
+ path->setClearButtonEnabled(true);
+ auto button = new QToolButton();
+ button->setIcon(QIcon(":/icons/folder.ico"));
+ // TODO: file prompt
+ //connect(button, &QAbstractButton::clicked, this, &ProjectSettingsEditor::);
+
+ // Add to list
+ auto editFrame = new QFrame();
+ auto layout = new QHBoxLayout(editFrame);
+ layout->addWidget(path);
+ layout->addWidget(button);
+ ui->layout_ProjectPaths->addRow(name, editFrame);
+ }
+}
+
void ProjectSettingsEditor::restoreWindowState() {
logInfo("Restoring project settings editor geometry from previous session.");
const QMap geometry = porymapConfig.getProjectSettingsEditorGeometry();
@@ -120,6 +152,8 @@ void ProjectSettingsEditor::refresh() {
// Set line edit texts
ui->lineEdit_BorderMetatiles->setText(projectConfig.getNewMapBorderMetatileIdsString());
ui->lineEdit_PrefabsPath->setText(projectConfig.getPrefabFilepath());
+ for (auto lineEdit : ui->scrollAreaContents_ProjectPaths->findChildren())
+ lineEdit->setText(projectConfig.getFilePath(lineEdit->objectName(), false));
this->refreshing = false; // Allow signals
}
@@ -157,11 +191,12 @@ void ProjectSettingsEditor::save() {
projectConfig.setMetatileEncounterTypeMask(ui->spinBox_EncounterTypeMask->value());
projectConfig.setMetatileLayerTypeMask(ui->spinBox_LayerTypeMask->value());
projectConfig.setPrefabFilepath(ui->lineEdit_PrefabsPath->text());
+ for (auto lineEdit : ui->scrollAreaContents_ProjectPaths->findChildren())
+ projectConfig.setFilePath(lineEdit->objectName(), lineEdit->text());
- // Parse border metatile list
- QList metatileIdStrings = ui->lineEdit_BorderMetatiles->text().split(",");
+ // Parse and save border metatile list
QList metatileIds;
- for (auto s : metatileIdStrings) {
+ for (auto s : ui->lineEdit_BorderMetatiles->text().split(",")) {
uint16_t metatileId = s.toUInt(nullptr, 0);
metatileIds.append(qMin(metatileId, static_cast(Project::getNumMetatilesTotal() - 1)));
}