Flush stamps list to file when deletins, Rename stamps undelete function to rescan
This commit is contained in:
parent
7313bd81ca
commit
b35fd0298c
@ -850,6 +850,8 @@ void Client::DeleteStamp(std::string stampID)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
updateStamps();
|
||||
}
|
||||
|
||||
std::string Client::AddStamp(GameSave * saveData)
|
||||
@ -911,7 +913,7 @@ void Client::updateStamps()
|
||||
return;
|
||||
}
|
||||
|
||||
void Client::UnDeleteStamps()
|
||||
void Client::RescanStamps()
|
||||
{
|
||||
DIR * directory;
|
||||
struct dirent * entry;
|
||||
@ -921,7 +923,7 @@ void Client::UnDeleteStamps()
|
||||
stampIDs.clear();
|
||||
while (entry = readdir(directory))
|
||||
{
|
||||
if(strncmp(entry->d_name, "..", 3) && strncmp(entry->d_name, ".", 2) && strstr(entry->d_name, ".stm"))
|
||||
if(strncmp(entry->d_name, "..", 3) && strncmp(entry->d_name, ".", 2) && strstr(entry->d_name, ".stm") && strlen(entry->d_name) == 14)
|
||||
{
|
||||
char stampname[11];
|
||||
strncpy(stampname, entry->d_name, 10);
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
void DeleteStamp(std::string stampID);
|
||||
std::string AddStamp(GameSave * saveData);
|
||||
std::vector<std::string> GetStamps(int start, int count);
|
||||
void Client::UnDeleteStamps();
|
||||
void RescanStamps();
|
||||
int GetStampsCount();
|
||||
SaveFile * GetFirstStamp();
|
||||
|
||||
|
@ -53,10 +53,10 @@ void LocalBrowserController::RemoveSelected()
|
||||
};
|
||||
|
||||
std::stringstream desc;
|
||||
desc << "Are you sure you want to delete " << browserModel->GetSelected().size() << " saves";
|
||||
desc << "Are you sure you want to delete " << browserModel->GetSelected().size() << " stamp";
|
||||
if(browserModel->GetSelected().size()>1)
|
||||
desc << "s";
|
||||
new ConfirmPrompt("Delete saves", desc.str(), new RemoveSelectedConfirmation(this));
|
||||
new ConfirmPrompt("Delete stamps", desc.str(), new RemoveSelectedConfirmation(this));
|
||||
}
|
||||
|
||||
void LocalBrowserController::removeSelectedC()
|
||||
@ -72,7 +72,7 @@ void LocalBrowserController::removeSelectedC()
|
||||
for(int i = 0; i < saves.size(); i++)
|
||||
{
|
||||
std::stringstream saveName;
|
||||
saveName << "Deleting save [" << saves[i] << "] ...";
|
||||
saveName << "Deleting stamp [" << saves[i] << "] ...";
|
||||
notifyStatus(saveName.str());
|
||||
Client::Ref().DeleteStamp(saves[i]);
|
||||
notifyProgress((float(i+1)/float(saves.size())*100));
|
||||
@ -89,9 +89,27 @@ void LocalBrowserController::removeSelectedC()
|
||||
new TaskWindow("Removing saves", new RemoveSavesTask(this, selected));
|
||||
}
|
||||
|
||||
void LocalBrowserController::UnDeleteStamps()
|
||||
void LocalBrowserController::RescanStamps()
|
||||
{
|
||||
browserModel->UnDeleteStamps();
|
||||
class RescanConfirmation: public ConfirmDialogueCallback {
|
||||
public:
|
||||
LocalBrowserController * c;
|
||||
RescanConfirmation(LocalBrowserController * c_) { c = c_; }
|
||||
virtual void ConfirmCallback(ConfirmPrompt::DialogueResult result) {
|
||||
if (result == ConfirmPrompt::ResultOkay)
|
||||
c->rescanStampsC();
|
||||
}
|
||||
virtual ~RescanConfirmation() { }
|
||||
};
|
||||
|
||||
std::stringstream desc;
|
||||
desc << "Rescanning the stamps folder can find stamps added to the stamps folder or recover stamps when the stamps.def file has been lost or damaged. However, be warned that this may mess up the current sorting order";
|
||||
new ConfirmPrompt("Rescan", desc.str(), new RescanConfirmation(this));
|
||||
}
|
||||
|
||||
void LocalBrowserController::rescanStampsC()
|
||||
{
|
||||
browserModel->RescanStamps();
|
||||
browserModel->UpdateSavesList(browserModel->GetPageNum());
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,8 @@ public:
|
||||
void removeSelectedC();
|
||||
void ClearSelection();
|
||||
void Selected(std::string stampID, bool selected);
|
||||
void UnDeleteStamps();
|
||||
void RescanStamps();
|
||||
void rescanStampsC();
|
||||
void RefreshSavesList();
|
||||
void OpenSave(SaveFile * stamp);
|
||||
void SetStamp();
|
||||
|
@ -87,9 +87,9 @@ void LocalBrowserModel::UpdateSavesList(int pageNumber)
|
||||
notifySavesListChanged();
|
||||
}
|
||||
|
||||
void LocalBrowserModel::UnDeleteStamps()
|
||||
void LocalBrowserModel::RescanStamps()
|
||||
{
|
||||
Client::Ref().UnDeleteStamps();
|
||||
Client::Ref().RescanStamps();
|
||||
}
|
||||
|
||||
int LocalBrowserModel::GetPageCount()
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
void AddObserver(LocalBrowserView * observer);
|
||||
std::vector<SaveFile *> GetSavesList();
|
||||
void UpdateSavesList(int pageNumber);
|
||||
void UnDeleteStamps();
|
||||
void RescanStamps();
|
||||
SaveFile * GetSave();
|
||||
void SetSave(SaveFile * newStamp);
|
||||
std::vector<std::string> GetSelected() { return selected; }
|
||||
|
@ -26,7 +26,7 @@ LocalBrowserView::LocalBrowserView():
|
||||
{
|
||||
nextButton = new ui::Button(ui::Point(XRES+BARSIZE-52, YRES+MENUSIZE-18), ui::Point(50, 16), "Next \x95");
|
||||
previousButton = new ui::Button(ui::Point(1, YRES+MENUSIZE-18), ui::Point(50, 16), "\x96 Prev");
|
||||
undeleteButton = new ui::Button(ui::Point(XRES+BARSIZE-122, YRES+MENUSIZE-18), ui::Point(60, 16), "Stamp Fix");
|
||||
undeleteButton = new ui::Button(ui::Point(XRES+BARSIZE-122, YRES+MENUSIZE-18), ui::Point(60, 16), "Rescan");
|
||||
infoLabel = new ui::Label(ui::Point(51, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-102, 16), "Loading...");
|
||||
AddComponent(infoLabel);
|
||||
AddComponent(nextButton);
|
||||
@ -68,8 +68,7 @@ LocalBrowserView::LocalBrowserView():
|
||||
UndeleteAction(LocalBrowserView * _v) { v = _v; }
|
||||
void ActionCallback(ui::Button * sender)
|
||||
{
|
||||
if(ConfirmPrompt::Blocking("Bring back deleted stamps", "Versions 83.1-83.8 had a bug where stamps past page 3 were deleted from the list. Click continue to bring these back and read every stamp in the stamps/ folder.\n\nWARNING:\nThis will also bring back all stamps deleted before version 74.2 (March 2012)", "Continue"))
|
||||
v->c->UnDeleteStamps();
|
||||
v->c->RescanStamps();
|
||||
}
|
||||
};
|
||||
undeleteButton->SetActionCallback(new UndeleteAction(this));
|
||||
|
Reference in New Issue
Block a user