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 ARCHIVES = 2, 36 PIN = 4, 37 HOMEBREW_STORE = 8, 38 STANDARD = 1 | 2 | 4, 39 }; 40 ENUM_CLASS_BITOPS(BrowseFlags); 41 42 bool LaunchFile(ScreenManager *screenManager, const Path &path); 43 44 class GameBrowser : public UI::LinearLayout { 45 public: 46 GameBrowser(const Path &path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr); 47 48 UI::Event OnChoice; 49 UI::Event OnHoldChoice; 50 UI::Event OnHighlight; 51 52 void FocusGame(const Path &gamePath); 53 void SetPath(const Path &path); 54 void Draw(UIContext &dc) override; 55 void Update() override; 56 57 protected: 58 virtual bool DisplayTopBar(); 59 virtual bool HasSpecialFiles(std::vector<Path> &filenames); 60 virtual Path HomePath(); 61 62 void Refresh(); 63 64 private: 65 bool IsCurrentPathPinned(); 66 const std::vector<Path> GetPinnedPaths(); 67 const std::string GetBaseName(const std::string &path); 68 69 UI::EventReturn GameButtonClick(UI::EventParams &e); 70 UI::EventReturn GameButtonHoldClick(UI::EventParams &e); 71 UI::EventReturn GameButtonHighlight(UI::EventParams &e); 72 UI::EventReturn NavigateClick(UI::EventParams &e); 73 UI::EventReturn LayoutChange(UI::EventParams &e); 74 UI::EventReturn LastClick(UI::EventParams &e); 75 UI::EventReturn BrowseClick(UI::EventParams &e); 76 UI::EventReturn StorageClick(UI::EventParams &e); 77 UI::EventReturn OnHomeClick(UI::EventParams &e); 78 UI::EventReturn PinToggleClick(UI::EventParams &e); 79 UI::EventReturn GridSettingsClick(UI::EventParams &e); 80 UI::EventReturn OnRecentClear(UI::EventParams &e); 81 UI::EventReturn OnHomebrewStore(UI::EventParams &e); 82 83 UI::ViewGroup *gameList_ = nullptr; 84 PathBrowser path_; 85 bool *gridStyle_ = nullptr; 86 BrowseFlags browseFlags_; 87 std::string lastText_; 88 std::string lastLink_; 89 Path focusGamePath_; 90 bool listingPending_ = false; 91 float lastScale_ = 1.0f; 92 bool lastLayoutWasGrid_ = true; 93 ScreenManager *screenManager_; 94 }; 95 96 class RemoteISOBrowseScreen; 97 98 class MainScreen : public UIScreenWithBackground { 99 public: 100 MainScreen(); 101 ~MainScreen(); 102 isTopLevel()103 bool isTopLevel() const override { return true; } 104 105 // Horrible hack to show the demos & homebrew tab after having installed a game from a zip file. 106 static bool showHomebrewTab; 107 108 protected: 109 void CreateViews() override; 110 void DrawBackground(UIContext &dc) override; 111 void update() override; 112 void sendMessage(const char *message, const char *value) override; 113 void dialogFinished(const Screen *dialog, DialogResult result) override; 114 115 bool UseVerticalLayout() const; 116 bool DrawBackgroundFor(UIContext &dc, const Path &gamePath, float progress); 117 118 UI::EventReturn OnGameSelected(UI::EventParams &e); 119 UI::EventReturn OnGameSelectedInstant(UI::EventParams &e); 120 UI::EventReturn OnGameHighlight(UI::EventParams &e); 121 // Event handlers 122 UI::EventReturn OnLoadFile(UI::EventParams &e); 123 UI::EventReturn OnGameSettings(UI::EventParams &e); 124 UI::EventReturn OnCredits(UI::EventParams &e); 125 UI::EventReturn OnSupport(UI::EventParams &e); 126 UI::EventReturn OnPPSSPPOrg(UI::EventParams &e); 127 UI::EventReturn OnForums(UI::EventParams &e); 128 UI::EventReturn OnExit(UI::EventParams &e); 129 UI::EventReturn OnDownloadUpgrade(UI::EventParams &e); 130 UI::EventReturn OnDismissUpgrade(UI::EventParams &e); 131 UI::EventReturn OnAllowStorage(UI::EventParams &e); 132 UI::EventReturn OnFullScreenToggle(UI::EventParams &e); 133 134 UI::LinearLayout *upgradeBar_ = nullptr; 135 UI::TabHolder *tabHolder_ = nullptr; 136 UI::Button *fullscreenButton_ = nullptr; 137 138 Path restoreFocusGamePath_; 139 std::vector<GameBrowser *> gameBrowsers_; 140 141 Path highlightedGamePath_; 142 Path prevHighlightedGamePath_; 143 float highlightProgress_ = 0.0f; 144 float prevHighlightProgress_ = 0.0f; 145 bool backFromStore_ = false; 146 bool lockBackgroundAudio_ = false; 147 bool lastVertical_; 148 bool confirmedTemporary_ = false; 149 UI::ScrollView *scrollAllGames_ = nullptr; 150 151 friend class RemoteISOBrowseScreen; 152 }; 153 154 class UmdReplaceScreen : public UIDialogScreenWithBackground { 155 public: UmdReplaceScreen()156 UmdReplaceScreen() {} 157 158 protected: 159 void CreateViews() override; 160 void update() override; 161 //virtual void sendMessage(const char *message, const char *value); 162 163 private: 164 UI::EventReturn OnGameSelected(UI::EventParams &e); 165 UI::EventReturn OnGameSelectedInstant(UI::EventParams &e); 166 167 UI::EventReturn OnCancel(UI::EventParams &e); 168 UI::EventReturn OnGameSettings(UI::EventParams &e); 169 }; 170 171 class GridSettingsScreen : public PopupScreen { 172 public: GridSettingsScreen(std::string label)173 GridSettingsScreen(std::string label) : PopupScreen(label) {} 174 void CreatePopupContents(UI::ViewGroup *parent) override; 175 UI::Event OnRecentChanged; 176 177 private: 178 UI::EventReturn GridPlusClick(UI::EventParams &e); 179 UI::EventReturn GridMinusClick(UI::EventParams &e); 180 UI::EventReturn OnRecentClearClick(UI::EventParams &e); 181 const float MAX_GAME_GRID_SCALE = 3.0f; 182 const float MIN_GAME_GRID_SCALE = 0.8f; 183 }; 184