Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/GameSettingsScreen.h
5668 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 "Common/UI/PopupScreens.h"
27
#include "Core/ConfigValues.h"
28
#include "UI/BaseScreens.h"
29
#include "UI/TabbedDialogScreen.h"
30
31
class Path;
32
33
// Per-game settings screen - enables you to configure graphic options, control options, etc
34
// per game.
35
class GameSettingsScreen : public UITabbedBaseDialogScreen {
36
public:
37
GameSettingsScreen(const Path &gamePath, std::string gameID = "", bool editThenRestore = false);
38
~GameSettingsScreen();
39
40
const char *tag() const override { return "GameSettings"; }
41
42
protected:
43
void CallbackRestoreDefaults(bool yes);
44
void CallbackMemstickFolder(bool yes);
45
void dialogFinished(const Screen *dialog, DialogResult result) override;
46
47
void CreateTabs() override;
48
bool ShowSearchControls() const override { return true; }
49
50
private:
51
void PreCreateViews() override;
52
53
void CreateGraphicsSettings(UI::ViewGroup *graphicsSettings);
54
void CreateControlsSettings(UI::ViewGroup *tools);
55
void CreateAudioSettings(UI::ViewGroup *audioSettings);
56
void CreateNetworkingSettings(UI::ViewGroup *networkingSettings);
57
void CreateToolsSettings(UI::ViewGroup *tools);
58
void CreateSystemSettings(UI::ViewGroup *systemSettings);
59
void CreateVRSettings(UI::ViewGroup *vrSettings);
60
61
std::string gameID_;
62
#ifdef _WIN32
63
UI::CheckBox *SavePathInMyDocumentChoice = nullptr;
64
UI::CheckBox *SavePathInOtherChoice = nullptr;
65
// Used to enable/disable the above two options.
66
bool installed_ = false;
67
bool otherinstalled_ = false;
68
#endif
69
70
std::string memstickDisplay_;
71
72
// Global settings handlers
73
void OnChangeQuickChat0(UI::EventParams &e);
74
void OnChangeQuickChat1(UI::EventParams &e);
75
void OnChangeQuickChat2(UI::EventParams &e);
76
void OnChangeQuickChat3(UI::EventParams &e);
77
void OnChangeQuickChat4(UI::EventParams &e);
78
void OnChangeBackground(UI::EventParams &e);
79
void OnRestoreDefaultSettings(UI::EventParams &e);
80
void OnRenderingBackend(UI::EventParams &e);
81
void OnRenderingDevice(UI::EventParams &e);
82
void OnInflightFramesChoice(UI::EventParams &e);
83
void OnCameraDeviceChange(UI::EventParams& e);
84
void OnMicDeviceChange(UI::EventParams& e);
85
void OnAudioDevice(UI::EventParams &e);
86
void OnJitAffectingSetting(UI::EventParams &e);
87
void OnShowMemstickScreen(UI::EventParams &e);
88
#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP)
89
void OnMemoryStickMyDoc(UI::EventParams &e);
90
void OnMemoryStickOther(UI::EventParams &e);
91
#endif
92
void OnImmersiveModeChange(UI::EventParams &e);
93
void OnSustainedPerformanceModeChange(UI::EventParams &e);
94
95
void OnAdhocGuides(UI::EventParams &e);
96
97
void TriggerRestartOrDo(std::function<void()> callback);
98
99
// Temporaries to convert setting types, cache enabled, etc.
100
int iAlternateSpeedPercent1_ = 0;
101
int iAlternateSpeedPercent2_ = 0;
102
int iAlternateSpeedPercentAnalog_ = 0;
103
int prevInflightFrames_ = -1;
104
bool enableReports_ = false;
105
bool enableReportsSet_ = false;
106
bool analogSpeedMapped_ = false;
107
108
// edit the game-specific settings and restore the global settings after exiting
109
bool editGameSpecificThenRestore_ = false;
110
111
// Android-only
112
std::string pendingMemstickFolder_;
113
};
114
115
class HostnameSelectScreen : public UI::PopupScreen {
116
public:
117
HostnameSelectScreen(std::string *value, std::vector<std::string> *listItems, std::string_view title)
118
: UI::PopupScreen(title, "OK", "Cancel"), listItems_(listItems), value_(value) {
119
resolver_ = std::thread([](HostnameSelectScreen *thiz) {
120
thiz->ResolverThread();
121
}, this);
122
}
123
~HostnameSelectScreen() {
124
{
125
std::unique_lock<std::mutex> guard(resolverLock_);
126
resolverState_ = ResolverState::QUIT;
127
resolverCond_.notify_one();
128
}
129
resolver_.join();
130
}
131
132
void CreatePopupContents(UI::ViewGroup *parent) override;
133
134
const char *tag() const override { return "HostnameSelect"; }
135
136
protected:
137
void OnCompleted(DialogResult result) override;
138
bool CanComplete(DialogResult result) override;
139
140
private:
141
void ResolverThread();
142
void SendEditKey(InputKeyCode keyCode, KeyInputFlags flags = (KeyInputFlags)0);
143
144
void OnNumberClick(UI::EventParams &e);
145
void OnPointClick(UI::EventParams &e);
146
void OnDeleteClick(UI::EventParams &e);
147
void OnDeleteAllClick(UI::EventParams &e);
148
void OnEditClick(UI::EventParams& e);
149
void OnShowIPListClick(UI::EventParams& e);
150
void OnIPClick(UI::EventParams& e);
151
152
enum class ResolverState {
153
WAITING,
154
QUEUED,
155
PROGRESS,
156
READY,
157
QUIT,
158
};
159
160
std::string *value_;
161
std::vector<std::string> *listItems_;
162
UI::TextEdit *addrView_ = nullptr;
163
UI::TextView *progressView_ = nullptr;
164
UI::LinearLayout *ipRows_ = nullptr;
165
166
std::thread resolver_;
167
ResolverState resolverState_ = ResolverState::WAITING;
168
std::mutex resolverLock_;
169
std::condition_variable resolverCond_;
170
std::string toResolve_ = "";
171
bool toResolveResult_ = false;
172
std::string lastResolved_ = "";
173
bool lastResolvedResult_ = false;
174
};
175
176
class GestureMappingScreen : public UITabbedBaseDialogScreen {
177
public:
178
GestureMappingScreen(const Path &gamePath) : UITabbedBaseDialogScreen(gamePath) {}
179
180
void CreateTabs() override;
181
const char *tag() const override { return "GestureMapping"; }
182
bool ShowSearchControls() const override { return false; }
183
protected:
184
void CreateGestureTab(UI::LinearLayout *parent, int zoneIndex, bool portrait);
185
};
186
187
class RestoreSettingsScreen : public UI::PopupScreen {
188
public:
189
RestoreSettingsScreen(std::string_view title);
190
void CreatePopupContents(UI::ViewGroup *parent) override;
191
192
const char *tag() const override { return "RestoreSettingsScreen"; }
193
private:
194
void OnCompleted(DialogResult result) override;
195
int restoreFlags_ = (int)(RestoreSettingsBits::SETTINGS); // RestoreSettingsBits enum
196
};
197
198
void TriggerRestart(const char *why, bool editThenRestore, const Path &gamePath);
199
200
#if PPSSPP_PLATFORM(MAC) || PPSSPP_PLATFORM(IOS)
201
void SetMemStickDirDarwin(int requesterToken);
202
#endif
203
204