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
+2
View File
@@ -19,6 +19,7 @@
#define STAGE_SHOP_TASKS 5 #define STAGE_SHOP_TASKS 5
#define STAGE_FADE_IN 6 #define STAGE_FADE_IN 6
#define STAGE_ASK_ABOUT 7 #define STAGE_ASK_ABOUT 7
#define STAGE_SHOP_PURCHASE 8
#define BOOSTER_SLOTS 3 #define BOOSTER_SLOTS 3
#define SHOP_SLOTS 11 #define SHOP_SLOTS 11
@@ -63,6 +64,7 @@ class GameStateShop: public GameState, public JGuiListener
int mInventory[SHOP_ITEMS]; int mInventory[SHOP_ITEMS];
int lightAlpha; int lightAlpha;
int alphaChange; int alphaChange;
int mBuying;
DeckDataWrapper * myCollection; DeckDataWrapper * myCollection;
+4 -4
View File
@@ -143,12 +143,12 @@ void GameStateDeckViewer::Start()
myDeck = NULL; myDeck = NULL;
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-150,20); menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-150,20);
menu->Add(0,"Save"); menu->Add(22,"Filter by...");
menu->Add(1,"Save & Rename");
menu->Add(2,"Switch decks without saving"); menu->Add(2,"Switch decks without saving");
if(options[Options::CHEATMODE].number) if(options[Options::CHEATMODE].number)
menu->Add(-1,"*Complete collection & reset*"); 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(3,"Back to main menu");
menu->Add(4,"Cancel"); menu->Add(4,"Cancel");
@@ -1511,7 +1511,7 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
myDeck->save(); myDeck->save();
playerdata->save(); playerdata->save();
pricelist->save(); pricelist->save();
mStage = STAGE_WAITING; mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
break; break;
case 1: case 1:
if(myDeck && myDeck->parent){ if(myDeck && myDeck->parent){
+1 -1
View File
@@ -84,8 +84,8 @@ void GameStateOptions::Start()
optionsTabs->Add(optionsList); optionsTabs->Add(optionsList);
optionsMenu = NEW SimpleMenu(-102, this,Constants::MENU_FONT, 50,170); 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(2, "Back to Main Menu");
optionsMenu->Add(1, "Save & Back to Main Menu");
optionsMenu->Add(3, "Cancel"); optionsMenu->Add(3, "Cancel");
optionsTabs->Entering(0); optionsTabs->Entering(0);
+16 -7
View File
@@ -128,7 +128,7 @@ string GameStateShop::descPurchase(int controlId, bool tiny){
string name; string name;
if(controlId < BOOSTER_SLOTS){ if(controlId < BOOSTER_SLOTS){
if(mBooster[controlId].altSet == mBooster[controlId].mainSet) if(mBooster[controlId].altSet == mBooster[controlId].mainSet)
mBooster[controlId].altSet = 0; mBooster[controlId].altSet = NULL;
if(mBooster[controlId].altSet) 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()); sprintf(buffer,_("%s & %s Booster (15 Cards)").c_str(),mBooster[controlId].mainSet->id.c_str(),mBooster[controlId].altSet->id.c_str());
else else
@@ -323,8 +323,6 @@ void GameStateShop::load(){
} }
} }
} }
void GameStateShop::save(bool force) void GameStateShop::save(bool force)
{ {
@@ -393,6 +391,11 @@ void GameStateShop::Update(float dt)
u32 btn; u32 btn;
switch(mStage){ switch(mStage){
case STAGE_SHOP_PURCHASE:
if (menu)
menu->Update(dt);
beginPurchase(mBuying);
break;
case STAGE_SHOP_MENU: case STAGE_SHOP_MENU:
if (menu){ if (menu){
menu->Update(dt); menu->Update(dt);
@@ -421,8 +424,8 @@ void GameStateShop::Update(float dt)
}else if(taskList->getState() == TaskList::TASKS_ACTIVE && btn == PSP_CTRL_START ){ }else if(taskList->getState() == TaskList::TASKS_ACTIVE && btn == PSP_CTRL_START ){
if(!menu){ if(!menu){
menu = NEW SimpleMenu(11,this,Constants::MENU_FONT,SCREEN_WIDTH/2-100,20); 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(15,"Return to shop");
menu->Add(12,"Save & Back to Main Menu");
menu->Add(13, "Cancel"); menu->Add(13, "Cancel");
} }
} }
@@ -620,11 +623,15 @@ void GameStateShop::ButtonPressed(int controllerId, int controlId)
switch(controllerId){ switch(controllerId){
case -102: //Buying something... case -102: //Buying something...
beginPurchase(controlId); mStage = STAGE_SHOP_PURCHASE;
if(menu)
menu->Close();
mBuying = controlId;
return; return;
case -145: case -145:
if(controlId == -1){ //Nope, don't buy. if(controlId == -1){ //Nope, don't buy.
menu->Close(); menu->Close();
mStage = STAGE_SHOP_SHOP;
return; return;
} }
if(sel > -1 && sel < SHOP_ITEMS){ if(sel > -1 && sel < SHOP_ITEMS){
@@ -635,14 +642,16 @@ void GameStateShop::ButtonPressed(int controllerId, int controlId)
else else
purchaseCard(sel); purchaseCard(sel);
} }
mStage = STAGE_SHOP_SHOP;
return; return;
} }
//Basic Menu. //Basic Menu.
switch(controlId){ switch(controlId){
case 12: case 12:
if (taskList) taskList->save(); if (taskList) taskList->save();
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
mStage = STAGE_SHOP_SHOP; mStage = STAGE_SHOP_SHOP;
mParent->DoTransition(TRANSITION_FADE,GAME_STATE_MENU);
save();
break; break;
case 14: case 14:
mStage = STAGE_SHOP_TASKS; mStage = STAGE_SHOP_TASKS;
@@ -662,5 +671,5 @@ void GameStateShop::ButtonPressed(int controllerId, int controlId)
default: default:
mStage = STAGE_SHOP_SHOP; mStage = STAGE_SHOP_SHOP;
} }
SAFE_DELETE(menu); menu->Close();
} }
+1 -1
View File
@@ -415,7 +415,7 @@ int WSrcDeck::totalPrice(){
int nb = it->second; int nb = it->second;
if (nb) total += pricelist->getPrice(it->first); if (nb) total += pricelist->getPrice(it->first);
} }
delete pricelist; SAFE_DELETE(pricelist);
return total; return total;
} }