Browse Source

Support bg_hidden_item_event

Marcus Huderle 6 years ago
parent
commit
c3d0769967
3 changed files with 25 additions and 32 deletions
  1. 0
    4
      event.h
  2. 4
    4
      mainwindow.cpp
  3. 21
    24
      project.cpp

+ 0
- 4
event.h View File

@@ -39,10 +39,6 @@ public:
39 39
         values.insert(key, value);
40 40
     }
41 41
 
42
-    bool is_hidden_item() {
43
-        return getInt("type") >= 5;
44
-    }
45
-
46 42
     QMap<QString, QString> values;
47 43
     QPixmap pixmap;
48 44
 };

+ 4
- 4
mainwindow.cpp View File

@@ -511,6 +511,8 @@ void MainWindow::updateSelectedObjects() {
511 511
         field_labels["item"] = "Item";
512 512
         field_labels["item_unknown5"] = "Unknown 5";
513 513
         field_labels["item_unknown6"] = "Unknown 6";
514
+        field_labels["weather"] = "Weather";
515
+        field_labels["flag"] = "Flag";
514 516
 
515 517
         QStringList fields;
516 518
 
@@ -556,11 +558,9 @@ void MainWindow::updateSelectedObjects() {
556 558
             fields << "type";
557 559
             fields << "script_label";
558 560
         }
559
-        else if (event_type == "hidden item") {
560
-            fields << "type";
561
+        else if (event_type == "event_hidden_item") {
561 562
             fields << "item";
562
-            fields << "item_unknown5";
563
-            fields << "item_unknown6";
563
+            fields << "flag";
564 564
         }
565 565
 
566 566
         for (QString key : fields) {

+ 21
- 24
project.cpp View File

@@ -667,7 +667,7 @@ void Project::loadObjectPixmaps(QList<Event*> objects) {
667 667
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(16, 0, 16, 16);
668 668
         } else if (event_type == "trap" || event_type == "trap_weather") {
669 669
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(32, 0, 16, 16);
670
-        } else if (event_type == "sign" || event_type == "hidden item") {
670
+        } else if (event_type == "sign" || event_type == "event_hidden_item") {
671 671
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(48, 0, 16, 16);
672 672
         }
673 673
 
@@ -768,7 +768,7 @@ void Project::saveMapEvents(Map *map) {
768 768
         text += "\n";
769 769
     }
770 770
 
771
-    if (map->events["sign"].length() + map->events["hidden item"].length() > 0) {
771
+    if (map->events["sign"].length() + map->events["event_hidden_item"].length() > 0) {
772 772
         text += QString("%1::\n").arg(map->bg_events_label);
773 773
         for (Event *sign : map->events["sign"]) {
774 774
             text += QString("\tbg_event %1").arg(sign->get("x"));
@@ -779,15 +779,12 @@ void Project::saveMapEvents(Map *map) {
779 779
             text += QString(", %1").arg(sign->get("script_label"));
780 780
             text += "\n";
781 781
         }
782
-        for (Event *item : map->events["hidden item"]) {
783
-            text += QString("\tbg_event %1").arg(item->get("x"));
782
+        for (Event *item : map->events["event_hidden_item"]) {
783
+            text += QString("\tbg_hidden_item_event %1").arg(item->get("x"));
784 784
             text += QString(", %1").arg(item->get("y"));
785 785
             text += QString(", %1").arg(item->get("elevation"));
786
-            text += QString(", %1").arg(item->get("type"));
787
-            text += QString(", 0");
788 786
             text += QString(", %1").arg(item->get("item"));
789
-            text += QString(", %1").arg(item->get("item_unknown5"));
790
-            text += QString(", %1").arg(item->get("item_unknown6"));
787
+            text += QString(", %1").arg(item->get("flag"));
791 788
             text += "\n";
792 789
         }
793 790
         text += "\n";
@@ -924,7 +921,7 @@ void Project::readMapEvents(Map *map) {
924 921
     }
925 922
 
926 923
     QList<QStringList> *bgs = getLabelMacros(parse(text), map->bg_events_label);
927
-    map->events["hidden item"].clear();
924
+    map->events["event_hidden_item"].clear();
928 925
     map->events["sign"].clear();
929 926
     for (QStringList command : *bgs) {
930 927
         if (command.value(0) == "bg_event") {
@@ -936,23 +933,23 @@ void Project::readMapEvents(Map *map) {
936 933
             bg->put("elevation", command.value(i++));
937 934
             bg->put("type", command.value(i++));
938 935
             i++;
939
-            if (bg->is_hidden_item()) {
940
-                bg->put("item", command.value(i++));
941
-                bg->put("item_unknown5", command.value(i++));
942
-                bg->put("item_unknown6", command.value(i++));
943
-
944
-                bg->put("event_type", "hidden item");
945
-                map->events["hidden item"].append(bg);
946
-            } else {
947
-                bg->put("script_label", command.value(i++));
948
-                //sign_unknown7
949
-
950
-                bg->put("event_type", "sign");
951
-                map->events["sign"].append(bg);
952
-            }
936
+            bg->put("script_label", command.value(i++));
937
+            //sign_unknown7
938
+            bg->put("event_type", "sign");
939
+            map->events["sign"].append(bg);
940
+        } else if (command.value(0) == "bg_hidden_item_event") {
941
+            Event *bg = new Event;
942
+            bg->put("map_name", map->name);
943
+            int i = 1;
944
+            bg->put("x", command.value(i++));
945
+            bg->put("y", command.value(i++));
946
+            bg->put("elevation", command.value(i++));
947
+            bg->put("item", command.value(i++));
948
+            bg->put("flag", command.value(i++));
949
+            bg->put("event_type", "event_hidden_item");
950
+            map->events["event_hidden_item"].append(bg);
953 951
         }
954 952
     }
955
-
956 953
 }
957 954
 
958 955
 QStringList Project::readCArray(QString text, QString label) {