From 2f408664ad4f1be8267f9e96d0997c73096a044c Mon Sep 17 00:00:00 2001 From: "techdragon.nguyen@gmail.com" Date: Wed, 1 Feb 2012 00:38:02 +0000 Subject: [PATCH] last fix for buttons only fixed the PC/SDL mouse impl. This fixes the iOS/Android platforms. iOS/Android platforms both issue a JGE_BTN_OK keypress on single tap in which the mouse version does not. that version issues the OK keypress in sync with the mouse click. --- projects/mtg/include/GameStateShop.h | 2 +- projects/mtg/src/GameStateShop.cpp | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/projects/mtg/include/GameStateShop.h b/projects/mtg/include/GameStateShop.h index d26173a19..1de196b5f 100644 --- a/projects/mtg/include/GameStateShop.h +++ b/projects/mtg/include/GameStateShop.h @@ -74,7 +74,7 @@ private: MTGDeck * booster; bool bListCards; InteractiveButton *cycleCardsButton, *showCardListButton; - bool disablePurchase; + bool disablePurchase, clearInput; void beginFilters(); void deleteDisplay(); diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index b79abd603..b925aa667 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -79,6 +79,7 @@ GameStateShop::GameStateShop(GameApp* parent) : showCardListButton = NEW InteractiveButton(NULL, kShowCardListButtonId, Fonts::MAIN_FONT, "Show List", SCREEN_WIDTH_F - 150, SCREEN_HEIGHT_F - 15, JGE_BTN_SEC); disablePurchase = false; + clearInput = false; } GameStateShop::~GameStateShop() @@ -609,6 +610,9 @@ void GameStateShop::Update(float dt) srcCards->Shuffle(); load(); disablePurchase = false; + clearInput = true; + return; + } else if (btn == JGE_BTN_CANCEL) options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number; @@ -627,19 +631,30 @@ void GameStateShop::Update(float dt) { bListCards = !bListCards; disablePurchase = false; + clearInput = true; + return; } else if (shopMenu) { - if (btn == JGE_BTN_OK && (cycleCardsButton->ButtonPressed() || showCardListButton->ButtonPressed())) +#if defined (IOS) || defined (ANDROID) + if ((cycleCardsButton->ButtonPressed() || showCardListButton->ButtonPressed())) +#else + if ( (btn == JGE_BTN_OK) && (cycleCardsButton->ButtonPressed() || showCardListButton->ButtonPressed())) +#endif { disablePurchase = true; return; } - else if (btn == JGE_BTN_OK && disablePurchase) - { - disablePurchase = false; - } + else +#if defined (IOS) || defined (ANDROID) + if (clearInput && (btn == JGE_BTN_OK)) + { + clearInput = false; + disablePurchase = false; + return; + } else +#endif if (shopMenu->CheckUserInput(btn)) srcCards->Touch(); }