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 bgEventFacingDirections;
|
||||||
QStringList trainerTypes;
|
QStringList trainerTypes;
|
||||||
QStringList globalScriptLabels;
|
QStringList globalScriptLabels;
|
||||||
|
QMap<QString, QMap<QString, int>> metatileLabelsMap;
|
||||||
QMap<QString, int> metatileBehaviorMap;
|
QMap<QString, int> metatileBehaviorMap;
|
||||||
QMap<int, QString> metatileBehaviorMapInverse;
|
QMap<int, QString> metatileBehaviorMapInverse;
|
||||||
QMap<QString, QString> facingDirections;
|
QMap<QString, QString> facingDirections;
|
||||||
|
@ -175,6 +176,7 @@ public:
|
||||||
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
||||||
bool readTilesetLabels();
|
bool readTilesetLabels();
|
||||||
bool readTilesetProperties();
|
bool readTilesetProperties();
|
||||||
|
bool readTilesetMetatileLabels();
|
||||||
bool readMaxMapDataSize();
|
bool readMaxMapDataSize();
|
||||||
bool readRegionMapSections();
|
bool readRegionMapSections();
|
||||||
bool readItemNames();
|
bool readItemNames();
|
||||||
|
|
|
@ -908,6 +908,7 @@ bool MainWindow::loadDataStructures() {
|
||||||
&& project->readMetatileBehaviors()
|
&& project->readMetatileBehaviors()
|
||||||
&& project->readTilesetProperties()
|
&& project->readTilesetProperties()
|
||||||
&& project->readTilesetLabels()
|
&& project->readTilesetLabels()
|
||||||
|
&& project->readTilesetMetatileLabels()
|
||||||
&& project->readMaxMapDataSize()
|
&& project->readMaxMapDataSize()
|
||||||
&& project->readHealLocations()
|
&& project->readHealLocations()
|
||||||
&& project->readMiscellaneousConstants()
|
&& project->readMiscellaneousConstants()
|
||||||
|
|
|
@ -1508,14 +1508,31 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::loadTilesetMetatileLabels(Tileset* tileset) {
|
bool Project::readTilesetMetatileLabels() {
|
||||||
QString tilesetPrefix = QString("METATILE_%1_").arg(QString(tileset->name).replace("gTileset_", ""));
|
metatileLabelsMap.clear();
|
||||||
|
|
||||||
QString metatileLabelsFilename = projectConfig.getFilePath(ProjectFilePath::constants_metatile_labels);
|
QString metatileLabelsFilename = projectConfig.getFilePath(ProjectFilePath::constants_metatile_labels);
|
||||||
fileWatcher.addPath(root + "/" + metatileLabelsFilename);
|
fileWatcher.addPath(root + "/" + metatileLabelsFilename);
|
||||||
QMap<QString, int> labels = parser.readCDefines(metatileLabelsFilename, QStringList() << tilesetPrefix);
|
|
||||||
|
|
||||||
for (QString labelName : labels.keys()) {
|
QMap<QString, int> labels = parser.readCDefines(metatileLabelsFilename, QStringList() << "METATILE_");
|
||||||
int metatileId = labels[labelName];
|
|
||||||
|
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
|
// subtract Project::num_tiles_primary from secondary metatiles
|
||||||
int offset = tileset->is_secondary ? Project::num_tiles_primary : 0;
|
int offset = tileset->is_secondary ? Project::num_tiles_primary : 0;
|
||||||
Metatile *metatile = Tileset::getMetatile(metatileId - offset, tileset, nullptr);
|
Metatile *metatile = Tileset::getMetatile(metatileId - offset, tileset, nullptr);
|
||||||
|
|
Loading…
Reference in a new issue