2013-11-20 13:42:48 +00:00
// Copyright (c) 2013- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
# pragma once
2016-10-12 09:32:24 +00:00
# include <functional>
2020-10-04 18:48:47 +00:00
# include "Common/UI/UIScreen.h"
# include "Common/UI/ViewGroup.h"
# include "Common/Net/HTTPClient.h"
2013-11-20 13:42:48 +00:00
# include "UI/MiscScreens.h"
// Game screen: Allows you to start a game, delete saves, delete the game,
// set game specific settings, etc.
// Uses GameInfoCache heavily to implement the functionality.
2018-08-12 22:05:00 +00:00
namespace json {
struct JsonGet ;
}
2017-12-10 08:44:44 +00:00
class ProductItemView ;
2013-11-20 13:42:48 +00:00
enum EntryType {
ENTRY_PBPZIP ,
ENTRY_ISO ,
} ;
struct StoreCategory {
std : : string name ;
} ;
struct StoreEntry {
EntryType type ;
std : : string name ;
std : : string description ;
std : : string author ;
std : : string iconURL ;
2024-09-01 23:05:55 +00:00
std : : string file ; // This is the folder name of the installed one too, and hence a "unique-ish" identifier. Also used as a-link on the license website, if !license.empty().
2013-11-20 13:42:48 +00:00
std : : string category ;
2013-11-29 16:34:21 +00:00
std : : string downloadURL ; // Only set for games that are not hosted on store.ppsspp.org
2024-09-01 23:05:55 +00:00
std : : string websiteURL ;
std : : string license ;
2015-10-01 10:37:16 +00:00
bool hidden ;
2024-05-06 11:50:56 +00:00
int contentRating ; // 100 means to hide it on iOS. No other values defined yet.
2013-11-20 13:42:48 +00:00
u64 size ;
} ;
class StoreScreen : public UIDialogScreenWithBackground {
public :
StoreScreen ( ) ;
~ StoreScreen ( ) ;
2017-03-15 05:01:18 +00:00
void update ( ) override ;
2022-09-16 08:14:00 +00:00
const char * tag ( ) const override { return " Store " ; }
2013-11-20 13:42:48 +00:00
protected :
2017-03-15 05:01:18 +00:00
void CreateViews ( ) override ;
2013-11-20 13:42:48 +00:00
UI : : EventReturn OnGameSelected ( UI : : EventParams & e ) ;
UI : : EventReturn OnRetry ( UI : : EventParams & e ) ;
2015-07-04 16:05:17 +00:00
UI : : EventReturn OnGameLaunch ( UI : : EventParams & e ) ;
2013-11-20 13:42:48 +00:00
private :
2023-12-14 11:23:31 +00:00
void ParseListing ( const std : : string & json ) ;
2017-12-10 08:44:44 +00:00
ProductItemView * GetSelectedItem ( ) ;
2013-11-20 13:42:48 +00:00
2023-12-14 11:23:31 +00:00
std : : string GetTranslatedString ( const json : : JsonGet json , const std : : string & key , const char * fallback = nullptr ) const ;
2013-11-20 13:42:48 +00:00
2023-07-21 20:04:05 +00:00
std : : shared_ptr < http : : Request > listing_ ;
std : : shared_ptr < http : : Request > image_ ;
2013-11-20 13:42:48 +00:00
// TODO: Replace with a PathBrowser or similar. Though that one only supports
// local filesystems at the moment.
std : : string storePath_ ;
2017-12-10 08:44:44 +00:00
bool loading_ = true ;
bool connectionError_ = false ;
2021-08-22 10:21:44 +00:00
int resultCode_ = 0 ;
2013-11-20 13:42:48 +00:00
std : : map < std : : string , StoreCategory > categories_ ;
// We download the whole store in one JSON request. Not super scalable but works fine
// for now. entries_ contains all the products in the store.
std : : vector < StoreEntry > entries_ ;
std : : string lang_ ;
2017-12-10 08:44:44 +00:00
std : : string lastSelectedName_ ;
2013-11-20 13:42:48 +00:00
2023-12-08 12:10:26 +00:00
UI : : ViewGroup * scrollItemView_ = nullptr ;
UI : : ViewGroup * productPanel_ = nullptr ;
UI : : TextView * titleText_ = nullptr ;
2013-11-20 13:42:48 +00:00
} ;