Populate hidden item dropdown menu with item constants
This commit is contained in:
parent
38360de140
commit
2bc949612d
3 changed files with 32 additions and 1 deletions
|
@ -284,6 +284,7 @@ void MainWindow::loadDataStructures() {
|
||||||
Project *project = editor->project;
|
Project *project = editor->project;
|
||||||
project->readMapAttributesTable();
|
project->readMapAttributesTable();
|
||||||
project->readAllMapAttributes();
|
project->readAllMapAttributes();
|
||||||
|
project->readItemNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::populateMapList() {
|
void MainWindow::populateMapList() {
|
||||||
|
@ -644,6 +645,11 @@ void MainWindow::updateSelectedObjects() {
|
||||||
combo->addItem(value);
|
combo->addItem(value);
|
||||||
}
|
}
|
||||||
combo->addItems(*editor->project->mapNames);
|
combo->addItems(*editor->project->mapNames);
|
||||||
|
} else if (key == "item") {
|
||||||
|
if (!editor->project->itemNames->contains(value)) {
|
||||||
|
combo->addItem(value);
|
||||||
|
}
|
||||||
|
combo->addItems(*editor->project->itemNames);
|
||||||
} else {
|
} else {
|
||||||
combo->addItem(value);
|
combo->addItem(value);
|
||||||
}
|
}
|
||||||
|
|
24
project.cpp
24
project.cpp
|
@ -18,6 +18,7 @@ Project::Project()
|
||||||
groupNames = new QStringList;
|
groupNames = new QStringList;
|
||||||
map_groups = new QMap<QString, int>;
|
map_groups = new QMap<QString, int>;
|
||||||
mapNames = new QStringList;
|
mapNames = new QStringList;
|
||||||
|
itemNames = new QStringList;
|
||||||
map_cache = new QMap<QString, Map*>;
|
map_cache = new QMap<QString, Map*>;
|
||||||
mapConstantsToMapNames = new QMap<QString, QString>;
|
mapConstantsToMapNames = new QMap<QString, QString>;
|
||||||
mapNamesToMapConstants = new QMap<QString, QString>;
|
mapNamesToMapConstants = new QMap<QString, QString>;
|
||||||
|
@ -1062,6 +1063,29 @@ QStringList Project::getBattleScenes() {
|
||||||
return names;
|
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 Project::getSongNames() {
|
||||||
QStringList names;
|
QStringList names;
|
||||||
QString text = readTextFile(root + "/include/constants/songs.h");
|
QString text = readTextFile(root + "/include/constants/songs.h");
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
QMap<int, QString> mapAttributesTableMaster;
|
QMap<int, QString> mapAttributesTableMaster;
|
||||||
QMap<QString, QMap<QString, QString>> mapAttributes;
|
QMap<QString, QMap<QString, QString>> mapAttributes;
|
||||||
QMap<QString, QMap<QString, QString>> mapAttributesMaster;
|
QMap<QString, QMap<QString, QString>> mapAttributesMaster;
|
||||||
|
QStringList *itemNames = NULL;
|
||||||
|
|
||||||
QMap<QString, Map*> *map_cache;
|
QMap<QString, Map*> *map_cache;
|
||||||
Map* loadMap(QString);
|
Map* loadMap(QString);
|
||||||
|
@ -73,6 +73,7 @@ public:
|
||||||
QStringList getWeathers();
|
QStringList getWeathers();
|
||||||
QStringList getMapTypes();
|
QStringList getMapTypes();
|
||||||
QStringList getBattleScenes();
|
QStringList getBattleScenes();
|
||||||
|
void readItemNames();
|
||||||
|
|
||||||
void loadObjectPixmaps(QList<Event*> objects);
|
void loadObjectPixmaps(QList<Event*> objects);
|
||||||
QMap<QString, int> getMapObjGfxConstants();
|
QMap<QString, int> getMapObjGfxConstants();
|
||||||
|
|
Loading…
Reference in a new issue