diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-16 21:03:40 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-16 21:03:40 (GMT) |
| commit | edad8f46af6cf2403c2ffa77ecfa138ae1b9f8d9 (patch) | |
| tree | 94ac1023a0241e27176d63aabee26fd1b876e08b /src/game/GameController.cpp | |
| parent | f19c7f62c77f6a3e8f5728e015166b0c625f5f67 (diff) | |
| download | powder-edad8f46af6cf2403c2ffa77ecfa138ae1b9f8d9.zip powder-edad8f46af6cf2403c2ffa77ecfa138ae1b9f8d9.tar.gz | |
Undo/Snapshots, fixes #118
Diffstat (limited to 'src/game/GameController.cpp')
| -rw-r--r-- | src/game/GameController.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 5237af7..91c64c0 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -23,6 +23,7 @@ #include "save/LocalSaveActivity.h" #include "save/ServerSaveActivity.h" #include "interface/Keys.h" +#include "simulation/Snapshot.h" using namespace std; @@ -187,6 +188,40 @@ GameController::~GameController() delete gameView; } +void GameController::HistoryRestore() +{ + std::deque<Snapshot*> history = gameModel->GetHistory(); + if(history.size()) + { + Snapshot * snap = history.back(); + gameModel->GetSimulation()->Restore(*snap); + if(history.size()>1) + { + history.pop_back(); + delete snap; + gameModel->SetHistory(history); + } + } +} + +void GameController::HistorySnapshot() +{ + std::deque<Snapshot*> history = gameModel->GetHistory(); + Snapshot * newSnap = gameModel->GetSimulation()->CreateSnapshot(); + if(newSnap) + { + if(history.size() >= 1) //History limit is current 1 + { + Snapshot * snap = history.front(); + history.pop_front(); + //snap->Particles.clear(); + delete snap; + } + history.push_back(newSnap); + gameModel->SetHistory(history); + } +} + GameView * GameController::GetView() { return gameView; |
