diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-17 20:46:06 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-17 20:46:06 (GMT) |
| commit | 4a60b97c700c2f1843b7e99313554cb89fb5da4e (patch) | |
| tree | 3b33ef6f74a4e8a4ff5968a81b9c4c429ccaa7c6 /src/game/GameModel.cpp | |
| parent | 6273089bf486bf46ad325d72c7290ebb272bd3d8 (diff) | |
| download | powder-4a60b97c700c2f1843b7e99313554cb89fb5da4e.zip powder-4a60b97c700c2f1843b7e99313554cb89fb5da4e.tar.gz | |
Some minor changes
Diffstat (limited to 'src/game/GameModel.cpp')
| -rw-r--r-- | src/game/GameModel.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp new file mode 100644 index 0000000..96b29a9 --- /dev/null +++ b/src/game/GameModel.cpp @@ -0,0 +1,75 @@ +#include "interface/Engine.h" +#include "GameModel.h" +#include "GameView.h" +#include "Simulation.h" +#include "Renderer.h" + +GameModel::GameModel(): + activeElement(1) +{ + sim = new Simulation(); + ren = new Renderer(ui::Engine::Ref().g, sim); +} + +void GameModel::AddObserver(GameView * observer){ + observers.push_back(observer); + + observer->NotifySimulationChanged(this); + observer->NotifyRendererChanged(this); + observer->NotifyPausedChanged(this); +} + +int GameModel::GetActiveElement() +{ + return activeElement; +} + +void GameModel::SetActiveElement(int element) +{ + activeElement = element; +} + +Simulation * GameModel::GetSimulation() +{ + return sim; +} + +Renderer * GameModel::GetRenderer() +{ + return ren; +} + +void GameModel::SetPaused(bool pauseState) +{ + sim->sys_pause = pauseState?1:0; + notifyPausedChanged(); +} + +bool GameModel::GetPaused() +{ + return sim->sys_pause?true:false; +} + +void GameModel::notifyRendererChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyRendererChanged(this); + } +} + +void GameModel::notifySimulationChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifySimulationChanged(this); + } +} + +void GameModel::notifyPausedChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyPausedChanged(this); + } +} |
