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/PSPDialog.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 "Common/CommonTypes.h"
21
#include "Common/Render/TextureAtlas.h"
22
#include "Common/Swap.h"
23
#include "Core/HLE/sceUtility.h"
24
#include "Core/Util/PPGeDraw.h"
25
26
class PointerWrap;
27
28
#define SCE_UTILITY_DIALOG_RESULT_SUCCESS 0
29
#define SCE_UTILITY_DIALOG_RESULT_CANCEL 1
30
#define SCE_UTILITY_DIALOG_RESULT_ABORT 2
31
32
const int SCE_ERROR_UTILITY_INVALID_STATUS = 0x80110001;
33
const int SCE_ERROR_UTILITY_INVALID_PARAM_SIZE = 0x80110004;
34
const int SCE_ERROR_UTILITY_WRONG_TYPE = 0x80110005;
35
const int ERROR_UTILITY_INVALID_ADHOC_CHANNEL = 0x80110104;
36
const int ERROR_UTILITY_INVALID_SYSTEM_PARAM_ID = 0x80110103;
37
38
struct pspUtilityDialogCommon
39
{
40
u32_le size; /** Size of the structure */
41
s32_le language; /** Language */
42
s32_le buttonSwap; /** Set to 1 for X/O button swap */
43
s32_le graphicsThread; /** Graphics thread priority */
44
s32_le accessThread; /** Access/fileio thread priority (SceJobThread) */
45
s32_le fontThread; /** Font thread priority (ScePafThread) */
46
s32_le soundThread; /** Sound thread priority */
47
s32_le result; /** Result */
48
s32_le reserved[4]; /** Set to 0 */
49
};
50
51
52
class PSPDialog
53
{
54
public:
55
PSPDialog(UtilityDialogType type);
56
virtual ~PSPDialog();
57
58
virtual int Update(int animSpeed) = 0;
59
virtual int Shutdown(bool force = false);
60
virtual void DoState(PointerWrap &p);
61
virtual pspUtilityDialogCommon *GetCommonParam();
62
63
enum DialogStatus
64
{
65
SCE_UTILITY_STATUS_NONE = 0,
66
SCE_UTILITY_STATUS_INITIALIZE = 1,
67
SCE_UTILITY_STATUS_RUNNING = 2,
68
SCE_UTILITY_STATUS_FINISHED = 3,
69
SCE_UTILITY_STATUS_SHUTDOWN = 4,
70
SCE_UTILITY_STATUS_SCREENSHOT_UNKNOWN = 5,
71
};
72
73
enum DialogStockButton
74
{
75
DS_BUTTON_NONE = 0x00,
76
DS_BUTTON_OK = 0x01,
77
DS_BUTTON_CANCEL = 0x02,
78
DS_BUTTON_BOTH = 0x03,
79
};
80
81
DialogStatus GetStatus();
82
UtilityDialogType DialogType() { return dialogType_; }
83
84
void StartDraw();
85
void EndDraw();
86
87
void FinishVolatile();
88
int FinishInit();
89
int FinishShutdown();
90
91
protected:
92
void InitCommon();
93
void UpdateCommon();
94
PPGeStyle FadedStyle(PPGeAlign align, float scale);
95
PPGeImageStyle FadedImageStyle();
96
void UpdateButtons();
97
bool IsButtonPressed(int checkButton);
98
bool IsButtonHeld(int checkButton, int &framesHeld, int framesHeldThreshold = 30, int framesHeldRepeatRate = 10);
99
// The caption override is assumed to have a size of 64 bytes.
100
void DisplayButtons(int flags, std::string_view caption = "");
101
void ChangeStatus(DialogStatus newStatus, int delayUs);
102
void ChangeStatusInit(int delayUs);
103
void ChangeStatusShutdown(int delayUs);
104
DialogStatus ReadStatus() const {
105
return status;
106
}
107
108
// TODO: Remove this once all dialogs are updated.
109
virtual bool UseAutoStatus() = 0;
110
111
static int GetConfirmButton();
112
static int GetCancelButton();
113
114
void StartFade(bool fadeIn_);
115
void UpdateFade(int animSpeed);
116
virtual void FinishFadeOut();
117
u32 CalcFadedColor(u32 inColor) const;
118
119
DialogStatus pendingStatus = SCE_UTILITY_STATUS_NONE;
120
u64 pendingStatusTicks = 0;
121
122
unsigned int lastButtons = 0;
123
unsigned int buttons = 0;
124
125
float fadeTimer = 0.0f;
126
bool isFading = false;
127
bool fadeIn = false;
128
u32 fadeValue = 0;
129
130
ImageID okButtonImg;
131
ImageID cancelButtonImg;
132
int okButtonFlag;
133
int cancelButtonFlag;
134
135
private:
136
DialogStatus status = SCE_UTILITY_STATUS_NONE;
137
UtilityDialogType dialogType_ = UtilityDialogType::NONE;
138
bool volatileLocked_ = false;
139
};
140
141