Browse Source

Merge pull request #48 from huderlem/fixpath

'Map Object' -> 'Event Object'
yenatch 6 years ago
parent
commit
ddb832de0c
No account linked to committer's email address
5 changed files with 57 additions and 57 deletions
  1. 33
    33
      editor.cpp
  2. 7
    7
      editor.h
  3. 3
    3
      mainwindow.cpp
  4. 12
    12
      project.cpp
  5. 2
    2
      project.h

+ 33
- 33
editor.cpp View File

47
     if (collision_item) {
47
     if (collision_item) {
48
         collision_item->setVisible(false);
48
         collision_item->setVisible(false);
49
     }
49
     }
50
-    if (objects_group) {
51
-        objects_group->setVisible(false);
50
+    if (events_group) {
51
+        events_group->setVisible(false);
52
     }
52
     }
53
     setBorderItemsVisible(true);
53
     setBorderItemsVisible(true);
54
     setConnectionItemsVisible(false);
54
     setConnectionItemsVisible(false);
64
     if (map_item) {
64
     if (map_item) {
65
         map_item->setVisible(false);
65
         map_item->setVisible(false);
66
     }
66
     }
67
-    if (objects_group) {
68
-        objects_group->setVisible(false);
67
+    if (events_group) {
68
+        events_group->setVisible(false);
69
     }
69
     }
70
     setBorderItemsVisible(true);
70
     setBorderItemsVisible(true);
71
     setConnectionItemsVisible(false);
71
     setConnectionItemsVisible(false);
73
 
73
 
74
 void Editor::setEditingObjects() {
74
 void Editor::setEditingObjects() {
75
     current_view = map_item;
75
     current_view = map_item;
76
-    if (objects_group) {
77
-        objects_group->setVisible(true);
76
+    if (events_group) {
77
+        events_group->setVisible(true);
78
     }
78
     }
79
     if (map_item) {
79
     if (map_item) {
80
         map_item->setVisible(true);
80
         map_item->setVisible(true);
108
     if (collision_item) {
108
     if (collision_item) {
109
         collision_item->setVisible(false);
109
         collision_item->setVisible(false);
110
     }
110
     }
111
-    if (objects_group) {
112
-        objects_group->setVisible(false);
111
+    if (events_group) {
112
+        events_group->setVisible(false);
113
     }
113
     }
114
     setBorderItemsVisible(true, 0.4);
114
     setBorderItemsVisible(true, 0.4);
115
     setConnectionItemsVisible(true);
115
     setConnectionItemsVisible(true);
315
         map = project->loadMap(map_name);
315
         map = project->loadMap(map_name);
316
         displayMap();
316
         displayMap();
317
         selected_events->clear();
317
         selected_events->clear();
318
-        updateSelectedObjects();
318
+        updateSelectedEvents();
319
     }
319
     }
320
 }
320
 }
321
 
321
 
359
     collision_item->draw();
359
     collision_item->draw();
360
     scene->addItem(collision_item);
360
     scene->addItem(collision_item);
361
 
361
 
362
-    objects_group = new EventGroup;
363
-    scene->addItem(objects_group);
362
+    events_group = new EventGroup;
363
+    scene->addItem(events_group);
364
 
364
 
365
     if (map_item) {
365
     if (map_item) {
366
         map_item->setVisible(false);
366
         map_item->setVisible(false);
368
     if (collision_item) {
368
     if (collision_item) {
369
         collision_item->setVisible(false);
369
         collision_item->setVisible(false);
370
     }
370
     }
371
-    if (objects_group) {
372
-        objects_group->setVisible(false);
371
+    if (events_group) {
372
+        events_group->setVisible(false);
373
     }
373
     }
374
 
374
 
375
     int tw = 16;
375
     int tw = 16;
384
     displayMetatiles();
384
     displayMetatiles();
385
     displayCollisionMetatiles();
385
     displayCollisionMetatiles();
386
     displayElevationMetatiles();
386
     displayElevationMetatiles();
387
-    displayMapObjects();
387
+    displayMapEvents();
388
     displayMapConnections();
388
     displayMapConnections();
389
     displayMapBorder();
389
     displayMapBorder();
390
     displayMapGrid();
390
     displayMapGrid();
411
     scene_elevation_metatiles->addItem(elevation_metatiles_item);
411
     scene_elevation_metatiles->addItem(elevation_metatiles_item);
412
 }
412
 }
413
 
413
 
414
-void Editor::displayMapObjects() {
415
-    for (QGraphicsItem *child : objects_group->childItems()) {
416
-        objects_group->removeFromGroup(child);
414
+void Editor::displayMapEvents() {
415
+    for (QGraphicsItem *child : events_group->childItems()) {
416
+        events_group->removeFromGroup(child);
417
     }
417
     }
418
 
418
 
419
     QList<Event *> events = map->getAllEvents();
419
     QList<Event *> events = map->getAllEvents();
420
-    project->loadObjectPixmaps(events);
420
+    project->loadEventPixmaps(events);
421
     for (Event *event : events) {
421
     for (Event *event : events) {
422
-        addMapObject(event);
422
+        addMapEvent(event);
423
     }
423
     }
424
     //objects_group->setFiltersChildEvents(false);
424
     //objects_group->setFiltersChildEvents(false);
425
-    objects_group->setHandlesChildEvents(false);
425
+    events_group->setHandlesChildEvents(false);
426
 
426
 
427
     emit objectsChanged();
427
     emit objectsChanged();
428
 }
428
 }
429
 
429
 
430
-DraggablePixmapItem *Editor::addMapObject(Event *event) {
430
+DraggablePixmapItem *Editor::addMapEvent(Event *event) {
431
     DraggablePixmapItem *object = new DraggablePixmapItem(event);
431
     DraggablePixmapItem *object = new DraggablePixmapItem(event);
432
     object->editor = this;
432
     object->editor = this;
433
-    objects_group->addToGroup(object);
433
+    events_group->addToGroup(object);
434
     return object;
434
     return object;
435
 }
435
 }
436
 
436
 
1236
 
1236
 
1237
 void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouse) {
1237
 void DraggablePixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouse) {
1238
     if (clicking) {
1238
     if (clicking) {
1239
-        this->editor->selectMapObject(this, mouse->modifiers() & Qt::ControlModifier);
1240
-        this->editor->updateSelectedObjects();
1239
+        this->editor->selectMapEvent(this, mouse->modifiers() & Qt::ControlModifier);
1240
+        this->editor->updateSelectedEvents();
1241
     }
1241
     }
1242
     active = false;
1242
     active = false;
1243
 }
1243
 }
1245
 QList<DraggablePixmapItem *> *Editor::getObjects() {
1245
 QList<DraggablePixmapItem *> *Editor::getObjects() {
1246
     QList<DraggablePixmapItem *> *list = new QList<DraggablePixmapItem *>;
1246
     QList<DraggablePixmapItem *> *list = new QList<DraggablePixmapItem *>;
1247
     for (Event *event : map->getAllEvents()) {
1247
     for (Event *event : map->getAllEvents()) {
1248
-        for (QGraphicsItem *child : objects_group->childItems()) {
1248
+        for (QGraphicsItem *child : events_group->childItems()) {
1249
             DraggablePixmapItem *item = (DraggablePixmapItem *)child;
1249
             DraggablePixmapItem *item = (DraggablePixmapItem *)child;
1250
             if (item->event == event) {
1250
             if (item->event == event) {
1251
                 list->append(item);
1251
                 list->append(item);
1270
     }
1270
     }
1271
 }
1271
 }
1272
 
1272
 
1273
-void Editor::updateSelectedObjects() {
1273
+void Editor::updateSelectedEvents() {
1274
     for (DraggablePixmapItem *item : *(getObjects())) {
1274
     for (DraggablePixmapItem *item : *(getObjects())) {
1275
         redrawObject(item);
1275
         redrawObject(item);
1276
     }
1276
     }
1277
     emit selectedObjectsChanged();
1277
     emit selectedObjectsChanged();
1278
 }
1278
 }
1279
 
1279
 
1280
-void Editor::selectMapObject(DraggablePixmapItem *object) {
1281
-    selectMapObject(object, false);
1280
+void Editor::selectMapEvent(DraggablePixmapItem *object) {
1281
+    selectMapEvent(object, false);
1282
 }
1282
 }
1283
 
1283
 
1284
-void Editor::selectMapObject(DraggablePixmapItem *object, bool toggle) {
1284
+void Editor::selectMapEvent(DraggablePixmapItem *object, bool toggle) {
1285
     if (selected_events && object) {
1285
     if (selected_events && object) {
1286
         if (selected_events->contains(object)) {
1286
         if (selected_events->contains(object)) {
1287
             if (toggle) {
1287
             if (toggle) {
1293
             }
1293
             }
1294
             selected_events->append(object);
1294
             selected_events->append(object);
1295
         }
1295
         }
1296
-        updateSelectedObjects();
1296
+        updateSelectedEvents();
1297
     }
1297
     }
1298
 }
1298
 }
1299
 
1299
 
1307
         event->put("map_name", map->name);
1307
         event->put("map_name", map->name);
1308
         event->put("event_type", event_type);
1308
         event->put("event_type", event_type);
1309
         map->addEvent(event);
1309
         map->addEvent(event);
1310
-        project->loadObjectPixmaps(map->getAllEvents());
1311
-        DraggablePixmapItem *object = addMapObject(event);
1310
+        project->loadEventPixmaps(map->getAllEvents());
1311
+        DraggablePixmapItem *object = addMapEvent(event);
1312
 
1312
 
1313
         return object;
1313
         return object;
1314
     }
1314
     }
1354
                 }
1354
                 }
1355
                 if (deselect) {
1355
                 if (deselect) {
1356
                     selected_events->clear();
1356
                     selected_events->clear();
1357
-                    updateSelectedObjects();
1357
+                    updateSelectedEvents();
1358
                 }
1358
                 }
1359
             }
1359
             }
1360
         }
1360
         }

+ 7
- 7
editor.h View File

38
     void displayMetatiles();
38
     void displayMetatiles();
39
     void displayCollisionMetatiles();
39
     void displayCollisionMetatiles();
40
     void displayElevationMetatiles();
40
     void displayElevationMetatiles();
41
-    void displayMapObjects();
41
+    void displayMapEvents();
42
     void displayMapConnections();
42
     void displayMapConnections();
43
     void displayMapBorder();
43
     void displayMapBorder();
44
     void displayMapGrid();
44
     void displayMapGrid();
58
     void updateEmergeMap(QString mapName);
58
     void updateEmergeMap(QString mapName);
59
     void setSelectedConnectionFromMap(QString mapName);
59
     void setSelectedConnectionFromMap(QString mapName);
60
 
60
 
61
-    DraggablePixmapItem *addMapObject(Event *event);
62
-    void selectMapObject(DraggablePixmapItem *object);
63
-    void selectMapObject(DraggablePixmapItem *object, bool toggle);
61
+    DraggablePixmapItem *addMapEvent(Event *event);
62
+    void selectMapEvent(DraggablePixmapItem *object);
63
+    void selectMapEvent(DraggablePixmapItem *object, bool toggle);
64
     DraggablePixmapItem *addNewEvent();
64
     DraggablePixmapItem *addNewEvent();
65
     DraggablePixmapItem *addNewEvent(QString event_type);
65
     DraggablePixmapItem *addNewEvent(QString event_type);
66
     void deleteEvent(Event *);
66
     void deleteEvent(Event *);
67
-    void updateSelectedObjects();
67
+    void updateSelectedEvents();
68
     void redrawObject(DraggablePixmapItem *item);
68
     void redrawObject(DraggablePixmapItem *item);
69
     QList<DraggablePixmapItem *> *getObjects();
69
     QList<DraggablePixmapItem *> *getObjects();
70
 
70
 
74
     ConnectionPixmapItem* selected_connection_item = NULL;
74
     ConnectionPixmapItem* selected_connection_item = NULL;
75
     QList<ConnectionPixmapItem*> connection_edit_items;
75
     QList<ConnectionPixmapItem*> connection_edit_items;
76
     CollisionPixmapItem *collision_item = NULL;
76
     CollisionPixmapItem *collision_item = NULL;
77
-    QGraphicsItemGroup *objects_group = NULL;
77
+    QGraphicsItemGroup *events_group = NULL;
78
     QList<QGraphicsPixmapItem*> borderItems;
78
     QList<QGraphicsPixmapItem*> borderItems;
79
 
79
 
80
     QGraphicsScene *scene_metatiles = NULL;
80
     QGraphicsScene *scene_metatiles = NULL;
161
         QList<Event*> objects;
161
         QList<Event*> objects;
162
         objects.append(event);
162
         objects.append(event);
163
         event->pixmap = QPixmap();
163
         event->pixmap = QPixmap();
164
-        editor->project->loadObjectPixmaps(objects);
164
+        editor->project->loadEventPixmaps(objects);
165
         editor->redrawObject(this);
165
         editor->redrawObject(this);
166
         emit spriteChanged(event->pixmap);
166
         emit spriteChanged(event->pixmap);
167
     }
167
     }

+ 3
- 3
mainwindow.cpp View File

509
         DraggablePixmapItem *object = editor->addNewEvent();
509
         DraggablePixmapItem *object = editor->addNewEvent();
510
         if (object) {
510
         if (object) {
511
             //if (editor->selected_events->length()) {
511
             //if (editor->selected_events->length()) {
512
-                editor->selectMapObject(object, true);
512
+                editor->selectMapEvent(object, true);
513
             //}
513
             //}
514
         }
514
         }
515
         updateSelectedObjects();
515
         updateSelectedObjects();
526
         events = editor->selected_events;
526
         events = editor->selected_events;
527
     }
527
     }
528
 
528
 
529
-    QMap<QString, int> map_obj_gfx_constants = editor->project->getMapObjGfxConstants();
529
+    QMap<QString, int> event_obj_gfx_constants = editor->project->getEventObjGfxConstants();
530
 
530
 
531
     QList<ObjectPropertiesFrame *> frames;
531
     QList<ObjectPropertiesFrame *> frames;
532
 
532
 
593
         if (event_type == "object") {
593
         if (event_type == "object") {
594
 
594
 
595
             frame->ui->sprite->setVisible(true);
595
             frame->ui->sprite->setVisible(true);
596
-            frame->ui->comboBox_sprite->addItems(map_obj_gfx_constants.keys());
596
+            frame->ui->comboBox_sprite->addItems(event_obj_gfx_constants.keys());
597
             frame->ui->comboBox_sprite->setCurrentText(item->event->get("sprite"));
597
             frame->ui->comboBox_sprite->setCurrentText(item->event->get("sprite"));
598
             connect(frame->ui->comboBox_sprite, SIGNAL(activated(QString)), item, SLOT(set_sprite(QString)));
598
             connect(frame->ui->comboBox_sprite, SIGNAL(activated(QString)), item, SLOT(set_sprite(QString)));
599
 
599
 

+ 12
- 12
project.cpp View File

1207
     return names;
1207
     return names;
1208
 }
1208
 }
1209
 
1209
 
1210
-QMap<QString, int> Project::getMapObjGfxConstants() {
1210
+QMap<QString, int> Project::getEventObjGfxConstants() {
1211
     QMap<QString, int> constants;
1211
     QMap<QString, int> constants;
1212
-    QString text = readTextFile(root + "/include/constants/map_objects.h");
1212
+    QString text = readTextFile(root + "/include/constants/event_objects.h");
1213
     if (!text.isNull()) {
1213
     if (!text.isNull()) {
1214
-        QStringList mapObjGfxPrefixes;
1215
-        mapObjGfxPrefixes << "MAP_OBJ_GFX_";
1216
-        constants = readCDefines(text, mapObjGfxPrefixes);
1214
+        QStringList eventObjGfxPrefixes;
1215
+        eventObjGfxPrefixes << "EVENT_OBJ_GFX_";
1216
+        constants = readCDefines(text, eventObjGfxPrefixes);
1217
     }
1217
     }
1218
     return constants;
1218
     return constants;
1219
 }
1219
 }
1224
     return path;
1224
     return path;
1225
 }
1225
 }
1226
 
1226
 
1227
-void Project::loadObjectPixmaps(QList<Event*> objects) {
1227
+void Project::loadEventPixmaps(QList<Event*> objects) {
1228
     bool needs_update = false;
1228
     bool needs_update = false;
1229
     for (Event *object : objects) {
1229
     for (Event *object : objects) {
1230
         if (object->pixmap.isNull()) {
1230
         if (object->pixmap.isNull()) {
1236
         return;
1236
         return;
1237
     }
1237
     }
1238
 
1238
 
1239
-    QMap<QString, int> constants = getMapObjGfxConstants();
1239
+    QMap<QString, int> constants = getEventObjGfxConstants();
1240
 
1240
 
1241
-    QString pointers_text = readTextFile(root + "/src/data/field_map_obj/map_object_graphics_info_pointers.h");
1242
-    QString info_text = readTextFile(root + "/src/data/field_map_obj/map_object_graphics_info.h");
1243
-    QString pic_text = readTextFile(root + "/src/data/field_map_obj/map_object_pic_tables.h");
1244
-    QString assets_text = readTextFile(root + "/src/event_object_movement.c");
1241
+    QString pointers_text = readTextFile(root + "/src/data/field_event_obj/event_object_graphics_info_pointers.h");
1242
+    QString info_text = readTextFile(root + "/src/data/field_event_obj/event_object_graphics_info.h");
1243
+    QString pic_text = readTextFile(root + "/src/data/field_event_obj/event_object_pic_tables.h");
1244
+    QString assets_text = readTextFile(root + "/src/data/field_event_obj/event_object_graphics.h");
1245
 
1245
 
1246
-    QStringList pointers = readCArray(pointers_text, "gMapObjectGraphicsInfoPointers");
1246
+    QStringList pointers = readCArray(pointers_text, "gEventObjectGraphicsInfoPointers");
1247
 
1247
 
1248
     for (Event *object : objects) {
1248
     for (Event *object : objects) {
1249
         if (!object->pixmap.isNull()) {
1249
         if (!object->pixmap.isNull()) {

+ 2
- 2
project.h View File

81
     void readFlagNames();
81
     void readFlagNames();
82
     void readVarNames();
82
     void readVarNames();
83
 
83
 
84
-    void loadObjectPixmaps(QList<Event*> objects);
85
-    QMap<QString, int> getMapObjGfxConstants();
84
+    void loadEventPixmaps(QList<Event*> objects);
85
+    QMap<QString, int> getEventObjGfxConstants();
86
     QString fixGraphicPath(QString path);
86
     QString fixGraphicPath(QString path);
87
 
87
 
88
     void readMapEvents(Map *map);
88
     void readMapEvents(Map *map);