had to add this to prevent crashing in the shop from buying a booster, i understand the need to reduce code but does every single function have to share every other classes functions? this was originally supposed to be a tiny change, but there was no way to define the difference between the card display used by shop and the ones used by grave and library.

This commit is contained in:
omegablast2002@yahoo.com
2010-11-12 19:12:19 +00:00
parent f24a7410db
commit 2c1e18050c
3 changed files with 70 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ class CardDisplay:public PlayGuiObjectController{
void rotateLeft();
void rotateRight();
bool CheckUserInput(JButton key);
bool CheckUserInputSHOP(JButton key);
bool CheckUserInput(int x, int y);
virtual void Update(float dt);
void Render();

View File

@@ -6,6 +6,7 @@
#include "TargetChooser.h"
#include "MTGGameZones.h"
#include "GameObserver.h"
#include "GameStateShop.h"
CardDisplay::CardDisplay() : mId(0), game(GameObserver::GetInstance()) {
tc = NULL;
@@ -131,7 +132,6 @@ bool CardDisplay::CheckUserInput(JButton key){
return true;
}
}
if (!mCount)
return false;
@@ -189,7 +189,74 @@ bool CardDisplay::CheckUserInput(JButton key){
default:
;
}
return false;
}
bool CardDisplay::CheckUserInputSHOP(JButton key){
if (JGE_BTN_SEC == key || JGE_BTN_PRI == key)
{
if (listener){
listener->ButtonPressed(mId, 0);
return true;
}
}
if (!mCount)
return false;
if (mActionButton == key)
{
if (mObjects[mCurr] && mObjects[mCurr]->ButtonPressed()){
CardGui * cardg = (CardGui *)mObjects[mCurr];
if (tc) {
tc->toggleTarget(cardg->card);
return true;
} else {
if (game) game->ButtonPressed(cardg);
return true;
}
}
return true;
}
switch(key)
{
case JGE_BTN_LEFT :
{
int n = mCurr;
n--;
if (n<start_item) {
if (n< 0) {
n = 0;
} else {
rotateLeft();
}
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_LEFT)){
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
case JGE_BTN_RIGHT :
{
int n = mCurr;
n++;
if (n>= mCount) {
n = mCount-1;
}
if (n>= start_item + nb_displayed_items) {
rotateRight();
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_RIGHT)){
mCurr = n;
mObjects[mCurr]->Entering();
}
}
return true;
default:
;
}
return false;
}

View File

@@ -519,7 +519,7 @@ void GameStateShop::Update(float dt)
if (btn == JGE_BTN_SEC)
deleteDisplay();
else {
boosterDisplay->CheckUserInput(btn);
boosterDisplay->CheckUserInputSHOP(btn);
boosterDisplay->Update(dt);}
return;
}else if (btn == JGE_BTN_SEC)