Add completion suggestions for global event scripts
This commit is contained in:
parent
d2386fac9b
commit
3ccf433d1e
3 changed files with 28 additions and 3 deletions
|
@ -60,6 +60,7 @@ public:
|
|||
QStringList *secretBaseIds = nullptr;
|
||||
QStringList *bgEventFacingDirections = nullptr;
|
||||
QStringList *trainerTypes = nullptr;
|
||||
QStringList eventScriptLabels;
|
||||
QMap<QString, int> metatileBehaviorMap;
|
||||
QMap<int, QString> metatileBehaviorMapInverse;
|
||||
QMap<QString, QString> facingDirections;
|
||||
|
@ -167,6 +168,7 @@ public:
|
|||
bool readMetatileBehaviors();
|
||||
bool readHealLocations();
|
||||
bool readMiscellaneousConstants();
|
||||
bool readEventScriptLabels();
|
||||
|
||||
void loadEventPixmaps(QList<Event*> objects);
|
||||
QMap<QString, int> getEventObjGfxConstants();
|
||||
|
@ -177,6 +179,7 @@ public:
|
|||
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
|
||||
QString getMapScriptsFilePath(const QString &mapName) const;
|
||||
QStringList getEventScriptsFilePaths() const;
|
||||
QCompleter *getEventScriptLabelCompleter(const QStringList &additionalCompletions) const;
|
||||
|
||||
bool loadMapBorder(Map *map);
|
||||
|
||||
|
@ -220,6 +223,8 @@ private:
|
|||
static int max_object_events;
|
||||
|
||||
QWidget *parent;
|
||||
QStringListModel *eventScriptLabelModel = nullptr;
|
||||
QCompleter *eventScriptLabelCompleter = nullptr;
|
||||
|
||||
signals:
|
||||
void reloadProject();
|
||||
|
|
|
@ -876,8 +876,9 @@ bool MainWindow::loadDataStructures() {
|
|||
&& project->readHealLocations()
|
||||
&& project->readMiscellaneousConstants()
|
||||
&& project->readSpeciesIconPaths()
|
||||
&& project->readWildMonData();
|
||||
|
||||
&& project->readWildMonData()
|
||||
&& project->readEventScriptLabels();
|
||||
|
||||
return success && loadProjectCombos();
|
||||
}
|
||||
|
||||
|
@ -1917,7 +1918,9 @@ void MainWindow::updateSelectedObjects() {
|
|||
"normal movement behavior actions.");
|
||||
combo->setMinimumContentsLength(4);
|
||||
} else if (key == "script_label") {
|
||||
combo->addItems(editor->map->eventScriptLabels());
|
||||
const auto localScriptLabels = editor->map->eventScriptLabels();
|
||||
combo->addItems(localScriptLabels);
|
||||
combo->setCompleter(editor->project->getEventScriptLabelCompleter(localScriptLabels));
|
||||
combo->setToolTip("The script which is executed with this event.");
|
||||
} else if (key == "trainer_type") {
|
||||
combo->addItems(*editor->project->trainerTypes);
|
||||
|
|
|
@ -2399,6 +2399,18 @@ bool Project::readMiscellaneousConstants() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Project::readEventScriptLabels() {
|
||||
for (const auto &filePath : getEventScriptsFilePaths())
|
||||
eventScriptLabels << ParseUtil::getGlobalScriptLabels(filePath);
|
||||
|
||||
eventScriptLabelModel = new QStringListModel(eventScriptLabels, this);
|
||||
eventScriptLabelCompleter = new QCompleter(eventScriptLabelModel, this);
|
||||
eventScriptLabelCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
eventScriptLabelCompleter->setFilterMode(Qt::MatchContains);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Project::fixPalettePath(QString path) {
|
||||
path = path.replace(QRegExp("\\.gbapal$"), ".pal");
|
||||
return path;
|
||||
|
@ -2462,6 +2474,11 @@ QStringList Project::getEventScriptsFilePaths() const {
|
|||
return filePaths;
|
||||
}
|
||||
|
||||
QCompleter *Project::getEventScriptLabelCompleter(const QStringList &additionalCompletions) const {
|
||||
eventScriptLabelModel->setStringList(eventScriptLabels + additionalCompletions);
|
||||
return eventScriptLabelCompleter;
|
||||
}
|
||||
|
||||
void Project::loadEventPixmaps(QList<Event*> objects) {
|
||||
bool needs_update = false;
|
||||
for (Event *object : objects) {
|
||||
|
|
Loading…
Reference in a new issue