From 722b9d93d6de17b9bcf59eb6718792723ff5e152 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Sat, 19 Sep 2015 21:19:17 -0400 Subject: [PATCH] a few minor improvements so that stamps are more consistent in tpt++ / my mod --- src/gui/game/GameController.cpp | 10 +++++++--- src/gui/game/GameController.h | 2 +- src/gui/game/GameView.cpp | 17 +++++++---------- src/gui/interface/Point.h | 3 ++- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp index 1cbbd0928e..fc721ee8f7 100644 --- a/src/gui/game/GameController.cpp +++ b/src/gui/game/GameController.cpp @@ -495,11 +495,15 @@ void GameController::DrawPoints(int toolSelection, queue & 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) diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h index 32ad035a2a..606b47bfed 100644 --- a/src/gui/game/GameController.h +++ b/src/gui/game/GameController.h @@ -155,7 +155,7 @@ class GameController: public ClientListener void ToggleAHeat(); void ToggleNewtonianGravity(); - void LoadClipboard(); + bool LoadClipboard(); void LoadStamp(GameSave *stamp); void RemoveNotification(Notification * notification); diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index f4f6b03c30..d96ddf9a28 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -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) { @@ -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; } @@ -1505,7 +1505,7 @@ 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; } @@ -1513,9 +1513,8 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool case 'v': if(ctrl) { - c->LoadClipboard(); - selectPoint2 = mousePosition; - selectPoint1 = selectPoint2; + if (c->LoadClipboard()); + selectPoint1 = selectPoint2 = mousePosition; } break; case 'l': @@ -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 ']': diff --git a/src/gui/interface/Point.h b/src/gui/interface/Point.h index 0257e858c5..fad4b535fd 100644 --- a/src/gui/interface/Point.h +++ b/src/gui/interface/Point.h @@ -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); } };