Browse Source

Prepopulate more dropdowns, and support new macro formats

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

+ 29
- 5
mainwindow.cpp View File

313
     project->readItemNames();
313
     project->readItemNames();
314
     project->readFlagNames();
314
     project->readFlagNames();
315
     project->readVarNames();
315
     project->readVarNames();
316
+    project->readMovementTypes();
317
+    project->readCoordEventWeatherNames();
318
+    project->readSecretBaseIds();
319
+    project->readBgEventFacingDirections();
316
     project->readMapsWithConnections();
320
     project->readMapsWithConnections();
317
 }
321
 }
318
 
322
 
598
         field_labels["script_label"] = "Script";
602
         field_labels["script_label"] = "Script";
599
         field_labels["event_flag"] = "Event Flag";
603
         field_labels["event_flag"] = "Event Flag";
600
         field_labels["replacement"] = "Replacement";
604
         field_labels["replacement"] = "Replacement";
601
-        field_labels["behavior"] = "Behavior";
605
+        field_labels["movement_type"] = "Movement";
602
         field_labels["radius_x"] = "Movement Radius X";
606
         field_labels["radius_x"] = "Movement Radius X";
603
         field_labels["radius_y"] = "Movement Radius Y";
607
         field_labels["radius_y"] = "Movement Radius Y";
604
         field_labels["trainer_see_type"] = "Trainer See Type";
608
         field_labels["trainer_see_type"] = "Trainer See Type";
613
         field_labels["item_unknown6"] = "Unknown 6";
617
         field_labels["item_unknown6"] = "Unknown 6";
614
         field_labels["weather"] = "Weather";
618
         field_labels["weather"] = "Weather";
615
         field_labels["flag"] = "Flag";
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
         QStringList fields;
622
         QStringList fields;
619
 
623
 
634
             //connect(item, SIGNAL(scriptChanged(QString)), frame->ui->comboBox_script, SLOT(setValue(QString)));
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
             fields << "radius_x";
642
             fields << "radius_x";
639
             fields << "radius_y";
643
             fields << "radius_y";
640
             fields << "script_label";
644
             fields << "script_label";
664
             fields << "flag";
668
             fields << "flag";
665
         }
669
         }
666
         else if (event_type == EventType::SecretBase) {
670
         else if (event_type == EventType::SecretBase) {
667
-            fields << "secret_base_map";
671
+            fields << "secret_base_id";
668
         }
672
         }
669
 
673
 
670
         for (QString key : fields) {
674
         for (QString key : fields) {
685
                     combo->addItem(value);
689
                     combo->addItem(value);
686
                 }
690
                 }
687
                 combo->addItems(*editor->project->itemNames);
691
                 combo->addItems(*editor->project->itemNames);
688
-            } else if (key == "flag") {
692
+            } else if (key == "flag" || key == "event_flag") {
689
                 if (!editor->project->flagNames->contains(value)) {
693
                 if (!editor->project->flagNames->contains(value)) {
690
                     combo->addItem(value);
694
                     combo->addItem(value);
691
                 }
695
                 }
695
                     combo->addItem(value);
699
                     combo->addItem(value);
696
                 }
700
                 }
697
                 combo->addItems(*editor->project->varNames);
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
             } else {
722
             } else {
699
                 combo->addItem(value);
723
                 combo->addItem(value);
700
             }
724
             }

+ 32
- 12
project.cpp View File

20
     itemNames = new QStringList;
20
     itemNames = new QStringList;
21
     flagNames = new QStringList;
21
     flagNames = new QStringList;
22
     varNames = new QStringList;
22
     varNames = new QStringList;
23
+    movementTypes = new QStringList;
24
+    coordEventWeatherNames = new QStringList;
25
+    secretBaseIds = new QStringList;
26
+    bgEventFacingDirections = new QStringList;
23
     map_cache = new QMap<QString, Map*>;
27
     map_cache = new QMap<QString, Map*>;
24
     mapConstantsToMapNames = new QMap<QString, QString>;
28
     mapConstantsToMapNames = new QMap<QString, QString>;
25
     mapNamesToMapConstants = new QMap<QString, QString>;
29
     mapNamesToMapConstants = new QMap<QString, QString>;
1086
     readCDefinesSorted(filepath, prefixes, varNames);
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
 void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QStringList* definesToSet) {
1117
 void Project::readCDefinesSorted(QString filepath, QStringList prefixes, QStringList* definesToSet) {
1090
     QString text = readTextFile(filepath);
1118
     QString text = readTextFile(filepath);
1091
     if (!text.isNull()) {
1119
     if (!text.isNull()) {
1098
             definesInverse.insert(defines[defineName], defineName);
1126
             definesInverse.insert(defines[defineName], defineName);
1099
         }
1127
         }
1100
         *definesToSet = definesInverse.values();
1128
         *definesToSet = definesInverse.values();
1129
+    } else {
1130
+        qDebug() << "Failed to read C defines file: " << filepath;
1101
     }
1131
     }
1102
 }
1132
 }
1103
 
1133
 
1319
             object->put("x", command.value(i++).toInt(nullptr, 0));
1349
             object->put("x", command.value(i++).toInt(nullptr, 0));
1320
             object->put("y", command.value(i++).toInt(nullptr, 0));
1350
             object->put("y", command.value(i++).toInt(nullptr, 0));
1321
             object->put("elevation", command.value(i++));
1351
             object->put("elevation", command.value(i++));
1322
-            object->put("behavior", command.value(i++));
1352
+            object->put("movement_type", command.value(i++));
1323
             object->put("radius_x", command.value(i++).toInt(nullptr, 0));
1353
             object->put("radius_x", command.value(i++).toInt(nullptr, 0));
1324
             object->put("radius_y", command.value(i++).toInt(nullptr, 0));
1354
             object->put("radius_y", command.value(i++).toInt(nullptr, 0));
1325
             object->put("trainer_see_type", command.value(i++));
1355
             object->put("trainer_see_type", command.value(i++));
1363
         if (command.value(0) == "coord_event") {
1393
         if (command.value(0) == "coord_event") {
1364
             Event *coord = new Event;
1394
             Event *coord = new Event;
1365
             coord->put("map_name", map->name);
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
             int i = 1;
1396
             int i = 1;
1373
             coord->put("x", command.value(i++));
1397
             coord->put("x", command.value(i++));
1374
             coord->put("y", command.value(i++));
1398
             coord->put("y", command.value(i++));
1376
             coord->put("script_var", command.value(i++));
1400
             coord->put("script_var", command.value(i++));
1377
             coord->put("script_var_value", command.value(i++));
1401
             coord->put("script_var_value", command.value(i++));
1378
             coord->put("script_label", command.value(i++));
1402
             coord->put("script_label", command.value(i++));
1379
-            //coord_unknown3
1380
-            //coord_unknown4
1381
-
1382
             coord->put("event_group_type", "coord_event_group");
1403
             coord->put("event_group_type", "coord_event_group");
1383
             coord->put("event_type", EventType::CoordScript);
1404
             coord->put("event_type", EventType::CoordScript);
1384
             map->events["coord_event_group"].append(coord);
1405
             map->events["coord_event_group"].append(coord);
1407
             bg->put("y", command.value(i++));
1428
             bg->put("y", command.value(i++));
1408
             bg->put("elevation", command.value(i++));
1429
             bg->put("elevation", command.value(i++));
1409
             bg->put("player_facing_direction", command.value(i++));
1430
             bg->put("player_facing_direction", command.value(i++));
1410
-            i++;
1411
             bg->put("script_label", command.value(i++));
1431
             bg->put("script_label", command.value(i++));
1412
             //sign_unknown7
1432
             //sign_unknown7
1413
             bg->put("event_group_type", "bg_event_group");
1433
             bg->put("event_group_type", "bg_event_group");
1432
             bg->put("x", command.value(i++));
1452
             bg->put("x", command.value(i++));
1433
             bg->put("y", command.value(i++));
1453
             bg->put("y", command.value(i++));
1434
             bg->put("elevation", command.value(i++));
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
             bg->put("event_group_type", "bg_event_group");
1456
             bg->put("event_group_type", "bg_event_group");
1437
             bg->put("event_type", EventType::SecretBase);
1457
             bg->put("event_type", EventType::SecretBase);
1438
             map->events["bg_event_group"].append(bg);
1458
             map->events["bg_event_group"].append(bg);

+ 8
- 0
project.h View File

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