Stamp fix button to bring back deleted stamps
This commit is contained in:
parent
cb8efcd0f9
commit
d45dd605e9
@ -21,11 +21,11 @@
|
||||
#endif
|
||||
|
||||
#ifndef MINOR_VERSION
|
||||
#define MINOR_VERSION 4
|
||||
#define MINOR_VERSION 9
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_NUM
|
||||
#define BUILD_NUM 213
|
||||
#define BUILD_NUM 232
|
||||
#endif
|
||||
|
||||
#ifndef SNAPSHOT_ID
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <stdio.h>
|
||||
#include <deque>
|
||||
#include <fstream>
|
||||
#include <dirent.h>
|
||||
|
||||
#ifdef MACOSX
|
||||
#include <mach-o/dyld.h>
|
||||
@ -910,6 +911,28 @@ void Client::updateStamps()
|
||||
return;
|
||||
}
|
||||
|
||||
void Client::UnDeleteStamps()
|
||||
{
|
||||
DIR * directory;
|
||||
struct dirent * entry;
|
||||
directory = opendir("stamps");
|
||||
if (directory != NULL)
|
||||
{
|
||||
stampIDs.clear();
|
||||
while (entry = readdir(directory))
|
||||
{
|
||||
if(strncmp(entry->d_name, "..", 3) && strncmp(entry->d_name, ".", 2) && strcmp(entry->d_name, ".stm"))
|
||||
{
|
||||
char stampname[11];
|
||||
strncpy(stampname, entry->d_name, 10);
|
||||
stampIDs.push_front(stampname);
|
||||
}
|
||||
}
|
||||
closedir(directory);
|
||||
updateStamps();
|
||||
}
|
||||
}
|
||||
|
||||
int Client::GetStampsCount()
|
||||
{
|
||||
return stampIDs.size();
|
||||
|
@ -112,6 +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();
|
||||
int GetStampsCount();
|
||||
SaveFile * GetFirstStamp();
|
||||
|
||||
|
@ -89,6 +89,12 @@ void LocalBrowserController::removeSelectedC()
|
||||
new TaskWindow("Removing saves", new RemoveSavesTask(this, selected));
|
||||
}
|
||||
|
||||
void LocalBrowserController::UnDeleteStamps()
|
||||
{
|
||||
browserModel->UnDeleteStamps();
|
||||
browserModel->UpdateSavesList(browserModel->GetPageNum());
|
||||
}
|
||||
|
||||
void LocalBrowserController::RefreshSavesList()
|
||||
{
|
||||
ClearSelection();
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
void removeSelectedC();
|
||||
void ClearSelection();
|
||||
void Selected(std::string stampID, bool selected);
|
||||
void UnDeleteStamps();
|
||||
void RefreshSavesList();
|
||||
void OpenSave(SaveFile * stamp);
|
||||
void SetStamp();
|
||||
|
@ -87,6 +87,11 @@ void LocalBrowserModel::UpdateSavesList(int pageNumber)
|
||||
notifySavesListChanged();
|
||||
}
|
||||
|
||||
void LocalBrowserModel::UnDeleteStamps()
|
||||
{
|
||||
Client::Ref().UnDeleteStamps();
|
||||
}
|
||||
|
||||
int LocalBrowserModel::GetPageCount()
|
||||
{
|
||||
return std::max(1, (int)(std::ceil(float(Client::Ref().GetStampsCount())/20.0f)));
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
void AddObserver(LocalBrowserView * observer);
|
||||
std::vector<SaveFile *> GetSavesList();
|
||||
void UpdateSavesList(int pageNumber);
|
||||
void UnDeleteStamps();
|
||||
SaveFile * GetSave();
|
||||
void SetSave(SaveFile * newStamp);
|
||||
std::vector<std::string> GetSelected() { return selected; }
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "interface/Keys.h"
|
||||
|
||||
#include "dialogues/ErrorMessage.h"
|
||||
#include "dialogues/ConfirmPrompt.h"
|
||||
#include "LocalBrowserController.h"
|
||||
#include "LocalBrowserModel.h"
|
||||
#include "LocalBrowserModelException.h"
|
||||
@ -25,10 +26,12 @@ 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");
|
||||
infoLabel = new ui::Label(ui::Point(51, YRES+MENUSIZE-18), ui::Point(XRES+BARSIZE-102, 16), "Loading...");
|
||||
AddComponent(infoLabel);
|
||||
AddComponent(nextButton);
|
||||
AddComponent(previousButton);
|
||||
AddComponent(undeleteButton);
|
||||
|
||||
class NextPageAction : public ui::ButtonAction
|
||||
{
|
||||
@ -58,6 +61,19 @@ LocalBrowserView::LocalBrowserView():
|
||||
previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
|
||||
previousButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
|
||||
class UndeleteAction : public ui::ButtonAction
|
||||
{
|
||||
LocalBrowserView * v;
|
||||
public:
|
||||
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();
|
||||
}
|
||||
};
|
||||
undeleteButton->SetActionCallback(new UndeleteAction(this));
|
||||
|
||||
class RemoveSelectedAction : public ui::ButtonAction
|
||||
{
|
||||
LocalBrowserView * v;
|
||||
|
@ -23,6 +23,7 @@ class LocalBrowserModel;
|
||||
class LocalBrowserView: public ui::Window {
|
||||
LocalBrowserController * c;
|
||||
std::vector<ui::SaveButton*> stampButtons;
|
||||
ui::Button * undeleteButton;
|
||||
ui::Button * previousButton;
|
||||
ui::Button * nextButton;
|
||||
ui::Label * infoLabel;
|
||||
|
Loading…
Reference in New Issue
Block a user