Skip to content

Commit c45598f

Browse files
Merge branch 'dev' of https://github.com/huderlem/porymap into metatile-layers
2 parents 26ad93f + 4ea92dd commit c45598f

File tree

16 files changed

+192
-78
lines changed

16 files changed

+192
-78
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project somewhat adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The MAJOR version number is bumped when there are **"Breaking Changes"** in the pret projects. For more on this, see [the manual page on breaking changes](https://huderlem.github.io/porymap/manual/breaking-changes.html).
66

77
## [Unreleased]
8+
### Added
9+
- Add an option under `Preferences` to include common scripts in the autocomplete for Script labels.
10+
- A link to Porymap's manual is now available under `Help`.
11+
812
### Changed
913
- The scroll position of the map view now remains the same between the Connections tab and the Map/Events tabs.
1014
- The Move tool now behaves more like a traditional pan tool (with no momentum).

forms/mainwindow.ui

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,6 +2926,7 @@
29262926
<string>Help</string>
29272927
</property>
29282928
<addaction name="actionAbout_Porymap"/>
2929+
<addaction name="actionOpen_Manual"/>
29292930
<addaction name="actionOpen_Log_File"/>
29302931
<addaction name="actionOpen_Config_Folder"/>
29312932
<addaction name="actionCheck_for_Updates"/>
@@ -3267,6 +3268,11 @@
32673268
<string>Alt+Right</string>
32683269
</property>
32693270
</action>
3271+
<action name="actionOpen_Manual">
3272+
<property name="text">
3273+
<string>Open Manual</string>
3274+
</property>
3275+
</action>
32703276
</widget>
32713277
<layoutdefault spacing="6" margin="11"/>
32723278
<customwidgets>

forms/preferenceeditor.ui

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<item row="3" column="0">
105105
<spacer name="verticalSpacer_5">
106106
<property name="orientation">
107-
<enum>Qt::Vertical</enum>
107+
<enum>Qt::Orientation::Vertical</enum>
108108
</property>
109109
<property name="sizeHint" stdset="0">
110110
<size>
@@ -159,7 +159,7 @@
159159
<item row="0" column="3">
160160
<spacer name="horizontalSpacer">
161161
<property name="orientation">
162-
<enum>Qt::Horizontal</enum>
162+
<enum>Qt::Orientation::Horizontal</enum>
163163
</property>
164164
<property name="sizeHint" stdset="0">
165165
<size>
@@ -209,7 +209,7 @@
209209
<item>
210210
<spacer name="verticalSpacer_4">
211211
<property name="orientation">
212-
<enum>Qt::Vertical</enum>
212+
<enum>Qt::Orientation::Vertical</enum>
213213
</property>
214214
<property name="sizeHint" stdset="0">
215215
<size>
@@ -253,13 +253,42 @@
253253
</widget>
254254
</item>
255255
<item>
256-
<widget class="QCheckBox" name="checkBox_AutocompleteAllScripts">
257-
<property name="toolTip">
258-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
259-
</property>
260-
<property name="text">
261-
<string>Autocomplete Script labels using all possible scripts</string>
256+
<widget class="QGroupBox" name="groupBox_ScriptAutocomplete">
257+
<property name="title">
258+
<string>Script label autocomplete</string>
262259
</property>
260+
<layout class="QVBoxLayout" name="verticalLayout_7">
261+
<item>
262+
<widget class="QRadioButton" name="radioButton_AutocompleteAllScripts">
263+
<property name="toolTip">
264+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, the list of suggestions when typing in an Event's Script field will include all global script labels in the project. This is the slowest option for Porymap's project opening.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
265+
</property>
266+
<property name="text">
267+
<string>All possible scripts</string>
268+
</property>
269+
</widget>
270+
</item>
271+
<item>
272+
<widget class="QRadioButton" name="radioButton_AutocompleteCommonScripts">
273+
<property name="toolTip">
274+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, the list of suggestions when typing in an Event's Script field will include script labels from the current map's scripts file, scripts in-use by the map's other events, and all script files in the &lt;span style=&quot; font-family:'SFMono-Regular','Menlo','Monaco','Consolas','Liberation Mono','Courier New','Courier','monospace'; font-size:11px; color:#e74c3c; background-color:#ffffff;&quot;&gt;data_scripts_folders &lt;/span&gt;folder.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
275+
</property>
276+
<property name="text">
277+
<string>Current map, and global script files</string>
278+
</property>
279+
</widget>
280+
</item>
281+
<item>
282+
<widget class="QRadioButton" name="radioButton_AutocompleteMapScripts">
283+
<property name="toolTip">
284+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If checked, the list of suggestions when typing in an Event's Script field will only include script labels from the current map's scripts file and scripts in-use by the map's other events. This is the fastest option for Porymap's project opening.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
285+
</property>
286+
<property name="text">
287+
<string>Current map only</string>
288+
</property>
289+
</widget>
290+
</item>
291+
</layout>
263292
</widget>
264293
</item>
265294
<item>
@@ -294,7 +323,7 @@
294323
<item>
295324
<spacer name="verticalSpacer_3">
296325
<property name="orientation">
297-
<enum>Qt::Vertical</enum>
326+
<enum>Qt::Orientation::Vertical</enum>
298327
</property>
299328
<property name="sizeHint" stdset="0">
300329
<size>
@@ -323,7 +352,7 @@
323352
<item>
324353
<widget class="QScrollArea" name="scrollArea_TextEditor">
325354
<property name="frameShape">
326-
<enum>QFrame::NoFrame</enum>
355+
<enum>QFrame::Shape::NoFrame</enum>
327356
</property>
328357
<property name="widgetResizable">
329358
<bool>true</bool>
@@ -333,21 +362,21 @@
333362
<rect>
334363
<x>0</x>
335364
<y>0</y>
336-
<width>476</width>
337-
<height>343</height>
365+
<width>495</width>
366+
<height>376</height>
338367
</rect>
339368
</property>
340369
<layout class="QGridLayout" name="gridLayout_2">
341370
<property name="sizeConstraint">
342-
<enum>QLayout::SetMinimumSize</enum>
371+
<enum>QLayout::SizeConstraint::SetMinimumSize</enum>
343372
</property>
344373
<item row="6" column="0" colspan="2">
345374
<widget class="QLabel" name="label_TextEditorGotoLineHelp">
346375
<property name="text">
347376
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;When this command is set a button will appear next to the &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;Script&lt;/span&gt; combo-box in the &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;Events&lt;/span&gt; tab which executes this command.&lt;span style=&quot; font-weight:600;&quot;&gt; %F&lt;/span&gt; will be substituted with the file path of the script and &lt;span style=&quot; font-weight:600;&quot;&gt;%L&lt;/span&gt; will be substituted with the line number of the script in that file. &lt;span style=&quot; font-weight:600;&quot;&gt;%F &lt;/span&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;must&lt;/span&gt; be given if &lt;span style=&quot; font-weight:600;&quot;&gt;%L&lt;/span&gt; is given. If &lt;span style=&quot; font-weight:600;&quot;&gt;%F&lt;/span&gt; is &lt;span style=&quot; font-style:italic;&quot;&gt;not&lt;/span&gt; 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.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
348377
</property>
349378
<property name="alignment">
350-
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
379+
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
351380
</property>
352381
<property name="wordWrap">
353382
<bool>true</bool>
@@ -380,7 +409,7 @@
380409
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the command that is executed when clicking &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;Open Project in Text Editor&lt;/span&gt; in the &lt;span style=&quot; font-weight:600; font-style:italic;&quot;&gt;Tools&lt;/span&gt; menu. &lt;span style=&quot; font-weight:600;&quot;&gt;%D&lt;/span&gt; will be substituted with the project's root directory. If &lt;span style=&quot; font-weight:600;&quot;&gt;%D&lt;/span&gt; is &lt;span style=&quot; font-style:italic;&quot;&gt;not&lt;/span&gt; specified then the project directory will be added to the end of the command.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
381410
</property>
382411
<property name="alignment">
383-
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
412+
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
384413
</property>
385414
<property name="wordWrap">
386415
<bool>true</bool>
@@ -410,10 +439,10 @@
410439
<item row="2" column="0" colspan="2">
411440
<spacer name="verticalSpacer_2">
412441
<property name="orientation">
413-
<enum>Qt::Vertical</enum>
442+
<enum>Qt::Orientation::Vertical</enum>
414443
</property>
415444
<property name="sizeType">
416-
<enum>QSizePolicy::Fixed</enum>
445+
<enum>QSizePolicy::Policy::Fixed</enum>
417446
</property>
418447
<property name="sizeHint" stdset="0">
419448
<size>
@@ -426,7 +455,7 @@
426455
<item row="7" column="0" colspan="2">
427456
<spacer name="verticalSpacer">
428457
<property name="orientation">
429-
<enum>Qt::Vertical</enum>
458+
<enum>Qt::Orientation::Vertical</enum>
430459
</property>
431460
<property name="sizeHint" stdset="0">
432461
<size>
@@ -447,7 +476,7 @@
447476
<item>
448477
<widget class="QDialogButtonBox" name="buttonBox">
449478
<property name="standardButtons">
450-
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
479+
<set>QDialogButtonBox::StandardButton::Apply|QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
451480
</property>
452481
</widget>
453482
</item>

include/config.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ extern const QVersionNumber porymapVersion;
2727

2828
#define CONFIG_BACKWARDS_COMPATABILITY
2929

30+
enum ScriptAutocompleteMode {
31+
MapOnly,
32+
MapAndCommon,
33+
All,
34+
};
35+
3036
class KeyValueConfigBase
3137
{
3238
public:
@@ -119,7 +125,7 @@ class PorymapConfig: public KeyValueConfigBase
119125
QString textEditorGotoLine;
120126
int paletteEditorBitDepth;
121127
int projectSettingsTab;
122-
bool loadAllEventScripts;
128+
ScriptAutocompleteMode scriptAutocompleteMode;
123129
bool warpBehaviorWarningDisabled;
124130
bool eventDeleteWarningDisabled;
125131
bool eventOverlayEnabled;

include/core/map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class Map : public QObject
148148
void modified();
149149
void scriptsModified();
150150
void mapDimensionsChanged(const QSize &size);
151-
void openScriptRequested(QString label);
151+
void openScriptRequested(const QString &label);
152152
void connectionAdded(MapConnection*);
153153
void connectionRemoved(MapConnection*);
154154
void layoutChanged();

include/editor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ class Editor : public QObject
209209

210210
public slots:
211211
void openMapScripts() const;
212-
void openScript(const QString &scriptLabel) const;
212+
bool openScript(const QString &scriptLabel) const;
213+
bool openScriptInFile(const QString &scriptLabel, const QString &filepath) const;
213214
void openProjectInTextEditor() const;
214215
void maskNonVisibleConnectionTiles();
215216
void onBorderMetatilesChanged();

include/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ private slots:
290290
void on_spinBox_SelectedCollision_valueChanged(int collision);
291291
void on_actionRegion_Map_Editor_triggered();
292292
void on_actionPreferences_triggered();
293+
void on_actionOpen_Manual_triggered();
293294
void on_actionCheck_for_Updates_triggered();
294295
void togglePreferenceSpecificUi();
295296
void on_actionProject_Settings_triggered();

include/project.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,11 @@ class Project : public QObject
215215

216216
static QString getScriptFileExtension(bool usePoryScript);
217217
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
218-
QStringList getEventScriptsFilepaths() const;
218+
219+
QStringList getAllEventScriptsFilepaths() const;
220+
QStringList getMapScriptsFilepaths() const;
221+
QStringList getCommonEventScriptsFilepaths() const;
222+
QStringList findScriptsFiles(const QString &searchDir, const QStringList &fileNames = {"*"}) const;
219223
void insertGlobalScriptLabels(QStringList &scriptLabels) const;
220224

221225
QString getDefaultPrimaryTilesetLabel() const;

include/ui/preferenceeditor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define PREFERENCES_H
33

44
#include <QMainWindow>
5+
#include "config.h"
56

67
class NoScrollComboBox;
78
class QAbstractButton;
@@ -23,7 +24,7 @@ class PreferenceEditor : public QMainWindow
2324
signals:
2425
void preferencesSaved();
2526
void themeChanged(const QString &theme);
26-
void scriptSettingsChanged(bool on);
27+
void scriptSettingsChanged(ScriptAutocompleteMode mode);
2728
void reloadProjectRequested();
2829

2930
private:

src/config.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ void PorymapConfig::reset() {
355355
this->textEditorGotoLine = "";
356356
this->paletteEditorBitDepth = 24;
357357
this->projectSettingsTab = 0;
358-
this->loadAllEventScripts = false;
358+
this->scriptAutocompleteMode = ScriptAutocompleteMode::MapOnly;
359359
this->warpBehaviorWarningDisabled = false;
360360
this->eventDeleteWarningDisabled = false;
361361
this->eventOverlayEnabled = false;
@@ -490,8 +490,13 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
490490
}
491491
} else if (key == "project_settings_tab") {
492492
this->projectSettingsTab = getConfigInteger(key, value, 0);
493+
#ifdef CONFIG_BACKWARDS_COMPATABILITY
494+
// Old setting replaced by script_autocomplete_mode
493495
} else if (key == "load_all_event_scripts") {
494-
this->loadAllEventScripts = getConfigBool(key, value);
496+
this->scriptAutocompleteMode = getConfigBool(key, value) ? ScriptAutocompleteMode::All : ScriptAutocompleteMode::MapOnly;
497+
#endif
498+
} else if (key == "script_autocomplete_mode") {
499+
this->scriptAutocompleteMode = static_cast<ScriptAutocompleteMode>(getConfigInteger(key, value, ScriptAutocompleteMode::MapOnly, ScriptAutocompleteMode::All));
495500
} else if (key == "warp_behavior_warning_disabled") {
496501
this->warpBehaviorWarningDisabled = getConfigBool(key, value);
497502
} else if (key == "event_delete_warning_disabled") {
@@ -613,7 +618,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
613618
map.insert("text_editor_goto_line", this->textEditorGotoLine);
614619
map.insert("palette_editor_bit_depth", QString::number(this->paletteEditorBitDepth));
615620
map.insert("project_settings_tab", QString::number(this->projectSettingsTab));
616-
map.insert("load_all_event_scripts", QString::number(this->loadAllEventScripts));
621+
map.insert("script_autocomplete_mode", QString::number(this->scriptAutocompleteMode));
617622
map.insert("warp_behavior_warning_disabled", QString::number(this->warpBehaviorWarningDisabled));
618623
map.insert("event_delete_warning_disabled", QString::number(this->eventDeleteWarningDisabled));
619624
map.insert("event_overlay_enabled", QString::number(this->eventOverlayEnabled));

0 commit comments

Comments
 (0)