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/GameSettingsScreen.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 "ppsspp_config.h"
21
#include <condition_variable>
22
#include <mutex>
23
#include <thread>
24
25
#include "Common/UI/UIScreen.h"
26
#include "Core/ConfigValues.h"
27
#include "UI/MiscScreens.h"
28
#include "UI/TabbedDialogScreen.h"
29
30
class Path;
31
32
// Per-game settings screen - enables you to configure graphic options, control options, etc
33
// per game.
34
class GameSettingsScreen : public TabbedUIDialogScreenWithGameBackground {
35
public:
36
GameSettingsScreen(const Path &gamePath, std::string gameID = "", bool editThenRestore = false);
37
38
void onFinish(DialogResult result) override;
39
const char *tag() const override { return "GameSettings"; }
40
41
protected:
42
void CallbackRestoreDefaults(bool yes);
43
void CallbackMemstickFolder(bool yes);
44
void dialogFinished(const Screen *dialog, DialogResult result) override;
45
46
void CreateTabs() override;
47
bool ShowSearchControls() const override { return true; }
48
49
private:
50
void PreCreateViews() override;
51
52
void CreateGraphicsSettings(UI::ViewGroup *graphicsSettings);
53
void CreateControlsSettings(UI::ViewGroup *tools);
54
void CreateAudioSettings(UI::ViewGroup *audioSettings);
55
void CreateNetworkingSettings(UI::ViewGroup *networkingSettings);
56
void CreateToolsSettings(UI::ViewGroup *tools);
57
void CreateSystemSettings(UI::ViewGroup *systemSettings);
58
void CreateVRSettings(UI::ViewGroup *vrSettings);
59
60
std::string gameID_;
61
UI::CheckBox *enableReportsCheckbox_ = nullptr;
62
UI::Choice *layoutEditorChoice_ = nullptr;
63
UI::Choice *displayEditor_ = nullptr;
64
UI::Choice *backgroundChoice_ = nullptr;
65
UI::PopupMultiChoice *resolutionChoice_ = nullptr;
66
UI::CheckBox *frameSkipAuto_ = nullptr;
67
#ifdef _WIN32
68
UI::CheckBox *SavePathInMyDocumentChoice = nullptr;
69
UI::CheckBox *SavePathInOtherChoice = nullptr;
70
// Used to enable/disable the above two options.
71
bool installed_ = false;
72
bool otherinstalled_ = false;
73
#endif
74
75
std::string memstickDisplay_;
76
77
// Event handlers
78
UI::EventReturn OnControlMapping(UI::EventParams &e);
79
UI::EventReturn OnCalibrateAnalogs(UI::EventParams &e);
80
UI::EventReturn OnTouchControlLayout(UI::EventParams &e);
81
UI::EventReturn OnTiltCustomize(UI::EventParams &e);
82
83
// Global settings handlers
84
UI::EventReturn OnAutoFrameskip(UI::EventParams &e);
85
UI::EventReturn OnTextureShader(UI::EventParams &e);
86
UI::EventReturn OnTextureShaderChange(UI::EventParams &e);
87
UI::EventReturn OnChangeQuickChat0(UI::EventParams &e);
88
UI::EventReturn OnChangeQuickChat1(UI::EventParams &e);
89
UI::EventReturn OnChangeQuickChat2(UI::EventParams &e);
90
UI::EventReturn OnChangeQuickChat3(UI::EventParams &e);
91
UI::EventReturn OnChangeQuickChat4(UI::EventParams &e);
92
UI::EventReturn OnChangeNickname(UI::EventParams &e);
93
UI::EventReturn OnChangeproAdhocServerAddress(UI::EventParams &e);
94
UI::EventReturn OnChangeBackground(UI::EventParams &e);
95
UI::EventReturn OnFullscreenChange(UI::EventParams &e);
96
UI::EventReturn OnFullscreenMultiChange(UI::EventParams &e);
97
UI::EventReturn OnResolutionChange(UI::EventParams &e);
98
UI::EventReturn OnRestoreDefaultSettings(UI::EventParams &e);
99
UI::EventReturn OnRenderingBackend(UI::EventParams &e);
100
UI::EventReturn OnRenderingDevice(UI::EventParams &e);
101
UI::EventReturn OnInflightFramesChoice(UI::EventParams &e);
102
UI::EventReturn OnCameraDeviceChange(UI::EventParams& e);
103
UI::EventReturn OnMicDeviceChange(UI::EventParams& e);
104
UI::EventReturn OnAudioDevice(UI::EventParams &e);
105
UI::EventReturn OnJitAffectingSetting(UI::EventParams &e);
106
UI::EventReturn OnShowMemstickScreen(UI::EventParams &e);
107
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
108
UI::EventReturn OnSavePathMydoc(UI::EventParams &e);
109
UI::EventReturn OnSavePathOther(UI::EventParams &e);
110
#endif
111
UI::EventReturn OnScreenRotation(UI::EventParams &e);
112
UI::EventReturn OnImmersiveModeChange(UI::EventParams &e);
113
UI::EventReturn OnSustainedPerformanceModeChange(UI::EventParams &e);
114
115
UI::EventReturn OnAdhocGuides(UI::EventParams &e);
116
117
// Temporaries to convert setting types, cache enabled, etc.
118
int iAlternateSpeedPercent1_ = 0;
119
int iAlternateSpeedPercent2_ = 0;
120
int iAlternateSpeedPercentAnalog_ = 0;
121
int prevInflightFrames_ = -1;
122
bool enableReports_ = false;
123
bool enableReportsSet_ = false;
124
bool analogSpeedMapped_ = false;
125
126
// edit the game-specific settings and restore the global settings after exiting
127
bool editThenRestore_ = false;
128
129
// Android-only
130
std::string pendingMemstickFolder_;
131
};
132
133
class DeveloperToolsScreen : public UIDialogScreenWithGameBackground {
134
public:
135
DeveloperToolsScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
136
137
void update() override;
138
void onFinish(DialogResult result) override;
139
140
const char *tag() const override { return "DeveloperTools"; }
141
142
protected:
143
void CreateViews() override;
144
145
private:
146
UI::EventReturn OnRunCPUTests(UI::EventParams &e);
147
UI::EventReturn OnLoggingChanged(UI::EventParams &e);
148
UI::EventReturn OnOpenTexturesIniFile(UI::EventParams &e);
149
UI::EventReturn OnLogConfig(UI::EventParams &e);
150
UI::EventReturn OnJitAffectingSetting(UI::EventParams &e);
151
UI::EventReturn OnJitDebugTools(UI::EventParams &e);
152
UI::EventReturn OnRemoteDebugger(UI::EventParams &e);
153
UI::EventReturn OnMIPSTracerEnabled(UI::EventParams &e);
154
UI::EventReturn OnMIPSTracerPathChanged(UI::EventParams &e);
155
UI::EventReturn OnMIPSTracerFlushTrace(UI::EventParams &e);
156
UI::EventReturn OnMIPSTracerClearJitCache(UI::EventParams &e);
157
UI::EventReturn OnMIPSTracerClearTracer(UI::EventParams &e);
158
UI::EventReturn OnGPUDriverTest(UI::EventParams &e);
159
UI::EventReturn OnFramedumpTest(UI::EventParams &e);
160
UI::EventReturn OnMemstickTest(UI::EventParams &e);
161
UI::EventReturn OnTouchscreenTest(UI::EventParams &e);
162
UI::EventReturn OnCopyStatesToRoot(UI::EventParams &e);
163
164
bool allowDebugger_ = false;
165
bool canAllowDebugger_ = true;
166
enum class HasIni {
167
NO,
168
YES,
169
MAYBE,
170
};
171
HasIni hasTexturesIni_ = HasIni::MAYBE;
172
173
bool MIPSTracerEnabled_ = false;
174
std::string MIPSTracerPath_ = "";
175
UI::InfoItem* MIPSTracerPath = nullptr;
176
};
177
178
class HostnameSelectScreen : public PopupScreen {
179
public:
180
HostnameSelectScreen(std::string *value, std::string_view title)
181
: PopupScreen(title, "OK", "Cancel"), value_(value) {
182
resolver_ = std::thread([](HostnameSelectScreen *thiz) {
183
thiz->ResolverThread();
184
}, this);
185
}
186
~HostnameSelectScreen() {
187
{
188
std::unique_lock<std::mutex> guard(resolverLock_);
189
resolverState_ = ResolverState::QUIT;
190
resolverCond_.notify_one();
191
}
192
resolver_.join();
193
}
194
195
void CreatePopupContents(UI::ViewGroup *parent) override;
196
197
const char *tag() const override { return "HostnameSelect"; }
198
199
protected:
200
void OnCompleted(DialogResult result) override;
201
bool CanComplete(DialogResult result) override;
202
203
private:
204
void ResolverThread();
205
void SendEditKey(InputKeyCode keyCode, int flags = 0);
206
207
UI::EventReturn OnNumberClick(UI::EventParams &e);
208
UI::EventReturn OnPointClick(UI::EventParams &e);
209
UI::EventReturn OnDeleteClick(UI::EventParams &e);
210
UI::EventReturn OnDeleteAllClick(UI::EventParams &e);
211
UI::EventReturn OnEditClick(UI::EventParams& e);
212
UI::EventReturn OnShowIPListClick(UI::EventParams& e);
213
UI::EventReturn OnIPClick(UI::EventParams& e);
214
215
enum class ResolverState {
216
WAITING,
217
QUEUED,
218
PROGRESS,
219
READY,
220
QUIT,
221
};
222
223
std::string *value_;
224
UI::TextEdit *addrView_ = nullptr;
225
UI::TextView *progressView_ = nullptr;
226
UI::LinearLayout *ipRows_ = nullptr;
227
228
std::thread resolver_;
229
ResolverState resolverState_ = ResolverState::WAITING;
230
std::mutex resolverLock_;
231
std::condition_variable resolverCond_;
232
std::string toResolve_ = "";
233
bool toResolveResult_ = false;
234
std::string lastResolved_ = "";
235
bool lastResolvedResult_ = false;
236
};
237
238
239
class GestureMappingScreen : public UIDialogScreenWithGameBackground {
240
public:
241
GestureMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
242
void CreateViews() override;
243
244
const char *tag() const override { return "GestureMapping"; }
245
};
246
247
class RestoreSettingsScreen : public PopupScreen {
248
public:
249
RestoreSettingsScreen(std::string_view title);
250
void CreatePopupContents(UI::ViewGroup *parent) override;
251
252
const char *tag() const override { return "RestoreSettingsScreen"; }
253
private:
254
void OnCompleted(DialogResult result) override;
255
int restoreFlags_ = (int)(RestoreSettingsBits::SETTINGS); // RestoreSettingsBits enum
256
};
257
258
void TriggerRestart(const char *why, bool editThenRestore, const Path &gamePath);
259
260