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
@@ -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;
+16 -4
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,11 +872,18 @@ bool WGuiMenu::nextItem(){
bool WGuiMenu::prevItem(){ bool WGuiMenu::prevItem(){
int potential = currentItem; int potential = currentItem;
WGuiBase * now = NULL; WGuiBase * now = NULL;
int nbitems = (int) items.size();
if(nbitems < 2)
return false;
if(currentItem < (int)items.size() && currentItem > -1) if(currentItem < (int)items.size() && currentItem > -1)
now = items[currentItem]; now = items[currentItem];
if (potential > 0){ if (potential > 0)
potential--; potential--;
else
potential = nbitems-1;
while(potential > 0 && items[potential]->Selectable() == false) while(potential > 0 && items[potential]->Selectable() == false)
potential--; potential--;
if(potential < 0 || !items[potential]->Selectable()) if(potential < 0 || !items[potential]->Selectable())
@@ -882,7 +895,6 @@ bool WGuiMenu::prevItem(){
syncMove(); syncMove();
return true; return true;
} }
}
if(sync) if(sync)
syncMove(); syncMove();
return false; return false;