Browse Source

Add ability to add all map event types

Marcus Huderle 6 years ago
parent
commit
ecce7d26f2
8 changed files with 288 additions and 120 deletions
  1. 1
    3
      editor.cpp
  2. 8
    0
      editor.h
  3. 200
    0
      event.cpp
  4. 18
    0
      event.h
  5. 10
    11
      mainwindow.cpp
  6. 1
    6
      map.cpp
  7. 0
    1
      map.h
  8. 50
    99
      project.cpp

+ 1
- 3
editor.cpp View File

@@ -1300,9 +1300,8 @@ void Editor::selectMapEvent(DraggablePixmapItem *object, bool toggle) {
1300 1300
 
1301 1301
 DraggablePixmapItem* Editor::addNewEvent(QString event_type) {
1302 1302
     if (project && map) {
1303
-        Event *event = new Event;
1303
+        Event *event = Event::createNewEvent(event_type, map->name);
1304 1304
         event->put("map_name", map->name);
1305
-        event->put("event_type", event_type);
1306 1305
         map->addEvent(event);
1307 1306
         project->loadEventPixmaps(map->getAllEvents());
1308 1307
         DraggablePixmapItem *object = addMapEvent(event);
@@ -1321,7 +1320,6 @@ void Editor::deleteEvent(Event *event) {
1321 1320
     //updateSelectedObjects();
1322 1321
 }
1323 1322
 
1324
-
1325 1323
 // dunno how to detect bubbling. QMouseEvent::isAccepted seems to always be true
1326 1324
 // check if selected_events changed instead. this has the side effect of deselecting
1327 1325
 // when you click on a selected event, since selected_events doesn't change.

+ 8
- 0
editor.h View File

@@ -62,6 +62,7 @@ public:
62 62
     void selectMapEvent(DraggablePixmapItem *object);
63 63
     void selectMapEvent(DraggablePixmapItem *object, bool toggle);
64 64
     DraggablePixmapItem *addNewEvent(QString event_type);
65
+    Event* createNewEvent(QString event_type);
65 66
     void deleteEvent(Event *);
66 67
     void updateSelectedEvents();
67 68
     void redrawObject(DraggablePixmapItem *item);
@@ -107,6 +108,13 @@ private:
107 108
     void updateMirroredConnectionDirection(Connection*, QString);
108 109
     void updateMirroredConnectionMap(Connection*, QString);
109 110
     void updateMirroredConnection(Connection*, QString, QString, bool isDelete = false);
111
+    Event* createNewObjectEvent();
112
+    Event* createNewWarpEvent();
113
+    Event* createNewCoordScriptEvent();
114
+    Event* createNewCoordWeatherEvent();
115
+    Event* createNewSignEvent();
116
+    Event* createNewHiddenItemEvent();
117
+    Event* createNewSecretBaseEvent();
110 118
 
111 119
 private slots:
112 120
     void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);

+ 200
- 0
event.cpp View File

@@ -11,3 +11,203 @@ QString EventType::SecretBase = "event_secret_base";
11 11
 Event::Event()
12 12
 {
13 13
 }
14
+
15
+Event* Event::createNewEvent(QString event_type, QString map_name)
16
+{
17
+    Event *event;
18
+    if (event_type == EventType::Object) {
19
+        event = createNewObjectEvent();
20
+    } else if (event_type == EventType::Warp) {
21
+        event = createNewWarpEvent(map_name);
22
+    } else if (event_type == EventType::CoordScript) {
23
+        event = createNewCoordScriptEvent();
24
+    } else if (event_type == EventType::CoordWeather) {
25
+        event = createNewCoordWeatherEvent();
26
+    } else if (event_type == EventType::Sign) {
27
+        event = createNewSignEvent();
28
+    } else if (event_type == EventType::HiddenItem) {
29
+        event = createNewHiddenItemEvent();
30
+    } else if (event_type == EventType::SecretBase) {
31
+        event = createNewSecretBaseEvent();
32
+    }
33
+
34
+    event->setX(0);
35
+    event->setY(0);
36
+    event->put("elevation", 3);
37
+    return event;
38
+}
39
+
40
+Event* Event::createNewObjectEvent()
41
+{
42
+    Event *event = new Event;
43
+    event->put("event_group_type", "object_event_group");
44
+    event->put("event_type", EventType::Object);
45
+    event->put("sprite", "EVENT_OBJ_GFX_BOY_1");
46
+    event->put("behavior", "1");
47
+    event->put("radius_x", 0);
48
+    event->put("radius_y", 0);
49
+    event->put("script_label", "NULL");
50
+    event->put("event_flag", "0");
51
+    event->put("replacement", "0");
52
+    event->put("trainer_see_type", "0");
53
+    event->put("sight_radius_tree_id", 0);
54
+    return event;
55
+}
56
+
57
+Event* Event::createNewWarpEvent(QString map_name)
58
+{
59
+    Event *event = new Event;
60
+    event->put("event_group_type", "warp_event_group");
61
+    event->put("event_type", EventType::Warp);
62
+    event->put("destination_warp", 0);
63
+    event->put("destination_map_name", map_name);
64
+    return event;
65
+}
66
+
67
+Event* Event::createNewCoordScriptEvent()
68
+{
69
+    Event *event = new Event;
70
+    event->put("event_group_type", "coord_event_group");
71
+    event->put("event_type", EventType::CoordScript);
72
+    event->put("script_label", "NULL");
73
+    event->put("script_var", "VAR_TEMP_0");
74
+    event->put("script_var_value", "0");
75
+    return event;
76
+}
77
+
78
+Event* Event::createNewCoordWeatherEvent()
79
+{
80
+    Event *event = new Event;
81
+    event->put("event_group_type", "coord_event_group");
82
+    event->put("event_type", EventType::CoordWeather);
83
+    event->put("weather", "COORD_EVENT_WEATHER_SUNNY");
84
+    return event;
85
+}
86
+
87
+Event* Event::createNewSignEvent()
88
+{
89
+    Event *event = new Event;
90
+    event->put("event_group_type", "bg_event_group");
91
+    event->put("event_type", EventType::Sign);
92
+    event->put("player_facing_direction", "0");
93
+    event->put("script_label", "NULL");
94
+    return event;
95
+}
96
+
97
+Event* Event::createNewHiddenItemEvent()
98
+{
99
+    Event *event = new Event;
100
+    event->put("event_group_type", "bg_event_group");
101
+    event->put("event_type", EventType::HiddenItem);
102
+    event->put("item", "ITEM_POTION");
103
+    event->put("flag", "FLAG_HIDDEN_ITEM_0");
104
+    return event;
105
+}
106
+
107
+Event* Event::createNewSecretBaseEvent()
108
+{
109
+    Event *event = new Event;
110
+    event->put("event_group_type", "bg_event_group");
111
+    event->put("event_type", EventType::SecretBase);
112
+    event->put("secret_base_map", "SECRET_BASE_RED_CAVE2_1");
113
+    return event;
114
+}
115
+
116
+QString Event::buildObjectEventMacro(int item_index)
117
+{
118
+    int radius_x = this->getInt("radius_x");
119
+    int radius_y = this->getInt("radius_y");
120
+    uint16_t x = this->getInt("x");
121
+    uint16_t y = this->getInt("y");
122
+
123
+    QString text = "";
124
+    text += QString("\tobject_event %1").arg(item_index + 1);
125
+    text += QString(", %1").arg(this->get("sprite"));
126
+    text += QString(", %1").arg(this->get("replacement"));
127
+    text += QString(", %1").arg(x);
128
+    text += QString(", %1").arg(y);
129
+    text += QString(", %1").arg(this->get("elevation"));
130
+    text += QString(", %1").arg(this->get("behavior"));
131
+    text += QString(", %1").arg(radius_x);
132
+    text += QString(", %1").arg(radius_y);
133
+    text += QString(", %1").arg(this->get("trainer_see_type"));
134
+    text += QString(", %1").arg(this->get("sight_radius_tree_id"));
135
+    text += QString(", %1").arg(this->get("script_label"));
136
+    text += QString(", %1").arg(this->get("event_flag"));
137
+    text += "\n";
138
+    return text;
139
+}
140
+
141
+QString Event::buildWarpEventMacro(QMap<QString, QString> *mapNamesToMapConstants)
142
+{
143
+    QString text = "";
144
+    text += QString("\twarp_def %1").arg(this->get("x"));
145
+    text += QString(", %1").arg(this->get("y"));
146
+    text += QString(", %1").arg(this->get("elevation"));
147
+    text += QString(", %1").arg(this->get("destination_warp"));
148
+    text += QString(", %1").arg(mapNamesToMapConstants->value(this->get("destination_map_name")));
149
+    text += "\n";
150
+    return text;
151
+}
152
+
153
+QString Event::buildCoordScriptEventMacro()
154
+{
155
+    QString text = "";
156
+    text += QString("\tcoord_event %1").arg(this->get("x"));
157
+    text += QString(", %1").arg(this->get("y"));
158
+    text += QString(", %1").arg(this->get("elevation"));
159
+    text += QString(", 0");
160
+    text += QString(", %1").arg(this->get("script_var"));
161
+    text += QString(", %1").arg(this->get("script_var_value"));
162
+    text += QString(", 0");
163
+    text += QString(", %1").arg(this->get("script_label"));
164
+    text += "\n";
165
+    return text;
166
+}
167
+
168
+QString Event::buildCoordWeatherEventMacro()
169
+{
170
+    QString text = "";
171
+    text += QString("\tcoord_weather_event %1").arg(this->get("x"));
172
+    text += QString(", %1").arg(this->get("y"));
173
+    text += QString(", %1").arg(this->get("elevation"));
174
+    text += QString(", %1").arg(this->get("weather"));
175
+    text += "\n";
176
+    return text;
177
+}
178
+
179
+QString Event::buildSignEventMacro()
180
+{
181
+    QString text = "";
182
+    text += QString("\tbg_event %1").arg(this->get("x"));
183
+    text += QString(", %1").arg(this->get("y"));
184
+    text += QString(", %1").arg(this->get("elevation"));
185
+    text += QString(", %1").arg(this->get("player_facing_direction"));
186
+    text += QString(", 0");
187
+    text += QString(", %1").arg(this->get("script_label"));
188
+    text += "\n";
189
+    return text;
190
+}
191
+
192
+QString Event::buildHiddenItemEventMacro()
193
+{
194
+    QString text = "";
195
+    text += QString("\tbg_hidden_item_event %1").arg(this->get("x"));
196
+    text += QString(", %1").arg(this->get("y"));
197
+    text += QString(", %1").arg(this->get("elevation"));
198
+    text += QString(", %1").arg(this->get("item"));
199
+    text += QString(", %1").arg(this->get("flag"));
200
+    text += "\n";
201
+    return text;
202
+}
203
+
204
+QString Event::buildSecretBaseEventMacro()
205
+{
206
+    QString text = "";
207
+    text += QString("\tbg_secret_base_event %1").arg(this->get("x"));
208
+    text += QString(", %1").arg(this->get("y"));
209
+    text += QString(", %1").arg(this->get("elevation"));
210
+    text += QString(", %1").arg(this->get("secret_base_map"));
211
+    text += "\n";
212
+    return text;
213
+}

+ 18
- 0
event.h View File

@@ -4,6 +4,7 @@
4 4
 #include <QString>
5 5
 #include <QPixmap>
6 6
 #include <QMap>
7
+#include <QDebug>
7 8
 
8 9
 class EventType
9 10
 {
@@ -50,6 +51,23 @@ public:
50 51
         values.insert(key, value);
51 52
     }
52 53
 
54
+    static Event* createNewEvent(QString, QString);
55
+    static Event* createNewObjectEvent();
56
+    static Event* createNewWarpEvent(QString);
57
+    static Event* createNewCoordScriptEvent();
58
+    static Event* createNewCoordWeatherEvent();
59
+    static Event* createNewSignEvent();
60
+    static Event* createNewHiddenItemEvent();
61
+    static Event* createNewSecretBaseEvent();
62
+
63
+    QString buildObjectEventMacro(int);
64
+    QString buildWarpEventMacro(QMap<QString, QString>*);
65
+    QString buildCoordScriptEventMacro();
66
+    QString buildCoordWeatherEventMacro();
67
+    QString buildSignEventMacro();
68
+    QString buildHiddenItemEventMacro();
69
+    QString buildSecretBaseEventMacro();
70
+
53 71
     QMap<QString, QString> values;
54 72
     QPixmap pixmap;
55 73
 };

+ 10
- 11
mainwindow.cpp View File

@@ -512,9 +512,7 @@ void MainWindow::addNewEvent(QString event_type)
512 512
     if (editor) {
513 513
         DraggablePixmapItem *object = editor->addNewEvent(event_type);
514 514
         if (object) {
515
-            //if (editor->selected_events->length()) {
516
-                editor->selectMapEvent(object, true);
517
-            //}
515
+            editor->selectMapEvent(object, false);
518 516
         }
519 517
         updateSelectedObjects();
520 518
     }
@@ -558,12 +556,13 @@ void MainWindow::updateSelectedObjects() {
558 556
         font.setCapitalization(QFont::Capitalize);
559 557
         frame->ui->label_name->setFont(font);
560 558
         QString event_type = item->event->get("event_type");
559
+        QString event_group_type = item->event->get("event_group_type");
561 560
         QString map_name = item->event->get("map_name");
562 561
         frame->ui->label_name->setText(
563
-            QString("%1 %2 %3")
562
+            QString("%1: %2 %3")
563
+                .arg(editor->project->getMap(map_name)->events.value(event_group_type).indexOf(item->event) + 1)
564 564
                 .arg(map_name)
565 565
                 .arg(event_type)
566
-                .arg(editor->project->getMap(map_name)->events.value(event_type).indexOf(item->event) + 1)
567 566
         );
568 567
 
569 568
         frame->ui->label_spritePixmap->setPixmap(item->event->pixmap);
@@ -578,13 +577,13 @@ void MainWindow::updateSelectedObjects() {
578 577
         field_labels["behavior"] = "Behavior";
579 578
         field_labels["radius_x"] = "Movement Radius X";
580 579
         field_labels["radius_y"] = "Movement Radius Y";
581
-        field_labels["property"] = "Property";
582
-        field_labels["sight_radius"] = "Sight Radius";
580
+        field_labels["trainer_see_type"] = "Trainer See Type";
581
+        field_labels["sight_radius_tree_id"] = "Sight Radius / Berry Tree ID";
583 582
         field_labels["destination_warp"] = "Destination Warp";
584 583
         field_labels["destination_map_name"] = "Destination Map";
585 584
         field_labels["script_var"] = "Var";
586 585
         field_labels["script_var_value"] = "Var Value";
587
-        field_labels["type"] = "Type";
586
+        field_labels["player_facing_direction"] = "Player Facing Direction";
588 587
         field_labels["item"] = "Item";
589 588
         field_labels["item_unknown5"] = "Unknown 5";
590 589
         field_labels["item_unknown6"] = "Unknown 6";
@@ -617,8 +616,8 @@ void MainWindow::updateSelectedObjects() {
617 616
             fields << "script_label";
618 617
             fields << "event_flag";
619 618
             fields << "replacement";
620
-            fields << "property";
621
-            fields << "sight_radius";
619
+            fields << "trainer_see_type";
620
+            fields << "sight_radius_tree_id";
622 621
         }
623 622
         else if (event_type == EventType::Warp) {
624 623
             fields << "destination_warp";
@@ -633,7 +632,7 @@ void MainWindow::updateSelectedObjects() {
633 632
             fields << "weather";
634 633
         }
635 634
         else if (event_type == EventType::Sign) {
636
-            fields << "type";
635
+            fields << "player_facing_direction";
637 636
             fields << "script_label";
638 637
         }
639 638
         else if (event_type == EventType::HiddenItem) {

+ 1
- 6
map.cpp View File

@@ -733,11 +733,6 @@ QList<Event *> Map::getAllEvents() {
733 733
     return all;
734 734
 }
735 735
 
736
-QList<Event *> Map::getEventsByType(QString type)
737
-{
738
-    return events.value(type);
739
-}
740
-
741 736
 void Map::removeEvent(Event *event) {
742 737
     for (QString key : events.keys()) {
743 738
         events[key].removeAll(event);
@@ -745,7 +740,7 @@ void Map::removeEvent(Event *event) {
745 740
 }
746 741
 
747 742
 void Map::addEvent(Event *event) {
748
-    events[event->get("event_type")].append(event);
743
+    events[event->get("event_group_type")].append(event);
749 744
 }
750 745
 
751 746
 bool Map::hasUnsavedChanges() {

+ 0
- 1
map.h View File

@@ -194,7 +194,6 @@ public:
194 194
     QString bg_events_label;
195 195
 
196 196
     QList<Event*> getAllEvents();
197
-    QList<Event*> getEventsByType(QString type);
198 197
     void removeEvent(Event *event);
199 198
     void addEvent(Event *event);
200 199
     QMap<QString, QList<Event*>> events;

+ 50
- 99
project.cpp View File

@@ -1186,97 +1186,48 @@ void Project::saveMapEvents(Map *map) {
1186 1186
     QString path = root + QString("/data/maps/%1/events.inc").arg(map->name);
1187 1187
     QString text = "";
1188 1188
 
1189
-    if (map->events["object"].length() > 0) {
1189
+    if (map->events["object_event_group"].length() > 0) {
1190 1190
         text += QString("%1::\n").arg(map->object_events_label);
1191
-        for (int i = 0; i < map->events["object"].length(); i++) {
1192
-            Event *object_event = map->events["object"].value(i);
1193
-            int radius_x = object_event->getInt("radius_x");
1194
-            int radius_y = object_event->getInt("radius_y");
1195
-            uint16_t x = object_event->getInt("x");
1196
-            uint16_t y = object_event->getInt("y");
1197
-
1198
-            text += QString("\tobject_event %1").arg(i + 1);
1199
-            text += QString(", %1").arg(object_event->get("sprite"));
1200
-            text += QString(", %1").arg(object_event->get("replacement"));
1201
-            text += QString(", %1").arg(x);
1202
-            text += QString(", %1").arg(y);
1203
-            text += QString(", %1").arg(object_event->get("elevation"));
1204
-            text += QString(", %1").arg(object_event->get("behavior"));
1205
-            text += QString(", %1").arg(radius_x);
1206
-            text += QString(", %1").arg(radius_y);
1207
-            text += QString(", %1").arg(object_event->get("property"));
1208
-            text += QString(", %1").arg(object_event->get("sight_radius"));
1209
-            text += QString(", %1").arg(object_event->get("script_label"));
1210
-            text += QString(", %1").arg(object_event->get("event_flag"));
1211
-            text += "\n";
1191
+        for (int i = 0; i < map->events["object_event_group"].length(); i++) {
1192
+            Event *object_event = map->events["object_event_group"].value(i);
1193
+            text += object_event->buildObjectEventMacro(i);
1212 1194
         }
1213 1195
         text += "\n";
1214 1196
     }
1215 1197
 
1216
-    if (map->events["warp"].length() > 0) {
1198
+    if (map->events["warp_event_group"].length() > 0) {
1217 1199
         text += QString("%1::\n").arg(map->warps_label);
1218
-        for (Event *warp : map->events["warp"]) {
1219
-            text += QString("\twarp_def %1").arg(warp->get("x"));
1220
-            text += QString(", %1").arg(warp->get("y"));
1221
-            text += QString(", %1").arg(warp->get("elevation"));
1222
-            text += QString(", %1").arg(warp->get("destination_warp"));
1223
-            text += QString(", %1").arg(mapNamesToMapConstants->value(warp->get("destination_map_name")));
1224
-            text += "\n";
1200
+        for (Event *warp : map->events["warp_event_group"]) {
1201
+            text += warp->buildWarpEventMacro(mapNamesToMapConstants);
1225 1202
         }
1226 1203
         text += "\n";
1227 1204
     }
1228 1205
 
1229
-    if (map->events["trap"].length() + map->events["trap_weather"].length() > 0) {
1206
+    if (map->events["coord_event_group"].length() > 0) {
1230 1207
         text += QString("%1::\n").arg(map->coord_events_label);
1231
-        for (Event *coords : map->events["trap"]) {
1232
-            text += QString("\tcoord_event %1").arg(coords->get("x"));
1233
-            text += QString(", %1").arg(coords->get("y"));
1234
-            text += QString(", %1").arg(coords->get("elevation"));
1235
-            text += QString(", 0");
1236
-            text += QString(", %1").arg(coords->get("script_var"));
1237
-            text += QString(", %1").arg(coords->get("script_var_value"));
1238
-            text += QString(", 0");
1239
-            text += QString(", %1").arg(coords->get("script_label"));
1240
-            text += "\n";
1241
-        }
1242
-        for (Event *coords : map->events["trap_weather"]) {
1243
-            text += QString("\tcoord_weather_event %1").arg(coords->get("x"));
1244
-            text += QString(", %1").arg(coords->get("y"));
1245
-            text += QString(", %1").arg(coords->get("elevation"));
1246
-            text += QString(", %1").arg(coords->get("weather"));
1247
-            text += "\n";
1208
+        for (Event *event : map->events["coord_event_group"]) {
1209
+            QString event_type = event->get("event_type");
1210
+            if (event_type == EventType::CoordScript) {
1211
+                text += event->buildCoordScriptEventMacro();
1212
+            } else if (event_type == EventType::CoordWeather) {
1213
+                text += event->buildCoordWeatherEventMacro();
1214
+            }
1248 1215
         }
1249 1216
         text += "\n";
1250 1217
     }
1251 1218
 
1252
-    if (map->events["sign"].length() +
1253
-        map->events["event_hidden_item"].length() +
1254
-        map->events["event_secret_base"].length() > 0)
1219
+    if (map->events["bg_event_group"].length() > 0)
1255 1220
     {
1256 1221
         text += QString("%1::\n").arg(map->bg_events_label);
1257
-        for (Event *sign : map->events["sign"]) {
1258
-            text += QString("\tbg_event %1").arg(sign->get("x"));
1259
-            text += QString(", %1").arg(sign->get("y"));
1260
-            text += QString(", %1").arg(sign->get("elevation"));
1261
-            text += QString(", %1").arg(sign->get("type"));
1262
-            text += QString(", 0");
1263
-            text += QString(", %1").arg(sign->get("script_label"));
1264
-            text += "\n";
1265
-        }
1266
-        for (Event *item : map->events["event_hidden_item"]) {
1267
-            text += QString("\tbg_hidden_item_event %1").arg(item->get("x"));
1268
-            text += QString(", %1").arg(item->get("y"));
1269
-            text += QString(", %1").arg(item->get("elevation"));
1270
-            text += QString(", %1").arg(item->get("item"));
1271
-            text += QString(", %1").arg(item->get("flag"));
1272
-            text += "\n";
1273
-        }
1274
-        for (Event *item : map->events["event_secret_base"]) {
1275
-            text += QString("\tbg_secret_base_event %1").arg(item->get("x"));
1276
-            text += QString(", %1").arg(item->get("y"));
1277
-            text += QString(", %1").arg(item->get("elevation"));
1278
-            text += QString(", %1").arg(item->get("secret_base_map"));
1279
-            text += "\n";
1222
+        for (Event *event : map->events["bg_event_group"]) {
1223
+            QString event_type = event->get("event_type");
1224
+            if (event_type == EventType::Sign) {
1225
+                text += event->buildSignEventMacro();
1226
+            } else if (event_type == EventType::HiddenItem) {
1227
+                text += event->buildHiddenItemEventMacro();
1228
+            } else if (event_type == EventType::SecretBase) {
1229
+                text += event->buildSecretBaseEventMacro();
1230
+            }
1280 1231
         }
1281 1232
         text += "\n";
1282 1233
     }
@@ -1310,7 +1261,7 @@ void Project::readMapEvents(Map *map) {
1310 1261
     map->bg_events_label = labels->value(3);
1311 1262
 
1312 1263
     QList<QStringList> *object_events = getLabelMacros(parseAsm(text), map->object_events_label);
1313
-    map->events["object"].clear();
1264
+    map->events["object_event_group"].clear();
1314 1265
     for (QStringList command : *object_events) {
1315 1266
         if (command.value(0) == "object_event") {
1316 1267
             Event *object = new Event;
@@ -1324,18 +1275,18 @@ void Project::readMapEvents(Map *map) {
1324 1275
             object->put("behavior", command.value(i++));
1325 1276
             object->put("radius_x", command.value(i++).toInt(nullptr, 0));
1326 1277
             object->put("radius_y", command.value(i++).toInt(nullptr, 0));
1327
-            object->put("property", command.value(i++));
1328
-            object->put("sight_radius", command.value(i++));
1278
+            object->put("trainer_see_type", command.value(i++));
1279
+            object->put("sight_radius_tree_id", command.value(i++));
1329 1280
             object->put("script_label", command.value(i++));
1330 1281
             object->put("event_flag", command.value(i++));
1331
-
1282
+            object->put("event_group_type", "object_event_group");
1332 1283
             object->put("event_type", EventType::Object);
1333
-            map->events["object"].append(object);
1284
+            map->events["object_event_group"].append(object);
1334 1285
         }
1335 1286
     }
1336 1287
 
1337 1288
     QList<QStringList> *warps = getLabelMacros(parseAsm(text), map->warps_label);
1338
-    map->events["warp"].clear();
1289
+    map->events["warp_event_group"].clear();
1339 1290
     for (QStringList command : *warps) {
1340 1291
         if (command.value(0) == "warp_def") {
1341 1292
             Event *warp = new Event;
@@ -1350,8 +1301,9 @@ void Project::readMapEvents(Map *map) {
1350 1301
             QString mapConstant = command.value(i++);
1351 1302
             if (mapConstantsToMapNames->contains(mapConstant)) {
1352 1303
                 warp->put("destination_map_name", mapConstantsToMapNames->value(mapConstant));
1304
+                warp->put("event_group_type", "warp_event_group");
1353 1305
                 warp->put("event_type", EventType::Warp);
1354
-                map->events["warp"].append(warp);
1306
+                map->events["warp_event_group"].append(warp);
1355 1307
             } else {
1356 1308
                 qDebug() << QString("Destination map constant '%1' is invalid for warp").arg(mapConstant);
1357 1309
             }
@@ -1359,8 +1311,7 @@ void Project::readMapEvents(Map *map) {
1359 1311
     }
1360 1312
 
1361 1313
     QList<QStringList> *coords = getLabelMacros(parseAsm(text), map->coord_events_label);
1362
-    map->events["trap"].clear();
1363
-    map->events["trap_weather"].clear();
1314
+    map->events["coord_event_group"].clear();
1364 1315
     for (QStringList command : *coords) {
1365 1316
         if (command.value(0) == "coord_event") {
1366 1317
             Event *coord = new Event;
@@ -1381,8 +1332,9 @@ void Project::readMapEvents(Map *map) {
1381 1332
             //coord_unknown3
1382 1333
             //coord_unknown4
1383 1334
 
1335
+            coord->put("event_group_type", "coord_event_group");
1384 1336
             coord->put("event_type", EventType::CoordScript);
1385
-            map->events["trap"].append(coord);
1337
+            map->events["coord_event_group"].append(coord);
1386 1338
         } else if (command.value(0) == "coord_weather_event") {
1387 1339
             Event *coord = new Event;
1388 1340
             coord->put("map_name", map->name);
@@ -1391,15 +1343,14 @@ void Project::readMapEvents(Map *map) {
1391 1343
             coord->put("y", command.value(i++));
1392 1344
             coord->put("elevation", command.value(i++));
1393 1345
             coord->put("weather", command.value(i++));
1346
+            coord->put("event_group_type", "coord_event_group");
1394 1347
             coord->put("event_type", EventType::CoordWeather);
1395
-            map->events["trap_weather"].append(coord);
1348
+            map->events["coord_event_group"].append(coord);
1396 1349
         }
1397 1350
     }
1398 1351
 
1399 1352
     QList<QStringList> *bgs = getLabelMacros(parseAsm(text), map->bg_events_label);
1400
-    map->events["sign"].clear();
1401
-    map->events["event_hidden_item"].clear();
1402
-    map->events["event_secret_base"].clear();
1353
+    map->events["bg_event_group"].clear();
1403 1354
     for (QStringList command : *bgs) {
1404 1355
         if (command.value(0) == "bg_event") {
1405 1356
             Event *bg = new Event;
@@ -1408,12 +1359,13 @@ void Project::readMapEvents(Map *map) {
1408 1359
             bg->put("x", command.value(i++));
1409 1360
             bg->put("y", command.value(i++));
1410 1361
             bg->put("elevation", command.value(i++));
1411
-            bg->put("type", command.value(i++));
1362
+            bg->put("player_facing_direction", command.value(i++));
1412 1363
             i++;
1413 1364
             bg->put("script_label", command.value(i++));
1414 1365
             //sign_unknown7
1366
+            bg->put("event_group_type", "bg_event_group");
1415 1367
             bg->put("event_type", EventType::Sign);
1416
-            map->events["sign"].append(bg);
1368
+            map->events["bg_event_group"].append(bg);
1417 1369
         } else if (command.value(0) == "bg_hidden_item_event") {
1418 1370
             Event *bg = new Event;
1419 1371
             bg->put("map_name", map->name);
@@ -1423,8 +1375,9 @@ void Project::readMapEvents(Map *map) {
1423 1375
             bg->put("elevation", command.value(i++));
1424 1376
             bg->put("item", command.value(i++));
1425 1377
             bg->put("flag", command.value(i++));
1378
+            bg->put("event_group_type", "bg_event_group");
1426 1379
             bg->put("event_type", EventType::HiddenItem);
1427
-            map->events["event_hidden_item"].append(bg);
1380
+            map->events["bg_event_group"].append(bg);
1428 1381
         } else if (command.value(0) == "bg_secret_base_event") {
1429 1382
             Event *bg = new Event;
1430 1383
             bg->put("map_name", map->name);
@@ -1433,8 +1386,9 @@ void Project::readMapEvents(Map *map) {
1433 1386
             bg->put("y", command.value(i++));
1434 1387
             bg->put("elevation", command.value(i++));
1435 1388
             bg->put("secret_base_map", command.value(i++));
1389
+            bg->put("event_group_type", "bg_event_group");
1436 1390
             bg->put("event_type", EventType::SecretBase);
1437
-            map->events["event_secret_base"].append(bg);
1391
+            map->events["bg_event_group"].append(bg);
1438 1392
         }
1439 1393
     }
1440 1394
 }
@@ -1444,13 +1398,10 @@ void Project::setNewMapEvents(Map *map) {
1444 1398
     map->warps_label = "0x0";
1445 1399
     map->coord_events_label = "0x0";
1446 1400
     map->bg_events_label = "0x0";
1447
-    map->events["object"].clear();
1448
-    map->events["warp"].clear();
1449
-    map->events["trap"].clear();
1450
-    map->events["trap_weather"].clear();
1451
-    map->events["sign"].clear();
1452
-    map->events["event_hidden_item"].clear();
1453
-    map->events["event_secret_base"].clear();
1401
+    map->events["object_event_group"].clear();
1402
+    map->events["warp_event_group"].clear();
1403
+    map->events["coord_event_group"].clear();
1404
+    map->events["bg_event_group"].clear();
1454 1405
 }
1455 1406
 
1456 1407
 QStringList Project::readCArray(QString text, QString label) {