#pragma once
#include <functional>
#include <string>
#include <atomic>
#include "ppsspp_config.h"
#include "Common/File/Path.h"
#include "Common/UI/UIScreen.h"
#include "Common/Thread/Promise.h"
#include "Core/Util/MemStick.h"
#include "UI/BaseScreens.h"
#include "UI/MiscViews.h"
class NoticeView;
class MemStickScreen : public UIBaseDialogScreen {
public:
MemStickScreen(bool initialSetup);
~MemStickScreen() = default;
const char *tag() const override { return "MemStick"; }
enum Choice {
CHOICE_BROWSE_FOLDER,
CHOICE_PRIVATE_DIRECTORY,
CHOICE_STORAGE_ROOT,
CHOICE_SET_MANUAL,
};
protected:
void CreateViews() override;
void dialogFinished(const Screen *dialog, DialogResult result) override;
void update() override;
ScreenRenderFlags render(ScreenRenderMode mode) override {
if (!done_) {
return UIBaseDialogScreen::render(mode);
} else {
}
return ScreenRenderFlags::NONE;
}
private:
void OnHelp(UI::EventParams &e);
void Browse(UI::EventParams &e);
void UseInternalStorage(UI::EventParams ¶ms);
void UseStorageRoot(UI::EventParams ¶ms);
void SetFolderManually(UI::EventParams ¶ms);
void OnConfirmClick(UI::EventParams ¶ms);
void OnChoiceClick(UI::EventParams ¶ms);
NoticeView *errorNoticeView_ = nullptr;
bool initialSetup_;
bool storageBrowserWorking_;
bool done_ = false;
#if PPSSPP_PLATFORM(UWP) && !defined(__LIBRETRO__)
int choice_ = CHOICE_PRIVATE_DIRECTORY;
#else
int choice_ = 0;
#endif
};
struct SpaceResult {
int64_t bytesFree;
};
class ConfirmMemstickMoveScreen : public UIBaseDialogScreen {
public:
ConfirmMemstickMoveScreen(const Path &newMemstickFolder, bool initialSetup);
~ConfirmMemstickMoveScreen();
const char *tag() const override { return "ConfirmMemstickMove"; }
protected:
void update() override;
void CreateViews() override;
private:
void OnMoveDataClick(UI::EventParams ¶ms);
void FinishFolderMove();
void OnConfirm(UI::EventParams ¶ms);
Path newMemstickFolder_;
bool existingFilesInNewFolder_;
bool folderConflict_;
#if PPSSPP_PLATFORM(UWP) && !defined(__LIBRETRO__)
bool moveData_ = false;
#else
bool moveData_ = true;
#endif
bool initialSetup_;
MoveProgressReporter progressReporter_;
UI::TextView *progressView_ = nullptr;
UI::TextView *newFreeSpaceView_ = nullptr;
Promise<MoveResult *> *moveDataTask_ = nullptr;
Promise<SpaceResult *> *newSpaceTask_ = nullptr;
std::string error_;
};