diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-06-08 21:04:14 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-06-08 21:04:14 (GMT) |
| commit | 0ee1e1875d00876b946f358308f39dc33ef96ea4 (patch) | |
| tree | c0ea64b19f03541cb71b96ed3acc4c6c3e2e1834 /src/game | |
| parent | 1dadb11fc218786a36cc46714a0478e229ca44a9 (diff) | |
| download | powder-0ee1e1875d00876b946f358308f39dc33ef96ea4.zip powder-0ee1e1875d00876b946f358308f39dc33ef96ea4.tar.gz | |
Load save data when showing the save preview
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/GameController.cpp | 5 | ||||
| -rw-r--r-- | src/game/GameController.h | 1 | ||||
| -rw-r--r-- | src/game/GameView.cpp | 20 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 01cf1de..e0e8673 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -234,6 +234,11 @@ ui::Point GameController::PointTranslate(ui::Point point) return point; } +ui::Point GameController::NormaliseBlockCoord(ui::Point point) +{ + return (point/CELL)*CELL; +} + void GameController::DrawRect(int toolSelection, ui::Point point1, ui::Point point2) { Simulation * sim = gameModel->GetSimulation(); diff --git a/src/game/GameController.h b/src/game/GameController.h index 25705bc..f2d05b9 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -94,6 +94,7 @@ public: void ShowConsole(); void FrameStep(); ui::Point PointTranslate(ui::Point point); + ui::Point NormaliseBlockCoord(ui::Point point); std::string ElementResolve(int type); }; diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index adc5883..89d9fac 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -898,17 +898,19 @@ void GameView::OnDraw() int thumbX = selectPoint2.X - (tempThumb->Size.X/2); int thumbY = selectPoint2.Y - (tempThumb->Size.Y/2); - if(thumbX<0) - thumbX = 0; - if(thumbX+(tempThumb->Size.X)>=XRES) - thumbX = XRES-tempThumb->Size.X; + ui::Point thumbPos = c->NormaliseBlockCoord(ui::Point(thumbX, thumbY)); - if(thumbY<0) - thumbY = 0; - if(thumbY+(tempThumb->Size.Y)>=YRES) - thumbY = YRES-tempThumb->Size.Y; + if(thumbPos.X<0) + thumbPos.X = 0; + if(thumbPos.X+(tempThumb->Size.X)>=XRES) + thumbPos.X = XRES-tempThumb->Size.X; + + if(thumbPos.Y<0) + thumbPos.Y = 0; + if(thumbPos.Y+(tempThumb->Size.Y)>=YRES) + thumbPos.Y = YRES-tempThumb->Size.Y; - g->draw_image(tempThumb->Data, thumbX, thumbY, tempThumb->Size.X, tempThumb->Size.Y, 128); + g->draw_image(tempThumb->Data, thumbPos.X, thumbPos.Y, tempThumb->Size.X, tempThumb->Size.Y, 128); } } else |
