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);
gameModel->AddObserver(gameView);
gameModel->SetAllowHistory();
gameView->SetDebugHUD(Client::Ref().GetPrefBool("Renderer.DebugMode", false));
@ -250,6 +251,11 @@ void GameController::HistoryRestore()
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();
unsigned int historyPosition = gameModel->GetHistoryPosition();
Snapshot * newSnap = gameModel->GetSimulation()->CreateSnapshot();

View File

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

View File

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