Add path override editor
This commit is contained in:
parent
7411ddaeef
commit
61cbbbf08a
8 changed files with 146 additions and 35 deletions
|
@ -3015,9 +3015,9 @@
|
|||
<addaction name="actionMonitor_Project_Files"/>
|
||||
<addaction name="actionOpen_Recent_Project_On_Launch"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionEdit_Project_Settings"/>
|
||||
<addaction name="actionEdit_Preferences"/>
|
||||
<addaction name="actionEdit_Shortcuts"/>
|
||||
<addaction name="actionProject_Settings"/>
|
||||
<addaction name="actionPreferences"/>
|
||||
<addaction name="actionShortcuts"/>
|
||||
<addaction name="actionCustom_Scripts"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
|
@ -3272,9 +3272,9 @@
|
|||
<string>Export Map Stitch Image...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEdit_Preferences">
|
||||
<action name="actionPreferences">
|
||||
<property name="text">
|
||||
<string>Edit Preferences...</string>
|
||||
<string>Preferences...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+,</string>
|
||||
|
@ -3285,9 +3285,9 @@
|
|||
<string>Open Project in Text Editor</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEdit_Shortcuts">
|
||||
<action name="actionShortcuts">
|
||||
<property name="text">
|
||||
<string>Edit Shortcuts...</string>
|
||||
<string>Shortcuts...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExport_Map_Timelapse_Image">
|
||||
|
@ -3310,9 +3310,9 @@
|
|||
<string>Import Map from Advance Map 1.92...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEdit_Project_Settings">
|
||||
<action name="actionProject_Settings">
|
||||
<property name="text">
|
||||
<string>Edit Project Settings...</string>
|
||||
<string>Project Settings...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCustom_Scripts">
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>570</width>
|
||||
<height>1041</height>
|
||||
<width>563</width>
|
||||
<height>1129</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -28,8 +28,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>1107</height>
|
||||
<width>537</width>
|
||||
<height>1427</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
|
@ -132,7 +132,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_Elevation">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_Elevation">
|
||||
<property name="toolTip">
|
||||
<string>The default elevation that will be used to fill new maps</string>
|
||||
</property>
|
||||
|
@ -153,7 +153,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_FillMetatile">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_FillMetatile">
|
||||
<property name="toolTip">
|
||||
<string>The default metatile value that will be used to fill new maps</string>
|
||||
</property>
|
||||
|
@ -309,7 +309,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_TerrainTypeMask">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_TerrainTypeMask">
|
||||
<property name="toolTip">
|
||||
<string>The mask used to read/write Terrain Type from the metatile's attributes data. If 0, this attribute is disabled.</string>
|
||||
</property>
|
||||
|
@ -366,7 +366,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_BehaviorMask">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_BehaviorMask">
|
||||
<property name="toolTip">
|
||||
<string>The mask used to read/write Metatile Behavior from the metatile's attributes data. If 0, this attribute is disabled.</string>
|
||||
</property>
|
||||
|
@ -399,7 +399,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_EncounterTypeMask">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_EncounterTypeMask">
|
||||
<property name="toolTip">
|
||||
<string>The mask used to read/write Encounter Type from the metatile's attributes data. If 0, this attribute is disabled.</string>
|
||||
</property>
|
||||
|
@ -426,7 +426,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_LayerTypeMask">
|
||||
<widget class="NoScrollSpinBox" name="spinBox_LayerTypeMask">
|
||||
<property name="toolTip">
|
||||
<string>The mask used to read/write Layer Type from the metatile's attributes data. If 0, this attribute is disabled.</string>
|
||||
</property>
|
||||
|
@ -441,6 +441,60 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_ProjectPaths">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Path Overrides</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>1</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_ProjectPaths">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaContents_ProjectPaths">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>507</width>
|
||||
<height>295</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="layout_ProjectPaths"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_Events">
|
||||
<property name="title">
|
||||
|
@ -577,6 +631,11 @@
|
|||
<extends>QComboBox</extends>
|
||||
<header>noscrollcombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>NoScrollSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>noscrollspinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../resources/images.qrc"/>
|
||||
|
|
|
@ -227,6 +227,7 @@ public:
|
|||
this->filePaths.clear();
|
||||
this->readKeys.clear();
|
||||
}
|
||||
static const QMap<ProjectFilePath, std::pair<QString, QString>> 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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ private:
|
|||
bool promptSaveChanges();
|
||||
bool promptRestoreDefaults();
|
||||
|
||||
void createProjectPathsTable();
|
||||
|
||||
private slots:
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
void choosePrefabsFileClicked(bool);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <QAction>
|
||||
#include <QAbstractButton>
|
||||
|
||||
const QMap<ProjectFilePath, std::pair<QString, QString>> defaultPaths = {
|
||||
const QMap<ProjectFilePath, std::pair<QString, QString>> 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<ProjectFilePath, std::pair<QString, QString>> 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<ProjectFilePath>(-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();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<QCheckBox *>())
|
||||
connect(checkBox, &QCheckBox::stateChanged, this, &ProjectSettingsEditor::markEdited);
|
||||
for (auto spinBox : ui->centralwidget->findChildren<QSpinBox *>())
|
||||
for (auto spinBox : ui->centralwidget->findChildren<NoScrollSpinBox *>())
|
||||
connect(spinBox, QOverload<int>::of(&QSpinBox::valueChanged), [this](int) { this->markEdited(); });
|
||||
for (auto lineEdit : ui->centralwidget->findChildren<QLineEdit *>())
|
||||
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<QString, QByteArray> 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<QLineEdit*>())
|
||||
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<QLineEdit*>())
|
||||
projectConfig.setFilePath(lineEdit->objectName(), lineEdit->text());
|
||||
|
||||
// Parse border metatile list
|
||||
QList<QString> metatileIdStrings = ui->lineEdit_BorderMetatiles->text().split(",");
|
||||
// Parse and save border metatile list
|
||||
QList<uint16_t> 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<uint16_t>(Project::getNumMetatilesTotal() - 1)));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue