added new buttons for shop for New Cards and displaying the card list.

This commit is contained in:
techdragon.nguyen@gmail.com
2012-01-30 18:02:26 +00:00
parent fb43b9012b
commit c42ba32ae7
5 changed files with 49 additions and 8 deletions

View File

@@ -435,7 +435,6 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
CGPoint newCoordinates = [self normalizeClickCoordinatesWithPoint: currentLocation];
g_engine->LeftClicked( newCoordinates.x, newCoordinates.y);
g_engine->HoldKey_NoRepeat(JGE_BTN_NONE);
BOOL clickedWithinGameArea = (currentLocation.y > es2renderer.viewPort.top &&
currentLocation.y < es2renderer.viewPort.bottom &&
@@ -467,7 +466,6 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
}
oldCoordinates = newCoordinates;
g_engine->ReleaseKey( JGE_BTN_NONE );
}

View File

@@ -10,6 +10,7 @@
#include "CardDisplay.h"
#include "DeckDataWrapper.h"
#include "Tasks.h"
#include "InteractiveButton.h"
#define STATE_BUY 1
#define STATE_SELL 2
@@ -72,10 +73,14 @@ private:
vector<MTGCardInstance*> subBooster;
MTGDeck * booster;
bool bListCards;
InteractiveButton *cycleCardsButton, *showCardListButton;
bool disablePurchase;
void beginFilters();
void deleteDisplay();
void enableButtons();
void renderButtons();
WSyncable bigSync;
SimpleMenu * menu;
PriceList * pricelist;

View File

@@ -26,6 +26,8 @@ const int kMenuButtonId = 10003;
const int kFilterButtonId = 10004;
const int kNextStatsButtonId = 10005;
const int kPrevStatsButtonId = 10006;
const int kCycleCardsButtonId = 10007;
const int kShowCardListButtonId = 10008;
class InteractiveButton: public SimpleButton
{

View File

@@ -12,6 +12,7 @@
#include "TestSuiteAI.h"
#include <hge/hgedistort.h>
#include "WFont.h"
float GameStateShop::_x1[] = { 79, 19, 27, 103, 154, 187, 102, 144, 198, 133, 183 };
float GameStateShop::_y1[] = { 150, 194, 222, 167, 164, 156, 195, 190, 175, 220, 220 };
@@ -74,10 +75,17 @@ GameStateShop::GameStateShop(GameApp* parent) :
kOtherCardsString = _(kOtherCardsString);
kCreditsString = _(kCreditsString);
cycleCardsButton = NEW InteractiveButton(NULL, kCycleCardsButtonId, Fonts::MAIN_FONT, "New Cards", SCREEN_WIDTH_F - 80, SCREEN_HEIGHT_F - 15, JGE_BTN_PRI);
showCardListButton = NEW InteractiveButton(NULL, kShowCardListButtonId, Fonts::MAIN_FONT, "Show List", SCREEN_WIDTH_F - 150, SCREEN_HEIGHT_F - 15, JGE_BTN_SEC);
disablePurchase = false;
}
GameStateShop::~GameStateShop()
{
SAFE_DELETE( cycleCardsButton );
SAFE_DELETE( showCardListButton );
End();
}
@@ -619,8 +627,18 @@ void GameStateShop::Update(float dt)
bListCards = !bListCards;
else if (shopMenu)
{
if (shopMenu->CheckUserInput(btn))
srcCards->Touch();
if (cycleCardsButton->ButtonPressed() || showCardListButton->ButtonPressed())
{
disablePurchase = true;
return;
}
else if (btn == JGE_BTN_OK && disablePurchase)
{
disablePurchase = false;
}
else
if (shopMenu->CheckUserInput(btn))
srcCards->Touch();
}
if (shopMenu)
shopMenu->Update(dt);
@@ -645,6 +663,19 @@ void GameStateShop::deleteDisplay()
subBooster.clear();
SAFE_DELETE(boosterDisplay);
}
void GameStateShop::enableButtons()
{
cycleCardsButton->setIsSelectionValid(true);
showCardListButton->setIsSelectionValid(true);
}
void GameStateShop::renderButtons()
{
cycleCardsButton->Render();
showCardListButton->Render();
}
void GameStateShop::Render()
{
//Erase
@@ -719,10 +750,14 @@ void GameStateShop::Render()
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(stream.str(), 5, SCREEN_HEIGHT - 14);
#ifndef TOUCH_ENABLED
float len = 4 + mFont->GetStringWidth(kOtherCardsString.c_str());
r->RenderQuad(pspIcons[6].get(), SCREEN_WIDTH - len - kGamepadIconSize - 10, SCREEN_HEIGHT - 8, 0, kGamepadIconSize, kGamepadIconSize);
mFont->DrawString(kOtherCardsString, SCREEN_WIDTH - len, SCREEN_HEIGHT - 14);
#else
enableButtons();
#endif
mFont->SetColor(ARGB(255,255,255,0));
mFont->DrawString(descPurchase(bigSync.getPos()).c_str(), SCREEN_WIDTH / 2, SCREEN_HEIGHT - 14, JGETEXT_CENTER);
mFont->SetColor(ARGB(255,255,255,255));
@@ -733,12 +768,13 @@ void GameStateShop::Render()
}
if (menu)
menu->Render();
renderButtons();
}
void GameStateShop::ButtonPressed(int controllerId, int controlId)
{
int sel = bigSync.getOffset();
switch (controllerId)
{
case -102: //Buying something...

View File

@@ -1562,6 +1562,7 @@
CEA376B71291C60500B9016A /* GuiPhaseBar.h */,
CEA376B81291C60500B9016A /* GuiPlay.h */,
CEA376B91291C60500B9016A /* GuiStatic.h */,
12272FC614CD68FB00192DC7 /* InteractiveButton.h */,
CEA376BA1291C60500B9016A /* ManaCost.h */,
CEA376BB1291C60500B9016A /* ManaCostHybrid.h */,
CEA376BC1291C60500B9016A /* MenuItem.h */,
@@ -1612,7 +1613,6 @@
CEA376EA1291C60500B9016A /* WFont.h */,
CEA376EB1291C60500B9016A /* WGui.h */,
CEA376EC1291C60500B9016A /* WResourceManager.h */,
12272FC614CD68FB00192DC7 /* InteractiveButton.h */,
);
path = include;
sourceTree = "<group>";