Read trainer type constants
This commit is contained in:
parent
1a2e7623ef
commit
76a8c0dc44
3 changed files with 22 additions and 24 deletions
|
@ -49,6 +49,7 @@ public:
|
||||||
QStringList *coordEventWeatherNames = nullptr;
|
QStringList *coordEventWeatherNames = nullptr;
|
||||||
QStringList *secretBaseIds = nullptr;
|
QStringList *secretBaseIds = nullptr;
|
||||||
QStringList *bgEventFacingDirections = nullptr;
|
QStringList *bgEventFacingDirections = nullptr;
|
||||||
|
QStringList *trainerTypes = nullptr;
|
||||||
QMap<QString, int> metatileBehaviorMap;
|
QMap<QString, int> metatileBehaviorMap;
|
||||||
QMap<int, QString> metatileBehaviorMapInverse;
|
QMap<int, QString> metatileBehaviorMapInverse;
|
||||||
QMap<QString, QString> facingDirections;
|
QMap<QString, QString> facingDirections;
|
||||||
|
@ -143,6 +144,7 @@ public:
|
||||||
bool readCoordEventWeatherNames();
|
bool readCoordEventWeatherNames();
|
||||||
bool readSecretBaseIds();
|
bool readSecretBaseIds();
|
||||||
bool readBgEventFacingDirections();
|
bool readBgEventFacingDirections();
|
||||||
|
bool readTrainerTypes();
|
||||||
bool readMetatileBehaviors();
|
bool readMetatileBehaviors();
|
||||||
bool readHealLocations();
|
bool readHealLocations();
|
||||||
bool readMiscellaneousConstants();
|
bool readMiscellaneousConstants();
|
||||||
|
|
|
@ -646,6 +646,7 @@ bool MainWindow::loadDataStructures() {
|
||||||
&& project->readMapBattleScenes()
|
&& project->readMapBattleScenes()
|
||||||
&& project->readWeatherNames()
|
&& project->readWeatherNames()
|
||||||
&& project->readBgEventFacingDirections()
|
&& project->readBgEventFacingDirections()
|
||||||
|
&& project->readTrainerTypes()
|
||||||
&& project->readMetatileBehaviors()
|
&& project->readMetatileBehaviors()
|
||||||
&& project->readTilesetProperties()
|
&& project->readTilesetProperties()
|
||||||
&& project->readHealLocations()
|
&& project->readHealLocations()
|
||||||
|
@ -1522,29 +1523,6 @@ void MainWindow::updateSelectedObjects() {
|
||||||
combo = new NoScrollComboBox(widget);
|
combo = new NoScrollComboBox(widget);
|
||||||
combo->setEditable(true);
|
combo->setEditable(true);
|
||||||
}
|
}
|
||||||
// trainer_type has custom values, so it has special signal logic.
|
|
||||||
if (key == "trainer_type") {
|
|
||||||
combo->addItem("NONE", "0");
|
|
||||||
combo->addItem("NORMAL", "1");
|
|
||||||
combo->addItem("SEE ALL DIRECTIONS", "3");
|
|
||||||
combo->setToolTip("The trainer type of this object event.\n"
|
|
||||||
"If it is not a trainer, use NONE. SEE ALL DIRECTIONS\n"
|
|
||||||
"should only be used with a sight radius of 1.");
|
|
||||||
combo->setMinimumContentsLength(10);
|
|
||||||
|
|
||||||
int index = combo->findData(value);
|
|
||||||
if (index != -1) {
|
|
||||||
combo->setCurrentIndex(index);
|
|
||||||
} else {
|
|
||||||
combo->setCurrentText(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
fl->addRow(new QLabel(field_labels[key], widget), combo);
|
|
||||||
widget->setLayout(fl);
|
|
||||||
frame->layout()->addWidget(widget);
|
|
||||||
item->bindToUserData(combo, key);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (key == "destination_map_name") {
|
if (key == "destination_map_name") {
|
||||||
if (!editor->project->mapNames->contains(value)) {
|
if (!editor->project->mapNames->contains(value)) {
|
||||||
|
@ -1628,6 +1606,11 @@ void MainWindow::updateSelectedObjects() {
|
||||||
combo->setMinimumContentsLength(4);
|
combo->setMinimumContentsLength(4);
|
||||||
} else if (key == "script_label") {
|
} else if (key == "script_label") {
|
||||||
combo->setToolTip("The script which is executed with this event.");
|
combo->setToolTip("The script which is executed with this event.");
|
||||||
|
} else if (key == "trainer_type") {
|
||||||
|
combo->addItems(*editor->project->trainerTypes);
|
||||||
|
combo->setToolTip("The trainer type of this object event.\n"
|
||||||
|
"If it is not a trainer, use NONE. SEE ALL DIRECTIONS\n"
|
||||||
|
"should only be used with a sight radius of 1.");
|
||||||
} else if (key == "sight_radius_tree_id") {
|
} else if (key == "sight_radius_tree_id") {
|
||||||
combo->setToolTip("The maximum sight range of a trainer,\n"
|
combo->setToolTip("The maximum sight range of a trainer,\n"
|
||||||
"OR the unique id of the berry tree.");
|
"OR the unique id of the berry tree.");
|
||||||
|
|
|
@ -44,6 +44,7 @@ Project::Project()
|
||||||
coordEventWeatherNames = new QStringList;
|
coordEventWeatherNames = new QStringList;
|
||||||
secretBaseIds = new QStringList;
|
secretBaseIds = new QStringList;
|
||||||
bgEventFacingDirections = new QStringList;
|
bgEventFacingDirections = new QStringList;
|
||||||
|
trainerTypes = 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>;
|
||||||
|
@ -2142,6 +2143,18 @@ bool Project::readBgEventFacingDirections() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Project::readTrainerTypes() {
|
||||||
|
trainerTypes->clear();
|
||||||
|
QStringList prefixes = (QStringList() << "TRAINER_TYPE_");
|
||||||
|
QString filename = "include/constants/trainer_types.h";
|
||||||
|
parser.readCDefinesSorted(filename, prefixes, trainerTypes);
|
||||||
|
if (trainerTypes->isEmpty()) {
|
||||||
|
logError(QString("Failed to read trainer type constants from %1").arg(filename));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Project::readMetatileBehaviors() {
|
bool Project::readMetatileBehaviors() {
|
||||||
this->metatileBehaviorMap.clear();
|
this->metatileBehaviorMap.clear();
|
||||||
this->metatileBehaviorMapInverse.clear();
|
this->metatileBehaviorMapInverse.clear();
|
||||||
|
@ -2150,7 +2163,7 @@ bool Project::readMetatileBehaviors() {
|
||||||
QString filename = "include/constants/metatile_behaviors.h";
|
QString filename = "include/constants/metatile_behaviors.h";
|
||||||
this->metatileBehaviorMap = parser.readCDefines(filename, prefixes);
|
this->metatileBehaviorMap = parser.readCDefines(filename, prefixes);
|
||||||
if (this->metatileBehaviorMap.isEmpty()) {
|
if (this->metatileBehaviorMap.isEmpty()) {
|
||||||
logError(QString("Failed to metatile behaviors from %1.").arg(filename));
|
logError(QString("Failed to read metatile behaviors from %1.").arg(filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue