diff --git a/editor/src/CenterGrid.cpp b/editor/src/CenterGrid.cpp index f2e43a519420cf24ffdd9b4111be39b8a05f7e31..fbf246e309f3ff02d16a47145ce87b849ddc8702 100644 --- a/editor/src/CenterGrid.cpp +++ b/editor/src/CenterGrid.cpp @@ -92,6 +92,10 @@ void CenterGrid::onTileClicked(int row, int col) if (m_spriteType == 0) { m_tileIDs[row][col] = m_currentSpriteID; + if (std::find(m_doorIDList.begin(), m_doorIDList.end(), m_currentSpriteID) != m_doorIDList.end()) + { + m_objectIDs[row][col] = m_currentSpriteID; + } } else if (m_spriteType == 1) { diff --git a/editor/src/CenterGrid.hpp b/editor/src/CenterGrid.hpp index f1dcbbc9ed6f164e9e7eee9fa4ffbf258d4ef0e6..d322af12b43e34b6ac8098540b7d00bc8bc9e3e8 100644 --- a/editor/src/CenterGrid.hpp +++ b/editor/src/CenterGrid.hpp @@ -139,6 +139,11 @@ class CenterGrid : public QWidget 82, 83, 84, 85, 86, 87, 88, 89, 114, 115, 116, 117, 118, 119, 120, 121, 146, 147, 148, 149, 150, 151, 152, 153, 178, 179, 180, 181, 182, 183, 184, 185, 210, 211, 212, 213, 214, 215, 216, 242, 243, 244, 245, 246, 247, 248}; + + /** + * @brief List of all spriteIDs that are doors + */ + std::vector<int> m_doorIDList = {102,103,104,134,135,136,166,167,168,198,199}; }; } // namespace editor \ No newline at end of file diff --git a/editor/src/HDF5Handler.cpp b/editor/src/HDF5Handler.cpp index f5c02c865de1d7f3e9ad3ffc60d5f51e91a48a70..504163bee2d39c44cda6b64adbfbec0a886041a5 100644 --- a/editor/src/HDF5Handler.cpp +++ b/editor/src/HDF5Handler.cpp @@ -45,14 +45,14 @@ void HDF5Handler::saveRoom(int id, QString name, QVector<QVector<int>> tileIDs, { for (int col = 0; col < 64; col++) { - newRoom.placeTile({row, col}, tileIDs[row][col]); + newRoom.placeTile({col, row}, tileIDs[row][col]); if (mobIDs[row][col] != -1) { - newRoom.placeEnemy({row, col}, mobIDs[row][col]); + newRoom.placeEnemy({col, row}, mobIDs[row][col]); } if (objectIDs[row][col] != -1) { - newRoom.placeObject({row, col}, objectIDs[row][col]); + newRoom.placeObject({col, row}, objectIDs[row][col]); } } } diff --git a/editor/src/MainWindow.cpp b/editor/src/MainWindow.cpp index 5877dd0c9a2f72fc32b495b1871a2c17018f7ff1..161dd7555ea133df333966318ad78dac7bb38609 100644 --- a/editor/src/MainWindow.cpp +++ b/editor/src/MainWindow.cpp @@ -96,9 +96,9 @@ MainWindow::MainWindow(DialogSelection selected, const std::filesystem::path &pa int32_t tileID = *it; if (tileID != -1) { - std::size_t index = std::distance(foundRoom.tilesBegin(), it++); - int x = index % width; - int y = index / width; + std::size_t index = std::distance(foundRoom.tilesBegin(), it); + int y = index % width; + int x = index / width; m_centerGrid->setCurrentSprite(m_leftWidget->getPixmapByIndex(tileID), tileID); m_centerGrid->onTileClicked(x, y); } @@ -106,8 +106,8 @@ MainWindow::MainWindow(DialogSelection selected, const std::filesystem::path &pa for (auto it = foundRoom.objectsBegin(); it != foundRoom.objectsEnd(); it++) { lvl::Placement gameObject = *it; - int x = gameObject.position.x; - int y = gameObject.position.y; + int y = gameObject.position.x; + int x = gameObject.position.y; int tileID = gameObject.id; m_centerGrid->setCurrentSprite(m_leftWidget->getPixmapByIndex(tileID), tileID); m_centerGrid->onTileClicked(x, y); @@ -115,8 +115,8 @@ MainWindow::MainWindow(DialogSelection selected, const std::filesystem::path &pa for (auto it = foundRoom.enemiesBegin(); it != foundRoom.enemiesEnd(); it++) { lvl::Placement gameObject = *it; - int x = gameObject.position.x; - int y = gameObject.position.y; + int y = gameObject.position.x; + int x = gameObject.position.y; int tileID = gameObject.id; switch (tileID) {