Jeck - Fixes for how options handle first boot, should resolve trophy room issue (no unlocked set on first boot).
This commit is contained in:
@@ -90,6 +90,9 @@ string Options::getName(int option){
|
|||||||
//Unlocked sets.
|
//Unlocked sets.
|
||||||
int setID = option - SET_UNLOCKS;
|
int setID = option - SET_UNLOCKS;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
if(setID < 0 || setID > setlist.size())
|
||||||
|
return "";
|
||||||
|
|
||||||
sprintf(buf,"unlocked_%s",setlist[setID].c_str());
|
sprintf(buf,"unlocked_%s",setlist[setID].c_str());
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
@@ -297,7 +300,6 @@ int GameOptions::save(){
|
|||||||
std::ofstream file(mFilename.c_str());
|
std::ofstream file(mFilename.c_str());
|
||||||
if (file){
|
if (file){
|
||||||
for ( int x=0; x < (int) values.size(); x++ ){
|
for ( int x=0; x < (int) values.size(); x++ ){
|
||||||
|
|
||||||
//Check that this is a valid option.
|
//Check that this is a valid option.
|
||||||
string name = Options::getName(x);
|
string name = Options::getName(x);
|
||||||
GameOption * opt = get(x);
|
GameOption * opt = get(x);
|
||||||
@@ -507,7 +509,7 @@ void GameSettings::checkProfile(){
|
|||||||
GameOptionAward * goa = dynamic_cast<GameOptionAward *>(globalOptions->get(x));
|
GameOptionAward * goa = dynamic_cast<GameOptionAward *>(globalOptions->get(x));
|
||||||
if(goa){
|
if(goa){
|
||||||
GameOptionAward * dupe = dynamic_cast<GameOptionAward *>(profileOptions->get(x));
|
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(!pcFile.size() || !fileExists(pcFile.c_str()))
|
||||||
{
|
{
|
||||||
//If we had any default settings, we'd set them here.
|
//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){
|
if(profileOptions){
|
||||||
//Force our directories to exist.
|
//Force our directories to exist.
|
||||||
MAKEDIR(RESPATH"/profiles");
|
MAKEDIR(RESPATH"/profiles");
|
||||||
@@ -544,14 +536,32 @@ void GameSettings::checkProfile(){
|
|||||||
|
|
||||||
profileOptions->save();
|
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){
|
void GameSettings::createUsersFirstDeck(int setId){
|
||||||
@@ -565,6 +575,9 @@ void GameSettings::createUsersFirstDeck(int setId){
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
MTGDeck *mCollection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION,"",false).c_str(), theGame->collection);
|
MTGDeck *mCollection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION,"",false).c_str(), theGame->collection);
|
||||||
|
if(mCollection->totalCards() > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
//10 lands of each
|
//10 lands of each
|
||||||
int sets[] = {setId};
|
int sets[] = {setId};
|
||||||
if (!mCollection->addRandomCards(10, sets,1, Constants::RARITY_L,"Forest")){
|
if (!mCollection->addRandomCards(10, sets,1, Constants::RARITY_L,"Forest")){
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ void GameStateAwards::Start()
|
|||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
mState = STATE_LISTVIEW;
|
mState = STATE_LISTVIEW;
|
||||||
|
options.checkProfile();
|
||||||
|
|
||||||
menu = NULL;
|
menu = NULL;
|
||||||
saveMe = options.newAward();
|
saveMe = options.newAward();
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ void GameStateMenu::Update(float dt)
|
|||||||
break;
|
break;
|
||||||
case MENU_STATE_MAJOR_FIRST_TIME :
|
case MENU_STATE_MAJOR_FIRST_TIME :
|
||||||
currentState &= MENU_STATE_MAJOR_MAINMENU;
|
currentState &= MENU_STATE_MAJOR_MAINMENU;
|
||||||
options.checkProfile(); //Handles building a new deck, if needed.
|
options.reloadProfile(); //Handles building a new deck, if needed.
|
||||||
break;
|
break;
|
||||||
case MENU_STATE_MAJOR_MAINMENU :
|
case MENU_STATE_MAJOR_MAINMENU :
|
||||||
if (!scrollerSet) fillScroller();
|
if (!scrollerSet) fillScroller();
|
||||||
|
|||||||
@@ -65,24 +65,10 @@ void GameStateShop::load(){
|
|||||||
int nbsets = 0;
|
int nbsets = 0;
|
||||||
int nbboostersets = 0;
|
int nbboostersets = 0;
|
||||||
|
|
||||||
//Unlock a default set if no set is unlocked
|
//Figure out which sets are available.
|
||||||
int ok = 0;
|
for (int i = 0; i < setlist.size(); i++){
|
||||||
int defaultSet = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < setlist.size(); i++){
|
|
||||||
|
|
||||||
if (setlist[i].compare("10E") == 0) defaultSet = i;
|
|
||||||
|
|
||||||
unlocked[i] = options[Options::optionSet(i)].number;
|
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++){
|
for (int i = 0; i < setlist.size(); i++){
|
||||||
if (unlocked[i]){
|
if (unlocked[i]){
|
||||||
sets[nbsets] = i;
|
sets[nbsets] = i;
|
||||||
|
|||||||
@@ -541,6 +541,7 @@ void WGuiList::Render(){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vHeight = 0;
|
vHeight = 0;
|
||||||
|
if(start >= 0)
|
||||||
for (nowPos=nbitems;nowPos > 1; nowPos--){
|
for (nowPos=nbitems;nowPos > 1; nowPos--){
|
||||||
if(!items[start]->Visible())
|
if(!items[start]->Visible())
|
||||||
continue;
|
continue;
|
||||||
@@ -1288,7 +1289,7 @@ WGuiAward::WGuiAward(int _id, string name, string _text): WGuiItem(name){
|
|||||||
WGuiAward::~WGuiAward(){
|
WGuiAward::~WGuiAward(){
|
||||||
GameOptionAward * goa = dynamic_cast<GameOptionAward*>(&options[id]);
|
GameOptionAward * goa = dynamic_cast<GameOptionAward*>(&options[id]);
|
||||||
if(goa)
|
if(goa)
|
||||||
goa->setViewed(true); //FIXME: This removes "New" status even if the award hasn't been selected.
|
goa->setViewed(true);
|
||||||
}
|
}
|
||||||
bool WGuiAward::Visible(){
|
bool WGuiAward::Visible(){
|
||||||
//WGuiAward is only visible when it's tied to an already acchieved award.
|
//WGuiAward is only visible when it's tied to an already acchieved award.
|
||||||
|
|||||||
Reference in New Issue
Block a user