usbloadergx/source/settings/CGameStatistics.h
dimok321 7db67e75af *Added several basic gui classes like drawing box/circle only with the GX engine without the need of a resource
*Created a checkbox class with them
*Changed the prompt window to a class
*Changed cover download to a checkbox selection of what you want to download. Changed discart download option to only switch between what is prioritized (original/customs)
*Fixed a little alignment issue of the progressbar
*Reverted the change for check disc in drive. Some drives couldn't handle it in IOS58 mode :\.
*Changed playcount from an 8 bit to a 32 bit counter (got 8bit by mistake) which limited it to 255
*a few little optimisations
2011-01-23 20:13:41 +00:00

73 lines
2.8 KiB
C++

#ifndef _GAME_STATISTICS_H_
#define _GAME_STATISTICS_H_
#include <string>
#include <stdio.h>
#include <gctypes.h>
#include <vector>
#include "usbloader/disc.h"
typedef struct _Stats
{
char id[7];
u8 FavoriteRank;
int PlayCount;
} GameStatus;
class CGameStatistics
{
public:
//!Constructor
CGameStatistics();
//!Destructor
~CGameStatistics();
//!Load
bool Load(const char * path);
//!Save
bool Save();
//!AddGame
bool AddGame(const GameStatus & NewGame);
//!Reset
bool RemoveAll();
//!Overload for removing one game out of the list
bool Remove(const char * id);
bool Remove(const u8 * id) { return Remove((const char *) id); };
bool Remove(const struct discHdr * game) { if(!game) return false; else return Remove(game->id); };
//!Overloads for set playcount
void SetPlayCount(const char * id, int count);
void SetPlayCount(const u8 * id, int count) { SetPlayCount((const char *) id, count); };
void SetPlayCount(const struct discHdr * game, int count) { if(!game) return; SetPlayCount(game->id, count); };
//!Overloads for get playcount
int GetPlayCount(const char * id) const;
int GetPlayCount(const u8 * id) const { return GetPlayCount((const char *) id); };
int GetPlayCount(const struct discHdr * game) const { if(!game) return 0; else return GetPlayCount(game->id); };
//!Overloads for set FavoriteRank
void SetFavoriteRank(const char * id, int rank);
void SetFavoriteRank(const u8 * id, int rank) { SetFavoriteRank((const char *) id, rank); };
void SetFavoriteRank(const struct discHdr * game, int rank) { if(!game) return; SetFavoriteRank(game->id, rank); };
//!Overloads for get FavoriteRank
int GetFavoriteRank(const char * id) const;
int GetFavoriteRank(const u8 * id) const { return GetFavoriteRank((const char *) id); };
int GetFavoriteRank(const struct discHdr * game) const { if(!game) return 0; else return GetFavoriteRank(game->id); };
//!Get GameStatus
GameStatus * GetGameStatus(const char * id) const;
//!Overload
GameStatus * GetGameStatus(const u8 * id) const { return GetGameStatus((const char *) id); };
//!Overload
GameStatus * GetGameStatus(const struct discHdr * game) const { if(!game) return NULL; else return GetGameStatus(game->id); };
protected:
bool ReadGameID(const char * src, char * GameID, int size);
bool SetSetting(GameStatus & game, char *name, char *value);
bool ValidVersion(FILE * file);
void ParseLine(char *line);
void TrimLine(char *dest, const char *src, int size);
std::string ConfigPath;
std::vector<GameStatus> GameList;
};
extern CGameStatistics GameStatistics;
#endif