Merge pull request #90 from gizmo98/patch-2
[libretro-ppsspp.git] / UI / Store.h
blobff7ba04e7a2c33903513d34725e77ff301550d9e
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/.
18 #pragma once
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.
32 struct json_value;
34 enum EntryType {
35 ENTRY_PBPZIP,
36 ENTRY_ISO,
39 struct StoreCategory {
40 std::string name;
43 struct StoreEntry {
44 EntryType type;
45 std::string name;
46 std::string description;
47 std::string author;
48 std::string iconURL;
49 std::string file; // This is the folder name of the installed one too, and hence a "unique-ish" identifier.
50 std::string category;
51 std::string downloadURL; // Only set for games that are not hosted on store.ppsspp.org
52 u64 size;
55 struct StoreFilter {
56 std::string categoryId;
59 class StoreScreen : public UIDialogScreenWithBackground {
60 public:
61 StoreScreen();
62 ~StoreScreen();
64 virtual void update(InputState &input);
65 virtual std::string tag() const { return "store"; }
67 protected:
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);
74 private:
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_;
89 bool loading_;
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_;
98 StoreFilter filter_;
99 std::string lang_;
101 UI::ViewGroup *productPanel_;