diff --git a/forms/preferenceeditor.ui b/forms/preferenceeditor.ui
index 228c21be..2ce37cbe 100644
--- a/forms/preferenceeditor.ui
+++ b/forms/preferenceeditor.ui
@@ -6,8 +6,8 @@
0
0
- 522
- 493
+ 530
+ 432
@@ -19,244 +19,302 @@
9
-
-
-
- Miscellaneous
+
+
+ 0
-
-
-
-
-
- If checked, a prompt to reload your project will appear if relevant project files are edited
-
-
- Monitor project files
-
-
-
- -
-
-
- If checked, Porymap will automatically open your most recently opened project on startup
-
-
- Open recent project on launch
-
-
-
- -
-
-
- If checked, Porymap will automatically alert you on startup if a new release is available
-
-
- Automatically check for updates
-
-
-
- -
-
-
- If checked, no warning will be shown when deleting an event that has an associated #define that may also be deleted.
-
-
- Disable warning when deleting events with IDs
-
-
-
-
-
-
- -
-
-
- Event Selection Mode
-
-
-
-
-
-
- If enabled, an event can be selected by clicking directly on the opaque pixels of its sprite. This may be preferable when events are overlapping.
-
-
- Select by clicking on sprite
-
-
-
- -
-
-
- If enabled, an event can be selected by clicking anywhere within its sprite dimensions. This may be preferable for events with small or mostly transparent sprites.
-
-
- Select by clicking within bounding rectangle
-
-
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- Application Theme
-
-
-
- -
-
-
- Preferred Text Editor
-
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
- QFrame::NoFrame
-
-
- true
-
-
-
-
- 0
- 0
- 492
- 327
-
+
+
+ General
+
+
+
+ 12
+
+
+ 12
+
+
+ 12
+
+
-
+
+
+ If checked, a prompt to reload your project will appear if relevant project files are edited
-
-
- QLayout::SetMinimumSize
-
-
-
-
-
- <html><head/><body><p>When this command is set a button will appear next to the <span style=" font-weight:600; font-style:italic;">Script</span> combo-box in the <span style=" font-weight:600; font-style:italic;">Events</span> tab which executes this command.<span style=" font-weight:600;"> %F</span> will be substituted with the file path of the script and <span style=" font-weight:600;">%L</span> will be substituted with the line number of the script in that file. <span style=" font-weight:600;">%F </span><span style=" font-style:italic;">must</span> be given if <span style=" font-weight:600;">%L</span> is given. If <span style=" font-weight:600;">%F</span> is <span style=" font-style:italic;">not</span> given then the script's file path will be added to the end of the command. If the script can't be found then the current map's scripts file is opened.</p></body></html>
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
-
-
- true
-
-
-
- -
-
-
- Goto Line Command
-
-
-
- -
-
+
+ Monitor project files
+
+
+
+ -
+
+
+ If checked, Porymap will automatically open your most recently opened project on startup
+
+
+ Open recent project on launch
+
+
+
+ -
+
+
+ If checked, Porymap will automatically alert you on startup if a new release is available
+
+
+ Automatically check for updates
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Application Theme
+
+
+
+ -
+
+
+ Qt::Orientation::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ Events
+
+
+
+ 12
+
+
+ 12
+
+
+ 12
+
+ -
+
+
+ If checked, no warning will be shown when deleting an event that has an associated #define that may also be deleted.
+
+
+ Disable warning when deleting events with IDs
+
+
+
+ -
+
+
+ <html><head/><body><p>If checked, the list of suggestions when typing in an Event's Script field will include all global script labels in the project. Enabling this setting will make Porymap's startup slower.</p></body></html>
+
+
+ Autocomplete Script labels using all possible scripts
+
+
+
+ -
+
+
+ Selection Mode
+
+
+
-
+
- The shell command for your preferred text editor (possibly an absolute path if the program doesn't exist in your PATH).
+ If enabled, an event can be selected by clicking directly on the opaque pixels of its sprite. This may be preferable when events are overlapping.
-
- e.g. code %D
-
-
- true
-
-
-
- -
-
- <html><head/><body><p>This is the command that is executed when clicking <span style=" font-weight:600; font-style:italic;">Open Project in Text Editor</span> in the <span style=" font-weight:600; font-style:italic;">Tools</span> menu. <span style=" font-weight:600;">%D</span> will be substituted with the project's root directory. If <span style=" font-weight:600;">%D</span> is <span style=" font-style:italic;">not</span> specified then the project directory will be added to the end of the command.</p></body></html>
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
-
-
- true
+ Select by clicking on sprite
- -
-
-
- Open Directory Command
-
-
-
- -
-
+
-
+
- The shell command for your preferred text editor to open a file to a specific line number (possibly an absolute path if the program doesn't exist in your PATH).
+ If enabled, an event can be selected by clicking anywhere within its sprite dimensions. This may be preferable for events with small or mostly transparent sprites.
-
- e.g. code --goto %F:%L
-
-
- true
+
+ Select by clicking within bounding rectangle
- -
-
-
- Qt::Vertical
-
-
- QSizePolicy::Fixed
-
-
-
- 20
- 15
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
+
+ -
+
+
+ Qt::Orientation::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ Text Editor
+
+
+
+ 12
+
+
+ 12
+
+
+ 12
+
+ -
+
+
+ QFrame::Shape::NoFrame
+
+
+ true
+
+
+
+
+ 0
+ 0
+ 476
+ 343
+
+
+
+
+ QLayout::SizeConstraint::SetMinimumSize
+
+
-
+
+
+ <html><head/><body><p>When this command is set a button will appear next to the <span style=" font-weight:600; font-style:italic;">Script</span> combo-box in the <span style=" font-weight:600; font-style:italic;">Events</span> tab which executes this command.<span style=" font-weight:600;"> %F</span> will be substituted with the file path of the script and <span style=" font-weight:600;">%L</span> will be substituted with the line number of the script in that file. <span style=" font-weight:600;">%F </span><span style=" font-style:italic;">must</span> be given if <span style=" font-weight:600;">%L</span> is given. If <span style=" font-weight:600;">%F</span> is <span style=" font-style:italic;">not</span> given then the script's file path will be added to the end of the command. If the script can't be found then the current map's scripts file is opened.</p></body></html>
+
+
+ Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop
+
+
+ true
+
+
+
+ -
+
+
+ Goto Line Command
+
+
+
+ -
+
+
+ The shell command for your preferred text editor (possibly an absolute path if the program doesn't exist in your PATH).
+
+
+ e.g. code %D
+
+
+ true
+
+
+
+ -
+
+
+ <html><head/><body><p>This is the command that is executed when clicking <span style=" font-weight:600; font-style:italic;">Open Project in Text Editor</span> in the <span style=" font-weight:600; font-style:italic;">Tools</span> menu. <span style=" font-weight:600;">%D</span> will be substituted with the project's root directory. If <span style=" font-weight:600;">%D</span> is <span style=" font-style:italic;">not</span> specified then the project directory will be added to the end of the command.</p></body></html>
+
+
+ Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop
+
+
+ true
+
+
+
+ -
+
+
+ Open Directory Command
+
+
+
+ -
+
+
+ The shell command for your preferred text editor to open a file to a specific line number (possibly an absolute path if the program doesn't exist in your PATH).
+
+
+ e.g. code --goto %F:%L
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Orientation::Vertical
+
+
+ QSizePolicy::Policy::Fixed
+
+
+
+ 20
+ 15
+
+
+
+
+ -
+
+
+ Qt::Orientation::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
-
- QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+ QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok
diff --git a/include/project.h b/include/project.h
index 4a8ec1f7..bdca7444 100644
--- a/include/project.h
+++ b/include/project.h
@@ -298,6 +298,7 @@ signals:
void mapSectionDisplayNameChanged(const QString &idName, const QString &displayName);
void mapSectionIdNamesChanged(const QStringList &idNames);
void mapsExcluded(const QStringList &excludedMapNames);
+ void eventScriptLabelsRead();
};
#endif // PROJECT_H
diff --git a/include/ui/eventframes.h b/include/ui/eventframes.h
index cfde161c..763d6baf 100644
--- a/include/ui/eventframes.h
+++ b/include/ui/eventframes.h
@@ -31,8 +31,6 @@ public:
void invalidateUi();
void invalidateValues();
- void populateScriptDropdown(NoScrollComboBox * combo, Project * project);
-
virtual void setActive(bool active);
public:
@@ -59,6 +57,8 @@ protected:
bool initialized = false;
bool connected = false;
+ void populateScriptDropdown(NoScrollComboBox * combo, Project * project);
+
private:
Event *event;
};
diff --git a/include/ui/preferenceeditor.h b/include/ui/preferenceeditor.h
index c59641c2..e4541495 100644
--- a/include/ui/preferenceeditor.h
+++ b/include/ui/preferenceeditor.h
@@ -23,6 +23,7 @@ public:
signals:
void preferencesSaved();
void themeChanged(const QString &theme);
+ void scriptSettingsChanged(bool on);
private:
Ui::PreferenceEditor *ui;
diff --git a/src/editor.cpp b/src/editor.cpp
index ad99dded..6c269195 100644
--- a/src/editor.cpp
+++ b/src/editor.cpp
@@ -13,6 +13,7 @@
#include "customattributesframe.h"
#include "validator.h"
#include "message.h"
+#include "eventframes.h"
#include
#include
#include
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index a38505e2..f91cc12e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2719,12 +2719,10 @@ void MainWindow::on_actionOpen_Config_Folder_triggered() {
void MainWindow::on_actionPreferences_triggered() {
if (!preferenceEditor) {
preferenceEditor = new PreferenceEditor(this);
- connect(preferenceEditor, &PreferenceEditor::themeChanged,
- this, &MainWindow::setTheme);
- connect(preferenceEditor, &PreferenceEditor::themeChanged,
- editor, &Editor::maskNonVisibleConnectionTiles);
- connect(preferenceEditor, &PreferenceEditor::preferencesSaved,
- this, &MainWindow::togglePreferenceSpecificUi);
+ connect(preferenceEditor, &PreferenceEditor::themeChanged, this, &MainWindow::setTheme);
+ connect(preferenceEditor, &PreferenceEditor::themeChanged, editor, &Editor::maskNonVisibleConnectionTiles);
+ connect(preferenceEditor, &PreferenceEditor::preferencesSaved, this, &MainWindow::togglePreferenceSpecificUi);
+ connect(preferenceEditor, &PreferenceEditor::scriptSettingsChanged, editor->project, &Project::readEventScriptLabels);
}
openSubWindow(preferenceEditor);
@@ -2739,8 +2737,9 @@ void MainWindow::togglePreferenceSpecificUi() {
if (this->updatePromoter)
this->updatePromoter->updatePreferences();
- // Redraw all events to use updated porymapConfig.eventSelectionShapeMode
- this->editor->redrawAllEvents();
+ // Changes to porymapConfig.loadAllEventScripts or porymapConfig.eventSelectionShapeMode
+ // require us to repopulate the EventFrames and redraw event pixmaps, respectively.
+ this->editor->updateEvents();
}
void MainWindow::openProjectSettingsEditor(int tab) {
diff --git a/src/project.cpp b/src/project.cpp
index c8f12a34..7977c41b 100644
--- a/src/project.cpp
+++ b/src/project.cpp
@@ -2602,15 +2602,14 @@ bool Project::readMiscellaneousConstants() {
bool Project::readEventScriptLabels() {
this->globalScriptLabels.clear();
- if (porymapConfig.loadAllEventScripts)
- return true;
-
- for (const auto &filePath : getEventScriptsFilePaths())
- this->globalScriptLabels << ParseUtil::getGlobalScriptLabels(filePath);
-
- this->globalScriptLabels.sort(Qt::CaseInsensitive);
- this->globalScriptLabels.removeDuplicates();
+ if (porymapConfig.loadAllEventScripts) {
+ for (const auto &filePath : getEventScriptsFilePaths())
+ this->globalScriptLabels << ParseUtil::getGlobalScriptLabels(filePath);
+ this->globalScriptLabels.sort(Qt::CaseInsensitive);
+ this->globalScriptLabels.removeDuplicates();
+ }
+ emit eventScriptLabelsRead();
return true;
}
diff --git a/src/ui/eventframes.cpp b/src/ui/eventframes.cpp
index 45085e7c..82334722 100644
--- a/src/ui/eventframes.cpp
+++ b/src/ui/eventframes.cpp
@@ -195,6 +195,9 @@ void EventFrame::populateScriptDropdown(NoScrollComboBox * combo, Project * proj
if (popup) popup->setUniformItemSizes(true);
combo->setCompleter(completer);
+
+ // If the project changes the script labels, update the EventFrame.
+ connect(project, &Project::eventScriptLabelsRead, this, &EventFrame::invalidateValues, Qt::UniqueConnection);
}
diff --git a/src/ui/preferenceeditor.cpp b/src/ui/preferenceeditor.cpp
index 130e1a62..f9071ec2 100644
--- a/src/ui/preferenceeditor.cpp
+++ b/src/ui/preferenceeditor.cpp
@@ -56,6 +56,7 @@ void PreferenceEditor::updateFields() {
ui->checkBox_OpenRecentProject->setChecked(porymapConfig.reopenOnLaunch);
ui->checkBox_CheckForUpdates->setChecked(porymapConfig.checkForUpdates);
ui->checkBox_DisableEventWarning->setChecked(porymapConfig.eventDeleteWarningDisabled);
+ ui->checkBox_AutocompleteAllScripts->setChecked(porymapConfig.loadAllEventScripts);
}
void PreferenceEditor::saveFields() {
@@ -64,6 +65,11 @@ void PreferenceEditor::saveFields() {
porymapConfig.theme = theme;
emit themeChanged(theme);
}
+ bool loadAllEventScripts = ui->checkBox_AutocompleteAllScripts->isChecked();
+ if (loadAllEventScripts != porymapConfig.loadAllEventScripts) {
+ porymapConfig.loadAllEventScripts = loadAllEventScripts;
+ emit scriptSettingsChanged(loadAllEventScripts);
+ }
porymapConfig.eventSelectionShapeMode = ui->radioButton_OnSprite->isChecked() ? QGraphicsPixmapItem::MaskShape : QGraphicsPixmapItem::BoundingRectShape;
porymapConfig.textEditorOpenFolder = ui->lineEdit_TextEditorOpenFolder->text();
porymapConfig.textEditorGotoLine = ui->lineEdit_TextEditorGotoLine->text();