mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-13 20:36:19 -05:00
Populate hidden item dropdown menu with item constants
This commit is contained in:
24
project.cpp
24
project.cpp
@@ -18,6 +18,7 @@ Project::Project()
|
||||
groupNames = new QStringList;
|
||||
map_groups = new QMap<QString, int>;
|
||||
mapNames = new QStringList;
|
||||
itemNames = new QStringList;
|
||||
map_cache = new QMap<QString, Map*>;
|
||||
mapConstantsToMapNames = new QMap<QString, QString>;
|
||||
mapNamesToMapConstants = new QMap<QString, QString>;
|
||||
@@ -1062,6 +1063,29 @@ QStringList Project::getBattleScenes() {
|
||||
return names;
|
||||
}
|
||||
|
||||
void Project::readItemNames() {
|
||||
QString text = readTextFile(root + "/include/constants/items.h");
|
||||
if (!text.isNull()) {
|
||||
QStringList itemDefinePrefixes;
|
||||
itemDefinePrefixes << "ITEM_";
|
||||
QMap<QString, int> itemDefines = readCDefines(text, itemDefinePrefixes);
|
||||
|
||||
// The item names should to be sorted by their underlying value, not alphabetically.
|
||||
// Reverse the map and read out the resulting keys in order.
|
||||
QMultiMap<int, QString> itemDefinesInverse;
|
||||
for (QString itemName : itemDefines.keys()) {
|
||||
itemDefinesInverse.insert(itemDefines[itemName], itemName);
|
||||
}
|
||||
|
||||
for (int itemValue : itemDefinesInverse.keys()) {
|
||||
QList<QString> names = itemDefinesInverse.values(itemValue);
|
||||
for (QString name : names) {
|
||||
itemNames->append(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QStringList Project::getSongNames() {
|
||||
QStringList names;
|
||||
QString text = readTextFile(root + "/include/constants/songs.h");
|
||||
|
||||
Reference in New Issue
Block a user