refactored menu classes
fixed some layout issues with detailed info popup changed requirements for detailed info popup button to be determined by the number of wins aginst AI deck instead of just the number of games.
This commit is contained in:
@@ -29,7 +29,6 @@ protected:
|
||||
string title;
|
||||
string displayTitle;
|
||||
WFont * mFont;
|
||||
float menuFontScale;
|
||||
float titleFontScale;
|
||||
|
||||
int maxItems, startId;
|
||||
@@ -42,26 +41,30 @@ protected:
|
||||
void initMenuItems();
|
||||
string getDescription();
|
||||
string getMetaInformation();
|
||||
DeckMetaData *selectedDeck;
|
||||
DeckMetaData *mSelectedDeck;
|
||||
int mSelectedDeckId;
|
||||
bool mShowDetailsScreen;
|
||||
bool mAlwaysShowDetailsButton;
|
||||
bool mClosed;
|
||||
|
||||
public:
|
||||
TextScroller * scroller;
|
||||
bool autoTranslate;
|
||||
TextScroller * mScroller;
|
||||
bool mAutoTranslate;
|
||||
float mSelectionTargetY;
|
||||
|
||||
//used for detailed info button
|
||||
JQuad * pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
DeckMetaData * getSelectedDeck();
|
||||
bool selectedDeckHasDetails();
|
||||
int selectedDeckId;
|
||||
bool showDetailsScreen;
|
||||
bool enableDetails;
|
||||
float selectionTargetY;
|
||||
bool closed;
|
||||
|
||||
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const int& startIndex = 0, const float& mFontScale = 1.0f);
|
||||
|
||||
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const int& startIndex = 0, bool alwaysShowDetailsButton = false);
|
||||
~DeckMenu();
|
||||
|
||||
DeckMetaData * getSelectedDeck();
|
||||
bool showDetailsScreen();
|
||||
bool isClosed() { return mClosed; }
|
||||
int getSelectedDeckId() { return mSelectedDeckId; }
|
||||
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
int percentVictories();
|
||||
DeckStat * getDeckStat(string opponentsFile);
|
||||
int nbGames();
|
||||
int nbVictories();
|
||||
};
|
||||
|
||||
class StatsWrapper
|
||||
|
||||
@@ -18,6 +18,7 @@ class SimpleMenu:public JGuiController{
|
||||
int maxItems,startId;
|
||||
float selectionT, selectionY;
|
||||
float timeOpen;
|
||||
bool mClosed;
|
||||
|
||||
static JQuad *spadeR, *spadeL, *jewel, *side;
|
||||
static JTexture *spadeRTex, *spadeLTex, *jewelTex, *sideTex;
|
||||
@@ -37,7 +38,7 @@ class SimpleMenu:public JGuiController{
|
||||
void Close();
|
||||
|
||||
float selectionTargetY;
|
||||
bool closed;
|
||||
bool isClosed() { return mClosed; }
|
||||
static void destroy();
|
||||
};
|
||||
|
||||
|
||||
@@ -24,18 +24,22 @@ private:
|
||||
DeckMetaData * mDeckInformation;
|
||||
string mTitle;
|
||||
WFont *mTextFont;
|
||||
StatsWrapper *stw;
|
||||
StatsWrapper *mStatsWrapper;
|
||||
bool mClosed;
|
||||
MTGAllCards * mCollection;
|
||||
|
||||
void drawHorzPole(float x, float y, float width);
|
||||
void drawVertPole(float x, float y, float height);
|
||||
|
||||
public:
|
||||
MTGAllCards * mCollection;
|
||||
bool autoTranslate;
|
||||
bool closed;
|
||||
|
||||
|
||||
SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL);
|
||||
~SimplePopup(void);
|
||||
|
||||
bool isClosed() { return mClosed; }
|
||||
MTGAllCards* getCollection() { return mCollection; }
|
||||
void Render();
|
||||
void Update(DeckMetaData* deckMetaData);
|
||||
|
||||
|
||||
@@ -10,9 +10,8 @@ DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const
|
||||
DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats)
|
||||
{
|
||||
backgroundName = "DeckEditorMenuBackdrop";
|
||||
|
||||
mShowDetailsScreen = false;
|
||||
deckTitle = selectedDeck ? selectedDeck->parent->meta_name : "";
|
||||
enableDetails = false;
|
||||
|
||||
mX = 123;
|
||||
mY = 70;
|
||||
@@ -36,9 +35,8 @@ DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const
|
||||
avatarY = 8;
|
||||
|
||||
float scrollerWidth = 80;
|
||||
SAFE_DELETE(scroller); // need to delete the scroller init in the base class
|
||||
this->showDetailsScreen = false;
|
||||
scroller = NEW TextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100, 1, 1);
|
||||
SAFE_DELETE(mScroller); // need to delete the scroller init in the base class
|
||||
mScroller = NEW TextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100, 1, 1);
|
||||
|
||||
}
|
||||
|
||||
@@ -98,5 +96,5 @@ void DeckEditorMenu::drawDeckStatistics()
|
||||
|
||||
DeckEditorMenu::~DeckEditorMenu()
|
||||
{
|
||||
SAFE_DELETE( scroller );
|
||||
SAFE_DELETE( mScroller );
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace
|
||||
const float kLineHeight = 20;
|
||||
const float kDescriptionVerticalBoxPadding = 5;
|
||||
const float kDescriptionHorizontalBoxPadding = 5;
|
||||
const int DETAILED_INFO_THRESHOLD = 4;
|
||||
const float kMenuFontScale = 1.0f;
|
||||
const int DETAILED_INFO_THRESHOLD = 20;
|
||||
}
|
||||
|
||||
hgeParticleSystem* DeckMenu::stars = NULL;
|
||||
@@ -31,14 +32,13 @@ hgeParticleSystem* DeckMenu::stars = NULL;
|
||||
// * descriptive information 125
|
||||
// *** Need to make this configurable in a file somewhere to allow for class reuse
|
||||
|
||||
DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _title, const int& startIndex, const float& mFontScale) :
|
||||
JGuiController(id, listener), fontId(fontId), menuFontScale(mFontScale)
|
||||
DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _title, const int& startIndex, bool showDetailsOverride) :
|
||||
JGuiController(id, listener), fontId(fontId), mShowDetailsScreen( showDetailsOverride )
|
||||
{
|
||||
|
||||
backgroundName = "DeckMenuBackdrop";
|
||||
|
||||
selectedDeck = NULL;
|
||||
enableDetails = true;
|
||||
mAlwaysShowDetailsButton = false;
|
||||
mSelectedDeck = NULL;
|
||||
mY = 55;
|
||||
mWidth = 176;
|
||||
mX = 125;
|
||||
@@ -61,7 +61,7 @@ DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _tit
|
||||
statsHeight = 50;
|
||||
statsWidth = 227;
|
||||
|
||||
selectedDeckId = startIndex;
|
||||
mSelectedDeckId = startIndex;
|
||||
|
||||
avatarX = 230;
|
||||
avatarY = 8;
|
||||
@@ -69,9 +69,9 @@ DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _tit
|
||||
menuInitialized = false;
|
||||
|
||||
float scrollerWidth = 80;
|
||||
scroller = NEW TextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100, 1, 1);
|
||||
mScroller = NEW TextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100, 1, 1);
|
||||
|
||||
autoTranslate = true;
|
||||
mAutoTranslate = true;
|
||||
maxItems = 7;
|
||||
mHeight = 2 * kVerticalMargin + (maxItems * kLineHeight);
|
||||
|
||||
@@ -83,14 +83,14 @@ DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _tit
|
||||
startId = 0;
|
||||
selectionT = 0;
|
||||
timeOpen = 0;
|
||||
closed = false;
|
||||
mClosed = false;
|
||||
|
||||
if (mFont->GetStringWidth(title.c_str()) > titleWidth)
|
||||
titleFontScale = 0.75f;
|
||||
else
|
||||
titleFontScale = 1.0f;
|
||||
|
||||
selectionTargetY = selectionY = kVerticalMargin;
|
||||
mSelectionTargetY = selectionY = kVerticalMargin;
|
||||
|
||||
if (NULL == stars) stars = NEW hgeParticleSystem(resources.RetrievePSI("stars.psi", resources.GetQuad("stars")));
|
||||
stars->FireAt(mX, mY);
|
||||
@@ -116,15 +116,19 @@ void DeckMenu::RenderBackground()
|
||||
|
||||
DeckMetaData * DeckMenu::getSelectedDeck()
|
||||
{
|
||||
if (selectedDeck) return selectedDeck;
|
||||
if (mSelectedDeck) return mSelectedDeck;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool DeckMenu::selectedDeckHasDetails()
|
||||
bool DeckMenu::showDetailsScreen()
|
||||
{
|
||||
DeckMetaData * currentMenuItem = getSelectedDeck();
|
||||
if (currentMenuItem) return (enableDetails && currentMenuItem->getGamesPlayed() > DETAILED_INFO_THRESHOLD);
|
||||
if (currentMenuItem)
|
||||
{
|
||||
if (mAlwaysShowDetailsButton) return true;
|
||||
if (mShowDetailsScreen && currentMenuItem->getVictories() > DETAILED_INFO_THRESHOLD) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -139,7 +143,7 @@ void DeckMenu::initMenuItems()
|
||||
currentMenuItem->Relocate(mX, y);
|
||||
if (currentMenuItem->hasFocus()) sY = y;
|
||||
}
|
||||
selectionTargetY = selectionY = sY;
|
||||
mSelectionTargetY = selectionY = sY;
|
||||
|
||||
//Grab a texture in VRAM.
|
||||
pspIconsTexture = resources.RetrieveTexture("iconspsp.png", RETRIEVE_LOCK);
|
||||
@@ -176,28 +180,24 @@ void DeckMenu::Render()
|
||||
{
|
||||
if (currentMenuItem->hasFocus())
|
||||
{
|
||||
selectedDeckId = i;
|
||||
selectedDeck = currentMenuItem->meta;
|
||||
mSelectedDeckId = i;
|
||||
mSelectedDeck = currentMenuItem->meta;
|
||||
|
||||
WFont *mainFont = resources.GetWFont(Fonts::MAIN_FONT);
|
||||
|
||||
// display the "more info" button if special condition is met
|
||||
if (selectedDeckHasDetails())
|
||||
{
|
||||
showDetailsScreen = true;
|
||||
if (showDetailsScreen())
|
||||
{
|
||||
float pspIconsSize = 0.5;
|
||||
const string detailedInfoString = "Detailed Info";
|
||||
float stringWidth = mainFont->GetStringWidth(detailedInfoString.c_str());
|
||||
float boxStartX = detailedInfoBoxX - stringWidth / 2;
|
||||
DWORD currentColor = mainFont->GetColor();
|
||||
renderer->FillRoundRect( boxStartX, detailedInfoBoxY - 5, stringWidth,
|
||||
mainFont->GetHeight() + 15, .5, ARGB( 125, 0, 255, 255) );
|
||||
renderer->FillRoundRect( boxStartX, detailedInfoBoxY - 5, stringWidth, mainFont->GetHeight() + 15, .5, ARGB( 255, 0, 0, 0) );
|
||||
renderer->RenderQuad(pspIcons[5], detailedInfoBoxX, detailedInfoBoxY + 2, 0, pspIconsSize, pspIconsSize);
|
||||
mainFont->SetColor(currentColor);
|
||||
mainFont->DrawString(detailedInfoString, boxStartX, detailedInfoBoxY + 10);
|
||||
}
|
||||
else
|
||||
showDetailsScreen = false;
|
||||
|
||||
// display the avatar image
|
||||
if (currentMenuItem->imageFilename.size() > 0)
|
||||
@@ -224,7 +224,7 @@ void DeckMenu::Render()
|
||||
{
|
||||
mFont->SetColor(ARGB(150,255,255,255));
|
||||
}
|
||||
mFont->SetScale(menuFontScale);
|
||||
mFont->SetScale(kMenuFontScale);
|
||||
currentMenuItem->RenderWithOffset(-kLineHeight * startId);
|
||||
}
|
||||
}
|
||||
@@ -238,7 +238,7 @@ void DeckMenu::Render()
|
||||
mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
|
||||
}
|
||||
mFont->SetScale(1.0f);
|
||||
scroller->Render();
|
||||
mScroller->Render();
|
||||
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ void DeckMenu::Update(float dt)
|
||||
else if (mCurr < startId) startId = mCurr;
|
||||
stars->Update(dt);
|
||||
selectionT += 3 * dt;
|
||||
selectionY += (selectionTargetY - selectionY) * 8 * dt;
|
||||
selectionY += (mSelectionTargetY - selectionY) * 8 * dt;
|
||||
|
||||
float starsX = starsOffsetX + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2);
|
||||
float starsY = selectionY + 5 * cos(selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId;
|
||||
@@ -261,22 +261,22 @@ void DeckMenu::Update(float dt)
|
||||
if (timeOpen >= 0)
|
||||
{
|
||||
timeOpen = 0;
|
||||
closed = true;
|
||||
mClosed = true;
|
||||
stars->FireAt(mX, mY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
closed = false;
|
||||
mClosed = false;
|
||||
timeOpen += dt * 10;
|
||||
}
|
||||
if (scroller) scroller->Update(dt);
|
||||
if (mScroller) mScroller->Update(dt);
|
||||
}
|
||||
|
||||
void DeckMenu::Add(int id, const char * text, string desc, bool forceFocus, DeckMetaData * deckMetaData)
|
||||
{
|
||||
DeckMenuItem * menuItem = NEW DeckMenuItem(this, id, fontId, text, 0, mY + kVerticalMargin + mCount * kLineHeight,
|
||||
(mCount == 0), autoTranslate, deckMetaData);
|
||||
DeckMenuItem * menuItem = NEW DeckMenuItem(this, id, fontId, text, 0,
|
||||
mY + kVerticalMargin + mCount * kLineHeight, (mCount == 0), mAutoTranslate, deckMetaData);
|
||||
Translator * t = Translator::GetInstance();
|
||||
map<string, string>::iterator it = t->deckValues.find(text);
|
||||
if (it != t->deckValues.end()) //translate decks desc
|
||||
@@ -299,13 +299,13 @@ void DeckMenu::updateScroller()
|
||||
{
|
||||
// add all the items from the Tasks db.
|
||||
TaskList taskList;
|
||||
scroller->Reset();
|
||||
mScroller->Reset();
|
||||
for (vector<Task*>::iterator it = taskList.tasks.begin(); it != taskList.tasks.end(); it++)
|
||||
{
|
||||
ostringstream taskDescription;
|
||||
taskDescription << "[ " << setw(4) << (*it)->getReward() << " / " << (*it)->getExpiration() << " ] "
|
||||
<< (*it)->getDesc() << endl;
|
||||
scroller->Add(taskDescription.str());
|
||||
mScroller->Add(taskDescription.str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,6 +323,6 @@ void DeckMenu::destroy()
|
||||
DeckMenu::~DeckMenu()
|
||||
{
|
||||
resources.Release(pspIconsTexture);
|
||||
SAFE_DELETE(scroller);
|
||||
scroller = NULL;
|
||||
SAFE_DELETE(mScroller);
|
||||
mScroller = NULL;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ void DeckMenuItem::Render()
|
||||
void DeckMenuItem::Entering()
|
||||
{
|
||||
mHasFocus = true;
|
||||
parent->selectionTargetY = mY;
|
||||
parent->mSelectionTargetY = mY;
|
||||
}
|
||||
|
||||
bool DeckMenuItem::Leaving(JButton key)
|
||||
|
||||
@@ -66,6 +66,7 @@ void DeckMetaData::loadStatsForPlayer(Player * statsPlayer, string deckStatsFile
|
||||
stats->load(deckStatsFileName.c_str());
|
||||
_nbGamesPlayed = stats->nbGames();
|
||||
_percentVictories = stats->percentVictories();
|
||||
_victories = stats->nbVictories();
|
||||
}
|
||||
}
|
||||
stats = NULL;
|
||||
|
||||
@@ -82,6 +82,21 @@ int DeckStats::nbGames()
|
||||
return nbgames;
|
||||
}
|
||||
|
||||
int DeckStats::nbVictories()
|
||||
{
|
||||
int victories = 0;
|
||||
int nbgames = 0;
|
||||
map<string, DeckStat *>::iterator it;
|
||||
for (it = stats.begin(); it != stats.end(); it++)
|
||||
{
|
||||
DeckStat * d = it->second;
|
||||
nbgames += d->nbgames;
|
||||
victories += d->victories;
|
||||
}
|
||||
|
||||
return victories;
|
||||
}
|
||||
|
||||
int DeckStats::percentVictories()
|
||||
{
|
||||
int victories = 0;
|
||||
|
||||
@@ -28,11 +28,11 @@ vector<DeckMetaData *> GameState::fillDeckMenu(SimpleMenu * _menu, const string&
|
||||
vector<DeckMetaData *> GameState::fillDeckMenu(DeckMenu * _menu, const string& path, const string& smallDeckPrefix,
|
||||
Player * statsPlayer)
|
||||
{
|
||||
bool translate = _menu->autoTranslate;
|
||||
_menu->autoTranslate = false;
|
||||
bool translate = _menu->mAutoTranslate;
|
||||
_menu->mAutoTranslate = false;
|
||||
vector<DeckMetaData *> deckMetaDataVector = getValidDeckMetaData(path, smallDeckPrefix, statsPlayer);
|
||||
renderDeckMenu(_menu, deckMetaDataVector);
|
||||
_menu->autoTranslate = translate;
|
||||
_menu->mAutoTranslate = translate;
|
||||
|
||||
return deckMetaDataVector;
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ void GameStateDeckViewer::Update(float dt)
|
||||
if (subMenu)
|
||||
{
|
||||
subMenu->Update(dt);
|
||||
if (subMenu->closed)
|
||||
if (subMenu->isClosed())
|
||||
{
|
||||
SAFE_DELETE(subMenu);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ void GameStateDuel::Start()
|
||||
decksneeded = 1;
|
||||
|
||||
deckmenu = NEW DeckMenu(DUEL_MENU_CHOOSE_DECK, this, Fonts::OPTION_FONT, "Choose a Deck",
|
||||
GameStateDuel::selectedPlayerDeckId);
|
||||
GameStateDuel::selectedPlayerDeckId, true);
|
||||
|
||||
DeckManager *deckManager = DeckManager::GetInstance();
|
||||
vector<DeckMetaData *> playerDeckList = getValidDeckMetaData(options.profileFile());
|
||||
@@ -279,7 +279,7 @@ void GameStateDuel::ensureOpponentMenu()
|
||||
if (opponentMenu == NULL)
|
||||
{
|
||||
opponentMenu = NEW DeckMenu(DUEL_MENU_CHOOSE_OPPONENT, this, Fonts::OPTION_FONT, "Choose Your Opponent",
|
||||
GameStateDuel::selectedAIDeckId);
|
||||
GameStateDuel::selectedAIDeckId, true);
|
||||
opponentMenu->Add(MENUITEM_RANDOM_AI, "Random");
|
||||
if (options[Options::EVILTWIN_MODE_UNLOCKED].number) opponentMenu->Add(MENUITEM_EVIL_TWIN, "Evil Twin", _(
|
||||
"Can you play against yourself?").c_str());
|
||||
@@ -349,7 +349,7 @@ void GameStateDuel::Update(float dt)
|
||||
if (!rules) rules = NEW Rules("mtg.txt");
|
||||
if (mParent->players[0] == PLAYER_TYPE_HUMAN)
|
||||
{
|
||||
if (!popupScreen || popupScreen->closed) deckmenu->Update(dt);
|
||||
if (!popupScreen || popupScreen->isClosed()) deckmenu->Update(dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -359,7 +359,7 @@ void GameStateDuel::Update(float dt)
|
||||
}
|
||||
break;
|
||||
case DUEL_STATE_CHOOSE_DECK1_TO_2:
|
||||
if (deckmenu->closed)
|
||||
if (deckmenu->isClosed())
|
||||
mGamePhase = DUEL_STATE_CHOOSE_DECK2;
|
||||
else
|
||||
deckmenu->Update(dt);
|
||||
@@ -384,7 +384,7 @@ void GameStateDuel::Update(float dt)
|
||||
case DUEL_STATE_CHOOSE_DECK2_TO_PLAY:
|
||||
if (mParent->players[1] == PLAYER_TYPE_HUMAN)
|
||||
{
|
||||
if (deckmenu->closed)
|
||||
if (deckmenu->isClosed())
|
||||
mGamePhase = DUEL_STATE_PLAY;
|
||||
else
|
||||
deckmenu->Update(dt);
|
||||
@@ -392,7 +392,7 @@ void GameStateDuel::Update(float dt)
|
||||
else
|
||||
{
|
||||
ensureOpponentMenu();
|
||||
if (opponentMenu->closed)
|
||||
if (opponentMenu->isClosed())
|
||||
mGamePhase = DUEL_STATE_PLAY;
|
||||
else
|
||||
opponentMenu->Update(dt);
|
||||
@@ -482,7 +482,7 @@ void GameStateDuel::Update(float dt)
|
||||
break;
|
||||
case DUEL_STATE_CANCEL:
|
||||
menu->Update(dt);
|
||||
if (menu->closed)
|
||||
if (menu->isClosed())
|
||||
{
|
||||
mGamePhase = DUEL_STATE_PLAY;
|
||||
SAFE_DELETE(menu);
|
||||
@@ -492,7 +492,7 @@ void GameStateDuel::Update(float dt)
|
||||
if (menu)
|
||||
{
|
||||
menu->Update(dt);
|
||||
if (menu->closed)
|
||||
if (menu->isClosed())
|
||||
{
|
||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
||||
playerdata->taskList->passOneDay();
|
||||
@@ -577,11 +577,11 @@ void GameStateDuel::Render()
|
||||
{
|
||||
if (opponentMenu)
|
||||
opponentMenu->Render();
|
||||
else if (deckmenu && !deckmenu->closed) deckmenu->Render();
|
||||
else if (deckmenu && !deckmenu->isClosed()) deckmenu->Render();
|
||||
|
||||
if (menu) menu->Render();
|
||||
|
||||
if (popupScreen && !popupScreen->closed) popupScreen->Render();
|
||||
if (popupScreen && !popupScreen->isClosed()) popupScreen->Render();
|
||||
}
|
||||
break;
|
||||
case DUEL_STATE_ERROR_NO_DECK:
|
||||
@@ -612,10 +612,10 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
|
||||
case DUEL_MENU_DETAILED_DECK1_INFO:
|
||||
if ((popupScreen || deckmenu->selectedDeckHasDetails()))
|
||||
if ((popupScreen || deckmenu->showDetailsScreen()))
|
||||
{
|
||||
DeckMetaData* selectedDeck = deckmenu->getSelectedDeck();
|
||||
if (!popupScreen->closed)
|
||||
if (!popupScreen->isClosed())
|
||||
{
|
||||
popupScreen->Close();
|
||||
mGamePhase = DUEL_STATE_CHOOSE_DECK1;
|
||||
@@ -629,10 +629,10 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
||||
}
|
||||
break;
|
||||
case DUEL_MENU_DETAILED_DECK2_INFO:
|
||||
if ((popupScreen || opponentMenu->selectedDeckHasDetails()))
|
||||
if ((popupScreen || opponentMenu->showDetailsScreen()))
|
||||
{
|
||||
DeckMetaData* selectedDeck = opponentMenu->getSelectedDeck();
|
||||
if (!popupScreen->closed)
|
||||
if (!popupScreen->isClosed())
|
||||
{
|
||||
popupScreen->Close();
|
||||
mGamePhase = DUEL_STATE_CHOOSE_DECK2_TO_PLAY;
|
||||
@@ -667,7 +667,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
||||
break;
|
||||
}
|
||||
|
||||
else if (controlId == MENUITEM_MORE_INFO && opponentMenu->showDetailsScreen)
|
||||
else if (controlId == MENUITEM_MORE_INFO && opponentMenu->showDetailsScreen())
|
||||
{
|
||||
DeckMetaData* selectedDeck = opponentMenu->getSelectedDeck();
|
||||
if (!popupScreen)
|
||||
@@ -684,7 +684,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
||||
mGamePhase = DUEL_STATE_DECK2_DETAILED_INFO;
|
||||
break;
|
||||
}
|
||||
else if (controlId == MENUITEM_MORE_INFO && !opponentMenu->showDetailsScreen)
|
||||
else if (controlId == MENUITEM_MORE_INFO && !opponentMenu->showDetailsScreen())
|
||||
{
|
||||
// do nothing, ignore all key requests until popup is dismissed.
|
||||
break;
|
||||
@@ -716,7 +716,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
||||
mGamePhase = DUEL_STATE_BACK_TO_MAIN_MENU;
|
||||
break;
|
||||
}
|
||||
else if (controlId == MENUITEM_MORE_INFO && deckmenu->showDetailsScreen)
|
||||
else if (controlId == MENUITEM_MORE_INFO && deckmenu->showDetailsScreen())
|
||||
{
|
||||
DeckMetaData* selectedDeck = deckmenu->getSelectedDeck();
|
||||
if (!popupScreen)
|
||||
@@ -724,7 +724,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
||||
popupScreen = NEW SimplePopup(DUEL_MENU_DETAILED_DECK1_INFO, this, Fonts::MAIN_FONT, "Detailed Information",
|
||||
selectedDeck, mParent->collection);
|
||||
popupScreen->Render();
|
||||
selectedPlayerDeckId = deckmenu->selectedDeckId;
|
||||
selectedPlayerDeckId = deckmenu->getSelectedDeckId();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -573,7 +573,7 @@ void GameStateMenu::Update(float dt)
|
||||
currentState &= ~MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
}
|
||||
if (subMenuController->closed)
|
||||
if (subMenuController->isClosed())
|
||||
{
|
||||
SAFE_DELETE(subMenuController);
|
||||
currentState &= ~MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
|
||||
@@ -452,7 +452,7 @@ void GameStateShop::beginFilters()
|
||||
}
|
||||
void GameStateShop::Update(float dt)
|
||||
{
|
||||
if (menu && menu->closed)
|
||||
if (menu && menu->isClosed())
|
||||
SAFE_DELETE(menu);
|
||||
srcCards->Update(dt);
|
||||
alphaChange = static_cast<int> (500 - (int) ((rand() % 1000)) * dt);
|
||||
@@ -536,7 +536,7 @@ void GameStateShop::Update(float dt)
|
||||
break;
|
||||
case STAGE_ASK_ABOUT:
|
||||
btn = mEngine->ReadButton();
|
||||
if (menu && !menu->closed)
|
||||
if (menu && !menu->isClosed())
|
||||
{
|
||||
menu->CheckUserInput(btn);
|
||||
menu->Update(dt);
|
||||
@@ -576,7 +576,7 @@ void GameStateShop::Update(float dt)
|
||||
break;
|
||||
case STAGE_SHOP_SHOP:
|
||||
btn = mEngine->ReadButton();
|
||||
if (menu && !menu->closed)
|
||||
if (menu && !menu->isClosed())
|
||||
{
|
||||
menu->CheckUserInput(btn);
|
||||
menu->Update(dt);
|
||||
|
||||
@@ -77,7 +77,7 @@ void GameStateStory::Update(float dt)
|
||||
if (menu)
|
||||
{
|
||||
menu->Update(dt);
|
||||
if (menu->closed)
|
||||
if (menu->isClosed())
|
||||
SAFE_DELETE(menu);
|
||||
//return;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ SimpleMenu::SimpleMenu(int id, JGuiListener* listener, int fontId, float x, floa
|
||||
maxItems = _maxItems;
|
||||
selectionT = 0;
|
||||
timeOpen = 0;
|
||||
closed = false;
|
||||
mClosed = false;
|
||||
selectionTargetY = selectionY = y + kVerticalMargin;
|
||||
|
||||
JRenderer* renderer = JRenderer::GetInstance();
|
||||
@@ -168,13 +168,13 @@ void SimpleMenu::Update(float dt)
|
||||
if (timeOpen >= 0)
|
||||
{
|
||||
timeOpen = 0;
|
||||
closed = true;
|
||||
mClosed = true;
|
||||
stars->FireAt(mX, mY);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
closed = false;
|
||||
mClosed = false;
|
||||
timeOpen += dt * 10;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const
|
||||
mMaxLines = 10;
|
||||
mTextFont = resources.GetWFont(fontId);
|
||||
this->mCount = 1;
|
||||
stw = NULL;
|
||||
mStatsWrapper = NULL;
|
||||
Update(deckMetaData);
|
||||
}
|
||||
|
||||
void SimplePopup::Render()
|
||||
{
|
||||
closed = false;
|
||||
mClosed = false;
|
||||
|
||||
JRenderer *r = JRenderer::GetInstance();
|
||||
string detailedInformation = getDetailedInformation(mDeckInformation->getFilename());
|
||||
@@ -45,9 +45,9 @@ void SimplePopup::Render()
|
||||
void SimplePopup::Update(DeckMetaData* selectedDeck)
|
||||
{
|
||||
mDeckInformation = selectedDeck;
|
||||
SAFE_DELETE(stw);
|
||||
stw = NEW StatsWrapper(mDeckInformation->getDeckId());
|
||||
stw->updateStats(mDeckInformation->getFilename(), mCollection);
|
||||
SAFE_DELETE(mStatsWrapper);
|
||||
mStatsWrapper = NEW StatsWrapper(mDeckInformation->getDeckId());
|
||||
mStatsWrapper->updateStats(mDeckInformation->getFilename(), mCollection);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,31 +56,31 @@ string SimplePopup::getDetailedInformation(string filename)
|
||||
ostringstream oss;
|
||||
oss
|
||||
<< "------- Deck Summary -----" << endl
|
||||
<< "Cards: "<< stw->cardCount << endl
|
||||
<< "Creatures: "<< setw(2) << stw->countCreatures
|
||||
<< " Enchantments: " << stw->countEnchantments << endl
|
||||
<< "Instants: " << setw(4) << stw->countInstants
|
||||
<< " Sorceries: " << setw(2) << stw->countSorceries << endl
|
||||
<< "Cards: "<< mStatsWrapper->cardCount << endl
|
||||
<< "Creatures: "<< setw(2) << mStatsWrapper->countCreatures
|
||||
<< " Enchantments: " << mStatsWrapper->countEnchantments << endl
|
||||
<< "Instants: " << setw(4) << mStatsWrapper->countInstants
|
||||
<< " Sorceries: " << setw(2) << mStatsWrapper->countSorceries << endl
|
||||
<< "Lands: "
|
||||
<< "A: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] << " "
|
||||
<< "G: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] + stw->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] << " "
|
||||
<< "R: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_RED ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_RED ] << " "
|
||||
<< "U: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLUE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLUE ] << " "
|
||||
<< "B: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_BLACK ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_BLACK ] << " "
|
||||
<< "W: " << setw(2) << left << stw->countLandsPerColor[ Constants::MTG_COLOR_WHITE ] + stw->countBasicLandsPerColor[ Constants::MTG_COLOR_WHITE ] << endl
|
||||
<< "A: " << setw(2) << left << mStatsWrapper->countLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] + mStatsWrapper->countBasicLandsPerColor[ Constants::MTG_COLOR_ARTIFACT ] << " "
|
||||
<< "G: " << setw(2) << left << mStatsWrapper->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] + mStatsWrapper->countLandsPerColor[ Constants::MTG_COLOR_GREEN ] << " "
|
||||
<< "R: " << setw(2) << left << mStatsWrapper->countLandsPerColor[ Constants::MTG_COLOR_RED ] + mStatsWrapper->countBasicLandsPerColor[ Constants::MTG_COLOR_RED ] << " "
|
||||
<< "U: " << setw(2) << left << mStatsWrapper->countLandsPerColor[ Constants::MTG_COLOR_BLUE ] + mStatsWrapper->countBasicLandsPerColor[ Constants::MTG_COLOR_BLUE ] << " "
|
||||
<< "B: " << setw(2) << left << mStatsWrapper->countLandsPerColor[ Constants::MTG_COLOR_BLACK ] + mStatsWrapper->countBasicLandsPerColor[ Constants::MTG_COLOR_BLACK ] << " "
|
||||
<< "W: " << setw(2) << left << mStatsWrapper->countLandsPerColor[ Constants::MTG_COLOR_WHITE ] + mStatsWrapper->countBasicLandsPerColor[ Constants::MTG_COLOR_WHITE ] << endl
|
||||
<< " --- Mana Curve --- " << endl;
|
||||
|
||||
for ( int costIdx = 0; costIdx < Constants::STATS_MAX_MANA_COST+1; ++costIdx )
|
||||
if ( stw->countCardsPerCost[ costIdx ] > 0 )
|
||||
oss << costIdx << ": " << setw(2) << left << stw->countCardsPerCost[ costIdx ] << " ";
|
||||
if ( mStatsWrapper->countCardsPerCost[ costIdx ] > 0 )
|
||||
oss << costIdx << ": " << setw(2) << left << mStatsWrapper->countCardsPerCost[ costIdx ] << " ";
|
||||
|
||||
oss << endl;
|
||||
|
||||
oss
|
||||
<< " --- Average Cost --- " << endl
|
||||
<< "Creature: "<< setprecision(2) << stw->avgCreatureCost << endl
|
||||
<< "Mana: " << setprecision(2) << stw->avgManaCost << " "
|
||||
<< "Spell: " << setprecision(2) << stw->avgSpellCost << endl;
|
||||
<< "Creature: "<< setprecision(2) << mStatsWrapper->avgCreatureCost << endl
|
||||
<< "Mana: " << setprecision(2) << mStatsWrapper->avgManaCost << " "
|
||||
<< "Spell: " << setprecision(2) << mStatsWrapper->avgSpellCost << endl;
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
@@ -93,7 +93,7 @@ string SimplePopup::getDetailedInformation(string filename)
|
||||
|
||||
void SimplePopup::Close()
|
||||
{
|
||||
closed = true;
|
||||
mClosed = true;
|
||||
mCount = 0;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ SimplePopup::~SimplePopup(void)
|
||||
{
|
||||
mTextFont = NULL;
|
||||
mDeckInformation = NULL;
|
||||
SAFE_DELETE(stw);
|
||||
SAFE_DELETE(mStatsWrapper);
|
||||
}
|
||||
|
||||
void SimplePopup::drawHorzPole(float x, float y, float width)
|
||||
|
||||
@@ -1616,7 +1616,7 @@ void WGuiFilters::setSrc(WSrcCards * wsc)
|
||||
}
|
||||
void WGuiFilters::Update(float dt)
|
||||
{
|
||||
if (subMenu && !subMenu->closed) subMenu->Update(dt);
|
||||
if (subMenu && !subMenu->isClosed()) subMenu->Update(dt);
|
||||
if (list)
|
||||
{
|
||||
list->Update(dt);
|
||||
@@ -1652,11 +1652,11 @@ void WGuiFilters::Render()
|
||||
list->setY(tY);
|
||||
list->Render();
|
||||
|
||||
if (subMenu && !subMenu->closed) subMenu->Render();
|
||||
if (subMenu && !subMenu->isClosed()) subMenu->Render();
|
||||
}
|
||||
bool WGuiFilters::CheckUserInput(JButton key)
|
||||
{
|
||||
if (subMenu && !subMenu->closed && subMenu->CheckUserInput(key)) return true;
|
||||
if (subMenu && !subMenu->isClosed() && subMenu->CheckUserInput(key)) return true;
|
||||
if (key == JGE_BTN_SEC)
|
||||
{//|| key == JGE_BTN_MENU){
|
||||
//TODO Pop up a "Are you sure?" dialog.
|
||||
|
||||
Reference in New Issue
Block a user