Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/GameSettingsScreen.h
3185 views
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 OnChangeproAdhocServerAddress(UI::EventParams &e);
93
UI::EventReturn OnChangeBackground(UI::EventParams &e);
94
UI::EventReturn OnFullscreenChange(UI::EventParams &e);
95
UI::EventReturn OnFullscreenMultiChange(UI::EventParams &e);
96
UI::EventReturn OnResolutionChange(UI::EventParams &e);
97
UI::EventReturn OnRestoreDefaultSettings(UI::EventParams &e);
98
UI::EventReturn OnRenderingBackend(UI::EventParams &e);
99
UI::EventReturn OnRenderingDevice(UI::EventParams &e);
100
UI::EventReturn OnInflightFramesChoice(UI::EventParams &e);
101
UI::EventReturn OnCameraDeviceChange(UI::EventParams& e);
102
UI::EventReturn OnMicDeviceChange(UI::EventParams& e);
103
UI::EventReturn OnAudioDevice(UI::EventParams &e);
104
UI::EventReturn OnJitAffectingSetting(UI::EventParams &e);
105
UI::EventReturn OnShowMemstickScreen(UI::EventParams &e);
106
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
107
UI::EventReturn OnMemoryStickMyDoc(UI::EventParams &e);
108
UI::EventReturn OnMemoryStickOther(UI::EventParams &e);
109
#endif
110
UI::EventReturn OnScreenRotation(UI::EventParams &e);
111
UI::EventReturn OnImmersiveModeChange(UI::EventParams &e);
112
UI::EventReturn OnSustainedPerformanceModeChange(UI::EventParams &e);
113
114
UI::EventReturn OnAdhocGuides(UI::EventParams &e);
115
116
// Temporaries to convert setting types, cache enabled, etc.
117
int iAlternateSpeedPercent1_ = 0;
118
int iAlternateSpeedPercent2_ = 0;
119
int iAlternateSpeedPercentAnalog_ = 0;
120
int prevInflightFrames_ = -1;
121
bool enableReports_ = false;
122
bool enableReportsSet_ = false;
123
bool analogSpeedMapped_ = false;
124
125
// edit the game-specific settings and restore the global settings after exiting
126
bool editThenRestore_ = false;
127
128
// Android-only
129
std::string pendingMemstickFolder_;
130
};
131
132
class HostnameSelectScreen : public PopupScreen {
133
public:
134
HostnameSelectScreen(std::string *value, std::string_view title)
135
: PopupScreen(title, "OK", "Cancel"), value_(value) {
136
resolver_ = std::thread([](HostnameSelectScreen *thiz) {
137
thiz->ResolverThread();
138
}, this);
139
}
140
~HostnameSelectScreen() {
141
{
142
std::unique_lock<std::mutex> guard(resolverLock_);
143
resolverState_ = ResolverState::QUIT;
144
resolverCond_.notify_one();
145
}
146
resolver_.join();
147
}
148
149
void CreatePopupContents(UI::ViewGroup *parent) override;
150
151
const char *tag() const override { return "HostnameSelect"; }
152
153
protected:
154
void OnCompleted(DialogResult result) override;
155
bool CanComplete(DialogResult result) override;
156
157
private:
158
void ResolverThread();
159
void SendEditKey(InputKeyCode keyCode, int flags = 0);
160
161
UI::EventReturn OnNumberClick(UI::EventParams &e);
162
UI::EventReturn OnPointClick(UI::EventParams &e);
163
UI::EventReturn OnDeleteClick(UI::EventParams &e);
164
UI::EventReturn OnDeleteAllClick(UI::EventParams &e);
165
UI::EventReturn OnEditClick(UI::EventParams& e);
166
UI::EventReturn OnShowIPListClick(UI::EventParams& e);
167
UI::EventReturn OnIPClick(UI::EventParams& e);
168
169
enum class ResolverState {
170
WAITING,
171
QUEUED,
172
PROGRESS,
173
READY,
174
QUIT,
175
};
176
177
std::string *value_;
178
UI::TextEdit *addrView_ = nullptr;
179
UI::TextView *progressView_ = nullptr;
180
UI::LinearLayout *ipRows_ = nullptr;
181
182
std::thread resolver_;
183
ResolverState resolverState_ = ResolverState::WAITING;
184
std::mutex resolverLock_;
185
std::condition_variable resolverCond_;
186
std::string toResolve_ = "";
187
bool toResolveResult_ = false;
188
std::string lastResolved_ = "";
189
bool lastResolvedResult_ = false;
190
};
191
192
193
class GestureMappingScreen : public UIDialogScreenWithGameBackground {
194
public:
195
GestureMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
196
void CreateViews() override;
197
198
const char *tag() const override { return "GestureMapping"; }
199
};
200
201
class RestoreSettingsScreen : public PopupScreen {
202
public:
203
RestoreSettingsScreen(std::string_view title);
204
void CreatePopupContents(UI::ViewGroup *parent) override;
205
206
const char *tag() const override { return "RestoreSettingsScreen"; }
207
private:
208
void OnCompleted(DialogResult result) override;
209
int restoreFlags_ = (int)(RestoreSettingsBits::SETTINGS); // RestoreSettingsBits enum
210
};
211
212
void TriggerRestart(const char *why, bool editThenRestore, const Path &gamePath);
213
214
#if PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS)
215
void SetMemStickDirDarwin(int requesterToken);
216
#endif
217
218