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/MiscScreens.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 <map>
22
#include <string>
23
#include <vector>
24
25
#include "Common/UI/UIScreen.h"
26
#include "Common/UI/PopupScreens.h"
27
#include "Common/File/DirListing.h"
28
#include "Common/File/Path.h"
29
30
struct ShaderInfo;
31
struct TextureShaderInfo;
32
33
extern Path boot_filename;
34
void UIBackgroundInit(UIContext &dc);
35
void UIBackgroundShutdown();
36
37
inline void NoOpVoidBool(bool) {}
38
39
class BackgroundScreen : public UIScreen {
40
public:
41
ScreenRenderFlags render(ScreenRenderMode mode) override;
42
void sendMessage(UIMessage message, const char *value) override;
43
44
private:
45
void CreateViews() override {}
46
const char *tag() const override { return "bg"; }
47
48
Path gamePath_;
49
};
50
51
// This doesn't have anything to do with the background anymore. It's just a PPSSPP UIScreen
52
// that knows how handle sendMessage properly. Same for all the below.
53
class UIScreenWithBackground : public UIScreen {
54
public:
55
UIScreenWithBackground() : UIScreen() {}
56
protected:
57
void sendMessage(UIMessage message, const char *value) override;
58
};
59
60
class UIScreenWithGameBackground : public UIScreenWithBackground {
61
public:
62
UIScreenWithGameBackground(const Path &gamePath) : UIScreenWithBackground(), gamePath_(gamePath) {}
63
void sendMessage(UIMessage message, const char *value) override;
64
protected:
65
Path gamePath_;
66
67
bool forceTransparent_ = false;
68
bool darkenGameBackground_ = true;
69
};
70
71
class UIDialogScreenWithBackground : public UIDialogScreen {
72
public:
73
UIDialogScreenWithBackground() : UIDialogScreen() {}
74
protected:
75
void sendMessage(UIMessage message, const char *value) override;
76
void AddStandardBack(UI::ViewGroup *parent);
77
};
78
79
class UIDialogScreenWithGameBackground : public UIDialogScreenWithBackground {
80
public:
81
UIDialogScreenWithGameBackground(const Path &gamePath)
82
: UIDialogScreenWithBackground(), gamePath_(gamePath) {}
83
void sendMessage(UIMessage message, const char *value) override;
84
protected:
85
Path gamePath_;
86
};
87
88
class PromptScreen : public UIDialogScreenWithGameBackground {
89
public:
90
PromptScreen(const Path& gamePath, std::string_view message, std::string_view yesButtonText, std::string_view noButtonText,
91
std::function<void(bool)> callback = &NoOpVoidBool);
92
93
void CreateViews() override;
94
95
void TriggerFinish(DialogResult result) override;
96
97
const char *tag() const override { return "Prompt"; }
98
99
private:
100
UI::EventReturn OnYes(UI::EventParams &e);
101
UI::EventReturn OnNo(UI::EventParams &e);
102
103
std::string message_;
104
std::string yesButtonText_;
105
std::string noButtonText_;
106
std::function<void(bool)> callback_;
107
};
108
109
class NewLanguageScreen : public UI::ListPopupScreen {
110
public:
111
NewLanguageScreen(std::string_view title);
112
113
const char *tag() const override { return "NewLanguage"; }
114
115
private:
116
void OnCompleted(DialogResult result) override;
117
bool ShowButtons() const override { return true; }
118
std::vector<File::FileInfo> langs_;
119
};
120
121
class TextureShaderScreen : public UI::ListPopupScreen {
122
public:
123
TextureShaderScreen(std::string_view title);
124
125
void CreateViews() override;
126
127
const char *tag() const override { return "TextureShader"; }
128
129
private:
130
void OnCompleted(DialogResult result) override;
131
bool ShowButtons() const override { return true; }
132
std::vector<TextureShaderInfo> shaders_;
133
};
134
135
enum class AfterLogoScreen {
136
TO_GAME_SETTINGS,
137
DEFAULT,
138
MEMSTICK_SCREEN_INITIAL_SETUP,
139
};
140
141
class LogoScreen : public UIScreen {
142
public:
143
LogoScreen(AfterLogoScreen afterLogoScreen = AfterLogoScreen::DEFAULT);
144
145
bool key(const KeyInput &key) override;
146
void touch(const TouchInput &touch) override;
147
void update() override;
148
void DrawForeground(UIContext &ui) override;
149
void sendMessage(UIMessage message, const char *value) override;
150
void CreateViews() override {}
151
152
const char *tag() const override { return "Logo"; }
153
154
private:
155
void Next();
156
int frames_ = 0;
157
double sinceStart_ = 0.0;
158
bool switched_ = false;
159
AfterLogoScreen afterLogoScreen_;
160
};
161
162
class CreditsScreen : public UIDialogScreenWithBackground {
163
public:
164
CreditsScreen();
165
void update() override;
166
void DrawForeground(UIContext &ui) override;
167
168
void CreateViews() override;
169
170
const char *tag() const override { return "Credits"; }
171
172
private:
173
UI::EventReturn OnSupport(UI::EventParams &e);
174
UI::EventReturn OnPPSSPPOrg(UI::EventParams &e);
175
UI::EventReturn OnPrivacy(UI::EventParams &e);
176
UI::EventReturn OnForums(UI::EventParams &e);
177
UI::EventReturn OnDiscord(UI::EventParams &e);
178
UI::EventReturn OnShare(UI::EventParams &e);
179
UI::EventReturn OnTwitter(UI::EventParams &e);
180
181
double startTime_ = 0.0;
182
};
183
184
class SettingInfoMessage : public UI::LinearLayout {
185
public:
186
SettingInfoMessage(int align, float cutOffY, UI::AnchorLayoutParams *lp);
187
188
void Show(std::string_view text, const UI::View *refView = nullptr);
189
190
void Draw(UIContext &dc) override;
191
std::string GetText() const;
192
193
private:
194
UI::TextView *text_ = nullptr;
195
double timeShown_ = 0.0;
196
float cutOffY_;
197
bool showing_ = false;
198
};
199
200
uint32_t GetBackgroundColorWithAlpha(const UIContext &dc);
201
202