Browse Source

Add ability to add all map event types

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

+ 8
- 0
editor.h View File

62
     void selectMapEvent(DraggablePixmapItem *object);
62
     void selectMapEvent(DraggablePixmapItem *object);
63
     void selectMapEvent(DraggablePixmapItem *object, bool toggle);
63
     void selectMapEvent(DraggablePixmapItem *object, bool toggle);
64
     DraggablePixmapItem *addNewEvent(QString event_type);
64
     DraggablePixmapItem *addNewEvent(QString event_type);
65
+    Event* createNewEvent(QString event_type);
65
     void deleteEvent(Event *);
66
     void deleteEvent(Event *);
66
     void updateSelectedEvents();
67
     void updateSelectedEvents();
67
     void redrawObject(DraggablePixmapItem *item);
68
     void redrawObject(DraggablePixmapItem *item);
107
     void updateMirroredConnectionDirection(Connection*, QString);
108
     void updateMirroredConnectionDirection(Connection*, QString);
108
     void updateMirroredConnectionMap(Connection*, QString);
109
     void updateMirroredConnectionMap(Connection*, QString);
109
     void updateMirroredConnection(Connection*, QString, QString, bool isDelete = false);
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
 private slots:
119
 private slots:
112
     void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
120
     void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);

+ 200
- 0
event.cpp View File

11
 Event::Event()
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
 #include <QString>
4
 #include <QString>
5
 #include <QPixmap>
5
 #include <QPixmap>
6
 #include <QMap>
6
 #include <QMap>
7
+#include <QDebug>
7
 
8
 
8
 class EventType
9
 class EventType
9
 {
10
 {
50
         values.insert(key, value);
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
     QMap<QString, QString> values;
71
     QMap<QString, QString> values;
54
     QPixmap pixmap;
72
     QPixmap pixmap;
55
 };
73
 };

+ 10
- 11
mainwindow.cpp View File

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

+ 1
- 6
map.cpp View File

733
     return all;
733
     return all;
734
 }
734
 }
735
 
735
 
736
-QList<Event *> Map::getEventsByType(QString type)
737
-{
738
-    return events.value(type);
739
-}
740
-
741
 void Map::removeEvent(Event *event) {
736
 void Map::removeEvent(Event *event) {
742
     for (QString key : events.keys()) {
737
     for (QString key : events.keys()) {
743
         events[key].removeAll(event);
738
         events[key].removeAll(event);
745
 }
740
 }
746
 
741
 
747
 void Map::addEvent(Event *event) {
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
 bool Map::hasUnsavedChanges() {
746
 bool Map::hasUnsavedChanges() {

+ 0
- 1
map.h View File

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

+ 50
- 99
project.cpp View File

1186
     QString path = root + QString("/data/maps/%1/events.inc").arg(map->name);
1186
     QString path = root + QString("/data/maps/%1/events.inc").arg(map->name);
1187
     QString text = "";
1187
     QString text = "";
1188
 
1188
 
1189
-    if (map->events["object"].length() > 0) {
1189
+    if (map->events["object_event_group"].length() > 0) {
1190
         text += QString("%1::\n").arg(map->object_events_label);
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
         text += "\n";
1195
         text += "\n";
1214
     }
1196
     }
1215
 
1197
 
1216
-    if (map->events["warp"].length() > 0) {
1198
+    if (map->events["warp_event_group"].length() > 0) {
1217
         text += QString("%1::\n").arg(map->warps_label);
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
         text += "\n";
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
         text += QString("%1::\n").arg(map->coord_events_label);
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
         text += "\n";
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
         text += QString("%1::\n").arg(map->bg_events_label);
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
         text += "\n";
1232
         text += "\n";
1282
     }
1233
     }
1310
     map->bg_events_label = labels->value(3);
1261
     map->bg_events_label = labels->value(3);
1311
 
1262
 
1312
     QList<QStringList> *object_events = getLabelMacros(parseAsm(text), map->object_events_label);
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
     for (QStringList command : *object_events) {
1265
     for (QStringList command : *object_events) {
1315
         if (command.value(0) == "object_event") {
1266
         if (command.value(0) == "object_event") {
1316
             Event *object = new Event;
1267
             Event *object = new Event;
1324
             object->put("behavior", command.value(i++));
1275
             object->put("behavior", command.value(i++));
1325
             object->put("radius_x", command.value(i++).toInt(nullptr, 0));
1276
             object->put("radius_x", command.value(i++).toInt(nullptr, 0));
1326
             object->put("radius_y", command.value(i++).toInt(nullptr, 0));
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
             object->put("script_label", command.value(i++));
1280
             object->put("script_label", command.value(i++));
1330
             object->put("event_flag", command.value(i++));
1281
             object->put("event_flag", command.value(i++));
1331
-
1282
+            object->put("event_group_type", "object_event_group");
1332
             object->put("event_type", EventType::Object);
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
     QList<QStringList> *warps = getLabelMacros(parseAsm(text), map->warps_label);
1288
     QList<QStringList> *warps = getLabelMacros(parseAsm(text), map->warps_label);
1338
-    map->events["warp"].clear();
1289
+    map->events["warp_event_group"].clear();
1339
     for (QStringList command : *warps) {
1290
     for (QStringList command : *warps) {
1340
         if (command.value(0) == "warp_def") {
1291
         if (command.value(0) == "warp_def") {
1341
             Event *warp = new Event;
1292
             Event *warp = new Event;
1350
             QString mapConstant = command.value(i++);
1301
             QString mapConstant = command.value(i++);
1351
             if (mapConstantsToMapNames->contains(mapConstant)) {
1302
             if (mapConstantsToMapNames->contains(mapConstant)) {
1352
                 warp->put("destination_map_name", mapConstantsToMapNames->value(mapConstant));
1303
                 warp->put("destination_map_name", mapConstantsToMapNames->value(mapConstant));
1304
+                warp->put("event_group_type", "warp_event_group");
1353
                 warp->put("event_type", EventType::Warp);
1305
                 warp->put("event_type", EventType::Warp);
1354
-                map->events["warp"].append(warp);
1306
+                map->events["warp_event_group"].append(warp);
1355
             } else {
1307
             } else {
1356
                 qDebug() << QString("Destination map constant '%1' is invalid for warp").arg(mapConstant);
1308
                 qDebug() << QString("Destination map constant '%1' is invalid for warp").arg(mapConstant);
1357
             }
1309
             }
1359
     }
1311
     }
1360
 
1312
 
1361
     QList<QStringList> *coords = getLabelMacros(parseAsm(text), map->coord_events_label);
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
     for (QStringList command : *coords) {
1315
     for (QStringList command : *coords) {
1365
         if (command.value(0) == "coord_event") {
1316
         if (command.value(0) == "coord_event") {
1366
             Event *coord = new Event;
1317
             Event *coord = new Event;
1381
             //coord_unknown3
1332
             //coord_unknown3
1382
             //coord_unknown4
1333
             //coord_unknown4
1383
 
1334
 
1335
+            coord->put("event_group_type", "coord_event_group");
1384
             coord->put("event_type", EventType::CoordScript);
1336
             coord->put("event_type", EventType::CoordScript);
1385
-            map->events["trap"].append(coord);
1337
+            map->events["coord_event_group"].append(coord);
1386
         } else if (command.value(0) == "coord_weather_event") {
1338
         } else if (command.value(0) == "coord_weather_event") {
1387
             Event *coord = new Event;
1339
             Event *coord = new Event;
1388
             coord->put("map_name", map->name);
1340
             coord->put("map_name", map->name);
1391
             coord->put("y", command.value(i++));
1343
             coord->put("y", command.value(i++));
1392
             coord->put("elevation", command.value(i++));
1344
             coord->put("elevation", command.value(i++));
1393
             coord->put("weather", command.value(i++));
1345
             coord->put("weather", command.value(i++));
1346
+            coord->put("event_group_type", "coord_event_group");
1394
             coord->put("event_type", EventType::CoordWeather);
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
     QList<QStringList> *bgs = getLabelMacros(parseAsm(text), map->bg_events_label);
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
     for (QStringList command : *bgs) {
1354
     for (QStringList command : *bgs) {
1404
         if (command.value(0) == "bg_event") {
1355
         if (command.value(0) == "bg_event") {
1405
             Event *bg = new Event;
1356
             Event *bg = new Event;
1408
             bg->put("x", command.value(i++));
1359
             bg->put("x", command.value(i++));
1409
             bg->put("y", command.value(i++));
1360
             bg->put("y", command.value(i++));
1410
             bg->put("elevation", command.value(i++));
1361
             bg->put("elevation", command.value(i++));
1411
-            bg->put("type", command.value(i++));
1362
+            bg->put("player_facing_direction", command.value(i++));
1412
             i++;
1363
             i++;
1413
             bg->put("script_label", command.value(i++));
1364
             bg->put("script_label", command.value(i++));
1414
             //sign_unknown7
1365
             //sign_unknown7
1366
+            bg->put("event_group_type", "bg_event_group");
1415
             bg->put("event_type", EventType::Sign);
1367
             bg->put("event_type", EventType::Sign);
1416
-            map->events["sign"].append(bg);
1368
+            map->events["bg_event_group"].append(bg);
1417
         } else if (command.value(0) == "bg_hidden_item_event") {
1369
         } else if (command.value(0) == "bg_hidden_item_event") {
1418
             Event *bg = new Event;
1370
             Event *bg = new Event;
1419
             bg->put("map_name", map->name);
1371
             bg->put("map_name", map->name);
1423
             bg->put("elevation", command.value(i++));
1375
             bg->put("elevation", command.value(i++));
1424
             bg->put("item", command.value(i++));
1376
             bg->put("item", command.value(i++));
1425
             bg->put("flag", command.value(i++));
1377
             bg->put("flag", command.value(i++));
1378
+            bg->put("event_group_type", "bg_event_group");
1426
             bg->put("event_type", EventType::HiddenItem);
1379
             bg->put("event_type", EventType::HiddenItem);
1427
-            map->events["event_hidden_item"].append(bg);
1380
+            map->events["bg_event_group"].append(bg);
1428
         } else if (command.value(0) == "bg_secret_base_event") {
1381
         } else if (command.value(0) == "bg_secret_base_event") {
1429
             Event *bg = new Event;
1382
             Event *bg = new Event;
1430
             bg->put("map_name", map->name);
1383
             bg->put("map_name", map->name);
1433
             bg->put("y", command.value(i++));
1386
             bg->put("y", command.value(i++));
1434
             bg->put("elevation", command.value(i++));
1387
             bg->put("elevation", command.value(i++));
1435
             bg->put("secret_base_map", command.value(i++));
1388
             bg->put("secret_base_map", command.value(i++));
1389
+            bg->put("event_group_type", "bg_event_group");
1436
             bg->put("event_type", EventType::SecretBase);
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
     map->warps_label = "0x0";
1398
     map->warps_label = "0x0";
1445
     map->coord_events_label = "0x0";
1399
     map->coord_events_label = "0x0";
1446
     map->bg_events_label = "0x0";
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
 QStringList Project::readCArray(QString text, QString label) {
1407
 QStringList Project::readCArray(QString text, QString label) {