Skip to content

Commit

Permalink
a few minor improvements so that stamps are more consistent in tpt++ …
Browse files Browse the repository at this point in the history
…/ my mod
  • Loading branch information
jacob1 committed Sep 20, 2015
1 parent 71d75e3 commit 722b9d9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
10 changes: 7 additions & 3 deletions src/gui/game/GameController.cpp
Expand Up @@ -495,11 +495,15 @@ void GameController::DrawPoints(int toolSelection, queue<ui::Point> & pointQueue
}
}

void GameController::LoadClipboard()
bool GameController::LoadClipboard()
{
gameModel->SetPlaceSave(gameModel->GetClipboard());
if(gameModel->GetPlaceSave() && gameModel->GetPlaceSave()->Collapsed())
GameSave *clip = gameModel->GetClipboard();
if (!clip)
return false;
gameModel->SetPlaceSave(clip);
if (gameModel->GetPlaceSave() && gameModel->GetPlaceSave()->Collapsed())
gameModel->GetPlaceSave()->Expand();
return true;
}

void GameController::LoadStamp(GameSave *stamp)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/game/GameController.h
Expand Up @@ -155,7 +155,7 @@ class GameController: public ClientListener
void ToggleAHeat();
void ToggleNewtonianGravity();

void LoadClipboard();
bool LoadClipboard();
void LoadStamp(GameSave *stamp);

void RemoveNotification(Notification * notification);
Expand Down
17 changes: 7 additions & 10 deletions src/gui/game/GameView.cpp
Expand Up @@ -1130,7 +1130,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
{
if (selectMode != SelectNone)
{
if (button == BUTTON_LEFT)
if (button == BUTTON_LEFT && selectPoint1.X != -1 && selectPoint1.Y != -1 && selectPoint2.X != -1 && selectPoint2.Y != -1)
{
if (selectMode == PlaceSave)
{
Expand Down Expand Up @@ -1496,7 +1496,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
if(ctrl)
{
selectMode = SelectCopy;
selectPoint1 = ui::Point(-1, -1);
selectPoint1 = selectPoint2 = ui::Point(-1, -1);
buttonTip = "\x0F\xEF\xEF\020Click-and-drag to specify an area to copy (right click = cancel)";
buttonTipShow = 120;
}
Expand All @@ -1505,17 +1505,16 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
if(ctrl)
{
selectMode = SelectCut;
selectPoint1 = ui::Point(-1, -1);
selectPoint1 = selectPoint2 = ui::Point(-1, -1);
buttonTip = "\x0F\xEF\xEF\020Click-and-drag to specify an area to copy then cut (right click = cancel)";
buttonTipShow = 120;
}
break;
case 'v':
if(ctrl)
{
c->LoadClipboard();
selectPoint2 = mousePosition;
selectPoint1 = selectPoint2;
if (c->LoadClipboard());
selectPoint1 = selectPoint2 = mousePosition;
}
break;
case 'l':
Expand All @@ -1524,15 +1523,13 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
if (stampList.size())
{
c->LoadStamp(Client::Ref().GetStamp(stampList[0])->GetGameSave());
selectPoint2 = mousePosition;
selectPoint1 = selectPoint2;
selectPoint1 = selectPoint2 = mousePosition;
isMouseDown = false;
break;
}
}
case 'k':
selectPoint2 = ui::Point(-1, -1);
selectPoint1 = selectPoint2;
selectPoint1 = selectPoint2 = ui::Point(-1, -1);
c->OpenStamps();
break;
case ']':
Expand Down
3 changes: 2 additions & 1 deletion src/gui/interface/Point.h
Expand Up @@ -134,10 +134,11 @@ struct Point
return (X != v.X || Y != v.Y);
}

inline void operator = (const Point& v)
inline Point operator = (const Point& v)
{
X = v.X;
Y = v.Y;
return Point(X, Y);
}

};
Expand Down

0 comments on commit 722b9d9

Please sign in to comment.