Bladeren bron

Support coord_event_weather

Marcus Huderle 6 jaren geleden
bovenliggende
commit
22722f09c7
2 gewijzigde bestanden met toevoegingen van 23 en 2 verwijderingen
  1. 3
    0
      mainwindow.cpp
  2. 20
    2
      project.cpp

+ 3
- 0
mainwindow.cpp Bestand weergeven

@@ -549,6 +549,9 @@ void MainWindow::updateSelectedObjects() {
549 549
             fields << "coord_unknown1";
550 550
             fields << "coord_unknown2";
551 551
         }
552
+        else if (event_type == "trap_weather") {
553
+            fields << "weather";
554
+        }
552 555
         else if (event_type == "sign") {
553 556
             fields << "type";
554 557
             fields << "script_label";

+ 20
- 2
project.cpp Bestand weergeven

@@ -665,7 +665,7 @@ void Project::loadObjectPixmaps(QList<Event*> objects) {
665 665
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(0, 0, 16, 16);
666 666
         } else if (event_type == "warp") {
667 667
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(16, 0, 16, 16);
668
-        } else if (event_type == "trap") {
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 670
         } else if (event_type == "sign" || event_type == "hidden item") {
671 671
             object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(48, 0, 16, 16);
@@ -745,7 +745,7 @@ void Project::saveMapEvents(Map *map) {
745 745
         text += "\n";
746 746
     }
747 747
 
748
-    if (map->events["trap"].length() > 0) {
748
+    if (map->events["trap"].length() + map->events["trap_weather"].length() > 0) {
749 749
         text += QString("%1::\n").arg(map->coord_events_label);
750 750
         for (Event *coords : map->events["trap"]) {
751 751
             text += QString("\tcoord_event %1").arg(coords->get("x"));
@@ -758,6 +758,13 @@ void Project::saveMapEvents(Map *map) {
758 758
             text += QString(", %1").arg(coords->get("script_label"));
759 759
             text += "\n";
760 760
         }
761
+        for (Event *coords : map->events["trap_weather"]) {
762
+            text += QString("\tcoord_weather_event %1").arg(coords->get("x"));
763
+            text += QString(", %1").arg(coords->get("y"));
764
+            text += QString(", %1").arg(coords->get("elevation"));
765
+            text += QString(", %1").arg(coords->get("weather"));
766
+            text += "\n";
767
+        }
761 768
         text += "\n";
762 769
     }
763 770
 
@@ -880,6 +887,7 @@ void Project::readMapEvents(Map *map) {
880 887
 
881 888
     QList<QStringList> *coords = getLabelMacros(parse(text), map->coord_events_label);
882 889
     map->events["trap"].clear();
890
+    map->events["trap_weather"].clear();
883 891
     for (QStringList command : *coords) {
884 892
         if (command.value(0) == "coord_event") {
885 893
             Event *coord = new Event;
@@ -902,6 +910,16 @@ void Project::readMapEvents(Map *map) {
902 910
 
903 911
             coord->put("event_type", "trap");
904 912
             map->events["trap"].append(coord);
913
+        } else if (command.value(0) == "coord_weather_event") {
914
+            Event *coord = new Event;
915
+            coord->put("map_name", map->name);
916
+            int i = 1;
917
+            coord->put("x", command.value(i++));
918
+            coord->put("y", command.value(i++));
919
+            coord->put("elevation", command.value(i++));
920
+            coord->put("weather", command.value(i++));
921
+            coord->put("event_type", "trap_weather");
922
+            map->events["trap_weather"].append(coord);
905 923
         }
906 924
     }
907 925