- reimplement r2609 with inheritance, and cleaned up the function code.
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-11-14 01:35:26 +00:00
parent d668fbb45c
commit b934f0a5ab
4 changed files with 22 additions and 72 deletions
-1
View File
@@ -21,7 +21,6 @@ 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();
+7 -1
View File
@@ -30,6 +30,12 @@
class MTGPack;
class MTGPacks;
class BoosterDisplay:public CardDisplay {
public:
BoosterDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL, int nb_displayed_items = 7);
bool CheckUserInput(JButton key);
};
class ShopBooster{
public:
ShopBooster();
@@ -61,7 +67,7 @@ class GameStateShop: public GameState, public JGuiListener
WGuiMenu * shopMenu;
WGuiFilters * filterMenu; //Filter menu slides in sideways from right, or up from bottom.
WGuiCardImage * bigDisplay;
CardDisplay * boosterDisplay;
BoosterDisplay * boosterDisplay;
vector<MTGCardInstance*> subBooster;
MTGDeck * booster;
bool bListCards;
-68
View File
@@ -6,7 +6,6 @@
#include "TargetChooser.h"
#include "MTGGameZones.h"
#include "GameObserver.h"
#include "GameStateShop.h"
CardDisplay::CardDisplay() : mId(0), game(GameObserver::GetInstance()) {
tc = NULL;
@@ -192,73 +191,6 @@ bool CardDisplay::CheckUserInput(JButton key){
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;
}
void CardDisplay::Render(){
+15 -2
View File
@@ -26,6 +26,19 @@ float GameStateShop::_y3[] = {164,205,257,184,180,170,219,212,195,251,252};
float GameStateShop::_x4[] = { 76, 90, 65,131,171,221,123,187,225,141,237};
float GameStateShop::_y4[] = {169,188,250,182,182,168,220,208,198,259,245};
BoosterDisplay::BoosterDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener, TargetChooser * tc, int nb_displayed_items):
CardDisplay(id, game,x,y,listener,tc,nb_displayed_items){}
bool BoosterDisplay::CheckUserInput(JButton key){
if (JGE_BTN_UP == key || JGE_BTN_DOWN == key)
return false;
return CardDisplay::CheckUserInput(key);
}
GameStateShop::GameStateShop(GameApp* parent): GameState(parent) {
menu = NULL;
for(int i=0;i<8;i++)
@@ -252,7 +265,7 @@ void GameStateShop::purchaseBooster(int controlId){
SAFE_DELETE(booster);
deleteDisplay();
booster = NEW MTGDeck(mParent->collection);
boosterDisplay = NEW CardDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5);
boosterDisplay = NEW BoosterDisplay(12,NULL, SCREEN_WIDTH - 200, SCREEN_HEIGHT/2,this,NULL,5);
mBooster[controlId].addToDeck(booster,srcCards);
string sort = mBooster[controlId].getSort();
@@ -519,7 +532,7 @@ void GameStateShop::Update(float dt)
if (btn == JGE_BTN_SEC)
deleteDisplay();
else {
boosterDisplay->CheckUserInputSHOP(btn);
boosterDisplay->CheckUserInput(btn);
boosterDisplay->Update(dt);}
return;
}else if (btn == JGE_BTN_SEC)