Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/Dialog/PSPSaveDialog.h
3186 views
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
class PSPSaveDialog : public PSPDialog {
27
public:
28
PSPSaveDialog(UtilityDialogType type);
29
~PSPSaveDialog();
30
31
int Init(int paramAddr);
32
int Update(int animSpeed) override;
33
int Shutdown(bool force = false) override;
34
void DoState(PointerWrap &p) override;
35
pspUtilityDialogCommon *GetCommonParam() override;
36
37
void ExecuteIOAction();
38
39
protected:
40
bool UseAutoStatus() override {
41
return false;
42
}
43
44
private:
45
void DisplayBanner(int which);
46
void DisplaySaveList(bool canMove = true);
47
void DisplaySaveIcon(bool checkExists);
48
void DisplaySaveDataInfo1();
49
void DisplaySaveDataInfo2(bool showNewData = false);
50
void DisplayMessage(std::string_view text, bool hasYesNo = false);
51
std::string GetSelectedSaveDirName() const;
52
53
void StartIOThread();
54
void ExecuteNotVisibleIOAction();
55
56
enum DisplayState {
57
DS_NONE,
58
59
DS_SAVE_LIST_CHOICE,
60
DS_SAVE_CONFIRM,
61
DS_SAVE_CONFIRM_OVERWRITE,
62
DS_SAVE_SAVING,
63
DS_SAVE_DONE,
64
65
DS_LOAD_LIST_CHOICE,
66
DS_LOAD_CONFIRM,
67
DS_LOAD_LOADING,
68
DS_LOAD_DONE,
69
DS_LOAD_NODATA,
70
71
DS_DELETE_LIST_CHOICE,
72
DS_DELETE_CONFIRM,
73
DS_DELETE_DELETING,
74
DS_DELETE_DONE,
75
DS_DELETE_NODATA,
76
77
DS_SAVE_FAILED,
78
DS_LOAD_FAILED,
79
DS_DELETE_FAILED,
80
};
81
82
enum DialogBanner {
83
DB_NONE,
84
DB_SAVE,
85
DB_LOAD,
86
DB_DELETE
87
};
88
89
DisplayState display = DS_NONE;
90
91
SavedataParam param;
92
SceUtilitySavedataParam request{};
93
// For detecting changes made by the game.
94
SceUtilitySavedataParam originalRequest{};
95
u32 requestAddr = 0;
96
int currentSelectedSave = 0;
97
98
enum SaveIOStatus {
99
SAVEIO_NONE,
100
SAVEIO_PENDING,
101
SAVEIO_DONE,
102
};
103
104
std::thread ioThread;
105
std::mutex paramLock;
106
volatile SaveIOStatus ioThreadStatus = SAVEIO_NONE;
107
};
108
109
void ResetSecondsSinceLastGameSave();
110
double SecondsSinceLastGameSave();
111
112