Merge pull request #581 from GriffinRichards/script-completer
Sort script dropdown, minor fixes
This commit is contained in:
commit
07f68f6ab7
5 changed files with 27 additions and 71 deletions
|
@ -200,8 +200,6 @@ public:
|
||||||
static QString getScriptFileExtension(bool usePoryScript);
|
static QString getScriptFileExtension(bool usePoryScript);
|
||||||
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
|
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
|
||||||
QStringList getEventScriptsFilePaths() const;
|
QStringList getEventScriptsFilePaths() const;
|
||||||
QCompleter *getEventScriptLabelCompleter(QStringList additionalScriptLabels);
|
|
||||||
QStringList getGlobalScriptLabels();
|
|
||||||
|
|
||||||
QString getDefaultPrimaryTilesetLabel();
|
QString getDefaultPrimaryTilesetLabel();
|
||||||
QString getDefaultSecondaryTilesetLabel();
|
QString getDefaultSecondaryTilesetLabel();
|
||||||
|
@ -251,9 +249,6 @@ private:
|
||||||
static int default_map_size;
|
static int default_map_size;
|
||||||
static int max_object_events;
|
static int max_object_events;
|
||||||
|
|
||||||
QStringListModel eventScriptLabelModel;
|
|
||||||
QCompleter eventScriptLabelCompleter;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void reloadProject();
|
void reloadProject();
|
||||||
void uncheckMonitorFilesAction();
|
void uncheckMonitorFilesAction();
|
||||||
|
|
|
@ -31,6 +31,8 @@ public:
|
||||||
void invalidateUi();
|
void invalidateUi();
|
||||||
void invalidateValues();
|
void invalidateValues();
|
||||||
|
|
||||||
|
void populateScriptDropdown(NoScrollComboBox * combo, Project * project);
|
||||||
|
|
||||||
virtual void setActive(bool active);
|
virtual void setActive(bool active);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -87,8 +89,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ObjectEvent *object;
|
ObjectEvent *object;
|
||||||
|
|
||||||
QCompleter *scriptCompleter = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,8 +158,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TriggerEvent *trigger;
|
TriggerEvent *trigger;
|
||||||
|
|
||||||
QCompleter *scriptCompleter = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,8 +201,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SignEvent *sign;
|
SignEvent *sign;
|
||||||
|
|
||||||
QCompleter *scriptCompleter = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -483,6 +483,7 @@ QStringList Map::getScriptLabels(Event::Group group) const {
|
||||||
|
|
||||||
// Add scripts from map's scripts file, and empty names.
|
// Add scripts from map's scripts file, and empty names.
|
||||||
scriptLabels.append(scriptsFileLabels);
|
scriptLabels.append(scriptsFileLabels);
|
||||||
|
scriptLabels.sort(Qt::CaseInsensitive);
|
||||||
scriptLabels.prepend("0x0");
|
scriptLabels.prepend("0x0");
|
||||||
scriptLabels.prepend("NULL");
|
scriptLabels.prepend("NULL");
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,7 @@ int Project::default_map_size = 20;
|
||||||
int Project::max_object_events = 64;
|
int Project::max_object_events = 64;
|
||||||
|
|
||||||
Project::Project(QWidget *parent) :
|
Project::Project(QWidget *parent) :
|
||||||
QObject(parent),
|
QObject(parent)
|
||||||
eventScriptLabelModel(this),
|
|
||||||
eventScriptLabelCompleter(this)
|
|
||||||
{
|
{
|
||||||
initSignals();
|
initSignals();
|
||||||
}
|
}
|
||||||
|
@ -2412,18 +2410,13 @@ bool Project::readMiscellaneousConstants() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Project::getGlobalScriptLabels() {
|
|
||||||
return this->eventScriptLabelModel.stringList();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Project::readEventScriptLabels() {
|
bool Project::readEventScriptLabels() {
|
||||||
|
globalScriptLabels.clear();
|
||||||
for (const auto &filePath : getEventScriptsFilePaths())
|
for (const auto &filePath : getEventScriptsFilePaths())
|
||||||
globalScriptLabels << ParseUtil::getGlobalScriptLabels(filePath);
|
globalScriptLabels << ParseUtil::getGlobalScriptLabels(filePath);
|
||||||
|
|
||||||
eventScriptLabelModel.setStringList(globalScriptLabels);
|
globalScriptLabels.sort(Qt::CaseInsensitive);
|
||||||
eventScriptLabelCompleter.setModel(&eventScriptLabelModel);
|
globalScriptLabels.removeDuplicates();
|
||||||
eventScriptLabelCompleter.setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
eventScriptLabelCompleter.setFilterMode(Qt::MatchContains);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2484,13 +2477,6 @@ QStringList Project::getEventScriptsFilePaths() const {
|
||||||
return filePaths;
|
return filePaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCompleter *Project::getEventScriptLabelCompleter(QStringList additionalScriptLabels) {
|
|
||||||
additionalScriptLabels << globalScriptLabels;
|
|
||||||
additionalScriptLabels.removeDuplicates();
|
|
||||||
eventScriptLabelModel.setStringList(additionalScriptLabels);
|
|
||||||
return &eventScriptLabelCompleter;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::setEventPixmap(Event *event, bool forceLoad) {
|
void Project::setEventPixmap(Event *event, bool forceLoad) {
|
||||||
if (event && (event->getPixmap().isNull() || forceLoad))
|
if (event && (event->getPixmap().isNull() || forceLoad))
|
||||||
event->loadPixmap(this);
|
event->loadPixmap(this);
|
||||||
|
|
|
@ -168,6 +168,23 @@ void EventFrame::setActive(bool active) {
|
||||||
this->blockSignals(!active);
|
this->blockSignals(!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());
|
||||||
|
|
||||||
|
// The dropdown's autocomplete has all script labels across the full project.
|
||||||
|
auto completer = new QCompleter(project->globalScriptLabels, combo);
|
||||||
|
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
|
||||||
|
completer->setFilterMode(Qt::MatchContains);
|
||||||
|
|
||||||
|
// Improve display speed for the autocomplete popup
|
||||||
|
auto popup = (QListView *)completer->popup();
|
||||||
|
if (popup) popup->setUniformItemSizes(true);
|
||||||
|
|
||||||
|
combo->setCompleter(completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ObjectFrame::setup() {
|
void ObjectFrame::setup() {
|
||||||
|
@ -367,20 +384,7 @@ void ObjectFrame::populate(Project *project) {
|
||||||
this->combo_flag->addItems(project->flagNames);
|
this->combo_flag->addItems(project->flagNames);
|
||||||
this->combo_trainer_type->addItems(project->trainerTypes);
|
this->combo_trainer_type->addItems(project->trainerTypes);
|
||||||
|
|
||||||
// The script dropdown is populated with scripts used by the map's events and from its scripts file.
|
this->populateScriptDropdown(this->combo_script, project);
|
||||||
QStringList scriptLabels;
|
|
||||||
if (this->object->getMap()) {
|
|
||||||
scriptLabels.append(this->object->getMap()->getScriptLabels());
|
|
||||||
this->combo_script->addItems(scriptLabels);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The dropdown's autocomplete has all script labels across the full project.
|
|
||||||
scriptLabels.append(project->getGlobalScriptLabels());
|
|
||||||
scriptLabels.removeDuplicates();
|
|
||||||
this->scriptCompleter = new QCompleter(scriptLabels, this);
|
|
||||||
this->scriptCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
this->scriptCompleter->setFilterMode(Qt::MatchContains);
|
|
||||||
this->combo_script->setCompleter(this->scriptCompleter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -637,20 +641,7 @@ void TriggerFrame::populate(Project *project) {
|
||||||
// var combo
|
// var combo
|
||||||
this->combo_var->addItems(project->varNames);
|
this->combo_var->addItems(project->varNames);
|
||||||
|
|
||||||
// The script dropdown is populated with scripts used by the map's events and from its scripts file.
|
this->populateScriptDropdown(this->combo_script, project);
|
||||||
QStringList scriptLabels;
|
|
||||||
if (this->trigger->getMap()) {
|
|
||||||
scriptLabels.append(this->trigger->getMap()->getScriptLabels());
|
|
||||||
this->combo_script->addItems(scriptLabels);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The dropdown's autocomplete has all script labels across the full project.
|
|
||||||
scriptLabels.append(project->getGlobalScriptLabels());
|
|
||||||
scriptLabels.removeDuplicates();
|
|
||||||
this->scriptCompleter = new QCompleter(scriptLabels, this);
|
|
||||||
this->scriptCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
this->scriptCompleter->setFilterMode(Qt::MatchContains);
|
|
||||||
this->combo_script->setCompleter(this->scriptCompleter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -772,20 +763,7 @@ void SignFrame::populate(Project *project) {
|
||||||
// facing dir
|
// facing dir
|
||||||
this->combo_facing_dir->addItems(project->bgEventFacingDirections);
|
this->combo_facing_dir->addItems(project->bgEventFacingDirections);
|
||||||
|
|
||||||
// The script dropdown is populated with scripts used by the map's events and from its scripts file.
|
this->populateScriptDropdown(this->combo_script, project);
|
||||||
QStringList scriptLabels;
|
|
||||||
if (this->sign->getMap()) {
|
|
||||||
scriptLabels.append(this->sign->getMap()->getScriptLabels());
|
|
||||||
this->combo_script->addItems(scriptLabels);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The dropdown's autocomplete has all script labels across the full project.
|
|
||||||
scriptLabels.append(project->getGlobalScriptLabels());
|
|
||||||
scriptLabels.removeDuplicates();
|
|
||||||
this->scriptCompleter = new QCompleter(scriptLabels, this);
|
|
||||||
this->scriptCompleter->setCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
this->scriptCompleter->setFilterMode(Qt::MatchContains);
|
|
||||||
this->combo_script->setCompleter(this->scriptCompleter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue