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/MainScreen.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 <functional>
21
22
#include "Common/File/Path.h"
23
#include "Common/UI/UIScreen.h"
24
#include "Common/UI/ViewGroup.h"
25
#include "UI/MiscScreens.h"
26
#include "Common/File/PathBrowser.h"
27
28
enum GameBrowserFlags {
29
FLAG_HOMEBREWSTOREBUTTON = 1
30
};
31
32
enum class BrowseFlags {
33
NONE = 0,
34
NAVIGATE = 1,
35
BROWSE = 2,
36
ARCHIVES = 4,
37
PIN = 8,
38
HOMEBREW_STORE = 16,
39
STANDARD = 1 | 2 | 4 | 8,
40
};
41
ENUM_CLASS_BITOPS(BrowseFlags);
42
43
bool LaunchFile(ScreenManager *screenManager, const Path &path);
44
45
class GameBrowser : public UI::LinearLayout {
46
public:
47
GameBrowser(int token, const Path &path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string_view lastText, std::string_view lastLink, UI::LayoutParams *layoutParams = nullptr);
48
49
UI::Event OnChoice;
50
UI::Event OnHoldChoice;
51
UI::Event OnHighlight;
52
53
void FocusGame(const Path &gamePath);
54
void SetPath(const Path &path);
55
void ApplySearchFilter(const std::string &filter);
56
void Draw(UIContext &dc) override;
57
void Update() override;
58
void RequestRefresh() {
59
refreshPending_ = true;
60
}
61
62
void SetHomePath(const Path &path) {
63
homePath_ = path;
64
}
65
66
protected:
67
virtual bool DisplayTopBar();
68
virtual bool HasSpecialFiles(std::vector<Path> &filenames);
69
virtual Path HomePath();
70
void ApplySearchFilter();
71
72
void Refresh();
73
74
Path homePath_;
75
76
private:
77
bool IsCurrentPathPinned();
78
std::vector<Path> GetPinnedPaths() const;
79
std::string GetBaseName(const std::string &path) const;
80
81
UI::EventReturn GameButtonClick(UI::EventParams &e);
82
UI::EventReturn GameButtonHoldClick(UI::EventParams &e);
83
UI::EventReturn GameButtonHighlight(UI::EventParams &e);
84
UI::EventReturn NavigateClick(UI::EventParams &e);
85
UI::EventReturn LayoutChange(UI::EventParams &e);
86
UI::EventReturn LastClick(UI::EventParams &e);
87
UI::EventReturn BrowseClick(UI::EventParams &e);
88
UI::EventReturn StorageClick(UI::EventParams &e);
89
UI::EventReturn OnHomeClick(UI::EventParams &e);
90
UI::EventReturn PinToggleClick(UI::EventParams &e);
91
UI::EventReturn GridSettingsClick(UI::EventParams &e);
92
UI::EventReturn OnRecentClear(UI::EventParams &e);
93
UI::EventReturn OnHomebrewStore(UI::EventParams &e);
94
95
enum class SearchState {
96
MATCH,
97
MISMATCH,
98
PENDING,
99
};
100
101
UI::ViewGroup *gameList_ = nullptr;
102
PathBrowser path_;
103
bool *gridStyle_ = nullptr;
104
BrowseFlags browseFlags_;
105
std::string lastText_;
106
std::string lastLink_;
107
std::string searchFilter_;
108
std::vector<SearchState> searchStates_;
109
Path focusGamePath_;
110
bool listingPending_ = false;
111
bool searchPending_ = false;
112
bool refreshPending_ = false;
113
float lastScale_ = 1.0f;
114
bool lastLayoutWasGrid_ = true;
115
ScreenManager *screenManager_;
116
int token_;
117
};
118
119
class RemoteISOBrowseScreen;
120
121
class MainScreen : public UIScreenWithBackground {
122
public:
123
MainScreen();
124
~MainScreen();
125
126
bool isTopLevel() const override { return true; }
127
128
const char *tag() const override { return "Main"; }
129
130
// Horrible hack to show the demos & homebrew tab after having installed a game from a zip file.
131
static bool showHomebrewTab;
132
133
bool key(const KeyInput &touch) override;
134
135
protected:
136
void CreateViews() override;
137
void DrawBackground(UIContext &dc) override;
138
void update() override;
139
void sendMessage(UIMessage message, const char *value) override;
140
void dialogFinished(const Screen *dialog, DialogResult result) override;
141
142
bool DrawBackgroundFor(UIContext &dc, const Path &gamePath, float progress);
143
144
UI::EventReturn OnGameSelected(UI::EventParams &e);
145
UI::EventReturn OnGameSelectedInstant(UI::EventParams &e);
146
UI::EventReturn OnGameHighlight(UI::EventParams &e);
147
// Event handlers
148
UI::EventReturn OnLoadFile(UI::EventParams &e);
149
UI::EventReturn OnGameSettings(UI::EventParams &e);
150
UI::EventReturn OnCredits(UI::EventParams &e);
151
UI::EventReturn OnSupport(UI::EventParams &e);
152
UI::EventReturn OnPPSSPPOrg(UI::EventParams &e);
153
UI::EventReturn OnForums(UI::EventParams &e);
154
UI::EventReturn OnExit(UI::EventParams &e);
155
UI::EventReturn OnDownloadUpgrade(UI::EventParams &e);
156
UI::EventReturn OnDismissUpgrade(UI::EventParams &e);
157
UI::EventReturn OnAllowStorage(UI::EventParams &e);
158
UI::EventReturn OnFullScreenToggle(UI::EventParams &e);
159
160
UI::LinearLayout *upgradeBar_ = nullptr;
161
UI::TabHolder *tabHolder_ = nullptr;
162
UI::Button *fullscreenButton_ = nullptr;
163
164
Path restoreFocusGamePath_;
165
std::vector<GameBrowser *> gameBrowsers_;
166
167
Path highlightedGamePath_;
168
Path prevHighlightedGamePath_;
169
float highlightProgress_ = 0.0f;
170
float prevHighlightProgress_ = 0.0f;
171
bool backFromStore_ = false;
172
bool lockBackgroundAudio_ = false;
173
bool lastVertical_;
174
bool confirmedTemporary_ = false;
175
UI::ScrollView *scrollAllGames_ = nullptr;
176
bool searchKeyModifier_ = false;
177
bool searchChanged_ = false;
178
std::string searchFilter_;
179
180
friend class RemoteISOBrowseScreen;
181
};
182
183
class UmdReplaceScreen : public UIDialogScreenWithBackground {
184
public:
185
const char *tag() const override { return "UmdReplace"; }
186
187
protected:
188
void CreateViews() override;
189
void update() override;
190
191
private:
192
UI::EventReturn OnGameSelected(UI::EventParams &e);
193
UI::EventReturn OnGameSettings(UI::EventParams &e);
194
};
195
196
class GridSettingsScreen : public PopupScreen {
197
public:
198
GridSettingsScreen(std::string_view label) : PopupScreen(label) {}
199
void CreatePopupContents(UI::ViewGroup *parent) override;
200
UI::Event OnRecentChanged;
201
202
const char *tag() const override { return "GridSettings"; }
203
204
private:
205
UI::EventReturn GridPlusClick(UI::EventParams &e);
206
UI::EventReturn GridMinusClick(UI::EventParams &e);
207
UI::EventReturn OnRecentClearClick(UI::EventParams &e);
208
const float MAX_GAME_GRID_SCALE = 3.0f;
209
const float MIN_GAME_GRID_SCALE = 0.8f;
210
};
211
212