Skip to content

Commit

Permalink
'l' always loads last save from disk (won't load cached deleted save)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Dec 15, 2014
1 parent 6410171 commit 35782fd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 54 deletions.
9 changes: 4 additions & 5 deletions src/gui/game/GameController.cpp
Expand Up @@ -111,10 +111,9 @@ class GameController::StampsCallback: public ControllerCallback
{
if(cc->localBrowser->GetSave())
{
cc->gameModel->SetStamp(cc->localBrowser->GetSave()->GetGameSave());
if (cc->localBrowser->GetMoveToFront())
Client::Ref().MoveStampToFront(cc->localBrowser->GetSave()->GetName());
cc->LoadStamp();
cc->LoadStamp(cc->localBrowser->GetSave()->GetGameSave());
}
}
};
Expand Down Expand Up @@ -487,9 +486,9 @@ void GameController::LoadClipboard()
gameModel->GetPlaceSave()->Expand();
}

void GameController::LoadStamp()
void GameController::LoadStamp(GameSave *stamp)
{
gameModel->SetPlaceSave(gameModel->GetStamp());
gameModel->SetPlaceSave(stamp);
if(gameModel->GetPlaceSave() && gameModel->GetPlaceSave()->Collapsed())
gameModel->GetPlaceSave()->Expand();
}
Expand Down Expand Up @@ -526,7 +525,7 @@ std::string GameController::StampRegion(ui::Point point1, ui::Point point2)
if(newSave)
{
newSave->paused = gameModel->GetPaused();
return gameModel->AddStamp(newSave);
return Client::Ref().AddStamp(newSave);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/game/GameController.h
Expand Up @@ -155,7 +155,7 @@ class GameController: public ClientListener
void ToggleNewtonianGravity();

void LoadClipboard();
void LoadStamp();
void LoadStamp(GameSave *stamp);

void RemoveNotification(Notification * notification);

Expand Down
38 changes: 0 additions & 38 deletions src/gui/game/GameModel.cpp
Expand Up @@ -27,7 +27,6 @@ GameModel::GameModel():
currentFile(NULL),
colourSelector(false),
clipboard(NULL),
stamp(NULL),
placeSave(NULL),
colour(255, 0, 0, 255),
toolStrength(1.0f),
Expand Down Expand Up @@ -96,15 +95,6 @@ GameModel::GameModel():
currentUser = Client::Ref().GetAuthUser();
}

//Set stamp to first stamp in list
vector<string> stamps = Client::Ref().GetStamps(0, 1);
if(stamps.size()>0)
{
SaveFile * stampFile = Client::Ref().GetStamp(stamps[0]);
if(stampFile && stampFile->GetGameSave())
stamp = stampFile->GetGameSave();
}

BuildMenus();

//Set default brush palette
Expand Down Expand Up @@ -192,8 +182,6 @@ GameModel::~GameModel()
delete placeSave;
if(clipboard)
delete clipboard;
if(stamp)
delete stamp;
if(currentSave)
delete currentSave;
if(currentFile)
Expand Down Expand Up @@ -903,19 +891,6 @@ void GameModel::ClearSimulation()
UpdateQuickOptions();
}

void GameModel::SetStamp(GameSave * save)
{
if(stamp != save)
{
if(stamp)
delete stamp;
if(save)
stamp = new GameSave(*save);
else
stamp = NULL;
}
}

void GameModel::SetPlaceSave(GameSave * save)
{
if(save != placeSave)
Expand All @@ -930,14 +905,6 @@ void GameModel::SetPlaceSave(GameSave * save)
notifyPlaceSaveChanged();
}

std::string GameModel::AddStamp(GameSave * save)
{
if(stamp)
delete stamp;
stamp = save;
return Client::Ref().AddStamp(save);
}

void GameModel::SetClipboard(GameSave * save)
{
if(clipboard)
Expand All @@ -955,11 +922,6 @@ GameSave * GameModel::GetPlaceSave()
return placeSave;
}

GameSave * GameModel::GetStamp()
{
return stamp;
}

void GameModel::Log(string message)
{
consoleLog.push_front(message);
Expand Down
4 changes: 0 additions & 4 deletions src/gui/game/GameModel.h
Expand Up @@ -38,7 +38,6 @@ class GameModel
vector<Notification*> notifications;
//int clipboardSize;
//unsigned char * clipboardData;
GameSave * stamp;
GameSave * clipboard;
GameSave * placeSave;
deque<string> consoleLog;
Expand Down Expand Up @@ -185,14 +184,11 @@ class GameModel
ui::Point AdjustZoomCoords(ui::Point position);
void SetZoomWindowPosition(ui::Point position);
ui::Point GetZoomWindowPosition();
void SetStamp(GameSave * newStamp);
std::string AddStamp(GameSave * save);
void SetClipboard(GameSave * save);
void SetPlaceSave(GameSave * save);
void Log(string message);
deque<string> GetLog();
GameSave * GetClipboard();
GameSave * GetStamp();
GameSave * GetPlaceSave();

std::vector<Notification*> GetNotifications();
Expand Down
18 changes: 12 additions & 6 deletions src/gui/game/GameView.cpp
Expand Up @@ -1479,12 +1479,18 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
}
break;
case 'l':
c->LoadStamp();
selectPoint2 = mousePosition;
selectPoint1 = selectPoint2;
isMouseDown = false;
drawMode = DrawPoints;
break;
{
std::vector<std::string> stampList = Client::Ref().GetStamps(0, 1);
if (stampList.size())
{
c->LoadStamp(Client::Ref().GetStamp(stampList[0])->GetGameSave());
selectPoint2 = mousePosition;
selectPoint1 = selectPoint2;
isMouseDown = false;
drawMode = DrawPoints;
break;
}
}
case 'k':
selectPoint2 = ui::Point(-1, -1);
selectPoint1 = selectPoint2;
Expand Down

0 comments on commit 35782fd

Please sign in to comment.