2010-09-18 13:46:25 +02:00
|
|
|
#ifndef GAME_LIST_H_
|
|
|
|
#define GAME_LIST_H_
|
|
|
|
|
|
|
|
#include <vector>
|
2011-02-02 19:30:15 +01:00
|
|
|
#include "Controls/DeviceHandler.hpp"
|
2010-09-18 13:46:25 +02:00
|
|
|
#include "wstring.hpp"
|
|
|
|
#include "usbloader/disc.h"
|
|
|
|
|
|
|
|
class GameList
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
public:
|
|
|
|
GameList() : selectedGame(0) { };
|
|
|
|
int ReadGameList();
|
|
|
|
int size() const { return FilteredList.size(); }
|
|
|
|
int GameCount() const { return FullGameList.size(); }
|
|
|
|
int FilterList(const wchar_t * gameFilter = NULL);
|
|
|
|
int LoadUnfiltered();
|
|
|
|
struct discHdr * at(int i) const { return operator[](i); }
|
|
|
|
struct discHdr * operator[](int i) const { if (i < 0 || i >= (int) FilteredList.size()) return NULL; return FilteredList[i]; }
|
|
|
|
struct discHdr * GetDiscHeader(const char * gameID) const;
|
|
|
|
const wchar_t * GetCurrentFilter() const { return GameFilter.c_str(); }
|
|
|
|
const wchar_t * GetAvailableSearchChars() const { return AvailableSearchChars.c_str(); }
|
|
|
|
void SortList();
|
|
|
|
void clear();
|
|
|
|
bool operator!() const { return (FullGameList.size() == 0); }
|
|
|
|
//! Gamelist scrolling operators
|
|
|
|
int operator+=(int i) { return (selectedGame = (selectedGame+i) % FilteredList.size()); }
|
|
|
|
int operator-=(int i) { return (selectedGame = (selectedGame-i+FilteredList.size()) % FilteredList.size()); }
|
|
|
|
int operator++() { return (selectedGame = (selectedGame+1) % FilteredList.size()); }
|
|
|
|
int operator--() { return (selectedGame = (selectedGame-1+FilteredList.size()) % FilteredList.size()); }
|
|
|
|
int operator++(int i) { return operator++(); }
|
|
|
|
int operator--(int i) { return operator--(); }
|
|
|
|
struct discHdr * GetCurrentSelected() const { return operator[](selectedGame); }
|
|
|
|
int GetPartitionNumber(const u8 *gameid) const;
|
2011-07-26 10:57:12 +02:00
|
|
|
int GetGameFS(const u8 *gameID) const { return DeviceHandler::Instance()->GetFilesystemType(USB1+GetPartitionNumber(gameID)); }
|
2011-07-26 00:28:22 +02:00
|
|
|
void RemovePartition(int part_num);
|
|
|
|
protected:
|
|
|
|
int InternalReadList(int part);
|
|
|
|
static bool NameSortCallback(const struct discHdr *a, const struct discHdr *b);
|
|
|
|
static bool PlaycountSortCallback(const struct discHdr *a, const struct discHdr *b);
|
|
|
|
static bool RankingSortCallback(const struct discHdr *a, const struct discHdr *b);
|
|
|
|
static bool PlayersSortCallback(const struct discHdr *a, const struct discHdr *b);
|
2010-09-18 13:46:25 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
wString AvailableSearchChars;
|
|
|
|
wString GameFilter;
|
|
|
|
int selectedGame;
|
|
|
|
std::vector<struct discHdr *> FilteredList;
|
|
|
|
std::vector<struct discHdr> FullGameList;
|
|
|
|
std::vector<int> GamePartitionList;
|
2010-09-18 13:46:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern GameList gameList;
|
|
|
|
|
|
|
|
#endif
|