Let the deck view base class handle buttons
This commit is contained in:
@@ -31,7 +31,9 @@ public:
|
||||
void Render();
|
||||
|
||||
MTGCard * Click(int x, int y);
|
||||
bool Button(Buttons button);
|
||||
|
||||
void changePosition(int offset);
|
||||
void changeFilter(int offset);
|
||||
|
||||
MTGCard *getActiveCard();
|
||||
|
||||
|
||||
@@ -39,8 +39,10 @@ public:
|
||||
|
||||
virtual void Render() = 0;
|
||||
virtual MTGCard * Click(int x, int y) = 0;
|
||||
virtual bool Button(Buttons button) = 0;
|
||||
bool Button(Buttons button);
|
||||
virtual MTGCard *getActiveCard() = 0;
|
||||
virtual void changePosition(int offset) = 0;
|
||||
virtual void changeFilter(int offset) = 0;
|
||||
|
||||
virtual void SetDeck(DeckDataWrapper *toShow);
|
||||
DeckDataWrapper *deck();
|
||||
|
||||
@@ -20,7 +20,10 @@ public:
|
||||
|
||||
void Render();
|
||||
MTGCard * Click(int x, int y);
|
||||
bool Button(Buttons button);
|
||||
|
||||
void changePosition(int offset);
|
||||
void changeFilter(int offset);
|
||||
|
||||
MTGCard *getActiveCard();
|
||||
private:
|
||||
int mCols;
|
||||
|
||||
@@ -147,34 +147,30 @@ MTGCard * CarouselDeckView::Click(int x, int y)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CarouselDeckView::Button(Buttons button)
|
||||
void CarouselDeckView::changePosition(int offset)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
case JGE_BTN_LEFT:
|
||||
mScrollTarget -= 1;
|
||||
mStage = SCROLL_TO_SELECTED;
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_RIGHT:
|
||||
if(offset > 0){
|
||||
mScrollTarget += 1;
|
||||
mStage = SCROLL_TO_SELECTED;
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_UP:
|
||||
}else if(offset < 0){
|
||||
mScrollTarget -= 1;
|
||||
mStage = SCROLL_TO_SELECTED;
|
||||
}
|
||||
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
void CarouselDeckView::changeFilter(int offset)
|
||||
{
|
||||
if(offset > 0){
|
||||
mStage = SLIDE_UP;
|
||||
SwitchFilter(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_DOWN:
|
||||
} else if(offset < 0){
|
||||
mStage = SLIDE_DOWN;
|
||||
SwitchFilter(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
MTGCard *CarouselDeckView::getActiveCard()
|
||||
|
||||
@@ -42,6 +42,32 @@ void DeckView::Update(float dt)
|
||||
}
|
||||
}
|
||||
|
||||
bool DeckView::Button(Buttons button)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
case JGE_BTN_LEFT:
|
||||
changePosition(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_RIGHT:
|
||||
changePosition(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_UP:
|
||||
changeFilter(1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_DOWN:
|
||||
changeFilter(-1);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeckView::SetDeck(DeckDataWrapper *toShow)
|
||||
{
|
||||
mCurrentDeck = toShow;
|
||||
|
||||
@@ -1536,26 +1536,13 @@ void GameStateDeckViewer::OnScroll(int inXVelocity, int inYVelocity)
|
||||
{
|
||||
if(abs(inXVelocity) > 300)
|
||||
{
|
||||
//determine how many cards to move, the faster the velocity the more cards to move.
|
||||
// the display is setup so that there is a max of 2 cards to the left and 7 cards to the right
|
||||
// of the current card.
|
||||
//FIXME: this 500 is a bit arbitrary
|
||||
int numCards = (magnitude / 500) % 8;
|
||||
int offset = 0;
|
||||
if ( (numCards == 0) && magnitude) numCards = 7;
|
||||
if ( !flickRight)
|
||||
{
|
||||
if (numCards > 1)
|
||||
offset = 0;
|
||||
}
|
||||
else
|
||||
offset = 2 + numCards;
|
||||
|
||||
//TODO: FIXME
|
||||
//mEngine->LeftClickedProcessed();
|
||||
//mEngine->LeftClicked(static_cast<int>(cardsCoordinates[offset].first), static_cast<int>(cardsCoordinates[offset].second));
|
||||
//mEngine->HoldKey_NoRepeat(JGE_BTN_OK);
|
||||
mView->changePosition(flickRight ? numCards : - numCards);
|
||||
}
|
||||
}
|
||||
else
|
||||
mEngine->HoldKey_NoRepeat(flickUp ? JGE_BTN_UP : JGE_BTN_DOWN);
|
||||
mView->changeFilter(flickUp ? 1 : -1);
|
||||
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
@@ -141,30 +141,24 @@ MTGCard * GridDeckView::Click(int x, int y)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool GridDeckView::Button(Buttons button)
|
||||
void GridDeckView::changePosition(int offset)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
case JGE_BTN_RIGHT:
|
||||
mScrollOffset.start(-1.0f, 0.3f);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_LEFT:
|
||||
if(offset < 0){
|
||||
mScrollOffset.start( 1.0f, 0.3f);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_UP:
|
||||
mSlide.start(2.0f, 0.3f);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
case JGE_BTN_DOWN:
|
||||
mSlide.start(-2.0f, 0.3f);
|
||||
last_user_activity = 0;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}else if(offset > 0){
|
||||
mScrollOffset.start(-1.0f, 0.3f);
|
||||
}
|
||||
return true;
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
void GridDeckView::changeFilter(int offset)
|
||||
{
|
||||
if(offset < 0){
|
||||
mSlide.start(-2.0f, 0.3f);
|
||||
}else if(offset > 0){
|
||||
mSlide.start(2.0f, 0.3f);
|
||||
}
|
||||
last_user_activity = 0;
|
||||
}
|
||||
|
||||
MTGCard* GridDeckView::getActiveCard()
|
||||
|
||||
Reference in New Issue
Block a user