CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/MemStickScreen.h
Views: 1401
1
// Copyright (c) 2013- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include <functional>
21
#include <string>
22
#include <atomic>
23
24
#include "ppsspp_config.h"
25
26
#include "Common/File/Path.h"
27
#include "Common/UI/UIScreen.h"
28
#include "Common/Thread/Promise.h"
29
30
#include "Core/Util/MemStick.h"
31
32
#include "UI/MiscScreens.h"
33
34
class NoticeView;
35
36
// MemStickScreen - let's you configure your memory stick directory.
37
// Currently only useful for Android.
38
class MemStickScreen : public UIDialogScreenWithBackground {
39
public:
40
MemStickScreen(bool initialSetup);
41
~MemStickScreen() {}
42
43
const char *tag() const override { return "MemStick"; }
44
45
enum Choice {
46
CHOICE_BROWSE_FOLDER,
47
CHOICE_PRIVATE_DIRECTORY,
48
CHOICE_STORAGE_ROOT,
49
CHOICE_SET_MANUAL,
50
};
51
52
protected:
53
void CreateViews() override;
54
55
void dialogFinished(const Screen *dialog, DialogResult result) override;
56
void update() override;
57
ScreenRenderFlags render(ScreenRenderMode mode) override {
58
// Simple anti-flicker due to delayed finish.
59
if (!done_) {
60
// render as usual.
61
return UIDialogScreenWithBackground::render(mode);
62
} else {
63
// no render. black frame insertion is better than flicker.
64
}
65
return ScreenRenderFlags::NONE;
66
}
67
68
private:
69
// Event handlers
70
UI::EventReturn OnHelp(UI::EventParams &e);
71
72
// Confirm button sub handlers
73
UI::EventReturn Browse(UI::EventParams &e);
74
UI::EventReturn UseInternalStorage(UI::EventParams &params);
75
UI::EventReturn UseStorageRoot(UI::EventParams &params);
76
UI::EventReturn SetFolderManually(UI::EventParams &params);
77
78
// Button handlers.
79
UI::EventReturn OnConfirmClick(UI::EventParams &params);
80
UI::EventReturn OnChoiceClick(UI::EventParams &params);
81
82
SettingInfoMessage *settingInfo_ = nullptr;
83
NoticeView *errorNoticeView_ = nullptr;
84
85
bool initialSetup_;
86
bool storageBrowserWorking_;
87
bool done_ = false;
88
89
#if PPSSPP_PLATFORM(UWP) && !defined(__LIBRETRO__)
90
int choice_ = CHOICE_PRIVATE_DIRECTORY;
91
#else
92
int choice_ = 0;
93
#endif
94
};
95
96
class ConfirmMemstickMoveScreen : public UIDialogScreenWithBackground {
97
public:
98
ConfirmMemstickMoveScreen(Path newMemstickFolder, bool initialSetup);
99
~ConfirmMemstickMoveScreen();
100
101
const char *tag() const override { return "ConfirmMemstickMove"; }
102
103
protected:
104
void update() override;
105
void CreateViews() override;
106
107
private:
108
UI::EventReturn OnMoveDataClick(UI::EventParams &params);
109
void FinishFolderMove();
110
111
UI::EventReturn OnConfirm(UI::EventParams &params);
112
113
Path newMemstickFolder_;
114
bool existingFilesInNewFolder_;
115
#if PPSSPP_PLATFORM(UWP) && !defined(__LIBRETRO__)
116
bool moveData_ = false;
117
#else
118
bool moveData_ = true;
119
#endif
120
bool initialSetup_;
121
122
MoveProgressReporter progressReporter_;
123
UI::TextView *progressView_ = nullptr;
124
125
Promise<MoveResult *> *moveDataTask_ = nullptr;
126
127
std::string error_;
128
};
129
130