ugly fix for two empty snapshots being created on startup

This commit is contained in:
jacob1 2017-02-09 23:08:44 -05:00
parent 787939db3d
commit 6040ccd27e
3 changed files with 10 additions and 0 deletions

View File

@ -144,6 +144,7 @@ GameController::GameController():
gameView->AttachController(this); gameView->AttachController(this);
gameModel->AddObserver(gameView); gameModel->AddObserver(gameView);
gameModel->SetAllowHistory();
gameView->SetDebugHUD(Client::Ref().GetPrefBool("Renderer.DebugMode", false)); gameView->SetDebugHUD(Client::Ref().GetPrefBool("Renderer.DebugMode", false));
@ -250,6 +251,11 @@ void GameController::HistoryRestore()
void GameController::HistorySnapshot() void GameController::HistorySnapshot()
{ {
// callbacks during initialization create two empty snapshots on startup
// Prevent that from happening here
if (!gameModel->GetAllowHistory())
return;
std::deque<Snapshot*> history = gameModel->GetHistory(); std::deque<Snapshot*> history = gameModel->GetHistory();
unsigned int historyPosition = gameModel->GetHistoryPosition(); unsigned int historyPosition = gameModel->GetHistoryPosition();
Snapshot * newSnap = gameModel->GetSimulation()->CreateSnapshot(); Snapshot * newSnap = gameModel->GetSimulation()->CreateSnapshot();

View File

@ -28,6 +28,7 @@ GameModel::GameModel():
currentFile(NULL), currentFile(NULL),
currentUser(0, ""), currentUser(0, ""),
toolStrength(1.0f), toolStrength(1.0f),
allowHistory(false),
redoHistory(NULL), redoHistory(NULL),
historyPosition(0), historyPosition(0),
activeColourPreset(0), activeColourPreset(0),

View File

@ -64,6 +64,7 @@ private:
Tool * regularToolset[4]; Tool * regularToolset[4];
User currentUser; User currentUser;
float toolStrength; float toolStrength;
bool allowHistory;
std::deque<Snapshot*> history; std::deque<Snapshot*> history;
Snapshot *redoHistory; Snapshot *redoHistory;
unsigned int historyPosition; unsigned int historyPosition;
@ -131,6 +132,8 @@ public:
void BuildFavoritesMenu(); void BuildFavoritesMenu();
void BuildQuickOptionMenu(GameController * controller); void BuildQuickOptionMenu(GameController * controller);
bool GetAllowHistory() { return allowHistory; }
void SetAllowHistory() { allowHistory = true; }
std::deque<Snapshot*> GetHistory(); std::deque<Snapshot*> GetHistory();
unsigned int GetHistoryPosition(); unsigned int GetHistoryPosition();
void SetHistory(std::deque<Snapshot*> newHistory); void SetHistory(std::deque<Snapshot*> newHistory);