Browse Source

Save map groups file

Marcus Huderle 6 years ago
parent
commit
17e5892cd4
2 changed files with 25 additions and 1 deletions
  1. 24
    1
      project.cpp
  2. 1
    0
      project.h

+ 24
- 1
project.cpp View File

466
     mapAttributes->insert(map->name, attrs);
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
 void Project::getTilesets(Map* map) {
491
 void Project::getTilesets(Map* map) {
470
     map->tileset_primary = getTileset(map->tileset_primary_label);
492
     map->tileset_primary = getTileset(map->tileset_primary_label);
471
     map->tileset_secondary = getTileset(map->tileset_secondary_label);
493
     map->tileset_secondary = getTileset(map->tileset_secondary_label);
614
     saveMapHeader(map);
636
     saveMapHeader(map);
615
     saveBlockdata(map);
637
     saveBlockdata(map);
616
     saveMapEvents(map);
638
     saveMapEvents(map);
639
+    map->isPersistedToFile = true;
617
 }
640
 }
618
 
641
 
619
 void Project::saveAllDataStructures() {
642
 void Project::saveAllDataStructures() {
620
     saveMapAttributesTable();
643
     saveMapAttributesTable();
621
     saveAllMapAttributes();
644
     saveAllMapAttributes();
622
-    // TODO: saveMapGroupsTable();
645
+    saveMapGroupsTable();
623
 }
646
 }
624
 
647
 
625
 void Project::loadTilesetAssets(Tileset* tileset) {
648
 void Project::loadTilesetAssets(Tileset* tileset) {

+ 1
- 0
project.h View File

67
     void saveMap(Map*);
67
     void saveMap(Map*);
68
     void saveAllDataStructures();
68
     void saveAllDataStructures();
69
     void saveAllMapAttributes();
69
     void saveAllMapAttributes();
70
+    void saveMapGroupsTable();
70
 
71
 
71
     QList<QStringList>* parse(QString text);
72
     QList<QStringList>* parse(QString text);
72
     QStringList getSongNames();
73
     QStringList getSongNames();