Jeck - Cleaned up and reordered some menus, fixed potential heap corruption in GameStateShop.

This commit is contained in:
wagic.jeck
2010-02-08 08:54:55 +00:00
parent 74254e4721
commit e96d4b9a07
5 changed files with 24 additions and 13 deletions

View File

@@ -19,6 +19,7 @@
#define STAGE_SHOP_TASKS 5
#define STAGE_FADE_IN 6
#define STAGE_ASK_ABOUT 7
#define STAGE_SHOP_PURCHASE 8
#define BOOSTER_SLOTS 3
#define SHOP_SLOTS 11
@@ -63,6 +64,7 @@ class GameStateShop: public GameState, public JGuiListener
int mInventory[SHOP_ITEMS];
int lightAlpha;
int alphaChange;
int mBuying;
DeckDataWrapper * myCollection;

View File

@@ -143,12 +143,12 @@ void GameStateDeckViewer::Start()
myDeck = NULL;
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-150,20);
menu->Add(0,"Save");
menu->Add(1,"Save & Rename");
menu->Add(22,"Filter by...");
menu->Add(2,"Switch decks without saving");
if(options[Options::CHEATMODE].number)
menu->Add(-1,"*Complete collection & reset*");
menu->Add(22,"Filter by...");
menu->Add(1,"Save & Rename");
menu->Add(0,"Save & Back to Main Menu");
menu->Add(3,"Back to main menu");
menu->Add(4,"Cancel");
@@ -1511,7 +1511,7 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
myDeck->save();
playerdata->save();
pricelist->save();
mStage = STAGE_WAITING;
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
break;
case 1:
if(myDeck && myDeck->parent){

View File

@@ -84,8 +84,8 @@ void GameStateOptions::Start()
optionsTabs->Add(optionsList);
optionsMenu = NEW SimpleMenu(-102, this,Constants::MENU_FONT, 50,170);
optionsMenu->Add(1, "Save & Back to Main Menu");
optionsMenu->Add(2, "Back to Main Menu");
optionsMenu->Add(1, "Save & Back to Main Menu");
optionsMenu->Add(3, "Cancel");
optionsTabs->Entering(0);

View File

@@ -128,7 +128,7 @@ string GameStateShop::descPurchase(int controlId, bool tiny){
string name;
if(controlId < BOOSTER_SLOTS){
if(mBooster[controlId].altSet == mBooster[controlId].mainSet)
mBooster[controlId].altSet = 0;
mBooster[controlId].altSet = NULL;
if(mBooster[controlId].altSet)
sprintf(buffer,_("%s & %s Booster (15 Cards)").c_str(),mBooster[controlId].mainSet->id.c_str(),mBooster[controlId].altSet->id.c_str());
else
@@ -323,8 +323,6 @@ void GameStateShop::load(){
}
}
}
void GameStateShop::save(bool force)
{
@@ -393,6 +391,11 @@ void GameStateShop::Update(float dt)
u32 btn;
switch(mStage){
case STAGE_SHOP_PURCHASE:
if (menu)
menu->Update(dt);
beginPurchase(mBuying);
break;
case STAGE_SHOP_MENU:
if (menu){
menu->Update(dt);
@@ -421,8 +424,8 @@ void GameStateShop::Update(float dt)
}else if(taskList->getState() == TaskList::TASKS_ACTIVE && btn == PSP_CTRL_START ){
if(!menu){
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-100,20);
menu->Add(12,"Save & Back to Main Menu");
menu->Add(15,"Return to shop");
menu->Add(12,"Save & Back to Main Menu");
menu->Add(13, "Cancel");
}
}
@@ -620,11 +623,15 @@ void GameStateShop::ButtonPressed(int controllerId, int controlId)
switch(controllerId){
case -102: //Buying something...
beginPurchase(controlId);
mStage = STAGE_SHOP_PURCHASE;
if(menu)
menu->Close();
mBuying = controlId;
return;
case -145:
if(controlId == -1){ //Nope, don't buy.
menu->Close();
mStage = STAGE_SHOP_SHOP;
return;
}
if(sel > -1 && sel < SHOP_ITEMS){
@@ -635,14 +642,16 @@ void GameStateShop::ButtonPressed(int controllerId, int controlId)
else
purchaseCard(sel);
}
mStage = STAGE_SHOP_SHOP;
return;
}
//Basic Menu.
switch(controlId){
case 12:
if (taskList) taskList->save();
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
mStage = STAGE_SHOP_SHOP;
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
save();
break;
case 14:
mStage = STAGE_SHOP_TASKS;
@@ -662,5 +671,5 @@ void GameStateShop::ButtonPressed(int controllerId, int controlId)
default:
mStage = STAGE_SHOP_SHOP;
}
SAFE_DELETE(menu);
menu->Close();
}

View File

@@ -415,7 +415,7 @@ int WSrcDeck::totalPrice(){
int nb = it->second;
if (nb) total += pricelist->getPrice(it->first);
}
delete pricelist;
SAFE_DELETE(pricelist);
return total;
}