Jeck - Fixes for how options handle first boot, should resolve trophy room issue (no unlocked set on first boot).

This commit is contained in:
wagic.jeck
2009-12-13 15:00:53 +00:00
parent 61f38b7494
commit b766dd6e4a
5 changed files with 40 additions and 39 deletions

View File

@@ -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<GameOptionAward *>(globalOptions->get(x));
if(goa){
GameOptionAward * dupe = dynamic_cast<GameOptionAward *>(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")){

View File

@@ -37,6 +37,7 @@ void GameStateAwards::Start()
{
char buf[256];
mState = STATE_LISTVIEW;
options.checkProfile();
menu = NULL;
saveMe = options.newAward();

View File

@@ -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();

View File

@@ -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;

View File

@@ -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<GameOptionAward*>(&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.