added more buttons to deck editor to cover all the functionality. Need to remove the PSP directions from the slide-in menus

This commit is contained in:
techdragon.nguyen@gmail.com
2012-01-30 04:23:11 +00:00
parent 28be95b401
commit 969e6ac5e6
5 changed files with 74 additions and 34 deletions

View File

@@ -97,7 +97,7 @@ private:
int lastTotal; int lastTotal;
int mSelected; int mSelected;
InteractiveButton *toggleDeckButton, *sellCardButton; InteractiveButton *toggleDeckButton, *sellCardButton, *statsNextButton, *statsPrevButton, *menuButton, *filterButton;
WGuiFilters * filterMenu; WGuiFilters * filterMenu;
WSrcDeckViewer * source; WSrcDeckViewer * source;
@@ -124,6 +124,7 @@ private:
void sellCard(); void sellCard();
void setButtonState(bool state); void setButtonState(bool state);
bool userPressedButton(); bool userPressedButton();
void RenderButtons();
pair<float, float> cardsCoordinates[CARDS_DISPLAYED]; pair<float, float> cardsCoordinates[CARDS_DISPLAYED];

View File

@@ -22,6 +22,10 @@ using std::string;
const int kDismissButtonId = 10000; const int kDismissButtonId = 10000;
const int kToggleDeckActionId = 10001; const int kToggleDeckActionId = 10001;
const int kSellCardActionId = 10002; const int kSellCardActionId = 10002;
const int kMenuButtonId = 10003;
const int kFilterButtonId = 10004;
const int kNextStatsButtonId = 10005;
const int kPrevStatsButtonId = 10006;
class InteractiveButton: public SimpleButton class InteractiveButton: public SimpleButton
{ {
@@ -34,9 +38,8 @@ public:
virtual void Entering(); virtual void Entering();
virtual bool ButtonPressed(); virtual bool ButtonPressed();
virtual void setImage( const JQuadPtr imagePtr, float xOffset = 0, float yOffset = 0); virtual void setImage( const JQuadPtr imagePtr );
virtual void checkUserClick(); virtual void checkUserClick();
//virtual void Update(float dt);
virtual void Render(); virtual void Render();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;

View File

@@ -198,6 +198,7 @@ void DeckMenu::initMenuItems()
} }
mSelectionTargetY = selectionY = sY; mSelectionTargetY = selectionY = sY;
#ifndef TOUCH_ENABLED
//Grab a texture in VRAM. //Grab a texture in VRAM.
pspIconsTexture = WResourceManager::Instance()->RetrieveTexture("iconspsp.png", RETRIEVE_MANAGE); pspIconsTexture = WResourceManager::Instance()->RetrieveTexture("iconspsp.png", RETRIEVE_MANAGE);
@@ -209,6 +210,7 @@ void DeckMenu::initMenuItems()
pspIcons[i]->SetHotSpot(16, 16); pspIcons[i]->SetHotSpot(16, 16);
} }
dismissButton->setImage(pspIcons[5]); dismissButton->setImage(pspIcons[5]);
#endif
} }
void DeckMenu::Render() void DeckMenu::Render()

View File

@@ -59,8 +59,12 @@ GameStateDeckViewer::GameStateDeckViewer(GameApp* parent) :
menu = NULL; menu = NULL;
stw = NULL; stw = NULL;
toggleDeckButton = NEW InteractiveButton(NULL, kToggleDeckActionId, Fonts::MAIN_FONT, "View Deck", 10, 10, JGE_BTN_PRI); toggleDeckButton = NEW InteractiveButton(NULL, kToggleDeckActionId, Fonts::MAIN_FONT, "View Deck", 10, SCREEN_HEIGHT_F - 15, JGE_BTN_PRI);
sellCardButton = NEW InteractiveButton(NULL, kSellCardActionId, Fonts::MAIN_FONT, "Sell Card", (SCREEN_WIDTH_F/ 2) - 100, SCREEN_HEIGHT_F - 40, JGE_BTN_SEC); sellCardButton = NEW InteractiveButton(NULL, kSellCardActionId, Fonts::MAIN_FONT, "Sell Card", (SCREEN_WIDTH_F/ 2) - 100, SCREEN_HEIGHT_F - 15, JGE_BTN_SEC);
statsNextButton = NEW InteractiveButton(NULL, kNextStatsButtonId, Fonts::MAIN_FONT, "Stats ->", SCREEN_WIDTH_F - 50, SCREEN_HEIGHT_F - 40, JGE_BTN_NEXT);
statsPrevButton = NEW InteractiveButton(NULL, kPrevStatsButtonId, Fonts::MAIN_FONT, "<- Stats", SCREEN_WIDTH_F - 115, SCREEN_HEIGHT_F - 40, JGE_BTN_PREV);
menuButton = NEW InteractiveButton(NULL, kMenuButtonId, Fonts::MAIN_FONT, "menu", SCREEN_WIDTH_F - 35, SCREEN_HEIGHT_F - 15, JGE_BTN_MENU);
filterButton = NEW InteractiveButton(NULL, kFilterButtonId, Fonts::MAIN_FONT, "filter", (SCREEN_WIDTH_F - 95), SCREEN_HEIGHT_F - 15, JGE_BTN_CTRL);
} }
GameStateDeckViewer::~GameStateDeckViewer() GameStateDeckViewer::~GameStateDeckViewer()
@@ -68,6 +72,10 @@ GameStateDeckViewer::~GameStateDeckViewer()
SAFE_DELETE(bgMusic); SAFE_DELETE(bgMusic);
SAFE_DELETE(toggleDeckButton); SAFE_DELETE(toggleDeckButton);
SAFE_DELETE(sellCardButton); SAFE_DELETE(sellCardButton);
SAFE_DELETE(statsPrevButton);
SAFE_DELETE(statsNextButton);
SAFE_DELETE(menuButton);
SAFE_DELETE(filterButton);
if (myDeck) if (myDeck)
{ {
@@ -250,7 +258,11 @@ void GameStateDeckViewer::Start()
pspIcons[i] = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, buf); pspIcons[i] = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, buf);
pspIcons[i]->SetHotSpot(16, 16); pspIcons[i]->SetHotSpot(16, 16);
} }
#ifndef TOUCH_ENABLED
toggleDeckButton->setImage( pspIcons[6] );
sellCardButton->setImage( pspIcons[7] );
#endif
//init welcome menu //init welcome menu
updateDecks(); updateDecks();
@@ -368,13 +380,32 @@ bool GameStateDeckViewer::userPressedButton()
return ( return (
(toggleDeckButton->ButtonPressed()) (toggleDeckButton->ButtonPressed())
|| (sellCardButton->ButtonPressed()) || (sellCardButton->ButtonPressed())
|| (statsNextButton->ButtonPressed())
|| (statsPrevButton->ButtonPressed())
|| (menuButton->ButtonPressed())
|| (filterButton->ButtonPressed())
); );
} }
void GameStateDeckViewer::setButtonState(bool state) void GameStateDeckViewer::setButtonState(bool state)
{ {
toggleDeckButton->setIsSelectionValid(state); toggleDeckButton->setIsSelectionValid(state);
sellCardButton->setIsSelectionValid(state); sellCardButton->setIsSelectionValid(state);
statsNextButton->setIsSelectionValid(state);
statsPrevButton->setIsSelectionValid(state);
filterButton->setIsSelectionValid(state);
menuButton->setIsSelectionValid(state);
}
void GameStateDeckViewer::RenderButtons()
{
toggleDeckButton->Render();
sellCardButton->Render();
menuButton->Render();
filterButton->Render();
statsNextButton->Render();
statsPrevButton->Render();
} }
void GameStateDeckViewer::Update(float dt) void GameStateDeckViewer::Update(float dt)
@@ -840,10 +871,12 @@ void GameStateDeckViewer::renderOnScreenMenu()
font->DrawString(_("View Collection"), rightPspX - 20, rightPspY - 15, JGETEXT_RIGHT); font->DrawString(_("View Collection"), rightPspX - 20, rightPspY - 15, JGETEXT_RIGHT);
} }
font->DrawString(_("Sell card"), rightPspX - 30, rightPspY + 20); font->DrawString(_("Sell card"), rightPspX - 30, rightPspY + 20);
//Bottom menus //Bottom menus
#ifndef TOUCH_ENABLED
font->DrawString(_("menu"), SCREEN_WIDTH - 35 + rightTransition, SCREEN_HEIGHT - 15); font->DrawString(_("menu"), SCREEN_WIDTH - 35 + rightTransition, SCREEN_HEIGHT - 15);
font->DrawString(_("filter"), SCREEN_WIDTH - 95 + rightTransition, SCREEN_HEIGHT - 15); font->DrawString(_("filter"), SCREEN_WIDTH - 95 + rightTransition, SCREEN_HEIGHT - 15);
#endif
//Your Deck Information //Your Deck Information
char buffer[300]; char buffer[300];
int nb_letters = 0; int nb_letters = 0;
@@ -897,9 +930,10 @@ void GameStateDeckViewer::renderOnScreenMenu()
r->FillRect(SCREEN_WIDTH / 2 + rightTransition, 0, SCREEN_WIDTH / 2, SCREEN_HEIGHT, ARGB(128,0,0,0)); r->FillRect(SCREEN_WIDTH / 2 + rightTransition, 0, SCREEN_WIDTH / 2, SCREEN_HEIGHT, ARGB(128,0,0,0));
r->FillRect(10 + leftTransition, 10, SCREEN_WIDTH / 2 - 10, SCREEN_HEIGHT - 20, ARGB(128,0,0,0)); r->FillRect(10 + leftTransition, 10, SCREEN_WIDTH / 2 - 10, SCREEN_HEIGHT - 20, ARGB(128,0,0,0));
r->FillRect(SCREEN_WIDTH / 2 + rightTransition, 10, SCREEN_WIDTH / 2 - 10, SCREEN_HEIGHT - 20, ARGB(128,0,0,0)); r->FillRect(SCREEN_WIDTH / 2 + rightTransition, 10, SCREEN_WIDTH / 2 - 10, SCREEN_HEIGHT - 20, ARGB(128,0,0,0));
#ifndef TOUCH_ENABLED
font->DrawString(_("menu"), SCREEN_WIDTH - 35 + rightTransition, SCREEN_HEIGHT - 15); font->DrawString(_("menu"), SCREEN_WIDTH - 35 + rightTransition, SCREEN_HEIGHT - 15);
font->DrawString(_("filter"), SCREEN_WIDTH - 95 + rightTransition, SCREEN_HEIGHT - 15); font->DrawString(_("filter"), SCREEN_WIDTH - 95 + rightTransition, SCREEN_HEIGHT - 15);
#endif
int nb_letters = 0; int nb_letters = 0;
float posX, posY; float posX, posY;
DWORD graphColor; DWORD graphColor;
@@ -1496,6 +1530,7 @@ void GameStateDeckViewer::Render()
if (displayed_deck->Size() > 0) if (displayed_deck->Size() > 0)
{ {
setButtonState(true);
renderSlideBar(); renderSlideBar();
} }
else else
@@ -1508,6 +1543,7 @@ void GameStateDeckViewer::Render()
} }
else if (mStage == STAGE_WELCOME) else if (mStage == STAGE_WELCOME)
{ {
setButtonState(false);
welcome_menu->Render(); welcome_menu->Render();
} }
else else
@@ -1532,8 +1568,7 @@ void GameStateDeckViewer::Render()
if (options.keypadActive()) options.keypadRender(); if (options.keypadActive()) options.keypadRender();
toggleDeckButton->Render(); RenderButtons();
sellCardButton->Render();
} }
int GameStateDeckViewer::loadDeck(int deckid) int GameStateDeckViewer::loadDeck(int deckid)

View File

@@ -15,7 +15,7 @@
#include "WResourceManager.h" #include "WResourceManager.h"
#include "WFont.h" #include "WFont.h"
const int kButtonHeight = 60; const int kButtonHeight = 30;
InteractiveButton::InteractiveButton(JGuiController* _parent, int id, int fontId, string text, float x, float y, JButton actionKey, bool hasFocus, bool autoTranslate) : InteractiveButton::InteractiveButton(JGuiController* _parent, int id, int fontId, string text, float x, float y, JButton actionKey, bool hasFocus, bool autoTranslate) :
SimpleButton( _parent, id, fontId, text, x, y, hasFocus, autoTranslate) SimpleButton( _parent, id, fontId, text, x, y, hasFocus, autoTranslate)
@@ -66,40 +66,39 @@ void InteractiveButton::Render()
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
const string detailedInfoString = _(getText()); const string detailedInfoString = _(getText());
float stringWidth = mainFont->GetStringWidth(detailedInfoString.c_str()); float stringWidth = mainFont->GetStringWidth(detailedInfoString.c_str());
float pspIconsSize = 0.5;
float mainFontHeight = mainFont->GetHeight();
float boxStartX = 0;
#ifndef TOUCH_ENABLED #ifndef TOUCH_ENABLED
mXOffset = -5; mXOffset = -5;
mYOffset = 10; mYOffset = 10;
float boxStartX = getX() - 5; boxStartX = getX() - 5;
float pspIconsSize = 0.5; renderer->FillRoundRect( boxStartX, getY() - 5, stringWidth, mainFontHeight + 15, .5, ARGB( 255, 0, 0, 0) );
if (buttonImage != NULL)
{
renderer->FillRoundRect( boxStartX, getY() - 5, stringWidth, mainFont->GetHeight() + 15, .5, ARGB(255, 0, 0, 0) );
renderer->RenderQuad(buttonImage.get(), boxStartX + (stringWidth/2), getY() + 2, 0, pspIconsSize, pspIconsSize);
}
else
{
mYOffset = -3;
mXOffset = 0;
renderer->FillRoundRect( boxStartX, getY() - 5, stringWidth , mainFont->GetHeight(), .5, ARGB(255, 192, 172, 119));
renderer->DrawRoundRect( boxStartX, getY() - 5, stringWidth + 6, mainFont->GetHeight(), .75, ARGB(255,255,255,255));
}
#else #else
mXOffset = 0; mXOffset = 0;
mYOffset = 0; mYOffset = 0;
renderer->FillRoundRect(getX() - 5, getY(), stringWidth - 3, mainFont->GetHeight() - 9, 5, ARGB(255, 192, 172, 119)); boxStartX = getX() - 5;
renderer->DrawRoundRect(getX() - 5, getY(), stringWidth - 3, mainFont->GetHeight() - 9, 5, ARGB(255,255,255,255)); renderer->FillRoundRect(boxStartX, getY(), stringWidth - 3, mainFont->GetHeight() - 9, 5, ARGB(255, 192, 172, 119));
renderer->DrawRoundRect(boxStartX, getY(), stringWidth - 3, mainFont->GetHeight() - 9, 5, ARGB(255, 255, 255, 255));
#endif #endif
mainFont->SetColor( ARGB(255, 200, 200, 200) ); float buttonXOffset = getX() - mXOffset;
mainFont->DrawString(detailedInfoString, getX() - mXOffset, getY() + mYOffset); float buttonYOffset = getY() + mYOffset;
if (buttonImage != NULL)
{
renderer->RenderQuad(buttonImage.get(), buttonXOffset - buttonImage.get()->mWidth/2, buttonYOffset + mainFontHeight/2, 0, pspIconsSize, pspIconsSize);
}
mainFont->SetColor(ARGB(255, 200, 200, 200));
mainFont->DrawString(detailedInfoString, buttonXOffset, buttonYOffset);
} }
void InteractiveButton::setImage( const JQuadPtr imagePtr, float xOffset, float yOffset) void InteractiveButton::setImage( const JQuadPtr imagePtr )
{ {
buttonImage = imagePtr; buttonImage = imagePtr;
mXOffset = xOffset; float imageXOffset = getX() - buttonImage.get()->mWidth;
mYOffset = yOffset;
if (imageXOffset < 0)
setX( getX() - imageXOffset/2 + 5 );
} }
/* Accessors */ /* Accessors */