instant save option option, hold ctrl when clicking a save in the save preview to skip the entire preview and not load the comments

This commit is contained in:
jacob1 2013-07-25 19:43:25 -04:00
parent beff3db8d2
commit bfc1cf99ca
10 changed files with 38 additions and 26 deletions

View File

@ -1378,8 +1378,9 @@ int LuaScriptInterface::simulation_loadStamp(lua_State * l)
int LuaScriptInterface::simulation_loadSave(lua_State * l)
{
int saveID = luaL_optint(l,1,0);
int history = luaL_optint(l,2,0); //Exact second a previous save was saved
luacon_controller->OpenSavePreview(saveID, history);
int instant = luaL_optint(l,2,0);
int history = luaL_optint(l,3,0); //Exact second a previous save was saved
luacon_controller->OpenSavePreview(saveID, history, instant?true:false);
return 0;
}

View File

@ -426,7 +426,7 @@ AnyType TPTScriptInterface::tptS_load(std::deque<std::string> * words)
//Arguments from stack
NumberType saveID = eval(words);
c->OpenSavePreview(saveID.Value(), 0);
c->OpenSavePreview(saveID.Value(), 0, false);
return NumberType(0);
}

View File

@ -588,7 +588,7 @@ bool GameController::MouseUp(int x, int y, unsigned button)
if (tempSaveID)
{
if ((*iter).text.c_str()[1] == 'c')
OpenSavePreview(tempSaveID, 0);
OpenSavePreview(tempSaveID, 0, false);
else if ((*iter).text.c_str()[1] == 't')
{
char url[256];
@ -1096,9 +1096,9 @@ void GameController::LoadSave(SaveInfo * save)
gameModel->SetSave(save);
}
void GameController::OpenSavePreview(int saveID, int saveDate)
void GameController::OpenSavePreview(int saveID, int saveDate, bool instant)
{
activePreview = new PreviewController(saveID, saveDate, new SaveOpenCallback(this));
activePreview = new PreviewController(saveID, saveDate, instant, new SaveOpenCallback(this));
ui::Engine::Ref().ShowWindow(activePreview->GetView());
}
@ -1106,7 +1106,7 @@ void GameController::OpenSavePreview()
{
if(gameModel->GetSave())
{
activePreview = new PreviewController(gameModel->GetSave()->GetID(), new SaveOpenCallback(this));
activePreview = new PreviewController(gameModel->GetSave()->GetID(), false, new SaveOpenCallback(this));
ui::Engine::Ref().ShowWindow(activePreview->GetView());
}
}

View File

@ -113,7 +113,7 @@ public:
void OpenLogin();
void OpenProfile();
void OpenTags();
void OpenSavePreview(int saveID, int saveDate);
void OpenSavePreview(int saveID, int saveDate, bool instant);
void OpenSavePreview();
void OpenLocalSaveWindow(bool asCurrent);
void OpenLocalBrowse();

View File

@ -8,7 +8,7 @@
#include "gui/login/LoginController.h"
#include "Controller.h"
PreviewController::PreviewController(int saveID, int saveDate, ControllerCallback * callback):
PreviewController::PreviewController(int saveID, int saveDate, bool instant, ControllerCallback * callback):
HasExited(false),
saveId(saveID),
saveDate(saveDate),
@ -18,6 +18,7 @@ PreviewController::PreviewController(int saveID, int saveDate, ControllerCallbac
previewView = new PreviewView();
previewModel->AddObserver(previewView);
previewView->AttachController(this);
previewModel->SetDoOpen(instant);
previewModel->UpdateSave(saveID, saveDate);
@ -31,7 +32,7 @@ PreviewController::PreviewController(int saveID, int saveDate, ControllerCallbac
this->callback = callback;
}
PreviewController::PreviewController(int saveID, ControllerCallback * callback):
PreviewController::PreviewController(int saveID, bool instant, ControllerCallback * callback):
HasExited(false),
saveId(saveID),
saveDate(0),
@ -164,7 +165,7 @@ void PreviewController::OpenInBrowser()
bool PreviewController::NextCommentPage()
{
if(previewModel->GetCommentsPageNum() < previewModel->GetCommentsPageCount() && previewModel->GetCommentsLoaded())
if(previewModel->GetCommentsPageNum() < previewModel->GetCommentsPageCount() && previewModel->GetCommentsLoaded() && !previewModel->GetDoOpen())
{
previewModel->UpdateComments(previewModel->GetCommentsPageNum()+1);
return true;
@ -174,7 +175,7 @@ bool PreviewController::NextCommentPage()
bool PreviewController::PrevCommentPage()
{
if(previewModel->GetCommentsPageNum()>1 && previewModel->GetCommentsLoaded())
if(previewModel->GetCommentsPageNum() > 1 && previewModel->GetCommentsLoaded() && !previewModel->GetDoOpen())
{
previewModel->UpdateComments(previewModel->GetCommentsPageNum()-1);
return true;

View File

@ -22,8 +22,8 @@ public:
inline int SaveID() { return saveId; };
bool HasExited;
PreviewController(int saveID, ControllerCallback * callback);
PreviewController(int saveID, int saveDate, ControllerCallback * callback);
PreviewController(int saveID, bool instant, ControllerCallback * callback);
PreviewController(int saveID, int saveDate, bool instant, ControllerCallback * callback);
void Exit();
void DoOpen();
void OpenInBrowser();

View File

@ -139,13 +139,16 @@ void PreviewModel::UpdateSave(int saveID, int saveDate)
pthread_create(&updateSaveInfoThread, 0, &PreviewModel::updateSaveInfoT, updateSaveInfoInfo);
}
if (!updateSaveCommentsInfo)
updateSaveCommentsInfo = new threadInfo(saveID, commentsPageNumber);
if (updateSaveCommentsInfo->threadFinished)
if (!GetDoOpen())
{
commentsLoaded = false;
updateSaveCommentsInfo->threadFinished = false;
pthread_create(&updateSaveCommentsThread, 0, &PreviewModel::updateSaveCommentsT, updateSaveCommentsInfo);
if (!updateSaveCommentsInfo)
updateSaveCommentsInfo = new threadInfo(saveID, commentsPageNumber);
if (updateSaveCommentsInfo->threadFinished)
{
commentsLoaded = false;
updateSaveCommentsInfo->threadFinished = false;
pthread_create(&updateSaveCommentsThread, 0, &PreviewModel::updateSaveCommentsT, updateSaveCommentsInfo);
}
}
}

View File

@ -36,6 +36,7 @@ SearchController::SearchController(ControllerCallback * callback):
HasExited(false),
nextQueryTime(0.0f),
nextQueryDone(true),
instantOpen(false),
searchModel(NULL)
{
searchModel = new SearchModel();
@ -46,9 +47,6 @@ SearchController::SearchController(ControllerCallback * callback):
searchModel->UpdateSaveList(1, "");
this->callback = callback;
//Set up interface
//windowPanel.AddChild();
}
SaveInfo * SearchController::GetLoadedSave()
@ -180,13 +178,18 @@ void SearchController::Selected(int saveID, bool selected)
searchModel->DeselectSave(saveID);
}
void SearchController::InstantOpen(bool instant)
{
instantOpen = instant;
}
void SearchController::OpenSave(int saveID)
{
if(activePreview)
delete activePreview;
Graphics * g = ui::Engine::Ref().g;
g->fillrect(XRES/3, YRES+MENUSIZE-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable
activePreview = new PreviewController(saveID, new OpenCallback(this));
activePreview = new PreviewController(saveID, instantOpen, new OpenCallback(this));
ui::Engine::Ref().ShowWindow(activePreview->GetView());
}
@ -196,7 +199,7 @@ void SearchController::OpenSave(int saveID, int saveDate)
delete activePreview;
Graphics * g = ui::Engine::Ref().g;
g->fillrect(XRES/3, YRES+MENUSIZE-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable
activePreview = new PreviewController(saveID, saveDate, new OpenCallback(this));
activePreview = new PreviewController(saveID, saveDate, instantOpen, new OpenCallback(this));
ui::Engine::Ref().ShowWindow(activePreview->GetView());
}

View File

@ -21,6 +21,7 @@ private:
double nextQueryTime;
std::string nextQuery;
bool nextQueryDone;
bool instantOpen;
void removeSelectedC();
void unpublishSelectedC();
public:
@ -37,6 +38,7 @@ public:
void ShowOwn(bool show);
void ShowFavourite(bool show);
void Selected(int saveID, bool selected);
void InstantOpen(bool instant);
void OpenSave(int saveID);
void OpenSave(int saveID, int saveDate);
void Update();

View File

@ -712,7 +712,9 @@ void SearchView::OnMouseWheel(int x, int y, int d)
}
void SearchView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
{
if(key==KEY_ESCAPE)
if (key == KEY_ESCAPE)
c->Exit();
if (ctrl)
c->InstantOpen(ctrl);
}