Skip to content

Commit

Permalink
prevent 'z' keypresses while doing stamp stuff, add skipDraw variable…
Browse files Browse the repository at this point in the history
… to prevent wasted drawing calls
  • Loading branch information
jacob1 committed Sep 25, 2015
1 parent 74471dc commit cf5ec57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/gui/game/GameView.cpp
Expand Up @@ -150,6 +150,7 @@ class SplitButton : public ui::Button
GameView::GameView():
ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)),
isMouseDown(false),
skipDraw(false),
zoomEnabled(false),
zoomCursorFixed(false),
mouseInZoom(false),
Expand Down Expand Up @@ -1077,10 +1078,12 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
currentPoint = mousePosition;
c->DrawPoints(toolIndex, lastPoint, currentPoint, true);
lastPoint = currentPoint;
skipDraw = true;
}
else if (drawMode == DrawFill)
{
c->DrawFill(toolIndex, mousePosition);
skipDraw = true;
}
}
else if (drawMode == DrawPoints || drawMode == DrawFill)
Expand Down Expand Up @@ -1376,7 +1379,9 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
c->SetPaused();
break;
case 'z':
if (ctrl)
if (selectMode != SelectNone && isMouseDown)
break;
if (ctrl && !isMouseDown)
{
c->HistoryRestore();
}
Expand Down Expand Up @@ -1609,11 +1614,16 @@ void GameView::OnBlur()

void GameView::OnTick(float dt)
{
if (selectMode==PlaceSave && !placeSaveThumb)
if (selectMode == PlaceSave && !placeSaveThumb)
selectMode = SelectNone;
if (zoomEnabled && !zoomCursorFixed)
c->SetZoomPosition(currentMouse);
if (selectMode == SelectNone && isMouseDown)

if (skipDraw)
{
skipDraw = false;
}
else if (selectMode == SelectNone && isMouseDown)
{
if (drawMode == DrawPoints)
{
Expand Down
1 change: 1 addition & 0 deletions src/gui/game/GameView.h
Expand Up @@ -34,6 +34,7 @@ class GameView: public ui::Window
{
private:
bool isMouseDown;
bool skipDraw;
bool zoomEnabled;
bool zoomCursorFixed;
bool mouseInZoom;
Expand Down

0 comments on commit cf5ec57

Please sign in to comment.