summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-02-02 12:09:11 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-02-02 12:09:11 (GMT)
commit8024caec55ff1b93eefe50663d4ddf63934f8d63 (patch)
treebd9b2ade18eea618f2955d15e2e37bd4c77c09aa /src
parent6641f1d54196a2193b258d3e76e2cca6ad3258b1 (diff)
downloadpowder-8024caec55ff1b93eefe50663d4ddf63934f8d63.zip
powder-8024caec55ff1b93eefe50663d4ddf63934f8d63.tar.gz
Flood fill
Diffstat (limited to 'src')
-rw-r--r--src/game/GameController.cpp7
-rw-r--r--src/game/GameView.cpp2
-rw-r--r--src/game/Tool.h7
3 files changed, 14 insertions, 2 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index 5c8ed6f..7df654f 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -173,7 +173,12 @@ void GameController::DrawLine(int toolSelection, ui::Point point1, ui::Point poi
void GameController::DrawFill(int toolSelection, ui::Point point)
{
-
+ Simulation * sim = gameModel->GetSimulation();
+ Tool * activeTool = gameModel->GetActiveTool(toolSelection);
+ Brush * cBrush = gameModel->GetBrush();
+ if(!activeTool || !cBrush)
+ return;
+ activeTool->DrawFill(sim, cBrush, point);
}
void GameController::DrawPoints(int toolSelection, queue<ui::Point*> & pointQueue)
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 9e4a6dd..1336552 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -549,7 +549,7 @@ void GameView::OnTick(float dt)
c->DrawPoints(toolIndex, pointQueue);
}
}
- if(drawMode == DrawFill)
+ if(drawMode == DrawFill && isMouseDown)
{
c->DrawFill(toolIndex, currentMouse);
}
diff --git a/src/game/Tool.h b/src/game/Tool.h
index bffa967..00b1184 100644
--- a/src/game/Tool.h
+++ b/src/game/Tool.h
@@ -31,6 +31,7 @@ public:
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) {}
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {}
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {}
+ virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) {};
int colRed, colBlue, colGreen;
};
@@ -51,6 +52,9 @@ public:
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
sim->create_box(position1.X, position1.Y, position2.X, position2.Y, toolID, 0);
}
+ virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
+ sim->flood_parts(position.X, position.Y, toolID, -1, -1, 0);
+ }
};
class GolTool: public Tool
@@ -70,6 +74,9 @@ public:
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
sim->create_box(position1.X, position1.Y, position2.X, position2.Y, PT_LIFE|(toolID<<8), 0);
}
+ virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
+ sim->flood_parts(position.X, position.Y, PT_LIFE|(toolID<<8), -1, -1, 0);
+ }
};
#endif /* TOOL_H_ */