Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/MemStickScreen.h
5656 views
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/BaseScreens.h"
33
#include "UI/MiscViews.h"
34
35
class NoticeView;
36
37
// MemStickScreen - let's you configure your memory stick directory.
38
// Currently only useful for Android.
39
class MemStickScreen : public UIBaseDialogScreen {
40
public:
41
MemStickScreen(bool initialSetup);
42
~MemStickScreen() = default;
43
44
const char *tag() const override { return "MemStick"; }
45
46
enum Choice {
47
CHOICE_BROWSE_FOLDER,
48
CHOICE_PRIVATE_DIRECTORY,
49
CHOICE_STORAGE_ROOT,
50
CHOICE_SET_MANUAL,
51
};
52
53
protected:
54
void CreateViews() override;
55
56
void dialogFinished(const Screen *dialog, DialogResult result) override;
57
void update() override;
58
ScreenRenderFlags render(ScreenRenderMode mode) override {
59
// Simple anti-flicker due to delayed finish.
60
if (!done_) {
61
// render as usual.
62
return UIBaseDialogScreen::render(mode);
63
} else {
64
// no render. black frame insertion is better than flicker.
65
}
66
return ScreenRenderFlags::NONE;
67
}
68
69
private:
70
// Event handlers
71
void OnHelp(UI::EventParams &e);
72
73
// Confirm button sub handlers
74
void Browse(UI::EventParams &e);
75
void UseInternalStorage(UI::EventParams &params);
76
void UseStorageRoot(UI::EventParams &params);
77
void SetFolderManually(UI::EventParams &params);
78
79
// Button handlers.
80
void OnConfirmClick(UI::EventParams &params);
81
void OnChoiceClick(UI::EventParams &params);
82
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
struct SpaceResult {
97
int64_t bytesFree;
98
};
99
100
class ConfirmMemstickMoveScreen : public UIBaseDialogScreen {
101
public:
102
ConfirmMemstickMoveScreen(const Path &newMemstickFolder, bool initialSetup);
103
~ConfirmMemstickMoveScreen();
104
105
const char *tag() const override { return "ConfirmMemstickMove"; }
106
107
protected:
108
void update() override;
109
void CreateViews() override;
110
111
private:
112
void OnMoveDataClick(UI::EventParams &params);
113
void FinishFolderMove();
114
115
void OnConfirm(UI::EventParams &params);
116
117
Path newMemstickFolder_;
118
bool existingFilesInNewFolder_;
119
bool folderConflict_;
120
121
#if PPSSPP_PLATFORM(UWP) && !defined(__LIBRETRO__)
122
bool moveData_ = false;
123
#else
124
bool moveData_ = true;
125
#endif
126
bool initialSetup_;
127
128
MoveProgressReporter progressReporter_;
129
UI::TextView *progressView_ = nullptr;
130
UI::TextView *newFreeSpaceView_ = nullptr;
131
132
Promise<MoveResult *> *moveDataTask_ = nullptr;
133
Promise<SpaceResult *> *newSpaceTask_ = nullptr;
134
135
std::string error_;
136
};
137
138