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