First attempt to reduce load time of player deck selection screens.
This change makes use of caching the DeckStats and DeckStatsWrappers into singleton caches that get flushed when you quit the game. The initial load time will be significant as lazy loading has not been coded yet for the ai decks. TODO: lazy load the player and ai decks as they appear on the screen. Currently, each screen loads all decks.
This commit is contained in:
@@ -19,11 +19,17 @@ public:
|
||||
|
||||
vector<DeckMetaData *> playerDeckOrderList;
|
||||
vector<DeckMetaData *> aiDeckOrderList;
|
||||
|
||||
|
||||
map<string, StatsWrapper *> playerDeckStatsMap;
|
||||
map<string, StatsWrapper *> aiDeckStatsMap;
|
||||
|
||||
void updateMetaDataList(vector<DeckMetaData *>* refList, bool isAI);
|
||||
vector<DeckMetaData *> * getPlayerDeckOrderList();
|
||||
vector<DeckMetaData *> * getAIDeckOrderList();
|
||||
|
||||
DeckMetaData * getDeckMetaDataById( int deckId, bool isAI );
|
||||
StatsWrapper * getExtendedStatsForDeckId( int deckId, MTGAllCards *collection, bool isAI );
|
||||
StatsWrapper * getExtendedDeckStats( DeckMetaData *selectedDeck, MTGAllCards *collection, bool isAI );
|
||||
static DeckManager * GetInstance();
|
||||
static void EndInstance();
|
||||
|
||||
@@ -31,10 +37,7 @@ public:
|
||||
//since the eventual move of all deck meta data should be managed by this class
|
||||
|
||||
static int getDifficultyRating(Player *statsPlayer, Player *player);
|
||||
|
||||
~DeckManager()
|
||||
{
|
||||
instanceFlag = false;
|
||||
}
|
||||
|
||||
~DeckManager();
|
||||
|
||||
};
|
||||
|
||||
@@ -15,9 +15,10 @@ class GameObserver;
|
||||
class DeckStat
|
||||
{
|
||||
public:
|
||||
DeckStat(int _nbgames = 0, int _victories = 0);
|
||||
|
||||
int nbgames;
|
||||
int victories;
|
||||
DeckStat(int _nbgames = 0, int _victories = 0);
|
||||
int percentVictories();
|
||||
};
|
||||
|
||||
@@ -26,8 +27,12 @@ class DeckStats
|
||||
protected:
|
||||
static DeckStats * mInstance;
|
||||
public:
|
||||
map<string, DeckStat *> stats;
|
||||
//map<string, DeckStat *> stats; // current set of statistics
|
||||
string currentDeck;
|
||||
map<string, map<string,DeckStat*> > masterDeckStats;
|
||||
|
||||
static DeckStats * GetInstance();
|
||||
static void EndInstance();
|
||||
void saveStats(Player * player, Player * opponent, GameObserver * game);
|
||||
void save(const char * filename);
|
||||
void save(Player * player);
|
||||
|
||||
Reference in New Issue
Block a user