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 <memory>
23 #include <string>
24 #include <vector>
25 
26 #include "Common/Data/Text/I18n.h"
27 #include "Common/Net/HTTPClient.h"
28 #include "Common/UI/UIScreen.h"
29 
30 #include "UI/MiscScreens.h"
31 #include "GPU/Common/ShaderCommon.h"
32 
33 class DevMenu : public PopupScreen {
34 public:
DevMenu(std::shared_ptr<I18NCategory> i18n)35 	DevMenu(std::shared_ptr<I18NCategory> i18n) : PopupScreen(i18n->T("Dev Tools")) {}
36 
37 	void CreatePopupContents(UI::ViewGroup *parent) override;
38 	void dialogFinished(const Screen *dialog, DialogResult result) override;
39 
40 protected:
41 	UI::EventReturn OnLogView(UI::EventParams &e);
42 	UI::EventReturn OnLogConfig(UI::EventParams &e);
43 	UI::EventReturn OnJitCompare(UI::EventParams &e);
44 	UI::EventReturn OnShaderView(UI::EventParams &e);
45 	UI::EventReturn OnFreezeFrame(UI::EventParams &e);
46 	UI::EventReturn OnDumpFrame(UI::EventParams &e);
47 	UI::EventReturn OnDeveloperTools(UI::EventParams &e);
48 	UI::EventReturn OnToggleAudioDebug(UI::EventParams &e);
49 	UI::EventReturn OnResetLimitedLogging(UI::EventParams &e);
50 };
51 
52 class JitDebugScreen : public UIDialogScreenWithBackground {
53 public:
JitDebugScreen()54 	JitDebugScreen() {}
55 	virtual void CreateViews() override;
56 
57 private:
58 	UI::EventReturn OnEnableAll(UI::EventParams &e);
59 	UI::EventReturn OnDisableAll(UI::EventParams &e);
60 };
61 
62 class LogConfigScreen : public UIDialogScreenWithBackground {
63 public:
LogConfigScreen()64 	LogConfigScreen() {}
65 	virtual void CreateViews() override;
66 
67 private:
68 	UI::EventReturn OnToggleAll(UI::EventParams &e);
69 	UI::EventReturn OnEnableAll(UI::EventParams &e);
70 	UI::EventReturn OnDisableAll(UI::EventParams &e);
71 	UI::EventReturn OnLogLevel(UI::EventParams &e);
72 	UI::EventReturn OnLogLevelChange(UI::EventParams &e);
73 };
74 
75 class LogScreen : public UIDialogScreenWithBackground {
76 public:
LogScreen()77 	LogScreen() : toBottom_(false) {}
78 	void CreateViews() override;
79 	void update() override;
80 
81 private:
82 	void UpdateLog();
83 	UI::EventReturn OnSubmit(UI::EventParams &e);
84 	UI::TextEdit *cmdLine_;
85 	UI::LinearLayout *vert_;
86 	UI::ScrollView *scroll_;
87 	bool toBottom_;
88 };
89 
90 class LogLevelScreen : public ListPopupScreen {
91 public:
92 	LogLevelScreen(const std::string &title);
93 
94 private:
95 	virtual void OnCompleted(DialogResult result);
96 
97 };
98 
99 class SystemInfoScreen : public UIDialogScreenWithBackground {
100 public:
SystemInfoScreen()101 	SystemInfoScreen() {}
102 	void CreateViews() override;
103 };
104 
105 class AddressPromptScreen : public PopupScreen {
106 public:
AddressPromptScreen(const std::string & title)107 	AddressPromptScreen(const std::string &title) : PopupScreen(title, "OK", "Cancel"), addrView_(NULL), addr_(0) {
108 		memset(buttons_, 0, sizeof(buttons_));
109 	}
110 
111 	virtual bool key(const KeyInput &key) override;
112 
113 	UI::Event OnChoice;
114 
115 protected:
116 	virtual void CreatePopupContents(UI::ViewGroup *parent) override;
117 	virtual void OnCompleted(DialogResult result) override;
118 	UI::EventReturn OnDigitButton(UI::EventParams &e);
119 	UI::EventReturn OnBackspace(UI::EventParams &e);
120 
121 private:
122 	void AddDigit(int n);
123 	void BackspaceDigit();
124 	void UpdatePreviewDigits();
125 
126 	UI::TextView *addrView_;
127 	UI::Button *buttons_[16];
128 	unsigned int addr_;
129 };
130 
131 class JitCompareScreen : public UIDialogScreenWithBackground {
132 public:
JitCompareScreen()133 	JitCompareScreen() : currentBlock_(-1) {}
134 	virtual void CreateViews() override;
135 
136 private:
137 	void UpdateDisasm();
138 	UI::EventReturn OnRandomBlock(UI::EventParams &e);
139 	UI::EventReturn OnRandomFPUBlock(UI::EventParams &e);
140 	UI::EventReturn OnRandomVFPUBlock(UI::EventParams &e);
141 	void OnRandomBlock(int flag);
142 
143 	UI::EventReturn OnCurrentBlock(UI::EventParams &e);
144 	UI::EventReturn OnSelectBlock(UI::EventParams &e);
145 	UI::EventReturn OnPrevBlock(UI::EventParams &e);
146 	UI::EventReturn OnNextBlock(UI::EventParams &e);
147 	UI::EventReturn OnBlockAddress(UI::EventParams &e);
148 	UI::EventReturn OnAddressChange(UI::EventParams &e);
149 	UI::EventReturn OnShowStats(UI::EventParams &e);
150 
151 	int currentBlock_;
152 
153 	UI::TextView *blockName_;
154 	UI::TextEdit *blockAddr_;
155 	UI::TextView *blockStats_;
156 
157 	UI::LinearLayout *leftDisasm_;
158 	UI::LinearLayout *rightDisasm_;
159 };
160 
161 class ShaderListScreen : public UIDialogScreenWithBackground {
162 public:
ShaderListScreen()163 	ShaderListScreen() {}
164 	void CreateViews() override;
165 
166 private:
167 	int ListShaders(DebugShaderType shaderType, UI::LinearLayout *view);
168 
169 	UI::EventReturn OnShaderClick(UI::EventParams &e);
170 
171 	UI::TabHolder *tabs_;
172 };
173 
174 class ShaderViewScreen : public UIDialogScreenWithBackground {
175 public:
ShaderViewScreen(std::string id,DebugShaderType type)176 	ShaderViewScreen(std::string id, DebugShaderType type)
177 		: id_(id), type_(type) {}
178 
179 	void CreateViews() override;
180 private:
181 	std::string id_;
182 	DebugShaderType type_;
183 };
184 
185 class FrameDumpTestScreen : public UIDialogScreenWithBackground {
186 public:
187 	FrameDumpTestScreen();
188 	~FrameDumpTestScreen();
189 
190 	void CreateViews() override;
191 	void update() override;
192 
193 private:
194 	UI::EventReturn OnLoadDump(UI::EventParams &e);
195 
196 	std::vector<std::string> files_;
197 	std::shared_ptr<http::Download> listing_;
198 	std::shared_ptr<http::Download> dumpDownload_;
199 };
200 
201 void DrawProfile(UIContext &ui);
202 const char *GetCompilerABI();
203