diff --git a/projects/mtg/src/GameOptions.cpp b/projects/mtg/src/GameOptions.cpp index e09524ecd..a4074a629 100644 --- a/projects/mtg/src/GameOptions.cpp +++ b/projects/mtg/src/GameOptions.cpp @@ -90,6 +90,9 @@ string Options::getName(int option){ //Unlocked sets. int setID = option - SET_UNLOCKS; char buf[512]; + if(setID < 0 || setID > setlist.size()) + return ""; + sprintf(buf,"unlocked_%s",setlist[setID].c_str()); return buf; @@ -297,7 +300,6 @@ int GameOptions::save(){ std::ofstream file(mFilename.c_str()); if (file){ for ( int x=0; x < (int) values.size(); x++ ){ - //Check that this is a valid option. string name = Options::getName(x); GameOption * opt = get(x); @@ -507,7 +509,7 @@ void GameSettings::checkProfile(){ GameOptionAward * goa = dynamic_cast(globalOptions->get(x)); if(goa){ GameOptionAward * dupe = dynamic_cast(profileOptions->get(x)); - if(dupe && !dupe->number) dupe->giveAward(); + if(dupe && goa->number && !dupe->number) dupe->giveAward(); } } } @@ -520,19 +522,9 @@ void GameSettings::checkProfile(){ if(!pcFile.size() || !fileExists(pcFile.c_str())) { //If we had any default settings, we'd set them here. - - //Find the set for which we have the most variety - int setId = 0; - int maxcards = 0; - for (int i=0; i< setlist.size(); i++){ - int value = theGame->collection->countBySet(i); - if (value > maxcards){ - maxcards = value; - setId = i; - } - } + - //Make the proper directories + //Make the proper directories if(profileOptions){ //Force our directories to exist. MAKEDIR(RESPATH"/profiles"); @@ -544,14 +536,32 @@ void GameSettings::checkProfile(){ profileOptions->save(); } - - //Save this set as "unlocked" - (*profileOptions)[Options::optionSet(setId)]=1; - profileOptions->save(); - - //Give the player their first deck - createUsersFirstDeck(setId); } + + + //Find the set for which we have the most variety + int setId = -1; + int maxcards = 0; + int ok = 0; + for (int i=0; i< setlist.size(); i++){ + int value = theGame->collection->countBySet(i); + if (value > maxcards){ + maxcards = value; + setId = i; + } + if(options[Options::optionSet(i)].number){ + ok = 1; + break; + } + } + if(!ok && setId >= 0){ + //Save this set as "unlocked" + (*profileOptions)[Options::optionSet(setId)]=1; + profileOptions->save(); + + //Give the player their first deck + createUsersFirstDeck(setId); + } } void GameSettings::createUsersFirstDeck(int setId){ @@ -565,6 +575,9 @@ void GameSettings::createUsersFirstDeck(int setId){ return; MTGDeck *mCollection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION,"",false).c_str(), theGame->collection); + if(mCollection->totalCards() > 0) + return; + //10 lands of each int sets[] = {setId}; if (!mCollection->addRandomCards(10, sets,1, Constants::RARITY_L,"Forest")){ diff --git a/projects/mtg/src/GameStateAwards.cpp b/projects/mtg/src/GameStateAwards.cpp index b8704ba29..37539833c 100644 --- a/projects/mtg/src/GameStateAwards.cpp +++ b/projects/mtg/src/GameStateAwards.cpp @@ -37,6 +37,7 @@ void GameStateAwards::Start() { char buf[256]; mState = STATE_LISTVIEW; + options.checkProfile(); menu = NULL; saveMe = options.newAward(); diff --git a/projects/mtg/src/GameStateMenu.cpp b/projects/mtg/src/GameStateMenu.cpp index d0fee35cb..8a6f08bfe 100644 --- a/projects/mtg/src/GameStateMenu.cpp +++ b/projects/mtg/src/GameStateMenu.cpp @@ -374,7 +374,7 @@ void GameStateMenu::Update(float dt) break; case MENU_STATE_MAJOR_FIRST_TIME : currentState &= MENU_STATE_MAJOR_MAINMENU; - options.checkProfile(); //Handles building a new deck, if needed. + options.reloadProfile(); //Handles building a new deck, if needed. break; case MENU_STATE_MAJOR_MAINMENU : if (!scrollerSet) fillScroller(); diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index 169fc65b6..af5b07f31 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -65,24 +65,10 @@ void GameStateShop::load(){ int nbsets = 0; int nbboostersets = 0; - //Unlock a default set if no set is unlocked - int ok = 0; - int defaultSet = 0; - - for (int i = 0; i < setlist.size(); i++){ - - if (setlist[i].compare("10E") == 0) defaultSet = i; - + //Figure out which sets are available. + for (int i = 0; i < setlist.size(); i++){ unlocked[i] = options[Options::optionSet(i)].number; - if (unlocked[i]) - ok = 1; } - if (!ok){ - unlocked[defaultSet] = 1; - options[Options::optionSet(defaultSet)] = GameOption(1); - options.save(); - } - for (int i = 0; i < setlist.size(); i++){ if (unlocked[i]){ sets[nbsets] = i; diff --git a/projects/mtg/src/OptionItem.cpp b/projects/mtg/src/OptionItem.cpp index 304b7451e..cd48df26f 100644 --- a/projects/mtg/src/OptionItem.cpp +++ b/projects/mtg/src/OptionItem.cpp @@ -541,6 +541,7 @@ void WGuiList::Render(){ break; } vHeight = 0; + if(start >= 0) for (nowPos=nbitems;nowPos > 1; nowPos--){ if(!items[start]->Visible()) continue; @@ -1288,7 +1289,7 @@ WGuiAward::WGuiAward(int _id, string name, string _text): WGuiItem(name){ WGuiAward::~WGuiAward(){ GameOptionAward * goa = dynamic_cast(&options[id]); if(goa) - goa->setViewed(true); //FIXME: This removes "New" status even if the award hasn't been selected. + goa->setViewed(true); } bool WGuiAward::Visible(){ //WGuiAward is only visible when it's tied to an already acchieved award.