Fix flags being listed out of order
This commit is contained in:
parent
70b8806737
commit
00ad1ec22a
4 changed files with 16 additions and 10 deletions
|
@ -29,6 +29,7 @@ to a file, it probably is not a good idea to edit yourself unless otherwise note
|
||||||
include/constants/global.h, yes, no,
|
include/constants/global.h, yes, no,
|
||||||
include/constants/map_groups.h, no, yes,
|
include/constants/map_groups.h, no, yes,
|
||||||
include/constants/items.h, yes, no,
|
include/constants/items.h, yes, no,
|
||||||
|
include/constants/opponents.h, yes, no, reads max trainers constant
|
||||||
include/constants/flags.h, yes, no,
|
include/constants/flags.h, yes, no,
|
||||||
include/constants/vars.h, yes, no,
|
include/constants/vars.h, yes, no,
|
||||||
include/constants/weather.h, yes, no,
|
include/constants/weather.h, yes, no,
|
||||||
|
|
|
@ -47,8 +47,8 @@ public:
|
||||||
QStringList readCArray(QString text, QString label);
|
QStringList readCArray(QString text, QString label);
|
||||||
QMap<QString, QString> readNamedIndexCArray(QString text, QString label);
|
QMap<QString, QString> readNamedIndexCArray(QString text, QString label);
|
||||||
QString readCIncbin(QString text, QString label);
|
QString readCIncbin(QString text, QString label);
|
||||||
QMap<QString, int> readCDefines(QString filename, QStringList prefixes);
|
QMap<QString, int> readCDefines(QString filename, QStringList prefixes, QMap<QString, int> = QMap<QString, int>());
|
||||||
void readCDefinesSorted(QString, QStringList, QStringList*);
|
void readCDefinesSorted(QString, QStringList, QStringList*, QMap<QString, int> = QMap<QString, int>());
|
||||||
QList<QStringList>* getLabelMacros(QList<QStringList>*, QString);
|
QList<QStringList>* getLabelMacros(QList<QStringList>*, QString);
|
||||||
QStringList* getLabelValues(QList<QStringList>*, QString);
|
QStringList* getLabelValues(QList<QStringList>*, QString);
|
||||||
bool tryParseJsonFile(QJsonDocument *out, QString filepath);
|
bool tryParseJsonFile(QJsonDocument *out, QString filepath);
|
||||||
|
|
|
@ -252,8 +252,7 @@ QString ParseUtil::readCIncbin(QString filename, QString label) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, int> ParseUtil::readCDefines(QString filename, QStringList prefixes) {
|
QMap<QString, int> ParseUtil::readCDefines(QString filename, QStringList prefixes, QMap<QString, int> allDefines) {
|
||||||
QMap<QString, int> allDefines;
|
|
||||||
QMap<QString, int> filteredDefines;
|
QMap<QString, int> filteredDefines;
|
||||||
|
|
||||||
file = filename;
|
file = filename;
|
||||||
|
@ -293,8 +292,8 @@ QMap<QString, int> ParseUtil::readCDefines(QString filename, QStringList prefixe
|
||||||
return filteredDefines;
|
return filteredDefines;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseUtil::readCDefinesSorted(QString filename, QStringList prefixes, QStringList* definesToSet) {
|
void ParseUtil::readCDefinesSorted(QString filename, QStringList prefixes, QStringList* definesToSet, QMap<QString, int> knownDefines) {
|
||||||
QMap<QString, int> defines = readCDefines(filename, prefixes);
|
QMap<QString, int> defines = readCDefines(filename, prefixes, knownDefines);
|
||||||
|
|
||||||
// The defines should to be sorted by their underlying value, not alphabetically.
|
// The defines should to be sorted by their underlying value, not alphabetically.
|
||||||
// Reverse the map and read out the resulting keys in order.
|
// Reverse the map and read out the resulting keys in order.
|
||||||
|
|
|
@ -2171,13 +2171,19 @@ bool Project::readItemNames() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::readFlagNames() {
|
bool Project::readFlagNames() {
|
||||||
|
// First read MAX_TRAINERS_COUNT, used to skip over trainer flags
|
||||||
|
// If this fails flags may simply be out of order, no need to check for success
|
||||||
|
QString opponentsFilename = "include/constants/opponents.h";
|
||||||
|
fileWatcher.addPath(root + "/" + opponentsFilename);
|
||||||
|
QMap<QString, int> maxTrainers = parser.readCDefines(opponentsFilename, QStringList() << "MAX_");
|
||||||
|
// Parse flags
|
||||||
flagNames->clear();
|
flagNames->clear();
|
||||||
QStringList prefixes = (QStringList() << "FLAG_");
|
QStringList prefixes = (QStringList() << "FLAG_");
|
||||||
QString filename = "include/constants/flags.h";
|
QString flagsFilename = "include/constants/flags.h";
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + flagsFilename);
|
||||||
parser.readCDefinesSorted(filename, prefixes, flagNames);
|
parser.readCDefinesSorted(flagsFilename, prefixes, flagNames, maxTrainers);
|
||||||
if (flagNames->isEmpty()) {
|
if (flagNames->isEmpty()) {
|
||||||
logError(QString("Failed to read flag constants from %1").arg(filename));
|
logError(QString("Failed to read flag constants from %1").arg(flagsFilename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue