fix problems with point queue, where it would draw a Point at A, a line from A to B, and a line from B to B every frame

This commit is contained in:
jacob1 2013-06-08 22:23:53 -04:00
parent 0f5d0859b4
commit 16cb95de64
3 changed files with 15 additions and 14 deletions

View File

@ -15,11 +15,13 @@ ConsoleController::ConsoleController(ControllerCallback * callback, CommandInter
void ConsoleController::EvaluateCommand(std::string command)
{
if (command.substr(0, 6) == "!load ")
CloseConsole();
int returnCode = commandInterface->Command(command);
if(command.length())
{
if (command.substr(0, 6) == "!load ")
CloseConsole();
int returnCode = commandInterface->Command(command);
consoleModel->AddLastCommand(ConsoleCommand(command, returnCode, commandInterface->GetLastError()));
}
else
CloseConsole();
}

View File

@ -444,7 +444,6 @@ void GameController::DrawPoints(int toolSelection, queue<ui::Point> & pointQueue
{
while(!pointQueue.empty())
{
//delete pointQueue.front();
pointQueue.pop();
}
}
@ -455,20 +454,25 @@ void GameController::DrawPoints(int toolSelection, queue<ui::Point> & pointQueue
if(!pointQueue.empty())
{
ui::Point sPoint(0, 0);
int size = pointQueue.size();
bool first = true;
while(!pointQueue.empty())
{
ui::Point fPoint = pointQueue.front();
//delete pointQueue.front();
pointQueue.pop();
if(!first)
if(size > 1)
{
activeTool->DrawLine(sim, cBrush, sPoint, fPoint, true);
if (!first)
{
activeTool->DrawLine(sim, cBrush, sPoint, fPoint, true);
printf("From (%d, %d) To (%d, %d)\n", sPoint.X, sPoint.Y, fPoint.X, fPoint.Y);
}
first = false;
}
else
{
first = false;
activeTool->Draw(sim, cBrush, fPoint);
printf("(%d, %d)\n", fPoint.X, fPoint.Y);
}
sPoint = fPoint;
}

View File

@ -1141,7 +1141,6 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
if(drawMode == DrawPoints)
{
c->ToolClick(toolIndex, c->PointTranslate(ui::Point(x, y)));
//pointQueue.push(ui::Point(x, y));
}
if(drawModeReset)
{
@ -1209,10 +1208,6 @@ void GameView::OnMouseWheel(int x, int y, int d)
else
{
c->AdjustBrushSize(d, false, shiftBehaviour, ctrlBehaviour);
if(isMouseDown)
{
pointQueue.push(ui::Point(c->PointTranslate(ui::Point(x, y))));
}
}
}
@ -1522,7 +1517,7 @@ void GameView::OnTick(float dt)
c->SetZoomPosition(currentMouse);
if(drawMode == DrawPoints)
{
if(isMouseDown)
if(isMouseDown && pointQueue.empty())
{
pointQueue.push(ui::Point(c->PointTranslate(currentMouse)));
}