summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-14 15:28:44 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-14 15:28:44 (GMT)
commite13476a4063bd7bdf428d53fd686864c1c90e0ec (patch)
tree901203df56ec6d6142f2996a55f01a55ca823e59 /src
parent70758cc70ef80632f6814c4fc4f9f13430bf8057 (diff)
downloadpowder-e13476a4063bd7bdf428d53fd686864c1c90e0ec.zip
powder-e13476a4063bd7bdf428d53fd686864c1c90e0ec.tar.gz
Cut region, fixes #105
Diffstat (limited to 'src')
-rw-r--r--src/game/GameController.cpp6
-rw-r--r--src/game/GameController.h1
-rw-r--r--src/game/GameView.cpp11
-rw-r--r--src/game/GameView.h2
4 files changed, 19 insertions, 1 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index 0855d04..9831c78 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 963b506..72ebd37 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 e73d509..a149053 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 93eb779..71a6e93 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;