Skip to content

Commit

Permalink
tptmp mouse syncing fix
Browse files Browse the repository at this point in the history
mouse lines now end on the point where the mouse is lifted up as intended, instead of at the point where the mouse is at the end of the frame
also remove unneeded variable
  • Loading branch information
jacob1 committed Sep 21, 2015
1 parent 6fc7875 commit cacef12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
27 changes: 8 additions & 19 deletions src/gui/game/GameView.cpp
Expand Up @@ -150,7 +150,6 @@ class SplitButton : public ui::Button
GameView::GameView():
ui::Window(ui::Point(0, 0), ui::Point(WINDOWW, WINDOWH)),
isMouseDown(false),
isMouseHeld(false),
zoomEnabled(false),
zoomCursorFixed(false),
mouseInZoom(false),
Expand Down Expand Up @@ -1066,7 +1065,7 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
if (selectPoint1.X != -1)
selectPoint2 = c->PointTranslate(ui::Point(x, y));
}
else if (isMouseDown || isMouseHeld)
else if (isMouseDown)
{
if (newMouseInZoom == mouseInZoom)
{
Expand All @@ -1078,7 +1077,6 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
else if (drawMode == DrawPoints || drawMode == DrawFill)
{
isMouseDown = false;
isMouseHeld = false;
c->MouseUp(x, y, 0, 2);
}
}
Expand Down Expand Up @@ -1130,7 +1128,6 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
zoomCursorFixed = true;
drawMode = DrawPoints;
isMouseDown = false;
isMouseHeld = false;
}
else
{
Expand Down Expand Up @@ -1179,11 +1176,10 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
if (isMouseDown)
{
isMouseDown = false;
ui::Point finalDrawPoint2 = c->PointTranslate(ui::Point(x, y));
if (drawMode == DrawRect || drawMode == DrawLine)
{
ui::Point finalDrawPoint2(0, 0);
drawPoint2 = c->PointTranslate(ui::Point(x, y));
finalDrawPoint2 = drawPoint2;
drawPoint2 = finalDrawPoint2;

if (drawSnap && drawMode == DrawLine)
{
Expand All @@ -1204,9 +1200,12 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
c->DrawLine(toolIndex, c->PointTranslate(drawPoint1), finalDrawPoint2);
}
}
if (drawMode == DrawPoints)
else if (drawMode == DrawPoints)
{
c->ToolClick(toolIndex, c->PointTranslate(ui::Point(x, y)));
// draw final line
c->DrawPoints(toolIndex, lastPoint, finalDrawPoint2, true);
// plop tool stuff (like STKM)
c->ToolClick(toolIndex, finalDrawPoint2);
}
if (drawModeReset)
{
Expand Down Expand Up @@ -1397,7 +1396,6 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
if (drawMode != DrawLine && !windTool)
{
isMouseDown = false;
isMouseHeld = false;
}
zoomCursorFixed = false;
c->SetZoomEnabled(true);
Expand Down Expand Up @@ -1534,7 +1532,6 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
c->LoadStamp(Client::Ref().GetStamp(stampList[0])->GetGameSave());
selectPoint1 = selectPoint2 = mousePosition;
isMouseDown = false;
isMouseHeld = false;
break;
}
}
Expand Down Expand Up @@ -1623,7 +1620,6 @@ void GameView::OnBlur()
disableCtrlBehaviour();
disableShiftBehaviour();
isMouseDown = false;
isMouseHeld = false;
drawMode = DrawPoints;
c->MouseUp(0, 0, 0, 1); // tell lua that mouse is up (even if it really isn't)
}
Expand All @@ -1640,12 +1636,6 @@ void GameView::OnTick(float dt)
{
c->DrawPoints(toolIndex, lastPoint, currentPoint, true);
lastPoint = currentPoint;
isMouseHeld = true;
}
else if (isMouseHeld)
{
c->DrawPoints(toolIndex, lastPoint, currentPoint, true);
isMouseHeld = false;
}
}
else if (drawMode == DrawFill && isMouseDown)
Expand Down Expand Up @@ -1816,7 +1806,6 @@ void GameView::DoTick(float dt)
if (!c->MouseTick())
{
isMouseDown = false;
isMouseHeld = false;
drawMode = DrawPoints;
}
Window::DoTick(dt);
Expand Down
1 change: 0 additions & 1 deletion src/gui/game/GameView.h
Expand Up @@ -34,7 +34,6 @@ class GameView: public ui::Window
{
private:
bool isMouseDown;
bool isMouseHeld; // same as isMouseDown but with a frame of lag (to do lines / ending point properly)
bool zoomEnabled;
bool zoomCursorFixed;
bool mouseInZoom;
Expand Down

0 comments on commit cacef12

Please sign in to comment.