mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-25 09:15:34 -05:00
Add completion suggestions for global event scripts
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user