diff --git a/mainwindow.cpp b/mainwindow.cpp index ea3a571c..f74240f4 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -222,6 +222,12 @@ void MainWindow::displayMapProperties() { ui->comboBox_Location->addItems(project->getLocations()); ui->comboBox_Location->setCurrentText(map->location); + QMap tilesets = project->getTilesets(); + ui->comboBox_PrimaryTileset->addItems(tilesets.value("primary")); + ui->comboBox_PrimaryTileset->setCurrentText(map->layout->tileset_primary_label); + ui->comboBox_SecondaryTileset->addItems(tilesets.value("secondary")); + ui->comboBox_SecondaryTileset->setCurrentText(map->layout->tileset_secondary_label); + ui->comboBox_Visibility->addItems(project->getVisibilities()); ui->comboBox_Visibility->setCurrentText(map->visibility); diff --git a/mainwindow.ui b/mainwindow.ui index 8714f10d..77405325 100755 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -290,7 +290,7 @@ 0 0 - 475 + 436 621 @@ -451,9 +451,146 @@ 0 + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Primary Tileset + + + + + + + true + + + + + + + Secondary Tileset + + + + + + + true + + + + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Raised + + + + 6 + + + QLayout::SetDefaultConstraint + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Border + + + + + + + + 0 + 0 + + + + + 16777215 + 48 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + Qt::ScrollBarAsNeeded + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + - + 0 0 @@ -470,6 +607,9 @@ true + + Qt::AlignHCenter|Qt::AlignTop + true @@ -479,7 +619,7 @@ 0 0 358 - 612 + 497 @@ -488,7 +628,7 @@ 0 - + QLayout::SetDefaultConstraint @@ -504,97 +644,26 @@ 0 - - 0 - - - 8 - - - - - - 0 - 0 - + + + + Qt::Vertical - - QFrame::NoFrame + + + 20 + 40 + - - QFrame::Raised - - - - 6 - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - Border - - - - - - - - 0 - 0 - - - - - 16777215 - 48 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Qt::ScrollBarAsNeeded - - - - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 40 - 20 - - - - - - + - + true - + 0 0 @@ -610,6 +679,32 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + diff --git a/project.cpp b/project.cpp index 5422e0a2..98c2680b 100755 --- a/project.cpp +++ b/project.cpp @@ -354,7 +354,7 @@ void Project::readMapLayout(Map* map) { map->layout = mapLayouts[map->layout_label]; } - getTilesets(map); + getMapTilesets(map); loadBlockdata(map); loadMapBorder(map); } @@ -494,7 +494,7 @@ void Project::saveMapConstantsHeader() { saveTextFile(root + "/include/constants/maps.h", text); } -void Project::getTilesets(Map* map) { +void Project::getMapTilesets(Map* map) { if (map->layout->has_unsaved_changes) { return; } @@ -955,7 +955,7 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum) { mapNamesToMapConstants->insert(map->name, map->constantName); setNewMapHeader(map, mapLayoutsTable.size() + 1); setNewMapLayout(map); - getTilesets(map); + getMapTilesets(map); setNewMapBlockdata(map); setNewMapBorder(map); setNewMapEvents(map); @@ -1001,6 +1001,47 @@ QStringList Project::getVisibilities() { return names; } +QMap Project::getTilesets() { + QMap allTilesets; + QStringList primaryTilesets; + QStringList secondaryTilesets; + allTilesets.insert("primary", primaryTilesets); + allTilesets.insert("secondary", secondaryTilesets); + QString headers_text = readTextFile(root + "/data/tilesets/headers.inc"); + QList* commands = parseAsm(headers_text); + int i = 0; + while (i < commands->length()) { + if (commands->at(i).length() != 2) + continue; + + if (commands->at(i).at(0) == ".label") { + QString tilesetLabel = commands->at(i).at(1); + // Advance to command specifying whether or not it is a secondary tileset + i += 2; + if (commands->at(i).at(0) != ".byte") { + qDebug() << "Unexpected command found for secondary tileset flag. Expected '.byte', but found: " << commands->at(i).at(0); + continue; + } + + QString secondaryTilesetValue = commands->at(i).at(1); + if (secondaryTilesetValue != "TRUE" && secondaryTilesetValue != "FALSE" && secondaryTilesetValue != "0" && secondaryTilesetValue != "1") { + qDebug() << "Unexpected secondary tileset flag found. Expected \"TRUE\", \"FALSE\", \"0\", or \"1\", but found: " << secondaryTilesetValue; + continue; + } + + bool isSecondaryTileset = (secondaryTilesetValue == "TRUE" || secondaryTilesetValue == "1"); + if (isSecondaryTileset) + allTilesets["secondary"].append(tilesetLabel); + else + allTilesets["primary"].append(tilesetLabel); + } + + i++; + } + + return allTilesets; +} + QStringList Project::getWeathers() { // TODO QStringList names; diff --git a/project.h b/project.h index ca5a29d2..61996ac5 100755 --- a/project.h +++ b/project.h @@ -57,7 +57,7 @@ public: QStringList* readLayoutValues(QString layoutName); void readMapLayout(Map*); void readMapsWithConnections(); - void getTilesets(Map*); + void getMapTilesets(Map*); void loadTilesetAssets(Tileset*); void saveBlockdata(Map*); @@ -74,6 +74,7 @@ public: QStringList getSongNames(); QStringList getLocations(); QStringList getVisibilities(); + QMap getTilesets(); QStringList getWeathers(); QStringList getMapTypes(); QStringList getBattleScenes();