do less work reading C defines while loading tileset labels
This commit is contained in:
parent
55c97a45d9
commit
f9bb6196e2
3 changed files with 25 additions and 5 deletions
|
@ -76,6 +76,7 @@ public:
|
|||
QStringList bgEventFacingDirections;
|
||||
QStringList trainerTypes;
|
||||
QStringList globalScriptLabels;
|
||||
QMap<QString, QMap<QString, int>> metatileLabelsMap;
|
||||
QMap<QString, int> metatileBehaviorMap;
|
||||
QMap<int, QString> metatileBehaviorMapInverse;
|
||||
QMap<QString, QString> facingDirections;
|
||||
|
@ -175,6 +176,7 @@ public:
|
|||
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
||||
bool readTilesetLabels();
|
||||
bool readTilesetProperties();
|
||||
bool readTilesetMetatileLabels();
|
||||
bool readMaxMapDataSize();
|
||||
bool readRegionMapSections();
|
||||
bool readItemNames();
|
||||
|
|
|
@ -908,6 +908,7 @@ bool MainWindow::loadDataStructures() {
|
|||
&& project->readMetatileBehaviors()
|
||||
&& project->readTilesetProperties()
|
||||
&& project->readTilesetLabels()
|
||||
&& project->readTilesetMetatileLabels()
|
||||
&& project->readMaxMapDataSize()
|
||||
&& project->readHealLocations()
|
||||
&& project->readMiscellaneousConstants()
|
||||
|
|
|
@ -1508,14 +1508,31 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
|
|||
}
|
||||
}
|
||||
|
||||
void Project::loadTilesetMetatileLabels(Tileset* tileset) {
|
||||
QString tilesetPrefix = QString("METATILE_%1_").arg(QString(tileset->name).replace("gTileset_", ""));
|
||||
bool Project::readTilesetMetatileLabels() {
|
||||
metatileLabelsMap.clear();
|
||||
|
||||
QString metatileLabelsFilename = projectConfig.getFilePath(ProjectFilePath::constants_metatile_labels);
|
||||
fileWatcher.addPath(root + "/" + metatileLabelsFilename);
|
||||
QMap<QString, int> labels = parser.readCDefines(metatileLabelsFilename, QStringList() << tilesetPrefix);
|
||||
|
||||
for (QString labelName : labels.keys()) {
|
||||
int metatileId = labels[labelName];
|
||||
QMap<QString, int> labels = parser.readCDefines(metatileLabelsFilename, QStringList() << "METATILE_");
|
||||
|
||||
for (QString label : this->tilesetLabelsOrdered) {
|
||||
QString tilesetName = QString(label).replace("gTileset_", "");
|
||||
for (QString key : labels.keys()) {
|
||||
if (key.contains(tilesetName)) {
|
||||
metatileLabelsMap[label][key] = labels[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::loadTilesetMetatileLabels(Tileset* tileset) {
|
||||
QString tilesetPrefix = QString("METATILE_%1_").arg(QString(tileset->name).replace("gTileset_", ""));
|
||||
|
||||
for (QString labelName : metatileLabelsMap[tileset->name].keys()) {
|
||||
int metatileId = metatileLabelsMap[tileset->name][labelName];
|
||||
// subtract Project::num_tiles_primary from secondary metatiles
|
||||
int offset = tileset->is_secondary ? Project::num_tiles_primary : 0;
|
||||
Metatile *metatile = Tileset::getMetatile(metatileId - offset, tileset, nullptr);
|
||||
|
|
Loading…
Reference in a new issue