diff --git a/src/Config.h b/src/Config.h index e58f11900..8baefd225 100644 --- a/src/Config.h +++ b/src/Config.h @@ -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 diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 238c216ed..a1becf494 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef MACOSX #include @@ -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(); diff --git a/src/client/Client.h b/src/client/Client.h index 95ae9520e..1cda795b7 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -112,6 +112,7 @@ public: void DeleteStamp(std::string stampID); std::string AddStamp(GameSave * saveData); std::vector GetStamps(int start, int count); + void Client::UnDeleteStamps(); int GetStampsCount(); SaveFile * GetFirstStamp(); diff --git a/src/localbrowser/LocalBrowserController.cpp b/src/localbrowser/LocalBrowserController.cpp index 9565759e2..6d1b42dec 100644 --- a/src/localbrowser/LocalBrowserController.cpp +++ b/src/localbrowser/LocalBrowserController.cpp @@ -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(); diff --git a/src/localbrowser/LocalBrowserController.h b/src/localbrowser/LocalBrowserController.h index 1f81ab6f7..1ba3bf637 100644 --- a/src/localbrowser/LocalBrowserController.h +++ b/src/localbrowser/LocalBrowserController.h @@ -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(); diff --git a/src/localbrowser/LocalBrowserModel.cpp b/src/localbrowser/LocalBrowserModel.cpp index a38ca1fce..4a7e780d8 100644 --- a/src/localbrowser/LocalBrowserModel.cpp +++ b/src/localbrowser/LocalBrowserModel.cpp @@ -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))); diff --git a/src/localbrowser/LocalBrowserModel.h b/src/localbrowser/LocalBrowserModel.h index e6b6905b5..6bd19eb62 100644 --- a/src/localbrowser/LocalBrowserModel.h +++ b/src/localbrowser/LocalBrowserModel.h @@ -32,6 +32,7 @@ public: void AddObserver(LocalBrowserView * observer); std::vector GetSavesList(); void UpdateSavesList(int pageNumber); + void UnDeleteStamps(); SaveFile * GetSave(); void SetSave(SaveFile * newStamp); std::vector GetSelected() { return selected; } diff --git a/src/localbrowser/LocalBrowserView.cpp b/src/localbrowser/LocalBrowserView.cpp index cbb98bfb9..daf623c0a 100644 --- a/src/localbrowser/LocalBrowserView.cpp +++ b/src/localbrowser/LocalBrowserView.cpp @@ -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; diff --git a/src/localbrowser/LocalBrowserView.h b/src/localbrowser/LocalBrowserView.h index 71c20ee33..7a8c8137a 100644 --- a/src/localbrowser/LocalBrowserView.h +++ b/src/localbrowser/LocalBrowserView.h @@ -23,6 +23,7 @@ class LocalBrowserModel; class LocalBrowserView: public ui::Window { LocalBrowserController * c; std::vector stampButtons; + ui::Button * undeleteButton; ui::Button * previousButton; ui::Button * nextButton; ui::Label * infoLabel;