mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-24 09:36:11 -05:00
Remove global scripts from autocomplete
This commit is contained in:
@@ -79,6 +79,7 @@ public:
|
||||
this->textEditorGotoLine = "";
|
||||
this->paletteEditorBitDepth = 24;
|
||||
this->projectSettingsTab = 0;
|
||||
this->loadAllEventScripts = false;
|
||||
this->warpBehaviorWarningDisabled = false;
|
||||
this->eventDeleteWarningDisabled = false;
|
||||
this->eventOverlayEnabled = false;
|
||||
@@ -135,6 +136,7 @@ public:
|
||||
QString textEditorGotoLine;
|
||||
int paletteEditorBitDepth;
|
||||
int projectSettingsTab;
|
||||
bool loadAllEventScripts;
|
||||
bool warpBehaviorWarningDisabled;
|
||||
bool eventDeleteWarningDisabled;
|
||||
bool eventOverlayEnabled;
|
||||
|
||||
@@ -219,6 +219,7 @@ public:
|
||||
static QString getScriptFileExtension(bool usePoryScript);
|
||||
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
|
||||
QStringList getEventScriptsFilePaths() const;
|
||||
void insertGlobalScriptLabels(QStringList &scriptLabels) const;
|
||||
|
||||
QString getDefaultPrimaryTilesetLabel() const;
|
||||
QString getDefaultSecondaryTilesetLabel() const;
|
||||
|
||||
@@ -390,6 +390,8 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
||||
}
|
||||
} else if (key == "project_settings_tab") {
|
||||
this->projectSettingsTab = getConfigInteger(key, value, 0);
|
||||
} else if (key == "load_all_event_scripts") {
|
||||
this->loadAllEventScripts = getConfigBool(key, value);
|
||||
} else if (key == "warp_behavior_warning_disabled") {
|
||||
this->warpBehaviorWarningDisabled = getConfigBool(key, value);
|
||||
} else if (key == "event_delete_warning_disabled") {
|
||||
@@ -479,6 +481,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
||||
map.insert("text_editor_goto_line", this->textEditorGotoLine);
|
||||
map.insert("palette_editor_bit_depth", QString::number(this->paletteEditorBitDepth));
|
||||
map.insert("project_settings_tab", QString::number(this->projectSettingsTab));
|
||||
map.insert("load_all_event_scripts", QString::number(this->loadAllEventScripts));
|
||||
map.insert("warp_behavior_warning_disabled", QString::number(this->warpBehaviorWarningDisabled));
|
||||
map.insert("event_delete_warning_disabled", QString::number(this->eventDeleteWarningDisabled));
|
||||
map.insert("event_overlay_enabled", QString::number(this->eventOverlayEnabled));
|
||||
|
||||
@@ -152,13 +152,12 @@ QStringList Map::getScriptLabels(Event::Group group) {
|
||||
scriptLabels = scriptTracker.getScripts();
|
||||
}
|
||||
|
||||
// Add scripts from map's scripts file, and empty names.
|
||||
// Add labels from the map's scripts file
|
||||
scriptLabels.append(m_scriptsFileLabels);
|
||||
scriptLabels.sort(Qt::CaseInsensitive);
|
||||
scriptLabels.prepend("0x0");
|
||||
scriptLabels.prepend("NULL");
|
||||
|
||||
scriptLabels.removeAll("");
|
||||
scriptLabels.removeAll("0");
|
||||
scriptLabels.removeAll("0x0");
|
||||
scriptLabels.removeDuplicates();
|
||||
|
||||
return scriptLabels;
|
||||
|
||||
@@ -2600,16 +2600,28 @@ bool Project::readMiscellaneousConstants() {
|
||||
}
|
||||
|
||||
bool Project::readEventScriptLabels() {
|
||||
globalScriptLabels.clear();
|
||||
for (const auto &filePath : getEventScriptsFilePaths())
|
||||
globalScriptLabels << ParseUtil::getGlobalScriptLabels(filePath);
|
||||
this->globalScriptLabels.clear();
|
||||
|
||||
globalScriptLabels.sort(Qt::CaseInsensitive);
|
||||
globalScriptLabels.removeDuplicates();
|
||||
if (porymapConfig.loadAllEventScripts)
|
||||
return true;
|
||||
|
||||
for (const auto &filePath : getEventScriptsFilePaths())
|
||||
this->globalScriptLabels << ParseUtil::getGlobalScriptLabels(filePath);
|
||||
|
||||
this->globalScriptLabels.sort(Qt::CaseInsensitive);
|
||||
this->globalScriptLabels.removeDuplicates();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::insertGlobalScriptLabels(QStringList &scriptLabels) const {
|
||||
if (this->globalScriptLabels.isEmpty())
|
||||
return;
|
||||
scriptLabels.append(this->globalScriptLabels);
|
||||
scriptLabels.sort();
|
||||
scriptLabels.removeDuplicates();
|
||||
}
|
||||
|
||||
QString Project::fixPalettePath(QString path) {
|
||||
static const QRegularExpression re_gbapal("\\.gbapal$");
|
||||
path = path.replace(re_gbapal, ".pal");
|
||||
|
||||
@@ -173,12 +173,19 @@ void EventFrame::setActive(bool active) {
|
||||
}
|
||||
|
||||
void EventFrame::populateScriptDropdown(NoScrollComboBox * combo, Project * project) {
|
||||
// The script dropdown is populated with scripts used by the map's events and from its scripts file.
|
||||
if (this->event->getMap())
|
||||
combo->addItems(this->event->getMap()->getScriptLabels(this->event->getEventGroup()));
|
||||
// The script dropdown and autocomplete are populated with scripts used by the map's events and from its scripts file.
|
||||
if (!this->event->getMap())
|
||||
return;
|
||||
|
||||
// The dropdown's autocomplete has all script labels across the full project.
|
||||
auto completer = new QCompleter(project->globalScriptLabels, combo);
|
||||
QStringList scripts = this->event->getMap()->getScriptLabels(this->event->getEventGroup());
|
||||
combo->addItems(scripts);
|
||||
|
||||
// Depending on the settings, the autocomplete may also contain all global scripts.
|
||||
if (porymapConfig.loadAllEventScripts) {
|
||||
project->insertGlobalScriptLabels(scripts);
|
||||
}
|
||||
|
||||
auto completer = new QCompleter(scripts, combo);
|
||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
|
||||
completer->setFilterMode(Qt::MatchContains);
|
||||
|
||||
Reference in New Issue
Block a user