Jeck - Fix for issue 316 (shop selection not cyclical).

This commit is contained in:
wagic.jeck
2010-02-10 14:03:08 +00:00
parent 7fd2956399
commit 9806edc6d0
3 changed files with 36 additions and 24 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ class GameStateShop: public GameState, public JGuiListener
void load(); void load();
void save(bool force=false); void save(bool force=false);
void assembleBooster(int controlId); void assembleBooster(int controlId);
void beginPurchase(int controlId); void beginPurchase(int controlId);
void purchaseCard(int controlId); void purchaseCard(int controlId);
+1 -1
View File
@@ -64,7 +64,7 @@ void GameStateShop::Start(){
mStage = STAGE_FADE_IN; mStage = STAGE_FADE_IN;
mElapsed = 0; mElapsed = 0;
booster = NULL; booster = NULL;
srcCards = NEW WSrcUnlockedCards(.25); srcCards = NEW WSrcUnlockedCards(0);
srcCards->setElapsed(15); srcCards->setElapsed(15);
bigSync = 0; bigSync = 0;
+34 -22
View File
@@ -839,12 +839,18 @@ void WGuiMenu::Update(float dt){
bool WGuiMenu::nextItem(){ bool WGuiMenu::nextItem(){
int potential = currentItem; int potential = currentItem;
int nbitems = (int) items.size(); int nbitems = (int) items.size();
if(nbitems < 2)
return false;
WGuiBase * now = NULL; WGuiBase * now = NULL;
if(currentItem < nbitems && currentItem > -1) if(currentItem < nbitems && currentItem > -1)
now = items[currentItem]; now = items[currentItem];
if (potential < nbitems-1){ if (potential < nbitems-1)
potential++; potential++;
else
potential = 0;
while(potential < nbitems-1 && items[potential]->Selectable() == false) while(potential < nbitems-1 && items[potential]->Selectable() == false)
potential++; potential++;
if(potential == nbitems || !items[potential]->Selectable()) if(potential == nbitems || !items[potential]->Selectable())
@@ -857,7 +863,7 @@ bool WGuiMenu::nextItem(){
syncMove(); syncMove();
return true; return true;
} }
}
if(sync) if(sync)
syncMove(); syncMove();
return false; return false;
@@ -866,26 +872,32 @@ bool WGuiMenu::nextItem(){
bool WGuiMenu::prevItem(){ bool WGuiMenu::prevItem(){
int potential = currentItem; int potential = currentItem;
WGuiBase * now = NULL; WGuiBase * now = NULL;
if(currentItem < (int)items.size() && currentItem > -1) int nbitems = (int) items.size();
now = items[currentItem]; if(nbitems < 2)
return false;
if (potential > 0){ if(currentItem < (int)items.size() && currentItem > -1)
potential--; now = items[currentItem];
while(potential > 0 && items[potential]->Selectable() == false)
potential--; if (potential > 0)
if(potential < 0 || !items[potential]->Selectable()) potential--;
potential = -1; else
else if(potential != currentItem && (!now || now->Leaving(buttonNext))){ potential = nbitems-1;
currentItem = potential;
items[currentItem]->Entering(buttonPrev); while(potential > 0 && items[potential]->Selectable() == false)
if(sync) potential--;
syncMove(); if(potential < 0 || !items[potential]->Selectable())
return true; potential = -1;
} else if(potential != currentItem && (!now || now->Leaving(buttonNext))){
} currentItem = potential;
if(sync) items[currentItem]->Entering(buttonPrev);
syncMove(); if(sync)
return false; syncMove();
return true;
}
if(sync)
syncMove();
return false;
} }
void WGuiMenu::setModal(bool val){ void WGuiMenu::setModal(bool val){