mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Fixed pencil not always erasing with right click in TileMap editor + fixed crash when erasing outside the map or floodfilling with the same tile as the clicked one.
This commit is contained in:
@@ -89,10 +89,14 @@ public:
|
||||
|
||||
virtual bool Do()
|
||||
{
|
||||
if (m_col < 0 || m_col >= m_tileMap.GetColumnsCount() || m_row < 0 || m_row >= m_tileMap.GetRowsCount())
|
||||
return true; //Out of bound position.
|
||||
|
||||
m_tileChanged.clear();
|
||||
m_oldTileId = m_tileMap.GetTile(m_layer, m_col, m_row);
|
||||
|
||||
FloodFill(m_col, m_row);
|
||||
if (m_newTileId != m_oldTileId) //Beware, flood fill will loop forever if replacing a tile with the same!
|
||||
FloodFill(m_col, m_row);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -73,9 +73,9 @@ void TileMapPanel::FillLayer(int layer, int tile)
|
||||
if(!m_tilemap)
|
||||
return;
|
||||
|
||||
for (int col = 0; col < m_tilemap->GetColumnsCount(); col++)
|
||||
for (unsigned int col = 0; col < m_tilemap->GetColumnsCount(); col++)
|
||||
{
|
||||
for (int row = 0; row < m_tilemap->GetRowsCount(); row++)
|
||||
for (unsigned int row = 0; row < m_tilemap->GetRowsCount(); row++)
|
||||
{
|
||||
m_tilemap->SetTile(layer, col, row, tile);
|
||||
}
|
||||
@@ -200,7 +200,7 @@ void TileMapPanel::OnMouseEvent(wxMouseEvent &event)
|
||||
return;
|
||||
|
||||
//Get the current tile position (column and row)
|
||||
int currentColumn, currentRow;
|
||||
unsigned int currentColumn, currentRow;
|
||||
wxPoint mousePos = CalcUnscrolledPosition(event.GetPosition());
|
||||
GetTileAt(mousePos, currentColumn, currentRow);
|
||||
|
||||
@@ -221,8 +221,7 @@ void TileMapPanel::OnMouseEvent(wxMouseEvent &event)
|
||||
else if(event.RightIsDown())
|
||||
{
|
||||
//Remove the tile
|
||||
if(m_tilemap->GetTile(m_mapCurrentLayer, currentColumn, currentRow) != m_tileToBeInserted)
|
||||
m_commandProcessor.Submit(new ChangeTileCommand(*m_tilemap, m_mapCurrentLayer, currentColumn, currentRow, -1));
|
||||
m_commandProcessor.Submit(new ChangeTileCommand(*m_tilemap, m_mapCurrentLayer, currentColumn, currentRow, -1));
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
@@ -288,7 +287,7 @@ wxPoint TileMapPanel::GetPositionOfTile(int column, int row)
|
||||
return wxPoint(column *(m_tileset->tileSize.x), row * (m_tileset->tileSize.y));
|
||||
}
|
||||
|
||||
void TileMapPanel::GetTileAt(wxPoint position, int &tileCol, int &tileRow)
|
||||
void TileMapPanel::GetTileAt(wxPoint position, unsigned int &tileCol, unsigned int &tileRow)
|
||||
{
|
||||
tileCol = (int)(position.x / m_tileset->tileSize.x);
|
||||
tileRow = (int)(position.y / m_tileset->tileSize.y);
|
||||
|
@@ -94,7 +94,7 @@ protected:
|
||||
|
||||
private:
|
||||
wxPoint GetPositionOfTile(int column, int row);
|
||||
void GetTileAt(wxPoint position, int &tileCol, int &tileRow);
|
||||
void GetTileAt(wxPoint position, unsigned int &tileCol, unsigned int &tileRow);
|
||||
|
||||
//Tile to be inserted
|
||||
int m_tileToBeInserted;
|
||||
@@ -108,10 +108,10 @@ private:
|
||||
|
||||
//Some parameters for the Rectangle Mode
|
||||
bool m_isDrawingRectangle;
|
||||
int m_beginCol;
|
||||
int m_beginRow;
|
||||
int m_endCol;
|
||||
int m_endRow;
|
||||
unsigned int m_beginCol;
|
||||
unsigned int m_beginRow;
|
||||
unsigned int m_endCol;
|
||||
unsigned int m_endRow;
|
||||
|
||||
//Command processor, to be able to undo/redo actions
|
||||
wxCommandProcessor m_commandProcessor;
|
||||
|
Reference in New Issue
Block a user