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