Browse Source

Prepopulate more dropdowns, and support new macro formats

Marcus Huderle 5 years ago
parent
commit
8930b2c01b
4 changed files with 73 additions and 24 deletions
  1. 4
    7
      event.cpp
  2. 29
    5
      mainwindow.cpp
  3. 32
    12
      project.cpp
  4. 8
    0
      project.h

+ 4
- 7
event.cpp View File

@@ -43,7 +43,7 @@ Event* Event::createNewObjectEvent()
43 43
     event->put("event_group_type", "object_event_group");
44 44
     event->put("event_type", EventType::Object);
45 45
     event->put("sprite", "EVENT_OBJ_GFX_BOY_1");
46
-    event->put("behavior", "1");
46
+    event->put("movement_type", "1");
47 47
     event->put("radius_x", 0);
48 48
     event->put("radius_y", 0);
49 49
     event->put("script_label", "NULL");
@@ -109,7 +109,7 @@ Event* Event::createNewSecretBaseEvent()
109 109
     Event *event = new Event;
110 110
     event->put("event_group_type", "bg_event_group");
111 111
     event->put("event_type", EventType::SecretBase);
112
-    event->put("secret_base_map", "SECRET_BASE_RED_CAVE2_1");
112
+    event->put("secret_base_id", "SECRET_BASE_RED_CAVE2_1");
113 113
     return event;
114 114
 }
115 115
 
@@ -127,7 +127,7 @@ QString Event::buildObjectEventMacro(int item_index)
127 127
     text += QString(", %1").arg(x);
128 128
     text += QString(", %1").arg(y);
129 129
     text += QString(", %1").arg(this->get("elevation"));
130
-    text += QString(", %1").arg(this->get("behavior"));
130
+    text += QString(", %1").arg(this->get("movement_type"));
131 131
     text += QString(", %1").arg(radius_x);
132 132
     text += QString(", %1").arg(radius_y);
133 133
     text += QString(", %1").arg(this->get("trainer_see_type"));
@@ -156,10 +156,8 @@ QString Event::buildCoordScriptEventMacro()
156 156
     text += QString("\tcoord_event %1").arg(this->get("x"));
157 157
     text += QString(", %1").arg(this->get("y"));
158 158
     text += QString(", %1").arg(this->get("elevation"));
159
-    text += QString(", 0");
160 159
     text += QString(", %1").arg(this->get("script_var"));
161 160
     text += QString(", %1").arg(this->get("script_var_value"));
162
-    text += QString(", 0");
163 161
     text += QString(", %1").arg(this->get("script_label"));
164 162
     text += "\n";
165 163
     return text;
@@ -183,7 +181,6 @@ QString Event::buildSignEventMacro()
183 181
     text += QString(", %1").arg(this->get("y"));
184 182
     text += QString(", %1").arg(this->get("elevation"));
185 183
     text += QString(", %1").arg(this->get("player_facing_direction"));
186
-    text += QString(", 0");
187 184
     text += QString(", %1").arg(this->get("script_label"));
188 185
     text += "\n";
189 186
     return text;
@@ -207,7 +204,7 @@ QString Event::buildSecretBaseEventMacro()
207 204
     text += QString("\tbg_secret_base_event %1").arg(this->get("x"));
208 205
     text += QString(", %1").arg(this->get("y"));
209 206
     text += QString(", %1").arg(this->get("elevation"));
210
-    text += QString(", %1").arg(this->get("secret_base_map"));
207
+    text += QString(", %1").arg(this->get("secret_base_id"));
211 208
     text += "\n";
212 209
     return text;
213 210
 }

+ 29
- 5
mainwindow.cpp View File

@@ -313,6 +313,10 @@ void MainWindow::loadDataStructures() {
313 313
     project->readItemNames();
314 314
     project->readFlagNames();
315 315
     project->readVarNames();
316
+    project->readMovementTypes();
317
+    project->readCoordEventWeatherNames();
318
+    project->readSecretBaseIds();
319
+    project->readBgEventFacingDirections();
316 320
     project->readMapsWithConnections();
317 321
 }
318 322
 
@@ -598,7 +602,7 @@ void MainWindow::updateSelectedObjects() {
598 602
         field_labels["script_label"] = "Script";
599 603
         field_labels["event_flag"] = "Event Flag";
600 604
         field_labels["replacement"] = "Replacement";
601
-        field_labels["behavior"] = "Behavior";
605
+        field_labels["movement_type"] = "Movement";
602 606
         field_labels["radius_x"] = "Movement Radius X";
603 607
         field_labels["radius_y"] = "Movement Radius Y";
604 608
         field_labels["trainer_see_type"] = "Trainer See Type";
@@ -613,7 +617,7 @@ void MainWindow::updateSelectedObjects() {
613 617
         field_labels["item_unknown6"] = "Unknown 6";
614 618
         field_labels["weather"] = "Weather";
615 619
         field_labels["flag"] = "Flag";
616
-        field_labels["secret_base_map"] = "Secret Base Map";
620
+        field_labels["secret_base_id"] = "Secret Base Id";
617 621
 
618 622
         QStringList fields;
619 623
 
@@ -634,7 +638,7 @@ void MainWindow::updateSelectedObjects() {
634 638
             //connect(item, SIGNAL(scriptChanged(QString)), frame->ui->comboBox_script, SLOT(setValue(QString)));
635 639
             */
636 640
 
637
-            fields << "behavior";
641
+            fields << "movement_type";
638 642
             fields << "radius_x";
639 643
             fields << "radius_y";
640 644
             fields << "script_label";
@@ -664,7 +668,7 @@ void MainWindow::updateSelectedObjects() {
664 668
             fields << "flag";
665 669
         }
666 670
         else if (event_type == EventType::SecretBase) {
667
-            fields << "secret_base_map";
671
+            fields << "secret_base_id";
668 672
         }
669 673
 
670 674
         for (QString key : fields) {
@@ -685,7 +689,7 @@ void MainWindow::updateSelectedObjects() {
685 689
                     combo->addItem(value);
686 690
                 }
687 691
                 combo->addItems(*editor->project->itemNames);
688
-            } else if (key == "flag") {
692
+            } else if (key == "flag" || key == "event_flag") {
689 693
                 if (!editor->project->flagNames->contains(value)) {
690 694
                     combo->addItem(value);
691 695
                 }
@@ -695,6 +699,26 @@ void MainWindow::updateSelectedObjects() {
695 699
                     combo->addItem(value);
696 700
                 }
697 701
                 combo->addItems(*editor->project->varNames);
702
+            } else if (key == "movement_type") {
703
+                if (!editor->project->movementTypes->contains(value)) {
704
+                    combo->addItem(value);
705
+                }
706
+                combo->addItems(*editor->project->movementTypes);
707
+            } else if (key == "weather") {
708
+                if (!editor->project->coordEventWeatherNames->contains(value)) {
709
+                    combo->addItem(value);
710
+                }
711
+                combo->addItems(*editor->project->coordEventWeatherNames);
712
+            } else if (key == "secret_base_id") {
713
+                if (!editor->project->secretBaseIds->contains(value)) {
714
+                    combo->addItem(value);
715
+                }
716
+                combo->addItems(*editor->project->secretBaseIds);
717
+            } else if (key == "player_facing_direction") {
718
+                if (!editor->project->bgEventFacingDirections->contains(value)) {
719
+                    combo->addItem(value);
720
+                }
721
+                combo->addItems(*editor->project->bgEventFacingDirections);
698 722
             } else {
699 723
                 combo->addItem(value);
700 724
             }

+ 32
- 12
project.cpp View File

@@ -20,6 +20,10 @@ Project::Project()
20 20
     itemNames = new QStringList;
21 21
     flagNames = new QStringList;
22 22
     varNames = new QStringList;
23
+    movementTypes = new QStringList;
24
+    coordEventWeatherNames = new QStringList;
25
+    secretBaseIds = new QStringList;
26
+    bgEventFacingDirections = new QStringList;
23 27
     map_cache = new QMap<QString, Map*>;
24 28
     mapConstantsToMapNames = new QMap<QString, QString>;
25 29
     mapNamesToMapConstants = new QMap<QString, QString>;
@@ -1086,6 +1090,30 @@ void Project::readVarNames() {
1086 1090
     readCDefinesSorted(filepath, prefixes, varNames);
1087 1091
 }
1088 1092
 
1093
+void Project::readMovementTypes() {
1094
+    QString filepath = root + "/include/constants/event_object_movement_constants.h";
1095
+    QStringList prefixes = (QStringList() << "MOVEMENT_TYPE_");
1096
+    readCDefinesSorted(filepath, prefixes, movementTypes);
1097
+}
1098
+
1099
+void Project::readCoordEventWeatherNames() {
1100
+    QString filepath = root + "/include/constants/weather.h";
1101
+    QStringList prefixes = (QStringList() << "COORD_EVENT_WEATHER_");
1102
+    readCDefinesSorted(filepath, prefixes, coordEventWeatherNames);
1103
+}
1104
+
1105
+void Project::readSecretBaseIds() {
1106
+    QString filepath = root + "/include/constants/secret_bases.h";
1107
+    QStringList prefixes = (QStringList() << "SECRET_BASE_");
1108
+    readCDefinesSorted(filepath, prefixes, secretBaseIds);
1109
+}
1110
+
1111
+void Project::readBgEventFacingDirections() {
1112
+    QString filepath = root + "/include/constants/bg_event_constants.h";
1113
+    QStringList prefixes = (QStringList() << "BG_EVENT_PLAYER_FACING_");
1114
+    readCDefinesSorted(filepath, prefixes, bgEventFacingDirections);
1115
+}
1116
+
1089 1117
 void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QStringList* definesToSet) {
1090 1118
     QString text = readTextFile(filepath);
1091 1119
     if (!text.isNull()) {
@@ -1098,6 +1126,8 @@ void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QString
1098 1126
             definesInverse.insert(defines[defineName], defineName);
1099 1127
         }
1100 1128
         *definesToSet = definesInverse.values();
1129
+    } else {
1130
+        qDebug() << "Failed to read C defines file: " << filepath;
1101 1131
     }
1102 1132
 }
1103 1133
 
@@ -1319,7 +1349,7 @@ void Project::readMapEvents(Map *map) {
1319 1349
             object->put("x", command.value(i++).toInt(nullptr, 0));
1320 1350
             object->put("y", command.value(i++).toInt(nullptr, 0));
1321 1351
             object->put("elevation", command.value(i++));
1322
-            object->put("behavior", command.value(i++));
1352
+            object->put("movement_type", command.value(i++));
1323 1353
             object->put("radius_x", command.value(i++).toInt(nullptr, 0));
1324 1354
             object->put("radius_y", command.value(i++).toInt(nullptr, 0));
1325 1355
             object->put("trainer_see_type", command.value(i++));
@@ -1363,12 +1393,6 @@ void Project::readMapEvents(Map *map) {
1363 1393
         if (command.value(0) == "coord_event") {
1364 1394
             Event *coord = new Event;
1365 1395
             coord->put("map_name", map->name);
1366
-            bool old_macro = false;
1367
-            if (command.length() >= 9) {
1368
-                command.removeAt(7);
1369
-                command.removeAt(4);
1370
-                old_macro = true;
1371
-            }
1372 1396
             int i = 1;
1373 1397
             coord->put("x", command.value(i++));
1374 1398
             coord->put("y", command.value(i++));
@@ -1376,9 +1400,6 @@ void Project::readMapEvents(Map *map) {
1376 1400
             coord->put("script_var", command.value(i++));
1377 1401
             coord->put("script_var_value", command.value(i++));
1378 1402
             coord->put("script_label", command.value(i++));
1379
-            //coord_unknown3
1380
-            //coord_unknown4
1381
-
1382 1403
             coord->put("event_group_type", "coord_event_group");
1383 1404
             coord->put("event_type", EventType::CoordScript);
1384 1405
             map->events["coord_event_group"].append(coord);
@@ -1407,7 +1428,6 @@ void Project::readMapEvents(Map *map) {
1407 1428
             bg->put("y", command.value(i++));
1408 1429
             bg->put("elevation", command.value(i++));
1409 1430
             bg->put("player_facing_direction", command.value(i++));
1410
-            i++;
1411 1431
             bg->put("script_label", command.value(i++));
1412 1432
             //sign_unknown7
1413 1433
             bg->put("event_group_type", "bg_event_group");
@@ -1432,7 +1452,7 @@ void Project::readMapEvents(Map *map) {
1432 1452
             bg->put("x", command.value(i++));
1433 1453
             bg->put("y", command.value(i++));
1434 1454
             bg->put("elevation", command.value(i++));
1435
-            bg->put("secret_base_map", command.value(i++));
1455
+            bg->put("secret_base_id", command.value(i++));
1436 1456
             bg->put("event_group_type", "bg_event_group");
1437 1457
             bg->put("event_type", EventType::SecretBase);
1438 1458
             map->events["bg_event_group"].append(bg);

+ 8
- 0
project.h View File

@@ -26,6 +26,10 @@ public:
26 26
     QStringList *itemNames = NULL;
27 27
     QStringList *flagNames = NULL;
28 28
     QStringList *varNames = NULL;
29
+    QStringList *movementTypes = NULL;
30
+    QStringList *coordEventWeatherNames = NULL;
31
+    QStringList *secretBaseIds = NULL;
32
+    QStringList *bgEventFacingDirections = NULL;
29 33
     QStringList mapsWithConnections;
30 34
 
31 35
     QMap<QString, Map*> *map_cache;
@@ -81,6 +85,10 @@ public:
81 85
     void readItemNames();
82 86
     void readFlagNames();
83 87
     void readVarNames();
88
+    void readMovementTypes();
89
+    void readCoordEventWeatherNames();
90
+    void readSecretBaseIds();
91
+    void readBgEventFacingDirections();
84 92
 
85 93
     void loadEventPixmaps(QList<Event*> objects);
86 94
     QMap<QString, int> getEventObjGfxConstants();