1 // Copyright (c) 2013- PPSSPP Project.
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.
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.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
20 #include "base/functional.h"
21 #include "ui/ui_screen.h"
22 #include "ui/viewgroup.h"
23 #include "net/http_client.h"
25 #include "Core/Util/GameManager.h"
26 #include "UI/MiscScreens.h"
28 // Game screen: Allows you to start a game, delete saves, delete the game,
29 // set game specific settings, etc.
30 // Uses GameInfoCache heavily to implement the functionality.
39 struct StoreCategory
{
46 std::string description
;
49 std::string file
; // This is the folder name of the installed one too, and hence a "unique-ish" identifier.
51 std::string downloadURL
; // Only set for games that are not hosted on store.ppsspp.org
56 std::string categoryId
;
59 class StoreScreen
: public UIDialogScreenWithBackground
{
64 virtual void update(InputState
&input
);
65 virtual std::string
tag() const { return "store"; }
68 virtual void CreateViews();
69 UI::EventReturn
OnGameSelected(UI::EventParams
&e
);
70 UI::EventReturn
OnCategorySelected(UI::EventParams
&e
);
71 UI::EventReturn
OnRetry(UI::EventParams
&e
);
72 UI::EventReturn
OnGameLaunch(UI::EventParams
&e
);
75 void SetFilter(const StoreFilter
&filter
);
76 void ParseListing(std::string json
);
77 std::vector
<StoreEntry
> FilterEntries();
79 std::string
GetStoreJsonURL(std::string storePath
) const;
80 std::string
GetTranslatedString(const json_value
*json
, std::string key
, const char *fallback
= 0) const;
82 std::shared_ptr
<http::Download
> listing_
;
83 std::shared_ptr
<http::Download
> image_
;
85 // TODO: Replace with a PathBrowser or similar. Though that one only supports
86 // local filesystems at the moment.
87 std::string storePath_
;
90 bool connectionError_
;
92 std::map
<std::string
, StoreCategory
> categories_
;
94 // We download the whole store in one JSON request. Not super scalable but works fine
95 // for now. entries_ contains all the products in the store.
96 std::vector
<StoreEntry
> entries_
;
101 UI::ViewGroup
*productPanel_
;