Take history snapshot before setting save (#358)
This commit is contained in:
parent
e13e31ce64
commit
1c12d1ec16
@ -51,6 +51,7 @@ public:
|
||||
{
|
||||
try
|
||||
{
|
||||
cc->HistorySnapshot();
|
||||
cc->gameModel->SetSave(cc->search->GetLoadedSave());
|
||||
cc->search->ReleaseLoadedSave();
|
||||
}
|
||||
@ -73,6 +74,7 @@ public:
|
||||
{
|
||||
try
|
||||
{
|
||||
cc->HistorySnapshot();
|
||||
cc->LoadSave(cc->activePreview->GetSaveInfo());
|
||||
}
|
||||
catch(GameModelException & ex)
|
||||
@ -144,7 +146,6 @@ GameController::GameController():
|
||||
|
||||
gameView->AttachController(this);
|
||||
gameModel->AddObserver(gameView);
|
||||
gameModel->SetAllowHistory();
|
||||
|
||||
gameView->SetDebugHUD(Client::Ref().GetPrefBool("Renderer.DebugMode", false));
|
||||
|
||||
@ -253,11 +254,6 @@ 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();
|
||||
@ -288,6 +284,8 @@ void GameController::HistorySnapshot()
|
||||
void GameController::HistoryForward()
|
||||
{
|
||||
std::deque<Snapshot*> history = gameModel->GetHistory();
|
||||
if (!history.size())
|
||||
return;
|
||||
unsigned int historyPosition = gameModel->GetHistoryPosition();
|
||||
unsigned int newHistoryPosition = std::min((size_t)historyPosition+1, history.size());
|
||||
Snapshot *snap;
|
||||
@ -1252,6 +1250,7 @@ void GameController::OpenLocalBrowse()
|
||||
virtual ~LocalSaveOpenCallback() {};
|
||||
virtual void FileSelected(SaveFile* file)
|
||||
{
|
||||
c->HistorySnapshot();
|
||||
c->LoadSaveFile(file);
|
||||
delete file;
|
||||
}
|
||||
@ -1488,6 +1487,7 @@ void GameController::ChangeBrush()
|
||||
|
||||
void GameController::ClearSim()
|
||||
{
|
||||
HistorySnapshot();
|
||||
gameModel->SetSave(NULL);
|
||||
gameModel->ClearSimulation();
|
||||
}
|
||||
@ -1496,10 +1496,12 @@ void GameController::ReloadSim()
|
||||
{
|
||||
if(gameModel->GetSave() && gameModel->GetSave()->GetGameSave())
|
||||
{
|
||||
HistorySnapshot();
|
||||
gameModel->SetSave(gameModel->GetSave());
|
||||
}
|
||||
else if(gameModel->GetSaveFile() && gameModel->GetSaveFile()->GetGameSave())
|
||||
{
|
||||
HistorySnapshot();
|
||||
gameModel->SetSaveFile(gameModel->GetSaveFile());
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ GameModel::GameModel():
|
||||
currentFile(NULL),
|
||||
currentUser(0, ""),
|
||||
toolStrength(1.0f),
|
||||
allowHistory(false),
|
||||
redoHistory(NULL),
|
||||
historyPosition(0),
|
||||
activeColourPreset(0),
|
||||
|
@ -64,7 +64,6 @@ private:
|
||||
Tool * regularToolset[4];
|
||||
User currentUser;
|
||||
float toolStrength;
|
||||
bool allowHistory;
|
||||
std::deque<Snapshot*> history;
|
||||
Snapshot *redoHistory;
|
||||
unsigned int historyPosition;
|
||||
@ -132,8 +131,6 @@ 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);
|
||||
|
@ -1035,7 +1035,6 @@ void GameView::NotifySaveChanged(GameModel * sender)
|
||||
}
|
||||
saveSimulationButton->Enabled = (saveSimulationButtonEnabled || ctrlBehaviour);
|
||||
SetSaveButtonTooltips();
|
||||
c->HistorySnapshot();
|
||||
}
|
||||
|
||||
void GameView::NotifyBrushChanged(GameModel * sender)
|
||||
|
Loading…
Reference in New Issue
Block a user