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/Core/Dialog/PSPSaveDialog.h
Views: 1401
1
// Copyright (c) 2012- 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 <thread>
21
#include <mutex>
22
23
#include "Core/Dialog/PSPDialog.h"
24
#include "Core/Dialog/SavedataParam.h"
25
26
#define SCE_UTILITY_SAVEDATA_ERROR_TYPE (0x80110300)
27
28
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_MS (0x80110301)
29
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_EJECT_MS (0x80110302)
30
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_ACCESS_ERROR (0x80110305)
31
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_DATA_BROKEN (0x80110306)
32
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA (0x80110307)
33
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_PARAM (0x80110308)
34
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_FILE_NOT_FOUND (0x80110309)
35
#define SCE_UTILITY_SAVEDATA_ERROR_LOAD_INTERNAL (0x8011030b)
36
37
#define SCE_UTILITY_SAVEDATA_ERROR_RW_NO_MEMSTICK (0x80110321)
38
#define SCE_UTILITY_SAVEDATA_ERROR_RW_MEMSTICK_FULL (0x80110323)
39
#define SCE_UTILITY_SAVEDATA_ERROR_RW_DATA_BROKEN (0x80110326)
40
#define SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA (0x80110327)
41
#define SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_PARAMS (0x80110328)
42
#define SCE_UTILITY_SAVEDATA_ERROR_RW_FILE_NOT_FOUND (0x80110329)
43
#define SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_STATUS (0x8011032c)
44
45
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_NO_MS (0x80110381)
46
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_EJECT_MS (0x80110382)
47
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE (0x80110383)
48
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_PROTECTED (0x80110384)
49
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_ACCESS_ERROR (0x80110385)
50
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_PARAM (0x80110388)
51
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_NO_UMD (0x80110389)
52
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_WRONG_UMD (0x8011038a)
53
#define SCE_UTILITY_SAVEDATA_ERROR_SAVE_INTERNAL (0x8011038b)
54
55
#define SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_MS (0x80110341)
56
#define SCE_UTILITY_SAVEDATA_ERROR_DELETE_EJECT_MS (0x80110342)
57
#define SCE_UTILITY_SAVEDATA_ERROR_DELETE_MS_PROTECTED (0x80110344)
58
#define SCE_UTILITY_SAVEDATA_ERROR_DELETE_ACCESS_ERROR (0x80110345)
59
#define SCE_UTILITY_SAVEDATA_ERROR_DELETE_NO_DATA (0x80110347)
60
#define SCE_UTILITY_SAVEDATA_ERROR_DELETE_PARAM (0x80110348)
61
#define SCE_UTILITY_SAVEDATA_ERROR_DELETE_INTERNAL (0x8011034b)
62
63
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_MS (0x801103C1)
64
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_EJECT_MS (0x801103C2)
65
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_ACCESS_ERROR (0x801103C5)
66
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_DATA (0x801103C7)
67
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_PARAM (0x801103C8)
68
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_NO_UMD (0x801103C9)
69
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_WRONG_UMD (0x801103Ca)
70
#define SCE_UTILITY_SAVEDATA_ERROR_SIZES_INTERNAL (0x801103Cb)
71
72
class PSPSaveDialog: public PSPDialog {
73
public:
74
PSPSaveDialog(UtilityDialogType type);
75
~PSPSaveDialog();
76
77
int Init(int paramAddr);
78
int Update(int animSpeed) override;
79
int Shutdown(bool force = false) override;
80
void DoState(PointerWrap &p) override;
81
pspUtilityDialogCommon *GetCommonParam() override;
82
83
void ExecuteIOAction();
84
85
protected:
86
bool UseAutoStatus() override {
87
return false;
88
}
89
90
private:
91
92
void DisplayBanner(int which);
93
void DisplaySaveList(bool canMove = true);
94
void DisplaySaveIcon(bool checkExists);
95
void DisplaySaveDataInfo1();
96
void DisplaySaveDataInfo2(bool showNewData = false);
97
void DisplayMessage(std::string_view text, bool hasYesNo = false);
98
std::string GetSelectedSaveDirName() const;
99
100
void JoinIOThread();
101
void StartIOThread();
102
void ExecuteNotVisibleIOAction();
103
104
enum DisplayState
105
{
106
DS_NONE,
107
108
DS_SAVE_LIST_CHOICE,
109
DS_SAVE_CONFIRM,
110
DS_SAVE_CONFIRM_OVERWRITE,
111
DS_SAVE_SAVING,
112
DS_SAVE_DONE,
113
114
DS_LOAD_LIST_CHOICE,
115
DS_LOAD_CONFIRM,
116
DS_LOAD_LOADING,
117
DS_LOAD_DONE,
118
DS_LOAD_NODATA,
119
120
DS_DELETE_LIST_CHOICE,
121
DS_DELETE_CONFIRM,
122
DS_DELETE_DELETING,
123
DS_DELETE_DONE,
124
DS_DELETE_NODATA,
125
126
DS_SAVE_FAILED,
127
DS_LOAD_FAILED,
128
DS_DELETE_FAILED,
129
};
130
131
enum DialogBanner
132
{
133
DB_NONE,
134
DB_SAVE,
135
DB_LOAD,
136
DB_DELETE
137
};
138
139
DisplayState display = DS_NONE;
140
141
SavedataParam param;
142
SceUtilitySavedataParam request{};
143
// For detecting changes made by the game.
144
SceUtilitySavedataParam originalRequest{};
145
u32 requestAddr = 0;
146
int currentSelectedSave = 0;
147
148
int yesnoChoice = 0;
149
150
enum SaveIOStatus
151
{
152
SAVEIO_NONE,
153
SAVEIO_PENDING,
154
SAVEIO_DONE,
155
};
156
157
std::thread *ioThread = nullptr;
158
std::mutex paramLock;
159
volatile SaveIOStatus ioThreadStatus;
160
};
161
162
163