diff --git a/include/core/parseutil.h b/include/core/parseutil.h index 7c9b225e..009e07c3 100644 --- a/include/core/parseutil.h +++ b/include/core/parseutil.h @@ -60,6 +60,9 @@ public: static int getScriptLineNumber(const QString &filePath, const QString &scriptLabel); static int getRawScriptLineNumber(QString text, const QString &scriptLabel); static int getPoryScriptLineNumber(QString text, const QString &scriptLabel); + static QStringList getGlobalScriptLabels(const QString &filePath); + static QStringList getGlobalRawScriptLabels(QString text); + static QStringList getGlobalPoryScriptLabels(QString text); static QString removeStringLiterals(QString text); static QString removeLineComments(QString text, const QString &commentSymbol); static QString removeLineComments(QString text, const QStringList &commentSymbols); @@ -74,6 +77,12 @@ private: QList generatePostfix(const QList &tokens); int evaluatePostfix(const QList &postfix); void error(const QString &message, const QString &expression); + + static const QRegularExpression re_incScriptLabel; + static const QRegularExpression re_globalIncScriptLabel; + static const QRegularExpression re_poryScriptLabel; + static const QRegularExpression re_globalPoryScriptLabel; + static const QRegularExpression re_poryRawSection; }; #endif // PARSEUTIL_H diff --git a/include/project.h b/include/project.h index 0a53887e..b33dcee9 100644 --- a/include/project.h +++ b/include/project.h @@ -62,6 +62,7 @@ public: QStringList secretBaseIds; QStringList bgEventFacingDirections; QStringList trainerTypes; + QStringList globalScriptLabels; QMap metatileBehaviorMap; QMap metatileBehaviorMapInverse; QMap facingDirections; @@ -168,6 +169,7 @@ public: bool readMetatileBehaviors(); bool readHealLocations(); bool readMiscellaneousConstants(); + bool readEventScriptLabels(); void loadEventPixmaps(QList objects); QMap getEventObjGfxConstants(); @@ -178,6 +180,7 @@ public: QString getScriptDefaultString(bool usePoryScript, QString mapName) const; QString getMapScriptsFilePath(const QString &mapName) const; QStringList getEventScriptsFilePaths() const; + QCompleter *getEventScriptLabelCompleter(QStringList additionalScriptLabels); bool loadMapBorder(Map *map); @@ -220,6 +223,9 @@ private: static int default_map_size; static int max_object_events; + QStringListModel eventScriptLabelModel; + QCompleter eventScriptLabelCompleter; + signals: void reloadProject(); void uncheckMonitorFilesAction(); diff --git a/src/core/map.cpp b/src/core/map.cpp index 3d839ecc..202d797b 100644 --- a/src/core/map.cpp +++ b/src/core/map.cpp @@ -427,8 +427,8 @@ QStringList Map::eventScriptLabels(const QString &event_group_type) const { scriptLabels << event->get("script_label"); } + scriptLabels.removeAll(""); scriptLabels.removeDuplicates(); - scriptLabels.removeAll(QString()); if (scriptLabels.contains("0x0")) scriptLabels.move(scriptLabels.indexOf("0x0"), scriptLabels.count() - 1); if (scriptLabels.contains("NULL")) diff --git a/src/core/parseutil.cpp b/src/core/parseutil.cpp index 30ebe19c..e45e8b10 100644 --- a/src/core/parseutil.cpp +++ b/src/core/parseutil.cpp @@ -6,6 +6,11 @@ #include #include +const QRegularExpression ParseUtil::re_incScriptLabel("\\b(?