diff --git a/event.cpp b/event.cpp index 6b47972e..c254d7af 100755 --- a/event.cpp +++ b/event.cpp @@ -43,7 +43,7 @@ Event* Event::createNewObjectEvent() event->put("event_group_type", "object_event_group"); event->put("event_type", EventType::Object); event->put("sprite", "EVENT_OBJ_GFX_BOY_1"); - event->put("behavior", "1"); + event->put("movement_type", "1"); event->put("radius_x", 0); event->put("radius_y", 0); event->put("script_label", "NULL"); @@ -109,7 +109,7 @@ Event* Event::createNewSecretBaseEvent() Event *event = new Event; event->put("event_group_type", "bg_event_group"); event->put("event_type", EventType::SecretBase); - event->put("secret_base_map", "SECRET_BASE_RED_CAVE2_1"); + event->put("secret_base_id", "SECRET_BASE_RED_CAVE2_1"); return event; } @@ -127,7 +127,7 @@ QString Event::buildObjectEventMacro(int item_index) text += QString(", %1").arg(x); text += QString(", %1").arg(y); text += QString(", %1").arg(this->get("elevation")); - text += QString(", %1").arg(this->get("behavior")); + text += QString(", %1").arg(this->get("movement_type")); text += QString(", %1").arg(radius_x); text += QString(", %1").arg(radius_y); text += QString(", %1").arg(this->get("trainer_see_type")); @@ -156,10 +156,8 @@ QString Event::buildCoordScriptEventMacro() text += QString("\tcoord_event %1").arg(this->get("x")); text += QString(", %1").arg(this->get("y")); text += QString(", %1").arg(this->get("elevation")); - text += QString(", 0"); text += QString(", %1").arg(this->get("script_var")); text += QString(", %1").arg(this->get("script_var_value")); - text += QString(", 0"); text += QString(", %1").arg(this->get("script_label")); text += "\n"; return text; @@ -183,7 +181,6 @@ QString Event::buildSignEventMacro() text += QString(", %1").arg(this->get("y")); text += QString(", %1").arg(this->get("elevation")); text += QString(", %1").arg(this->get("player_facing_direction")); - text += QString(", 0"); text += QString(", %1").arg(this->get("script_label")); text += "\n"; return text; @@ -207,7 +204,7 @@ QString Event::buildSecretBaseEventMacro() text += QString("\tbg_secret_base_event %1").arg(this->get("x")); text += QString(", %1").arg(this->get("y")); text += QString(", %1").arg(this->get("elevation")); - text += QString(", %1").arg(this->get("secret_base_map")); + text += QString(", %1").arg(this->get("secret_base_id")); text += "\n"; return text; } diff --git a/mainwindow.cpp b/mainwindow.cpp index 87254a63..4cc3f760 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -313,6 +313,10 @@ void MainWindow::loadDataStructures() { project->readItemNames(); project->readFlagNames(); project->readVarNames(); + project->readMovementTypes(); + project->readCoordEventWeatherNames(); + project->readSecretBaseIds(); + project->readBgEventFacingDirections(); project->readMapsWithConnections(); } @@ -598,7 +602,7 @@ void MainWindow::updateSelectedObjects() { field_labels["script_label"] = "Script"; field_labels["event_flag"] = "Event Flag"; field_labels["replacement"] = "Replacement"; - field_labels["behavior"] = "Behavior"; + field_labels["movement_type"] = "Movement"; field_labels["radius_x"] = "Movement Radius X"; field_labels["radius_y"] = "Movement Radius Y"; field_labels["trainer_see_type"] = "Trainer See Type"; @@ -613,7 +617,7 @@ void MainWindow::updateSelectedObjects() { field_labels["item_unknown6"] = "Unknown 6"; field_labels["weather"] = "Weather"; field_labels["flag"] = "Flag"; - field_labels["secret_base_map"] = "Secret Base Map"; + field_labels["secret_base_id"] = "Secret Base Id"; QStringList fields; @@ -634,7 +638,7 @@ void MainWindow::updateSelectedObjects() { //connect(item, SIGNAL(scriptChanged(QString)), frame->ui->comboBox_script, SLOT(setValue(QString))); */ - fields << "behavior"; + fields << "movement_type"; fields << "radius_x"; fields << "radius_y"; fields << "script_label"; @@ -664,7 +668,7 @@ void MainWindow::updateSelectedObjects() { fields << "flag"; } else if (event_type == EventType::SecretBase) { - fields << "secret_base_map"; + fields << "secret_base_id"; } for (QString key : fields) { @@ -685,7 +689,7 @@ void MainWindow::updateSelectedObjects() { combo->addItem(value); } combo->addItems(*editor->project->itemNames); - } else if (key == "flag") { + } else if (key == "flag" || key == "event_flag") { if (!editor->project->flagNames->contains(value)) { combo->addItem(value); } @@ -695,6 +699,26 @@ void MainWindow::updateSelectedObjects() { combo->addItem(value); } combo->addItems(*editor->project->varNames); + } else if (key == "movement_type") { + if (!editor->project->movementTypes->contains(value)) { + combo->addItem(value); + } + combo->addItems(*editor->project->movementTypes); + } else if (key == "weather") { + if (!editor->project->coordEventWeatherNames->contains(value)) { + combo->addItem(value); + } + combo->addItems(*editor->project->coordEventWeatherNames); + } else if (key == "secret_base_id") { + if (!editor->project->secretBaseIds->contains(value)) { + combo->addItem(value); + } + combo->addItems(*editor->project->secretBaseIds); + } else if (key == "player_facing_direction") { + if (!editor->project->bgEventFacingDirections->contains(value)) { + combo->addItem(value); + } + combo->addItems(*editor->project->bgEventFacingDirections); } else { combo->addItem(value); } diff --git a/project.cpp b/project.cpp index 68b7a742..e23f308d 100755 --- a/project.cpp +++ b/project.cpp @@ -20,6 +20,10 @@ Project::Project() itemNames = new QStringList; flagNames = new QStringList; varNames = new QStringList; + movementTypes = new QStringList; + coordEventWeatherNames = new QStringList; + secretBaseIds = new QStringList; + bgEventFacingDirections = new QStringList; map_cache = new QMap; mapConstantsToMapNames = new QMap; mapNamesToMapConstants = new QMap; @@ -1086,6 +1090,30 @@ void Project::readVarNames() { readCDefinesSorted(filepath, prefixes, varNames); } +void Project::readMovementTypes() { + QString filepath = root + "/include/constants/event_object_movement_constants.h"; + QStringList prefixes = (QStringList() << "MOVEMENT_TYPE_"); + readCDefinesSorted(filepath, prefixes, movementTypes); +} + +void Project::readCoordEventWeatherNames() { + QString filepath = root + "/include/constants/weather.h"; + QStringList prefixes = (QStringList() << "COORD_EVENT_WEATHER_"); + readCDefinesSorted(filepath, prefixes, coordEventWeatherNames); +} + +void Project::readSecretBaseIds() { + QString filepath = root + "/include/constants/secret_bases.h"; + QStringList prefixes = (QStringList() << "SECRET_BASE_"); + readCDefinesSorted(filepath, prefixes, secretBaseIds); +} + +void Project::readBgEventFacingDirections() { + QString filepath = root + "/include/constants/bg_event_constants.h"; + QStringList prefixes = (QStringList() << "BG_EVENT_PLAYER_FACING_"); + readCDefinesSorted(filepath, prefixes, bgEventFacingDirections); +} + void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QStringList* definesToSet) { QString text = readTextFile(filepath); if (!text.isNull()) { @@ -1098,6 +1126,8 @@ void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QString definesInverse.insert(defines[defineName], defineName); } *definesToSet = definesInverse.values(); + } else { + qDebug() << "Failed to read C defines file: " << filepath; } } @@ -1319,7 +1349,7 @@ void Project::readMapEvents(Map *map) { object->put("x", command.value(i++).toInt(nullptr, 0)); object->put("y", command.value(i++).toInt(nullptr, 0)); object->put("elevation", command.value(i++)); - object->put("behavior", command.value(i++)); + object->put("movement_type", command.value(i++)); object->put("radius_x", command.value(i++).toInt(nullptr, 0)); object->put("radius_y", command.value(i++).toInt(nullptr, 0)); object->put("trainer_see_type", command.value(i++)); @@ -1363,12 +1393,6 @@ void Project::readMapEvents(Map *map) { if (command.value(0) == "coord_event") { Event *coord = new Event; coord->put("map_name", map->name); - bool old_macro = false; - if (command.length() >= 9) { - command.removeAt(7); - command.removeAt(4); - old_macro = true; - } int i = 1; coord->put("x", command.value(i++)); coord->put("y", command.value(i++)); @@ -1376,9 +1400,6 @@ void Project::readMapEvents(Map *map) { coord->put("script_var", command.value(i++)); coord->put("script_var_value", command.value(i++)); coord->put("script_label", command.value(i++)); - //coord_unknown3 - //coord_unknown4 - coord->put("event_group_type", "coord_event_group"); coord->put("event_type", EventType::CoordScript); map->events["coord_event_group"].append(coord); @@ -1407,7 +1428,6 @@ void Project::readMapEvents(Map *map) { bg->put("y", command.value(i++)); bg->put("elevation", command.value(i++)); bg->put("player_facing_direction", command.value(i++)); - i++; bg->put("script_label", command.value(i++)); //sign_unknown7 bg->put("event_group_type", "bg_event_group"); @@ -1432,7 +1452,7 @@ void Project::readMapEvents(Map *map) { bg->put("x", command.value(i++)); bg->put("y", command.value(i++)); bg->put("elevation", command.value(i++)); - bg->put("secret_base_map", command.value(i++)); + bg->put("secret_base_id", command.value(i++)); bg->put("event_group_type", "bg_event_group"); bg->put("event_type", EventType::SecretBase); map->events["bg_event_group"].append(bg); diff --git a/project.h b/project.h index 18ab4282..d7ed0f3e 100755 --- a/project.h +++ b/project.h @@ -26,6 +26,10 @@ public: QStringList *itemNames = NULL; QStringList *flagNames = NULL; QStringList *varNames = NULL; + QStringList *movementTypes = NULL; + QStringList *coordEventWeatherNames = NULL; + QStringList *secretBaseIds = NULL; + QStringList *bgEventFacingDirections = NULL; QStringList mapsWithConnections; QMap *map_cache; @@ -81,6 +85,10 @@ public: void readItemNames(); void readFlagNames(); void readVarNames(); + void readMovementTypes(); + void readCoordEventWeatherNames(); + void readSecretBaseIds(); + void readBgEventFacingDirections(); void loadEventPixmaps(QList objects); QMap getEventObjGfxConstants();