Bladeren bron

Save map groups file

Marcus Huderle 6 jaren geleden
bovenliggende
commit
17e5892cd4
2 gewijzigde bestanden met toevoegingen van 25 en 1 verwijderingen
  1. 24
    1
      project.cpp
  2. 1
    0
      project.h

+ 24
- 1
project.cpp Bestand weergeven

@@ -466,6 +466,28 @@ void Project::setNewMapAttributes(Map* map) {
466 466
     mapAttributes->insert(map->name, attrs);
467 467
 }
468 468
 
469
+void Project::saveMapGroupsTable() {
470
+    QString text = "";
471
+    int groupNum = 0;
472
+    for (QStringList* mapNames : *groupedMapNames) {
473
+        text += QString("\t.align 2\n");
474
+        text += QString("gMapGroup%1::\n").arg(groupNum);
475
+        for (QString mapName : *mapNames) {
476
+            text += QString("\t.4byte %1\n").arg(mapName);
477
+        }
478
+        text += QString("\n");
479
+        groupNum++;
480
+    }
481
+
482
+    text += QString("\t.align 2\n");
483
+    text += QString("gMapGroups::\n");
484
+    for (int i = 0; i < groupNum; i++) {
485
+        text += QString("\t.4byte gMapGroup%1\n").arg(i);
486
+    }
487
+
488
+    saveTextFile(root + "/data/maps/_groups.inc", text);
489
+}
490
+
469 491
 void Project::getTilesets(Map* map) {
470 492
     map->tileset_primary = getTileset(map->tileset_primary_label);
471 493
     map->tileset_secondary = getTileset(map->tileset_secondary_label);
@@ -614,12 +636,13 @@ void Project::saveMap(Map *map) {
614 636
     saveMapHeader(map);
615 637
     saveBlockdata(map);
616 638
     saveMapEvents(map);
639
+    map->isPersistedToFile = true;
617 640
 }
618 641
 
619 642
 void Project::saveAllDataStructures() {
620 643
     saveMapAttributesTable();
621 644
     saveAllMapAttributes();
622
-    // TODO: saveMapGroupsTable();
645
+    saveMapGroupsTable();
623 646
 }
624 647
 
625 648
 void Project::loadTilesetAssets(Tileset* tileset) {

+ 1
- 0
project.h Bestand weergeven

@@ -67,6 +67,7 @@ public:
67 67
     void saveMap(Map*);
68 68
     void saveAllDataStructures();
69 69
     void saveAllMapAttributes();
70
+    void saveMapGroupsTable();
70 71
 
71 72
     QList<QStringList>* parse(QString text);
72 73
     QStringList getSongNames();