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