Allow empty behavior names, simplify fieldmap parsing
This commit is contained in:
parent
ee6d6c7bcc
commit
93fb8cf471
3 changed files with 26 additions and 55 deletions
|
@ -174,7 +174,6 @@ public:
|
||||||
QString defaultSong;
|
QString defaultSong;
|
||||||
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
||||||
bool readTilesetLabels();
|
bool readTilesetLabels();
|
||||||
bool readTilesetProperties();
|
|
||||||
bool readTilesetMetatileLabels();
|
bool readTilesetMetatileLabels();
|
||||||
bool readRegionMapSections();
|
bool readRegionMapSections();
|
||||||
bool readItemNames();
|
bool readItemNames();
|
||||||
|
@ -197,6 +196,7 @@ public:
|
||||||
bool readObjEventGfxConstants();
|
bool readObjEventGfxConstants();
|
||||||
bool readSongNames();
|
bool readSongNames();
|
||||||
bool readEventGraphics();
|
bool readEventGraphics();
|
||||||
|
bool readFieldmapProperties();
|
||||||
bool readFieldmapMasks();
|
bool readFieldmapMasks();
|
||||||
QMap<QString, QMap<QString, QString>> readObjEventGfxInfo();
|
QMap<QString, QMap<QString, QString>> readObjEventGfxInfo();
|
||||||
|
|
||||||
|
|
|
@ -933,10 +933,10 @@ bool MainWindow::loadDataStructures() {
|
||||||
&& project->readBgEventFacingDirections()
|
&& project->readBgEventFacingDirections()
|
||||||
&& project->readTrainerTypes()
|
&& project->readTrainerTypes()
|
||||||
&& project->readMetatileBehaviors()
|
&& project->readMetatileBehaviors()
|
||||||
&& project->readTilesetProperties()
|
&& project->readFieldmapProperties()
|
||||||
|
&& project->readFieldmapMasks()
|
||||||
&& project->readTilesetLabels()
|
&& project->readTilesetLabels()
|
||||||
&& project->readTilesetMetatileLabels()
|
&& project->readTilesetMetatileLabels()
|
||||||
&& project->readFieldmapMasks()
|
|
||||||
&& project->readHealLocations()
|
&& project->readHealLocations()
|
||||||
&& project->readMiscellaneousConstants()
|
&& project->readMiscellaneousConstants()
|
||||||
&& project->readSpeciesIconPaths()
|
&& project->readSpeciesIconPaths()
|
||||||
|
|
|
@ -1870,7 +1870,7 @@ bool Project::readTilesetLabels() {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::readTilesetProperties() {
|
bool Project::readFieldmapProperties() {
|
||||||
const QString numTilesPrimaryName = projectConfig.getIdentifier(ProjectIdentifier::define_tiles_primary);
|
const QString numTilesPrimaryName = projectConfig.getIdentifier(ProjectIdentifier::define_tiles_primary);
|
||||||
const QString numTilesTotalName = projectConfig.getIdentifier(ProjectIdentifier::define_tiles_total);
|
const QString numTilesTotalName = projectConfig.getIdentifier(ProjectIdentifier::define_tiles_total);
|
||||||
const QString numMetatilesPrimaryName = projectConfig.getIdentifier(ProjectIdentifier::define_metatiles_primary);
|
const QString numMetatilesPrimaryName = projectConfig.getIdentifier(ProjectIdentifier::define_metatiles_primary);
|
||||||
|
@ -1885,57 +1885,25 @@ bool Project::readTilesetProperties() {
|
||||||
numPalsTotalName,
|
numPalsTotalName,
|
||||||
maxMapSizeName,
|
maxMapSizeName,
|
||||||
};
|
};
|
||||||
QString filename = projectConfig.getFilePath(ProjectFilePath::constants_fieldmap);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_fieldmap);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
QMap<QString, int> defines = parser.readCDefinesByName(filename, names);
|
const QMap<QString, int> defines = parser.readCDefinesByName(filename, names);
|
||||||
|
|
||||||
auto it = defines.find(numTilesPrimaryName);
|
auto loadDefine = [defines](const QString name, int * dest) {
|
||||||
if (it != defines.end()) {
|
auto it = defines.find(name);
|
||||||
Project::num_tiles_primary = it.value();
|
if (it != defines.end()) {
|
||||||
}
|
*dest = it.value();
|
||||||
else {
|
} else {
|
||||||
logWarn(QString("Value for tileset property '%1' not found. Using default (%2) instead.")
|
logWarn(QString("Value for tileset property '%1' not found. Using default (%2) instead.").arg(name).arg(*dest));
|
||||||
.arg(numTilesPrimaryName)
|
}
|
||||||
.arg(Project::num_tiles_primary));
|
};
|
||||||
}
|
loadDefine(numTilesPrimaryName, &Project::num_tiles_primary);
|
||||||
it = defines.find(numTilesTotalName);
|
loadDefine(numTilesTotalName, &Project::num_tiles_total);
|
||||||
if (it != defines.end()) {
|
loadDefine(numMetatilesPrimaryName, &Project::num_metatiles_primary);
|
||||||
Project::num_tiles_total = it.value();
|
loadDefine(numPalsPrimaryName, &Project::num_pals_primary);
|
||||||
}
|
loadDefine(numPalsTotalName, &Project::num_pals_total);
|
||||||
else {
|
|
||||||
logWarn(QString("Value for tileset property '%1' not found. Using default (%2) instead.")
|
|
||||||
.arg(numTilesTotalName)
|
|
||||||
.arg(Project::num_tiles_total));
|
|
||||||
}
|
|
||||||
it = defines.find(numMetatilesPrimaryName);
|
|
||||||
if (it != defines.end()) {
|
|
||||||
Project::num_metatiles_primary = it.value();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logWarn(QString("Value for tileset property '%1' not found. Using default (%2) instead.")
|
|
||||||
.arg(numMetatilesPrimaryName)
|
|
||||||
.arg(Project::num_metatiles_primary));
|
|
||||||
}
|
|
||||||
it = defines.find(numPalsPrimaryName);
|
|
||||||
if (it != defines.end()) {
|
|
||||||
Project::num_pals_primary = it.value();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logWarn(QString("Value for tileset property '%1' not found. Using default (%2) instead.")
|
|
||||||
.arg(numPalsPrimaryName)
|
|
||||||
.arg(Project::num_pals_primary));
|
|
||||||
}
|
|
||||||
it = defines.find(numPalsTotalName);
|
|
||||||
if (it != defines.end()) {
|
|
||||||
Project::num_pals_total = it.value();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logWarn(QString("Value for tileset property '%1' not found. Using default (%2) instead.")
|
|
||||||
.arg(numPalsTotalName)
|
|
||||||
.arg(Project::num_pals_total));
|
|
||||||
}
|
|
||||||
|
|
||||||
it = defines.find(maxMapSizeName);
|
auto it = defines.find(maxMapSizeName);
|
||||||
if (it != defines.end()) {
|
if (it != defines.end()) {
|
||||||
int min = getMapDataSize(1, 1);
|
int min = getMapDataSize(1, 1);
|
||||||
if (it.value() >= min) {
|
if (it.value() >= min) {
|
||||||
|
@ -2319,14 +2287,18 @@ bool Project::readTrainerTypes() {
|
||||||
bool Project::readMetatileBehaviors() {
|
bool Project::readMetatileBehaviors() {
|
||||||
this->metatileBehaviorMap.clear();
|
this->metatileBehaviorMap.clear();
|
||||||
this->metatileBehaviorMapInverse.clear();
|
this->metatileBehaviorMapInverse.clear();
|
||||||
|
this->warpBehaviorValues.clear();
|
||||||
|
|
||||||
const QStringList prefixes = {projectConfig.getIdentifier(ProjectIdentifier::regex_behaviors)};
|
const QStringList prefixes = {projectConfig.getIdentifier(ProjectIdentifier::regex_behaviors)};
|
||||||
QString filename = projectConfig.getFilePath(ProjectFilePath::constants_metatile_behaviors);
|
QString filename = projectConfig.getFilePath(ProjectFilePath::constants_metatile_behaviors);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
QMap<QString, int> defines = parser.readCDefinesByPrefix(filename, prefixes);
|
QMap<QString, int> defines = parser.readCDefinesByPrefix(filename, prefixes);
|
||||||
if (defines.isEmpty()) {
|
if (defines.isEmpty()) {
|
||||||
logError(QString("Failed to read metatile behaviors from %1.").arg(filename));
|
// Not having any metatile behavior names is ok (their values will be displayed instead).
|
||||||
return false;
|
// If the user's metatiles can have nonzero values then warn them, as they likely want names.
|
||||||
|
if (projectConfig.getMetatileBehaviorMask())
|
||||||
|
logWarn(QString("Failed to read metatile behaviors from %1.").arg(filename));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto i = defines.cbegin(), end = defines.cend(); i != end; i++) {
|
for (auto i = defines.cbegin(), end = defines.cend(); i != end; i++) {
|
||||||
|
@ -2337,7 +2309,6 @@ bool Project::readMetatileBehaviors() {
|
||||||
|
|
||||||
// Construct warp behavior value list for the warp metatile behavior warning
|
// Construct warp behavior value list for the warp metatile behavior warning
|
||||||
const QStringList warpBehaviorNames = projectConfig.getWarpBehaviors();
|
const QStringList warpBehaviorNames = projectConfig.getWarpBehaviors();
|
||||||
this->warpBehaviorValues.clear();
|
|
||||||
for (auto name : warpBehaviorNames) {
|
for (auto name : warpBehaviorNames) {
|
||||||
if (this->metatileBehaviorMap.contains(name)) {
|
if (this->metatileBehaviorMap.contains(name)) {
|
||||||
int value = this->metatileBehaviorMap.value(name);
|
int value = this->metatileBehaviorMap.value(name);
|
||||||
|
|
Loading…
Reference in a new issue