void GameController::DrawLine(int toolSelection, ui::Point point1, ui::Point point2)
{
	Simulation * sim = gameModel->GetSimulation();
	Tool * activeTool = gameModel->GetActiveTool(toolSelection);
	gameModel->SetLastTool(activeTool);
	Brush * cBrush = gameModel->GetBrush();
	if(!activeTool || !cBrush)
		return;
	activeTool->SetStrength(gameModel->GetToolStrength());
	activeTool->DrawLine(sim, cBrush, point1, point2);
}
void GameController::DrawPoints(int toolSelection, ui::Point oldPos, ui::Point newPos, bool held)
{
    Simulation * sim = gameModel->GetSimulation();
    Tool * activeTool = gameModel->GetActiveTool(toolSelection);
    gameModel->SetLastTool(activeTool);
    Brush * cBrush = gameModel->GetBrush();
    if (!activeTool || !cBrush)
    {
        return;
    }

    activeTool->SetStrength(gameModel->GetToolStrength());
    if (!held)
        activeTool->Draw(sim, cBrush, newPos);
    else
        activeTool->DrawLine(sim, cBrush, oldPos, newPos, true);
}
Пример #3
0
void GameController::DrawPoints(int toolSelection, queue<ui::Point> & pointQueue)
{
	Simulation * sim = gameModel->GetSimulation();
	Tool * activeTool = gameModel->GetActiveTool(toolSelection);
	gameModel->SetLastTool(activeTool);
	Brush * cBrush = gameModel->GetBrush();
	if(!activeTool || !cBrush)
	{
		if(!pointQueue.empty())
		{
			while(!pointQueue.empty())
			{
				pointQueue.pop();
			}
		}
		return;
	}

	activeTool->SetStrength(gameModel->GetToolStrength());
	if(!pointQueue.empty())
	{
		ui::Point sPoint(0, 0);
		int size = pointQueue.size();
		bool first = true;
		while(!pointQueue.empty())
		{
			ui::Point fPoint = pointQueue.front();
			pointQueue.pop();
			if(size > 1)
			{
				if (!first)
				{
					activeTool->DrawLine(sim, cBrush, sPoint, fPoint, true);
				}
				first = false;
			}
			else
			{
				activeTool->Draw(sim, cBrush, fPoint);
			}
			sPoint = fPoint;
		}
	}
}