Skip to content
Snippets Groups Projects
Unverified Commit 13dce1b9 authored by Julian Dreuth's avatar Julian Dreuth Committed by Leon Lux
Browse files

Fix/editor doors

parent 4b1b4023
Branches
Tags
1 merge request!55Abgabe des Projektes
......@@ -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)
{
......
......@@ -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
......@@ -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]);
}
}
}
......
......@@ -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)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment