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
         values.insert(key, value);
39
         values.insert(key, value);
40
     }
40
     }
41
 
41
 
42
-    bool is_hidden_item() {
43
-        return getInt("type") >= 5;
44
-    }
45
-
46
     QMap<QString, QString> values;
42
     QMap<QString, QString> values;
47
     QPixmap pixmap;
43
     QPixmap pixmap;
48
 };
44
 };

+ 4
- 4
mainwindow.cpp View File

511
         field_labels["item"] = "Item";
511
         field_labels["item"] = "Item";
512
         field_labels["item_unknown5"] = "Unknown 5";
512
         field_labels["item_unknown5"] = "Unknown 5";
513
         field_labels["item_unknown6"] = "Unknown 6";
513
         field_labels["item_unknown6"] = "Unknown 6";
514
+        field_labels["weather"] = "Weather";
515
+        field_labels["flag"] = "Flag";
514
 
516
 
515
         QStringList fields;
517
         QStringList fields;
516
 
518
 
556
             fields << "type";
558
             fields << "type";
557
             fields << "script_label";
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
             fields << "item";
562
             fields << "item";
562
-            fields << "item_unknown5";
563
-            fields << "item_unknown6";
563
+            fields << "flag";
564
         }
564
         }
565
 
565
 
566
         for (QString key : fields) {
566
         for (QString key : fields) {

+ 21
- 24
project.cpp View File

667
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(16, 0, 16, 16);
667
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(16, 0, 16, 16);
668
         } else if (event_type == "trap" || event_type == "trap_weather") {
668
         } else if (event_type == "trap" || event_type == "trap_weather") {
669
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(32, 0, 16, 16);
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
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(48, 0, 16, 16);
671
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(48, 0, 16, 16);
672
         }
672
         }
673
 
673
 
768
         text += "\n";
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
         text += QString("%1::\n").arg(map->bg_events_label);
772
         text += QString("%1::\n").arg(map->bg_events_label);
773
         for (Event *sign : map->events["sign"]) {
773
         for (Event *sign : map->events["sign"]) {
774
             text += QString("\tbg_event %1").arg(sign->get("x"));
774
             text += QString("\tbg_event %1").arg(sign->get("x"));
779
             text += QString(", %1").arg(sign->get("script_label"));
779
             text += QString(", %1").arg(sign->get("script_label"));
780
             text += "\n";
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
             text += QString(", %1").arg(item->get("y"));
784
             text += QString(", %1").arg(item->get("y"));
785
             text += QString(", %1").arg(item->get("elevation"));
785
             text += QString(", %1").arg(item->get("elevation"));
786
-            text += QString(", %1").arg(item->get("type"));
787
-            text += QString(", 0");
788
             text += QString(", %1").arg(item->get("item"));
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
             text += "\n";
788
             text += "\n";
792
         }
789
         }
793
         text += "\n";
790
         text += "\n";
924
     }
921
     }
925
 
922
 
926
     QList<QStringList> *bgs = getLabelMacros(parse(text), map->bg_events_label);
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
     map->events["sign"].clear();
925
     map->events["sign"].clear();
929
     for (QStringList command : *bgs) {
926
     for (QStringList command : *bgs) {
930
         if (command.value(0) == "bg_event") {
927
         if (command.value(0) == "bg_event") {
936
             bg->put("elevation", command.value(i++));
933
             bg->put("elevation", command.value(i++));
937
             bg->put("type", command.value(i++));
934
             bg->put("type", command.value(i++));
938
             i++;
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
 QStringList Project::readCArray(QString text, QString label) {
955
 QStringList Project::readCArray(QString text, QString label) {