From e13476a4063bd7bdf428d53fd686864c1c90e0ec Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 14 Aug 2012 16:28:44 +0100 Subject: [PATCH] Cut region, fixes #105 --- src/game/GameController.cpp | 6 ++++++ src/game/GameController.h | 1 + src/game/GameView.cpp | 11 +++++++++++ src/game/GameView.h | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 0855d041c..9831c7816 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -432,6 +432,12 @@ void GameController::CopyRegion(ui::Point point1, ui::Point point2) gameModel->SetClipboard(newSave); } +void GameController::CutRegion(ui::Point point1, ui::Point point2) +{ + CopyRegion(point1, point2); + gameModel->GetSimulation()->clear_area(point1.X, point1.Y, point2.X-point1.X, point2.Y-point1.Y); +} + bool GameController::MouseMove(int x, int y, int dx, int dy) { return commandInterface->OnMouseMove(x, y, dx, dy); diff --git a/src/game/GameController.h b/src/game/GameController.h index 963b50617..72ebd375c 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -81,6 +81,7 @@ public: void DrawFill(int toolSelection, ui::Point point); void StampRegion(ui::Point point1, ui::Point point2); void CopyRegion(ui::Point point1, ui::Point point2); + void CutRegion(ui::Point point1, ui::Point point2); void Update(); void SetPaused(bool pauseState); void SetPaused(); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index e73d5094e..a149053f7 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1032,6 +1032,8 @@ void GameView::OnMouseUp(int x, int y, unsigned button) { if(selectMode==SelectCopy) c->CopyRegion(ui::Point(x1, y1), ui::Point(x2, y2)); + else if(selectMode==SelectCut) + c->CutRegion(ui::Point(x1, y1), ui::Point(x2, y2)); else if(selectMode==SelectStamp) c->StampRegion(ui::Point(x1, y1), ui::Point(x2, y2)); } @@ -1299,6 +1301,15 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool infoTipPresence = 120; } break; + case 'x': + if(ctrl) + { + selectMode = SelectCut; + selectPoint1 = ui::Point(-1, -1); + infoTip = "\x0F\xEF\xEF\x10Select an area to cut"; + infoTipPresence = 120; + } + break; case 'v': if(ctrl) { diff --git a/src/game/GameView.h b/src/game/GameView.h index 93eb77904..71a6e9314 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -26,7 +26,7 @@ enum DrawMode enum SelectMode { - SelectNone, SelectStamp, SelectCopy, PlaceSave + SelectNone, SelectStamp, SelectCopy, SelectCut, PlaceSave }; class GameController;