Stop repeated parsing of event_objects.h and songs.h
This commit is contained in:
parent
b79ba466e0
commit
366fb5c8a8
6 changed files with 29 additions and 24 deletions
|
@ -51,6 +51,8 @@ public:
|
||||||
QMap<QString, QString> mapSecToMapHoverName;
|
QMap<QString, QString> mapSecToMapHoverName;
|
||||||
QMap<QString, int> mapSectionNameToValue;
|
QMap<QString, int> mapSectionNameToValue;
|
||||||
QMap<int, QString> mapSectionValueToName;
|
QMap<int, QString> mapSectionValueToName;
|
||||||
|
QStringList gfxNames;
|
||||||
|
QStringList songNames;
|
||||||
QStringList itemNames;
|
QStringList itemNames;
|
||||||
QStringList flagNames;
|
QStringList flagNames;
|
||||||
QStringList varNames;
|
QStringList varNames;
|
||||||
|
@ -151,7 +153,6 @@ public:
|
||||||
void saveTilesetPalettes(Tileset*);
|
void saveTilesetPalettes(Tileset*);
|
||||||
|
|
||||||
QString defaultSong;
|
QString defaultSong;
|
||||||
QStringList getSongNames();
|
|
||||||
QStringList getVisibilities();
|
QStringList getVisibilities();
|
||||||
QMap<QString, QStringList> getTilesetLabels();
|
QMap<QString, QStringList> getTilesetLabels();
|
||||||
bool readTilesetProperties();
|
bool readTilesetProperties();
|
||||||
|
@ -173,9 +174,10 @@ public:
|
||||||
bool readHealLocations();
|
bool readHealLocations();
|
||||||
bool readMiscellaneousConstants();
|
bool readMiscellaneousConstants();
|
||||||
bool readEventScriptLabels();
|
bool readEventScriptLabels();
|
||||||
|
bool readObjEventGfxConstants();
|
||||||
|
bool readSongNames();
|
||||||
|
|
||||||
void loadEventPixmaps(QList<Event*> objects);
|
void loadEventPixmaps(QList<Event*> objects);
|
||||||
QMap<QString, int> getEventObjGfxConstants();
|
|
||||||
QString fixPalettePath(QString path);
|
QString fixPalettePath(QString path);
|
||||||
QString fixGraphicPath(QString path);
|
QString fixGraphicPath(QString path);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ Event* Event::createNewObjectEvent(Project *project)
|
||||||
Event *event = new Event;
|
Event *event = new Event;
|
||||||
event->put("event_group_type", "object_event_group");
|
event->put("event_group_type", "object_event_group");
|
||||||
event->put("event_type", EventType::Object);
|
event->put("event_type", EventType::Object);
|
||||||
event->put("sprite", project->getEventObjGfxConstants().keys().first());
|
event->put("sprite", project->gfxNames.first());
|
||||||
event->put("movement_type", project->movementTypes.first());
|
event->put("movement_type", project->movementTypes.first());
|
||||||
if (projectConfig.getObjectEventInConnectionEnabled()) {
|
if (projectConfig.getObjectEventInConnectionEnabled()) {
|
||||||
event->put("in_connection", false);
|
event->put("in_connection", false);
|
||||||
|
|
|
@ -941,7 +941,9 @@ bool MainWindow::loadDataStructures() {
|
||||||
&& project->readMiscellaneousConstants()
|
&& project->readMiscellaneousConstants()
|
||||||
&& project->readSpeciesIconPaths()
|
&& project->readSpeciesIconPaths()
|
||||||
&& project->readWildMonData()
|
&& project->readWildMonData()
|
||||||
&& project->readEventScriptLabels();
|
&& project->readEventScriptLabels()
|
||||||
|
&& project->readObjEventGfxConstants()
|
||||||
|
&& project->readSongNames();
|
||||||
|
|
||||||
return success && loadProjectCombos();
|
return success && loadProjectCombos();
|
||||||
}
|
}
|
||||||
|
@ -960,7 +962,7 @@ bool MainWindow::loadProjectCombos() {
|
||||||
const QSignalBlocker blocker7(ui->comboBox_Type);
|
const QSignalBlocker blocker7(ui->comboBox_Type);
|
||||||
|
|
||||||
ui->comboBox_Song->clear();
|
ui->comboBox_Song->clear();
|
||||||
ui->comboBox_Song->addItems(project->getSongNames());
|
ui->comboBox_Song->addItems(project->songNames);
|
||||||
ui->comboBox_Location->clear();
|
ui->comboBox_Location->clear();
|
||||||
ui->comboBox_Location->addItems(project->mapSectionValueToName.values());
|
ui->comboBox_Location->addItems(project->mapSectionValueToName.values());
|
||||||
|
|
||||||
|
@ -1954,8 +1956,6 @@ void MainWindow::updateSelectedObjects() {
|
||||||
delete button;
|
delete button;
|
||||||
openScriptButtons.clear();
|
openScriptButtons.clear();
|
||||||
|
|
||||||
QMap<QString, int> event_obj_gfx_constants = editor->project->getEventObjGfxConstants();
|
|
||||||
|
|
||||||
QList<EventPropertiesFrame *> frames;
|
QList<EventPropertiesFrame *> frames;
|
||||||
|
|
||||||
bool inConnectionEnabled = projectConfig.getObjectEventInConnectionEnabled();
|
bool inConnectionEnabled = projectConfig.getObjectEventInConnectionEnabled();
|
||||||
|
@ -2043,7 +2043,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
if (event_type == EventType::Object) {
|
if (event_type == EventType::Object) {
|
||||||
|
|
||||||
frame->ui->sprite->setVisible(true);
|
frame->ui->sprite->setVisible(true);
|
||||||
frame->ui->comboBox_sprite->addItems(event_obj_gfx_constants.keys());
|
frame->ui->comboBox_sprite->addItems(editor->project->gfxNames);
|
||||||
frame->ui->comboBox_sprite->setCurrentIndex(frame->ui->comboBox_sprite->findText(item->event->get("sprite")));
|
frame->ui->comboBox_sprite->setCurrentIndex(frame->ui->comboBox_sprite->findText(item->event->get("sprite")));
|
||||||
connect(frame->ui->comboBox_sprite, &QComboBox::currentTextChanged, item, &DraggablePixmapItem::set_sprite);
|
connect(frame->ui->comboBox_sprite, &QComboBox::currentTextChanged, item, &DraggablePixmapItem::set_sprite);
|
||||||
connect(frame->ui->comboBox_sprite, &QComboBox::currentTextChanged, this, &MainWindow::markMapEdited);
|
connect(frame->ui->comboBox_sprite, &QComboBox::currentTextChanged, this, &MainWindow::markMapEdited);
|
||||||
|
|
|
@ -1078,8 +1078,7 @@ QString MainWindow::getSong() {
|
||||||
void MainWindow::setSong(QString song) {
|
void MainWindow::setSong(QString song) {
|
||||||
if (!this->ui || !this->editor || !this->editor->project)
|
if (!this->ui || !this->editor || !this->editor->project)
|
||||||
return;
|
return;
|
||||||
QStringList songs = this->editor->project->getSongNames();
|
if (!this->editor->project->songNames.contains(song)) {
|
||||||
if (!songs.contains(song)) {
|
|
||||||
logError(QString("Unknown song '%1'").arg(song));
|
logError(QString("Unknown song '%1'").arg(song));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2276,25 +2276,31 @@ bool Project::readMetatileBehaviors() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Project::getSongNames() {
|
bool Project::readSongNames() {
|
||||||
QStringList songDefinePrefixes{ "\\bSE_", "\\bMUS_" };
|
QStringList songDefinePrefixes{ "\\bSE_", "\\bMUS_" };
|
||||||
QString filename = "include/constants/songs.h";
|
QString filename = "include/constants/songs.h";
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
QMap<QString, int> songDefines = parser.readCDefines(filename, songDefinePrefixes);
|
QMap<QString, int> songDefines = parser.readCDefines(filename, songDefinePrefixes);
|
||||||
QStringList names = songDefines.keys();
|
this->songNames = songDefines.keys();
|
||||||
this->defaultSong = names.value(0, "MUS_DUMMY");
|
this->defaultSong = this->songNames.value(0, "MUS_DUMMY");
|
||||||
|
if (this->songNames.isEmpty()) {
|
||||||
return names;
|
logError(QString("Failed to read song names from %1.").arg(filename));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, int> Project::getEventObjGfxConstants() {
|
bool Project::readObjEventGfxConstants() {
|
||||||
QStringList eventObjGfxPrefixes("\\bOBJ_EVENT_GFX_");
|
QStringList objEventGfxPrefixes("\\bOBJ_EVENT_GFX_");
|
||||||
|
|
||||||
QString filename = "include/constants/event_objects.h";
|
QString filename = "include/constants/event_objects.h";
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
QMap<QString, int> constants = parser.readCDefines(filename, eventObjGfxPrefixes);
|
QMap<QString, int> gfxDefines = parser.readCDefines(filename, objEventGfxPrefixes);
|
||||||
|
this->gfxNames = gfxDefines.keys();
|
||||||
return constants;
|
if (this->gfxNames.isEmpty()) {
|
||||||
|
logError(QString("Failed to read object event graphics constants from %1.").arg(filename));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::readMiscellaneousConstants() {
|
bool Project::readMiscellaneousConstants() {
|
||||||
|
@ -2424,8 +2430,6 @@ void Project::loadEventPixmaps(QList<Event*> objects) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, int> constants = getEventObjGfxConstants();
|
|
||||||
|
|
||||||
fileWatcher.addPaths(QStringList() << root + "/" + "src/data/object_events/object_event_graphics_info_pointers.h"
|
fileWatcher.addPaths(QStringList() << root + "/" + "src/data/object_events/object_event_graphics_info_pointers.h"
|
||||||
<< root + "/" + "src/data/object_events/object_event_graphics_info.h"
|
<< root + "/" + "src/data/object_events/object_event_graphics_info.h"
|
||||||
<< root + "/" + "src/data/object_events/object_event_pic_tables.h"
|
<< root + "/" + "src/data/object_events/object_event_pic_tables.h"
|
||||||
|
|
|
@ -116,7 +116,7 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
|
||||||
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
||||||
ui->comboBox_NewMap_Group->setCurrentText(project->groupNames.at(groupNum));
|
ui->comboBox_NewMap_Group->setCurrentText(project->groupNames.at(groupNum));
|
||||||
|
|
||||||
ui->comboBox_Song->addItems(project->getSongNames());
|
ui->comboBox_Song->addItems(project->songNames);
|
||||||
|
|
||||||
if (existingLayout) {
|
if (existingLayout) {
|
||||||
ui->spinBox_NewMap_Width->setValue(project->mapLayouts.value(layoutId)->width.toInt(nullptr, 0));
|
ui->spinBox_NewMap_Width->setValue(project->mapLayouts.value(layoutId)->width.toInt(nullptr, 0));
|
||||||
|
|
Loading…
Reference in a new issue