Browse Source

Merge pull request #52 from huderlem/events

Events Editing
yenatch 5 years ago
parent
commit
10b6d3a0d3
No account linked to committer's email address
13 changed files with 538 additions and 192 deletions
  1. 2
    7
      editor.cpp
  2. 9
    2
      editor.h
  3. 208
    0
      event.cpp
  4. 30
    1
      event.h
  5. 23
    20
      mainwindow.cpp
  6. 1
    2
      mainwindow.h
  7. 8
    9
      mainwindow.ui
  8. 21
    6
      map.cpp
  9. 7
    9
      map.h
  10. 103
    0
      neweventtoolbutton.cpp
  11. 35
    0
      neweventtoolbutton.h
  12. 4
    2
      pretmap.pro
  13. 87
    134
      project.cpp

+ 2
- 7
editor.cpp View File

@@ -1,4 +1,5 @@
1 1
 #include "editor.h"
2
+#include "event.h"
2 3
 #include <QCheckBox>
3 4
 #include <QPainter>
4 5
 #include <QMouseEvent>
@@ -1297,15 +1298,10 @@ void Editor::selectMapEvent(DraggablePixmapItem *object, bool toggle) {
1297 1298
     }
1298 1299
 }
1299 1300
 
1300
-DraggablePixmapItem* Editor::addNewEvent() {
1301
-    return addNewEvent("object");
1302
-}
1303
-
1304 1301
 DraggablePixmapItem* Editor::addNewEvent(QString event_type) {
1305 1302
     if (project && map) {
1306
-        Event *event = new Event;
1303
+        Event *event = Event::createNewEvent(event_type, map->name);
1307 1304
         event->put("map_name", map->name);
1308
-        event->put("event_type", event_type);
1309 1305
         map->addEvent(event);
1310 1306
         project->loadEventPixmaps(map->getAllEvents());
1311 1307
         DraggablePixmapItem *object = addMapEvent(event);
@@ -1324,7 +1320,6 @@ void Editor::deleteEvent(Event *event) {
1324 1320
     //updateSelectedObjects();
1325 1321
 }
1326 1322
 
1327
-
1328 1323
 // dunno how to detect bubbling. QMouseEvent::isAccepted seems to always be true
1329 1324
 // check if selected_events changed instead. this has the side effect of deselecting
1330 1325
 // when you click on a selected event, since selected_events doesn't change.

+ 9
- 2
editor.h View File

@@ -61,8 +61,8 @@ public:
61 61
     DraggablePixmapItem *addMapEvent(Event *event);
62 62
     void selectMapEvent(DraggablePixmapItem *object);
63 63
     void selectMapEvent(DraggablePixmapItem *object, bool toggle);
64
-    DraggablePixmapItem *addNewEvent();
65 64
     DraggablePixmapItem *addNewEvent(QString event_type);
65
+    Event* createNewEvent(QString event_type);
66 66
     void deleteEvent(Event *);
67 67
     void updateSelectedEvents();
68 68
     void redrawObject(DraggablePixmapItem *item);
@@ -108,6 +108,13 @@ private:
108 108
     void updateMirroredConnectionDirection(Connection*, QString);
109 109
     void updateMirroredConnectionMap(Connection*, QString);
110 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();
111 118
 
112 119
 private slots:
113 120
     void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
@@ -166,7 +173,7 @@ public:
166 173
         emit spriteChanged(event->pixmap);
167 174
     }
168 175
     void bind(QComboBox *combo, QString key) {
169
-        connect(combo, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),
176
+        connect(combo, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
170 177
                 this, [this, key](QString value){
171 178
             this->event->put(key, value);
172 179
         });

+ 208
- 0
event.cpp View File

@@ -1,5 +1,213 @@
1 1
 #include "event.h"
2 2
 
3
+QString EventType::Object = "event_object";
4
+QString EventType::Warp = "event_warp";
5
+QString EventType::CoordScript = "event_trap";
6
+QString EventType::CoordWeather = "event_trap_weather";
7
+QString EventType::Sign = "event_sign";
8
+QString EventType::HiddenItem = "event_hidden_item";
9
+QString EventType::SecretBase = "event_secret_base";
10
+
3 11
 Event::Event()
4 12
 {
5 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
+}

+ 30
- 1
event.h View File

@@ -4,12 +4,24 @@
4 4
 #include <QString>
5 5
 #include <QPixmap>
6 6
 #include <QMap>
7
+#include <QDebug>
8
+
9
+class EventType
10
+{
11
+public:
12
+    static QString Object;
13
+    static QString Warp;
14
+    static QString CoordScript;
15
+    static QString CoordWeather;
16
+    static QString Sign;
17
+    static QString HiddenItem;
18
+    static QString SecretBase;
19
+};
7 20
 
8 21
 class Event
9 22
 {
10 23
 public:
11 24
     Event();
12
-
13 25
 public:
14 26
     int x() {
15 27
         return getInt("x");
@@ -39,6 +51,23 @@ public:
39 51
         values.insert(key, value);
40 52
     }
41 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
+
42 71
     QMap<QString, QString> values;
43 72
     QPixmap pixmap;
44 73
 };

+ 23
- 20
mainwindow.cpp View File

@@ -24,6 +24,10 @@ MainWindow::MainWindow(QWidget *parent) :
24 24
     QCoreApplication::setApplicationName("pretmap");
25 25
 
26 26
     ui->setupUi(this);
27
+
28
+    ui->newEventToolButton->initButton();
29
+    connect(ui->newEventToolButton, SIGNAL(newEventAdded(QString)), this, SLOT(addNewEvent(QString)));
30
+
27 31
     new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z), this, SLOT(redo()));
28 32
 
29 33
     editor = new Editor(ui);
@@ -503,14 +507,12 @@ void MainWindow::on_actionRedo_triggered()
503 507
     redo();
504 508
 }
505 509
 
506
-void MainWindow::on_toolButton_newObject_clicked()
510
+void MainWindow::addNewEvent(QString event_type)
507 511
 {
508 512
     if (editor) {
509
-        DraggablePixmapItem *object = editor->addNewEvent();
513
+        DraggablePixmapItem *object = editor->addNewEvent(event_type);
510 514
         if (object) {
511
-            //if (editor->selected_events->length()) {
512
-                editor->selectMapEvent(object, true);
513
-            //}
515
+            editor->selectMapEvent(object, false);
514 516
         }
515 517
         updateSelectedObjects();
516 518
     }
@@ -554,12 +556,13 @@ void MainWindow::updateSelectedObjects() {
554 556
         font.setCapitalization(QFont::Capitalize);
555 557
         frame->ui->label_name->setFont(font);
556 558
         QString event_type = item->event->get("event_type");
559
+        QString event_group_type = item->event->get("event_group_type");
557 560
         QString map_name = item->event->get("map_name");
558 561
         frame->ui->label_name->setText(
559
-            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)
560 564
                 .arg(map_name)
561 565
                 .arg(event_type)
562
-                .arg(editor->project->getMap(map_name)->events.value(event_type).indexOf(item->event) + 1)
563 566
         );
564 567
 
565 568
         frame->ui->label_spritePixmap->setPixmap(item->event->pixmap);
@@ -574,13 +577,13 @@ void MainWindow::updateSelectedObjects() {
574 577
         field_labels["behavior"] = "Behavior";
575 578
         field_labels["radius_x"] = "Movement Radius X";
576 579
         field_labels["radius_y"] = "Movement Radius Y";
577
-        field_labels["property"] = "Property";
578
-        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";
579 582
         field_labels["destination_warp"] = "Destination Warp";
580 583
         field_labels["destination_map_name"] = "Destination Map";
581 584
         field_labels["script_var"] = "Var";
582 585
         field_labels["script_var_value"] = "Var Value";
583
-        field_labels["type"] = "Type";
586
+        field_labels["player_facing_direction"] = "Player Facing Direction";
584 587
         field_labels["item"] = "Item";
585 588
         field_labels["item_unknown5"] = "Unknown 5";
586 589
         field_labels["item_unknown6"] = "Unknown 6";
@@ -590,7 +593,7 @@ void MainWindow::updateSelectedObjects() {
590 593
 
591 594
         QStringList fields;
592 595
 
593
-        if (event_type == "object") {
596
+        if (event_type == EventType::Object) {
594 597
 
595 598
             frame->ui->sprite->setVisible(true);
596 599
             frame->ui->comboBox_sprite->addItems(event_obj_gfx_constants.keys());
@@ -613,30 +616,30 @@ void MainWindow::updateSelectedObjects() {
613 616
             fields << "script_label";
614 617
             fields << "event_flag";
615 618
             fields << "replacement";
616
-            fields << "property";
617
-            fields << "sight_radius";
619
+            fields << "trainer_see_type";
620
+            fields << "sight_radius_tree_id";
618 621
         }
619
-        else if (event_type == "warp") {
622
+        else if (event_type == EventType::Warp) {
620 623
             fields << "destination_warp";
621 624
             fields << "destination_map_name";
622 625
         }
623
-        else if (event_type == "trap") {
626
+        else if (event_type == EventType::CoordScript) {
624 627
             fields << "script_label";
625 628
             fields << "script_var";
626 629
             fields << "script_var_value";
627 630
         }
628
-        else if (event_type == "trap_weather") {
631
+        else if (event_type == EventType::CoordWeather) {
629 632
             fields << "weather";
630 633
         }
631
-        else if (event_type == "sign") {
632
-            fields << "type";
634
+        else if (event_type == EventType::Sign) {
635
+            fields << "player_facing_direction";
633 636
             fields << "script_label";
634 637
         }
635
-        else if (event_type == "event_hidden_item") {
638
+        else if (event_type == EventType::HiddenItem) {
636 639
             fields << "item";
637 640
             fields << "flag";
638 641
         }
639
-        else if (event_type == "event_secret_base") {
642
+        else if (event_type == EventType::SecretBase) {
640 643
             fields << "secret_base_map";
641 644
         }
642 645
 

+ 1
- 2
mainwindow.h View File

@@ -56,10 +56,9 @@ private slots:
56 56
 
57 57
     void on_actionRedo_triggered();
58 58
 
59
-    void on_toolButton_newObject_clicked();
60
-
61 59
     void on_toolButton_deleteObject_clicked();
62 60
 
61
+    void addNewEvent(QString);
63 62
     void updateSelectedObjects();
64 63
 
65 64
     void on_toolButton_Paint_clicked();

+ 8
- 9
mainwindow.ui View File

@@ -60,7 +60,7 @@
60 60
         </sizepolicy>
61 61
        </property>
62 62
        <property name="currentIndex">
63
-        <number>0</number>
63
+        <number>1</number>
64 64
        </property>
65 65
        <property name="tabsClosable">
66 66
         <bool>false</bool>
@@ -904,13 +904,7 @@
904 904
                  <number>0</number>
905 905
                 </property>
906 906
                 <item>
907
-                 <widget class="QToolButton" name="toolButton_newObject">
908
-                  <property name="sizePolicy">
909
-                   <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
910
-                    <horstretch>0</horstretch>
911
-                    <verstretch>0</verstretch>
912
-                   </sizepolicy>
913
-                  </property>
907
+                 <widget class="NewEventToolButton" name="newEventToolButton">
914 908
                   <property name="minimumSize">
915 909
                    <size>
916 910
                     <width>40</width>
@@ -918,7 +912,7 @@
918 912
                    </size>
919 913
                   </property>
920 914
                   <property name="text">
921
-                   <string>New</string>
915
+                   <string>New Object</string>
922 916
                   </property>
923 917
                   <property name="icon">
924 918
                    <iconset resource="resources/images.qrc">
@@ -1794,6 +1788,11 @@
1794 1788
    <extends>QGraphicsView</extends>
1795 1789
    <header>graphicsview.h</header>
1796 1790
   </customwidget>
1791
+  <customwidget>
1792
+   <class>NewEventToolButton</class>
1793
+   <extends>QToolButton</extends>
1794
+   <header>neweventtoolbutton.h</header>
1795
+  </customwidget>
1797 1796
  </customwidgets>
1798 1797
  <resources>
1799 1798
   <include location="resources/images.qrc"/>

+ 21
- 6
map.cpp View File

@@ -31,6 +31,26 @@ QString Map::mapConstantFromName(QString mapName) {
31 31
     return constantName;
32 32
 }
33 33
 
34
+QString Map::objectEventsLabelFromName(QString mapName)
35
+{
36
+    return QString("%1_EventObjects").arg(mapName);
37
+}
38
+
39
+QString Map::warpEventsLabelFromName(QString mapName)
40
+{
41
+    return QString("%1_MapWarps").arg(mapName);
42
+}
43
+
44
+QString Map::coordEventsLabelFromName(QString mapName)
45
+{
46
+    return QString("%1_MapCoordEvents").arg(mapName);
47
+}
48
+
49
+QString Map::bgEventsLabelFromName(QString mapName)
50
+{
51
+    return QString("%1_MapBGEvents").arg(mapName);
52
+}
53
+
34 54
 int Map::getWidth() {
35 55
     return layout->width.toInt(nullptr, 0);
36 56
 }
@@ -733,11 +753,6 @@ QList<Event *> Map::getAllEvents() {
733 753
     return all;
734 754
 }
735 755
 
736
-QList<Event *> Map::getEventsByType(QString type)
737
-{
738
-    return events.value(type);
739
-}
740
-
741 756
 void Map::removeEvent(Event *event) {
742 757
     for (QString key : events.keys()) {
743 758
         events[key].removeAll(event);
@@ -745,7 +760,7 @@ void Map::removeEvent(Event *event) {
745 760
 }
746 761
 
747 762
 void Map::addEvent(Event *event) {
748
-    events[event->get("event_type")].append(event);
763
+    events[event->get("event_group_type")].append(event);
749 764
 }
750 765
 
751 766
 bool Map::hasUnsavedChanges() {

+ 7
- 9
map.h View File

@@ -129,12 +129,16 @@ public:
129 129
 public:
130 130
     void setName(QString mapName);
131 131
     static QString mapConstantFromName(QString mapName);
132
+    static QString objectEventsLabelFromName(QString mapName);
133
+    static QString warpEventsLabelFromName(QString mapName);
134
+    static QString coordEventsLabelFromName(QString mapName);
135
+    static QString bgEventsLabelFromName(QString mapName);
132 136
     int getWidth();
133 137
     int getHeight();
134 138
     Tileset* getBlockTileset(int);
135
-    int getBlockIndex(int layout_id);
136
-    int getSelectedBlockIndex(int layout_id);
137
-    int getDisplayedBlockIndex(int layout_id);
139
+    int getBlockIndex(int);
140
+    int getSelectedBlockIndex(int);
141
+    int getDisplayedBlockIndex(int);
138 142
     Metatile* getMetatile(int);
139 143
     QImage getMetatileImage(int);
140 144
     QImage getMetatileTile(int);
@@ -188,13 +192,7 @@ public:
188 192
     void redo();
189 193
     void commit();
190 194
 
191
-    QString object_events_label;
192
-    QString warps_label;
193
-    QString coord_events_label;
194
-    QString bg_events_label;
195
-
196 195
     QList<Event*> getAllEvents();
197
-    QList<Event*> getEventsByType(QString type);
198 196
     void removeEvent(Event *event);
199 197
     void addEvent(Event *event);
200 198
     QMap<QString, QList<Event*>> events;

+ 103
- 0
neweventtoolbutton.cpp View File

@@ -0,0 +1,103 @@
1
+#include "neweventtoolbutton.h"
2
+#include <QMenu>
3
+#include <QDebug>
4
+
5
+// Custom QToolButton which has a context menu that expands to allow
6
+// selection of different types of map events.
7
+NewEventToolButton::NewEventToolButton(QWidget *parent) :
8
+    QToolButton(parent)
9
+{
10
+    setPopupMode(QToolButton::MenuButtonPopup);
11
+    QObject::connect(this, SIGNAL(triggered(QAction*)),
12
+                     this, SLOT(setDefaultAction(QAction*)));
13
+}
14
+
15
+void NewEventToolButton::initButton()
16
+{
17
+    // Add a context menu to select different types of map events.
18
+    this->newObjectAction = new QAction("New Object", this);
19
+    this->newObjectAction->setIcon(QIcon(":/icons/add.ico"));
20
+    connect(this->newObjectAction, SIGNAL(triggered(bool)), this, SLOT(newObject()));
21
+
22
+    this->newWarpAction = new QAction("New Warp", this);
23
+    this->newWarpAction->setIcon(QIcon(":/icons/add.ico"));
24
+    connect(this->newWarpAction, SIGNAL(triggered(bool)), this, SLOT(newWarp()));
25
+
26
+    this->newCoordScriptAction = new QAction("New Coord Script", this);
27
+    this->newCoordScriptAction->setIcon(QIcon(":/icons/add.ico"));
28
+    connect(this->newCoordScriptAction, SIGNAL(triggered(bool)), this, SLOT(newCoordScript()));
29
+
30
+    this->newCoordWeatherAction = new QAction("New Coord Weather", this);
31
+    this->newCoordWeatherAction->setIcon(QIcon(":/icons/add.ico"));
32
+    connect(this->newCoordWeatherAction, SIGNAL(triggered(bool)), this, SLOT(newCoordWeather()));
33
+
34
+    this->newSignAction = new QAction("New Sign", this);
35
+    this->newSignAction->setIcon(QIcon(":/icons/add.ico"));
36
+    connect(this->newSignAction, SIGNAL(triggered(bool)), this, SLOT(newSign()));
37
+
38
+    this->newHiddenItemAction = new QAction("New Hidden Item", this);
39
+    this->newHiddenItemAction->setIcon(QIcon(":/icons/add.ico"));
40
+    connect(this->newHiddenItemAction, SIGNAL(triggered(bool)), this, SLOT(newHiddenItem()));
41
+
42
+    this->newSecretBaseAction = new QAction("New Secret Base", this);
43
+    this->newSecretBaseAction->setIcon(QIcon(":/icons/add.ico"));
44
+    connect(this->newSecretBaseAction, SIGNAL(triggered(bool)), this, SLOT(newSecretBase()));
45
+
46
+    QMenu *alignMenu = new QMenu();
47
+    alignMenu->addAction(this->newObjectAction);
48
+    alignMenu->addAction(this->newWarpAction);
49
+    alignMenu->addAction(this->newCoordScriptAction);
50
+    alignMenu->addAction(this->newCoordWeatherAction);
51
+    alignMenu->addAction(this->newSignAction);
52
+    alignMenu->addAction(this->newHiddenItemAction);
53
+    alignMenu->addAction(this->newSecretBaseAction);
54
+    this->setMenu(alignMenu);
55
+    this->setDefaultAction(this->newObjectAction);
56
+}
57
+
58
+QString NewEventToolButton::getSelectedEventType()
59
+{
60
+    return this->selectedEventType;
61
+}
62
+
63
+void NewEventToolButton::newObject()
64
+{
65
+    this->selectedEventType = EventType::Object;
66
+    emit newEventAdded(this->selectedEventType);
67
+}
68
+
69
+void NewEventToolButton::newWarp()
70
+{
71
+    this->selectedEventType = EventType::Warp;
72
+    emit newEventAdded(this->selectedEventType);
73
+}
74
+
75
+void NewEventToolButton::newCoordScript()
76
+{
77
+    this->selectedEventType = EventType::CoordScript;
78
+    emit newEventAdded(this->selectedEventType);
79
+}
80
+
81
+void NewEventToolButton::newCoordWeather()
82
+{
83
+    this->selectedEventType = EventType::CoordWeather;
84
+    emit newEventAdded(this->selectedEventType);
85
+}
86
+
87
+void NewEventToolButton::newSign()
88
+{
89
+    this->selectedEventType = EventType::Sign;
90
+    emit newEventAdded(this->selectedEventType);
91
+}
92
+
93
+void NewEventToolButton::newHiddenItem()
94
+{
95
+    this->selectedEventType = EventType::HiddenItem;
96
+    emit newEventAdded(this->selectedEventType);
97
+}
98
+
99
+void NewEventToolButton::newSecretBase()
100
+{
101
+    this->selectedEventType = EventType::SecretBase;
102
+    emit newEventAdded(this->selectedEventType);
103
+}

+ 35
- 0
neweventtoolbutton.h View File

@@ -0,0 +1,35 @@
1
+#ifndef NEWEVENTTOOLBUTTON_H
2
+#define NEWEVENTTOOLBUTTON_H
3
+
4
+#include "event.h"
5
+#include <QToolButton>
6
+
7
+class NewEventToolButton : public QToolButton
8
+{
9
+    Q_OBJECT
10
+public:
11
+    explicit NewEventToolButton(QWidget *parent = 0);
12
+    void initButton();
13
+    QString getSelectedEventType();
14
+public slots:
15
+    void newObject();
16
+    void newWarp();
17
+    void newCoordScript();
18
+    void newCoordWeather();
19
+    void newSign();
20
+    void newHiddenItem();
21
+    void newSecretBase();
22
+signals:
23
+    void newEventAdded(QString);
24
+private:
25
+    QString selectedEventType;
26
+    QAction *newObjectAction;
27
+    QAction *newWarpAction;
28
+    QAction *newCoordScriptAction;
29
+    QAction *newCoordWeatherAction;
30
+    QAction *newSignAction;
31
+    QAction *newHiddenItemAction;
32
+    QAction *newSecretBaseAction;
33
+};
34
+
35
+#endif // NEWEVENTTOOLBUTTON_H

+ 4
- 2
pretmap.pro View File

@@ -25,7 +25,8 @@ SOURCES += main.cpp\
25 25
     editor.cpp \
26 26
     objectpropertiesframe.cpp \
27 27
     graphicsview.cpp \
28
-    parseutil.cpp
28
+    parseutil.cpp \
29
+    neweventtoolbutton.cpp
29 30
 
30 31
 HEADERS  += mainwindow.h \
31 32
     project.h \
@@ -39,7 +40,8 @@ HEADERS  += mainwindow.h \
39 40
     editor.h \
40 41
     objectpropertiesframe.h \
41 42
     graphicsview.h \
42
-    parseutil.h
43
+    parseutil.h \
44
+    neweventtoolbutton.h
43 45
 
44 46
 FORMS    += mainwindow.ui \
45 47
     objectpropertiesframe.ui

+ 87
- 134
project.cpp View File

@@ -1152,17 +1152,17 @@ void Project::loadEventPixmaps(QList<Event*> objects) {
1152 1152
             continue;
1153 1153
         }
1154 1154
         QString event_type = object->get("event_type");
1155
-        if (event_type == "object") {
1155
+        if (event_type == EventType::Object) {
1156 1156
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(0, 0, 16, 16);
1157
-        } else if (event_type == "warp") {
1157
+        } else if (event_type == EventType::Warp) {
1158 1158
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(16, 0, 16, 16);
1159
-        } else if (event_type == "trap" || event_type == "trap_weather") {
1159
+        } else if (event_type == EventType::CoordScript || event_type == EventType::CoordWeather) {
1160 1160
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(32, 0, 16, 16);
1161
-        } else if (event_type == "sign" || event_type == "event_hidden_item" || event_type == "event_secret_base") {
1161
+        } else if (event_type == EventType::Sign || event_type == EventType::HiddenItem || event_type == EventType::SecretBase) {
1162 1162
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(48, 0, 16, 16);
1163 1163
         }
1164 1164
 
1165
-        if (event_type == "object") {
1165
+        if (event_type == EventType::Object) {
1166 1166
             int sprite_id = constants.value(object->get("sprite"));
1167 1167
 
1168 1168
             QString info_label = pointers.value(sprite_id).replace("&", "");
@@ -1178,117 +1178,74 @@ void Project::loadEventPixmaps(QList<Event*> objects) {
1178 1178
                     object->pixmap = pixmap;
1179 1179
                 }
1180 1180
             }
1181
-
1182 1181
         }
1183 1182
     }
1184
-
1185 1183
 }
1186 1184
 
1187 1185
 void Project::saveMapEvents(Map *map) {
1188 1186
     QString path = root + QString("/data/maps/%1/events.inc").arg(map->name);
1189 1187
     QString text = "";
1190
-
1191
-    if (map->events["object"].length() > 0) {
1192
-        text += QString("%1::\n").arg(map->object_events_label);
1193
-        for (int i = 0; i < map->events["object"].length(); i++) {
1194
-            Event *object_event = map->events["object"].value(i);
1195
-            int radius_x = object_event->getInt("radius_x");
1196
-            int radius_y = object_event->getInt("radius_y");
1197
-            uint16_t x = object_event->getInt("x");
1198
-            uint16_t y = object_event->getInt("y");
1199
-
1200
-            text += QString("\tobject_event %1").arg(i + 1);
1201
-            text += QString(", %1").arg(object_event->get("sprite"));
1202
-            text += QString(", %1").arg(object_event->get("replacement"));
1203
-            text += QString(", %1").arg(x);
1204
-            text += QString(", %1").arg(y);
1205
-            text += QString(", %1").arg(object_event->get("elevation"));
1206
-            text += QString(", %1").arg(object_event->get("behavior"));
1207
-            text += QString(", %1").arg(radius_x);
1208
-            text += QString(", %1").arg(radius_y);
1209
-            text += QString(", %1").arg(object_event->get("property"));
1210
-            text += QString(", %1").arg(object_event->get("sight_radius"));
1211
-            text += QString(", %1").arg(object_event->get("script_label"));
1212
-            text += QString(", %1").arg(object_event->get("event_flag"));
1213
-            text += "\n";
1188
+    QString objectEventsLabel = "0x0";
1189
+    QString warpEventsLabel = "0x0";
1190
+    QString coordEventsLabel = "0x0";
1191
+    QString bgEventsLabel = "0x0";
1192
+
1193
+    if (map->events["object_event_group"].length() > 0) {
1194
+        objectEventsLabel = Map::objectEventsLabelFromName(map->name);
1195
+        text += QString("%1::\n").arg(objectEventsLabel);
1196
+        for (int i = 0; i < map->events["object_event_group"].length(); i++) {
1197
+            Event *object_event = map->events["object_event_group"].value(i);
1198
+            text += object_event->buildObjectEventMacro(i);
1214 1199
         }
1215 1200
         text += "\n";
1216 1201
     }
1217 1202
 
1218
-    if (map->events["warp"].length() > 0) {
1219
-        text += QString("%1::\n").arg(map->warps_label);
1220
-        for (Event *warp : map->events["warp"]) {
1221
-            text += QString("\twarp_def %1").arg(warp->get("x"));
1222
-            text += QString(", %1").arg(warp->get("y"));
1223
-            text += QString(", %1").arg(warp->get("elevation"));
1224
-            text += QString(", %1").arg(warp->get("destination_warp"));
1225
-            text += QString(", %1").arg(mapNamesToMapConstants->value(warp->get("destination_map_name")));
1226
-            text += "\n";
1203
+    if (map->events["warp_event_group"].length() > 0) {
1204
+        warpEventsLabel = Map::warpEventsLabelFromName(map->name);
1205
+        text += QString("%1::\n").arg(warpEventsLabel);
1206
+        for (Event *warp : map->events["warp_event_group"]) {
1207
+            text += warp->buildWarpEventMacro(mapNamesToMapConstants);
1227 1208
         }
1228 1209
         text += "\n";
1229 1210
     }
1230 1211
 
1231
-    if (map->events["trap"].length() + map->events["trap_weather"].length() > 0) {
1232
-        text += QString("%1::\n").arg(map->coord_events_label);
1233
-        for (Event *coords : map->events["trap"]) {
1234
-            text += QString("\tcoord_event %1").arg(coords->get("x"));
1235
-            text += QString(", %1").arg(coords->get("y"));
1236
-            text += QString(", %1").arg(coords->get("elevation"));
1237
-            text += QString(", 0");
1238
-            text += QString(", %1").arg(coords->get("script_var"));
1239
-            text += QString(", %1").arg(coords->get("script_var_value"));
1240
-            text += QString(", 0");
1241
-            text += QString(", %1").arg(coords->get("script_label"));
1242
-            text += "\n";
1243
-        }
1244
-        for (Event *coords : map->events["trap_weather"]) {
1245
-            text += QString("\tcoord_weather_event %1").arg(coords->get("x"));
1246
-            text += QString(", %1").arg(coords->get("y"));
1247
-            text += QString(", %1").arg(coords->get("elevation"));
1248
-            text += QString(", %1").arg(coords->get("weather"));
1249
-            text += "\n";
1212
+    if (map->events["coord_event_group"].length() > 0) {
1213
+        coordEventsLabel = Map::coordEventsLabelFromName(map->name);
1214
+        text += QString("%1::\n").arg(coordEventsLabel);
1215
+        for (Event *event : map->events["coord_event_group"]) {
1216
+            QString event_type = event->get("event_type");
1217
+            if (event_type == EventType::CoordScript) {
1218
+                text += event->buildCoordScriptEventMacro();
1219
+            } else if (event_type == EventType::CoordWeather) {
1220
+                text += event->buildCoordWeatherEventMacro();
1221
+            }
1250 1222
         }
1251 1223
         text += "\n";
1252 1224
     }
1253 1225
 
1254
-    if (map->events["sign"].length() +
1255
-        map->events["event_hidden_item"].length() +
1256
-        map->events["event_secret_base"].length() > 0)
1226
+    if (map->events["bg_event_group"].length() > 0)
1257 1227
     {
1258
-        text += QString("%1::\n").arg(map->bg_events_label);
1259
-        for (Event *sign : map->events["sign"]) {
1260
-            text += QString("\tbg_event %1").arg(sign->get("x"));
1261
-            text += QString(", %1").arg(sign->get("y"));
1262
-            text += QString(", %1").arg(sign->get("elevation"));
1263
-            text += QString(", %1").arg(sign->get("type"));
1264
-            text += QString(", 0");
1265
-            text += QString(", %1").arg(sign->get("script_label"));
1266
-            text += "\n";
1267
-        }
1268
-        for (Event *item : map->events["event_hidden_item"]) {
1269
-            text += QString("\tbg_hidden_item_event %1").arg(item->get("x"));
1270
-            text += QString(", %1").arg(item->get("y"));
1271
-            text += QString(", %1").arg(item->get("elevation"));
1272
-            text += QString(", %1").arg(item->get("item"));
1273
-            text += QString(", %1").arg(item->get("flag"));
1274
-            text += "\n";
1275
-        }
1276
-        for (Event *item : map->events["event_secret_base"]) {
1277
-            text += QString("\tbg_secret_base_event %1").arg(item->get("x"));
1278
-            text += QString(", %1").arg(item->get("y"));
1279
-            text += QString(", %1").arg(item->get("elevation"));
1280
-            text += QString(", %1").arg(item->get("secret_base_map"));
1281
-            text += "\n";
1228
+        bgEventsLabel = Map::bgEventsLabelFromName(map->name);
1229
+        text += QString("%1::\n").arg(bgEventsLabel);
1230
+        for (Event *event : map->events["bg_event_group"]) {
1231
+            QString event_type = event->get("event_type");
1232
+            if (event_type == EventType::Sign) {
1233
+                text += event->buildSignEventMacro();
1234
+            } else if (event_type == EventType::HiddenItem) {
1235
+                text += event->buildHiddenItemEventMacro();
1236
+            } else if (event_type == EventType::SecretBase) {
1237
+                text += event->buildSecretBaseEventMacro();
1238
+            }
1282 1239
         }
1283 1240
         text += "\n";
1284 1241
     }
1285 1242
 
1286 1243
     text += QString("%1::\n").arg(map->events_label);
1287 1244
     text += QString("\tmap_events %1, %2, %3, %4\n")
1288
-            .arg(map->object_events_label)
1289
-            .arg(map->warps_label)
1290
-            .arg(map->coord_events_label)
1291
-            .arg(map->bg_events_label);
1245
+            .arg(objectEventsLabel)
1246
+            .arg(warpEventsLabel)
1247
+            .arg(coordEventsLabel)
1248
+            .arg(bgEventsLabel);
1292 1249
 
1293 1250
     saveTextFile(path, text);
1294 1251
 }
@@ -1306,13 +1263,13 @@ void Project::readMapEvents(Map *map) {
1306 1263
     }
1307 1264
 
1308 1265
     QStringList *labels = getLabelValues(parseAsm(text), map->events_label);
1309
-    map->object_events_label = labels->value(0);
1310
-    map->warps_label = labels->value(1);
1311
-    map->coord_events_label = labels->value(2);
1312
-    map->bg_events_label = labels->value(3);
1266
+    QString objectEventsLabel = labels->value(0);
1267
+    QString warpEventsLabel = labels->value(1);
1268
+    QString coordEventsLabel = labels->value(2);
1269
+    QString bgEventsLabel = labels->value(3);
1313 1270
 
1314
-    QList<QStringList> *object_events = getLabelMacros(parseAsm(text), map->object_events_label);
1315
-    map->events["object"].clear();
1271
+    QList<QStringList> *object_events = getLabelMacros(parseAsm(text), objectEventsLabel);
1272
+    map->events["object_event_group"].clear();
1316 1273
     for (QStringList command : *object_events) {
1317 1274
         if (command.value(0) == "object_event") {
1318 1275
             Event *object = new Event;
@@ -1326,18 +1283,18 @@ void Project::readMapEvents(Map *map) {
1326 1283
             object->put("behavior", command.value(i++));
1327 1284
             object->put("radius_x", command.value(i++).toInt(nullptr, 0));
1328 1285
             object->put("radius_y", command.value(i++).toInt(nullptr, 0));
1329
-            object->put("property", command.value(i++));
1330
-            object->put("sight_radius", command.value(i++));
1286
+            object->put("trainer_see_type", command.value(i++));
1287
+            object->put("sight_radius_tree_id", command.value(i++));
1331 1288
             object->put("script_label", command.value(i++));
1332 1289
             object->put("event_flag", command.value(i++));
1333
-
1334
-            object->put("event_type", "object");
1335
-            map->events["object"].append(object);
1290
+            object->put("event_group_type", "object_event_group");
1291
+            object->put("event_type", EventType::Object);
1292
+            map->events["object_event_group"].append(object);
1336 1293
         }
1337 1294
     }
1338 1295
 
1339
-    QList<QStringList> *warps = getLabelMacros(parseAsm(text), map->warps_label);
1340
-    map->events["warp"].clear();
1296
+    QList<QStringList> *warps = getLabelMacros(parseAsm(text), warpEventsLabel);
1297
+    map->events["warp_event_group"].clear();
1341 1298
     for (QStringList command : *warps) {
1342 1299
         if (command.value(0) == "warp_def") {
1343 1300
             Event *warp = new Event;
@@ -1352,17 +1309,17 @@ void Project::readMapEvents(Map *map) {
1352 1309
             QString mapConstant = command.value(i++);
1353 1310
             if (mapConstantsToMapNames->contains(mapConstant)) {
1354 1311
                 warp->put("destination_map_name", mapConstantsToMapNames->value(mapConstant));
1355
-                warp->put("event_type", "warp");
1356
-                map->events["warp"].append(warp);
1312
+                warp->put("event_group_type", "warp_event_group");
1313
+                warp->put("event_type", EventType::Warp);
1314
+                map->events["warp_event_group"].append(warp);
1357 1315
             } else {
1358 1316
                 qDebug() << QString("Destination map constant '%1' is invalid for warp").arg(mapConstant);
1359 1317
             }
1360 1318
         }
1361 1319
     }
1362 1320
 
1363
-    QList<QStringList> *coords = getLabelMacros(parseAsm(text), map->coord_events_label);
1364
-    map->events["trap"].clear();
1365
-    map->events["trap_weather"].clear();
1321
+    QList<QStringList> *coords = getLabelMacros(parseAsm(text), coordEventsLabel);
1322
+    map->events["coord_event_group"].clear();
1366 1323
     for (QStringList command : *coords) {
1367 1324
         if (command.value(0) == "coord_event") {
1368 1325
             Event *coord = new Event;
@@ -1383,8 +1340,9 @@ void Project::readMapEvents(Map *map) {
1383 1340
             //coord_unknown3
1384 1341
             //coord_unknown4
1385 1342
 
1386
-            coord->put("event_type", "trap");
1387
-            map->events["trap"].append(coord);
1343
+            coord->put("event_group_type", "coord_event_group");
1344
+            coord->put("event_type", EventType::CoordScript);
1345
+            map->events["coord_event_group"].append(coord);
1388 1346
         } else if (command.value(0) == "coord_weather_event") {
1389 1347
             Event *coord = new Event;
1390 1348
             coord->put("map_name", map->name);
@@ -1393,15 +1351,14 @@ void Project::readMapEvents(Map *map) {
1393 1351
             coord->put("y", command.value(i++));
1394 1352
             coord->put("elevation", command.value(i++));
1395 1353
             coord->put("weather", command.value(i++));
1396
-            coord->put("event_type", "trap_weather");
1397
-            map->events["trap_weather"].append(coord);
1354
+            coord->put("event_group_type", "coord_event_group");
1355
+            coord->put("event_type", EventType::CoordWeather);
1356
+            map->events["coord_event_group"].append(coord);
1398 1357
         }
1399 1358
     }
1400 1359
 
1401
-    QList<QStringList> *bgs = getLabelMacros(parseAsm(text), map->bg_events_label);
1402
-    map->events["sign"].clear();
1403
-    map->events["event_hidden_item"].clear();
1404
-    map->events["event_secret_base"].clear();
1360
+    QList<QStringList> *bgs = getLabelMacros(parseAsm(text), bgEventsLabel);
1361
+    map->events["bg_event_group"].clear();
1405 1362
     for (QStringList command : *bgs) {
1406 1363
         if (command.value(0) == "bg_event") {
1407 1364
             Event *bg = new Event;
@@ -1410,12 +1367,13 @@ void Project::readMapEvents(Map *map) {
1410 1367
             bg->put("x", command.value(i++));
1411 1368
             bg->put("y", command.value(i++));
1412 1369
             bg->put("elevation", command.value(i++));
1413
-            bg->put("type", command.value(i++));
1370
+            bg->put("player_facing_direction", command.value(i++));
1414 1371
             i++;
1415 1372
             bg->put("script_label", command.value(i++));
1416 1373
             //sign_unknown7
1417
-            bg->put("event_type", "sign");
1418
-            map->events["sign"].append(bg);
1374
+            bg->put("event_group_type", "bg_event_group");
1375
+            bg->put("event_type", EventType::Sign);
1376
+            map->events["bg_event_group"].append(bg);
1419 1377
         } else if (command.value(0) == "bg_hidden_item_event") {
1420 1378
             Event *bg = new Event;
1421 1379
             bg->put("map_name", map->name);
@@ -1425,8 +1383,9 @@ void Project::readMapEvents(Map *map) {
1425 1383
             bg->put("elevation", command.value(i++));
1426 1384
             bg->put("item", command.value(i++));
1427 1385
             bg->put("flag", command.value(i++));
1428
-            bg->put("event_type", "event_hidden_item");
1429
-            map->events["event_hidden_item"].append(bg);
1386
+            bg->put("event_group_type", "bg_event_group");
1387
+            bg->put("event_type", EventType::HiddenItem);
1388
+            map->events["bg_event_group"].append(bg);
1430 1389
         } else if (command.value(0) == "bg_secret_base_event") {
1431 1390
             Event *bg = new Event;
1432 1391
             bg->put("map_name", map->name);
@@ -1435,24 +1394,18 @@ void Project::readMapEvents(Map *map) {
1435 1394
             bg->put("y", command.value(i++));
1436 1395
             bg->put("elevation", command.value(i++));
1437 1396
             bg->put("secret_base_map", command.value(i++));
1438
-            bg->put("event_type", "event_secret_base");
1439
-            map->events["event_secret_base"].append(bg);
1397
+            bg->put("event_group_type", "bg_event_group");
1398
+            bg->put("event_type", EventType::SecretBase);
1399
+            map->events["bg_event_group"].append(bg);
1440 1400
         }
1441 1401
     }
1442 1402
 }
1443 1403
 
1444 1404
 void Project::setNewMapEvents(Map *map) {
1445
-    map->object_events_label = "0x0";
1446
-    map->warps_label = "0x0";
1447
-    map->coord_events_label = "0x0";
1448
-    map->bg_events_label = "0x0";
1449
-    map->events["object"].clear();
1450
-    map->events["warp"].clear();
1451
-    map->events["trap"].clear();
1452
-    map->events["trap_weather"].clear();
1453
-    map->events["sign"].clear();
1454
-    map->events["event_hidden_item"].clear();
1455
-    map->events["event_secret_base"].clear();
1405
+    map->events["object_event_group"].clear();
1406
+    map->events["warp_event_group"].clear();
1407
+    map->events["coord_event_group"].clear();
1408
+    map->events["bg_event_group"].clear();
1456 1409
 }
1457 1410
 
1458 1411
 QStringList Project::readCArray(QString text, QString label) {