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

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

View File

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

View File

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