diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-22 14:45:37 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-22 14:45:37 (GMT) |
| commit | 19c1fa5dcb4c4a2ba9d692e136b17da316a2631b (patch) | |
| tree | 8436e6674dc4375f0392a9142be1a06ddf888337 /src/game/GameModel.cpp | |
| parent | 91bb5a8b781fba33901c0a2804b86055ed588aa4 (diff) | |
| download | powder-19c1fa5dcb4c4a2ba9d692e136b17da316a2631b.zip powder-19c1fa5dcb4c4a2ba9d692e136b17da316a2631b.tar.gz | |
Brush class for drawing on simulation, more interface for game
Diffstat (limited to 'src/game/GameModel.cpp')
| -rw-r--r-- | src/game/GameModel.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index 54c8dd4..3070093 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -3,11 +3,15 @@ #include "GameView.h" #include "simulation/Simulation.h" #include "Renderer.h" +#include "interface/Point.h" +#include "Brush.h" GameModel::GameModel(): activeElement(1), sim(NULL), - ren(NULL) + ren(NULL), + currentSave(NULL), + currentBrush(new Brush(ui::Point(4, 4))) { sim = new Simulation(); ren = new Renderer(ui::Engine::Ref().g, sim); @@ -19,12 +23,19 @@ GameModel::~GameModel() delete ren; } +Brush * GameModel::GetBrush() +{ + return currentBrush; +} + void GameModel::AddObserver(GameView * observer){ observers.push_back(observer); observer->NotifySimulationChanged(this); observer->NotifyRendererChanged(this); observer->NotifyPausedChanged(this); + observer->NotifySaveChanged(this); + observer->NotifyBrushChanged(this); } int GameModel::GetActiveElement() @@ -37,6 +48,16 @@ void GameModel::SetActiveElement(int element) activeElement = element; } +Save * GameModel::GetSave() +{ + return currentSave; +} +void GameModel::SetSave(Save * newSave) +{ + currentSave = newSave; + notifySaveChanged(); +} + Simulation * GameModel::GetSimulation() { return sim; @@ -58,6 +79,11 @@ bool GameModel::GetPaused() return sim->sys_pause?true:false; } +void GameModel::ClearSimulation() +{ + sim->clear_sim(); +} + void GameModel::notifyRendererChanged() { for(int i = 0; i < observers.size(); i++) @@ -66,6 +92,14 @@ void GameModel::notifyRendererChanged() } } +void GameModel::notifySaveChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifySaveChanged(this); + } +} + void GameModel::notifySimulationChanged() { for(int i = 0; i < observers.size(); i++) @@ -81,3 +115,11 @@ void GameModel::notifyPausedChanged() observers[i]->NotifyPausedChanged(this); } } + +void GameModel::notifyBrushChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyBrushChanged(this); + } +} |
