added border to extra details popup as per design at
http://wololo.net/forum/viewtopic.php?f=37&t=2380 and http://wololo.net/forum/viewtopic.php?f=37&t=2382
This commit is contained in:
@@ -1,115 +1,167 @@
|
||||
/*
|
||||
* SimplePopup.cpp
|
||||
*
|
||||
* Created on: Nov 18, 2010
|
||||
* Author: Michael
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "SimplePopup.h"
|
||||
#include "JTypes.h"
|
||||
#include "GameApp.h"
|
||||
#include "DeckStats.h"
|
||||
#include "DeckManager.h"
|
||||
#include <iomanip>
|
||||
|
||||
SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title, DeckMetaData* deckMetaData, MTGAllCards * collection) :
|
||||
JGuiController(id, listener), mFontId(fontId), mCollection(collection)
|
||||
{
|
||||
mX = 35;
|
||||
mY = 50;
|
||||
mTitle = _title;
|
||||
mMaxLines = 10;
|
||||
mTextFont = resources.GetWFont(fontId);
|
||||
this->mCount = 1;
|
||||
mStatsWrapper = NULL;
|
||||
Update(deckMetaData);
|
||||
}
|
||||
|
||||
void SimplePopup::Render()
|
||||
{
|
||||
mClosed = false;
|
||||
|
||||
JRenderer *r = JRenderer::GetInstance();
|
||||
string detailedInformation = getDetailedInformation(mDeckInformation->getFilename());
|
||||
|
||||
mTextFont->SetScale(0.85f);
|
||||
const float textWidth = 183.0f;
|
||||
const float textHeight = mTextFont->GetHeight() * 10;
|
||||
r->DrawRoundRect(mX, mY, textWidth, textHeight, 2.0f, ARGB( 255, 125, 255, 0) );
|
||||
r->FillRoundRect(mX, mY, textWidth, textHeight, 2.0f, ARGB( 255, 0, 0, 0 ) );
|
||||
|
||||
mTextFont->DrawString(detailedInformation.c_str(), mX + 20 , mY + 10);
|
||||
|
||||
}
|
||||
void SimplePopup::Update(DeckMetaData* selectedDeck)
|
||||
{
|
||||
mDeckInformation = selectedDeck;
|
||||
SAFE_DELETE(mStatsWrapper);
|
||||
mStatsWrapper = NEW StatsWrapper(mDeckInformation->getDeckId());
|
||||
mStatsWrapper->updateStats(mDeckInformation->getFilename(), mCollection);
|
||||
}
|
||||
|
||||
|
||||
string SimplePopup::getDetailedInformation(string filename)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss
|
||||
<< "------- Deck Summary -----" << 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 << 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 ( mStatsWrapper->countCardsPerCost[ costIdx ] > 0 )
|
||||
oss << costIdx << ": " << setw(2) << left << mStatsWrapper->countCardsPerCost[ costIdx ] << " ";
|
||||
|
||||
oss << endl;
|
||||
|
||||
oss
|
||||
<< " --- Average Cost --- " << endl
|
||||
<< "Creature: "<< setprecision(2) << mStatsWrapper->avgCreatureCost << endl
|
||||
<< "Mana: " << setprecision(2) << mStatsWrapper->avgManaCost << " "
|
||||
<< "Spell: " << setprecision(2) << mStatsWrapper->avgSpellCost << endl;
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
void SimplePopup::Update(float dt)
|
||||
{
|
||||
JButton key = mEngine->ReadButton();
|
||||
CheckUserInput(key);
|
||||
}
|
||||
|
||||
void SimplePopup::Close()
|
||||
{
|
||||
mClosed = true;
|
||||
mCount = 0;
|
||||
}
|
||||
|
||||
SimplePopup::~SimplePopup(void)
|
||||
{
|
||||
mTextFont = NULL;
|
||||
mDeckInformation = NULL;
|
||||
SAFE_DELETE(mStatsWrapper);
|
||||
}
|
||||
|
||||
void SimplePopup::drawHorzPole(float x, float y, float width)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SimplePopup::drawVertPole(float x, float y, float height)
|
||||
{
|
||||
|
||||
}
|
||||
/*
|
||||
* SimplePopup.cpp
|
||||
*
|
||||
* Created on: Nov 18, 2010
|
||||
* Author: Michael
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "SimplePopup.h"
|
||||
#include "JTypes.h"
|
||||
#include "GameApp.h"
|
||||
#include "DeckStats.h"
|
||||
#include "DeckManager.h"
|
||||
#include <iomanip>
|
||||
|
||||
SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title, DeckMetaData* deckMetaData, MTGAllCards * collection) :
|
||||
JGuiController(id, listener), mFontId(fontId), mCollection(collection)
|
||||
{
|
||||
mX = 18;
|
||||
mY = 66;
|
||||
mWidth = 180.0f;
|
||||
mTitle = _title;
|
||||
mMaxLines = 11;
|
||||
|
||||
mTextFont = resources.GetWFont(fontId);
|
||||
this->mCount = 1; // a hack to ensure the menus do book keeping correctly. Since we aren't adding items to the menu, this is required
|
||||
mStatsWrapper = NULL;
|
||||
Update(deckMetaData);
|
||||
}
|
||||
|
||||
void SimplePopup::Render()
|
||||
{
|
||||
mClosed = false;
|
||||
|
||||
JRenderer *r = JRenderer::GetInstance();
|
||||
string detailedInformation = getDetailedInformation(mDeckInformation->getFilename());
|
||||
|
||||
mTextFont->SetScale(0.85f);
|
||||
const float textHeight = mTextFont->GetHeight() * mMaxLines;
|
||||
r->DrawRoundRect(mX, mY, mWidth, textHeight, 2.0f, ARGB( 255, 125, 255, 0) );
|
||||
r->FillRoundRect(mX, mY, mWidth, textHeight, 2.0f, ARGB( 255, 0, 0, 0 ) );
|
||||
|
||||
drawBoundingBox( mX, mY, mWidth, textHeight );
|
||||
|
||||
mTextFont->DrawString(detailedInformation.c_str(), mX + 20 , mY + 15);
|
||||
|
||||
}
|
||||
|
||||
void SimplePopup::drawBoundingBox( float x, float y, float width, float height )
|
||||
{
|
||||
JRenderer *r = JRenderer::GetInstance();
|
||||
|
||||
//draw the corners
|
||||
string topCornerImageName = "top_corner.png";
|
||||
string bottomCornerImageName = "bottom_corner.png";
|
||||
string verticalBarImageName = "vert_bar.png";
|
||||
string horizontalBarImageName = "top_bar.png";
|
||||
|
||||
const float boxWidth = ( width + 15 ) / 3.0f;
|
||||
const float boxHeight = ( height + 15 ) / 3.0f;
|
||||
|
||||
drawHorzPole( horizontalBarImageName, false, false, x, y, boxWidth );
|
||||
drawHorzPole( horizontalBarImageName, false, true, x, y + height, boxWidth );
|
||||
|
||||
drawVertPole( verticalBarImageName, false, false, x, y, boxHeight );
|
||||
drawVertPole( verticalBarImageName, true, false, x + width, y, boxHeight );
|
||||
|
||||
drawCorner( topCornerImageName, false, false, x, y );
|
||||
drawCorner( topCornerImageName, true, false, x + width, y );
|
||||
drawCorner( bottomCornerImageName, false, false, x, y + height );
|
||||
drawCorner( bottomCornerImageName, true, false, x + width, y + height );
|
||||
}
|
||||
|
||||
void SimplePopup::Update(DeckMetaData* selectedDeck)
|
||||
{
|
||||
mDeckInformation = selectedDeck;
|
||||
SAFE_DELETE(mStatsWrapper);
|
||||
mStatsWrapper = NEW StatsWrapper(mDeckInformation->getDeckId());
|
||||
mStatsWrapper->updateStats(mDeckInformation->getFilename(), mCollection);
|
||||
}
|
||||
|
||||
|
||||
string SimplePopup::getDetailedInformation(string filename)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss
|
||||
<< "------- Deck Summary -----" << 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 << 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 ( mStatsWrapper->countCardsPerCost[ costIdx ] > 0 )
|
||||
oss << costIdx << ": " << setw(2) << left << mStatsWrapper->countCardsPerCost[ costIdx ] << " ";
|
||||
|
||||
oss << endl;
|
||||
|
||||
oss
|
||||
<< " --- Average Cost --- " << endl
|
||||
<< "Creature: "<< setprecision(2) << mStatsWrapper->avgCreatureCost << endl
|
||||
<< "Mana: " << setprecision(2) << mStatsWrapper->avgManaCost << " "
|
||||
<< "Spell: " << setprecision(2) << mStatsWrapper->avgSpellCost << endl;
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
void SimplePopup::Update(float dt)
|
||||
{
|
||||
JButton key = mEngine->ReadButton();
|
||||
CheckUserInput(key);
|
||||
}
|
||||
|
||||
// drawing routines
|
||||
void SimplePopup::drawCorner(string imageName, bool flipX, bool flipY, float x, float y)
|
||||
{
|
||||
JRenderer* r = JRenderer::GetInstance();
|
||||
JQuad *horizontalBarImage = resources.RetrieveTempQuad( imageName, TEXTURE_SUB_5551);
|
||||
horizontalBarImage->SetHFlip(flipX);
|
||||
horizontalBarImage->SetVFlip(flipY);
|
||||
|
||||
r->RenderQuad( horizontalBarImage, x, y);
|
||||
}
|
||||
|
||||
void SimplePopup::drawHorzPole(string imageName, bool flipX = false, bool flipY = false, float x = 0, float y = 0, float width = SCREEN_WIDTH_F)
|
||||
{
|
||||
JRenderer* r = JRenderer::GetInstance();
|
||||
JQuad *horizontalBarImage = resources.RetrieveTempQuad( imageName, TEXTURE_SUB_5551);
|
||||
horizontalBarImage->SetHFlip(flipX);
|
||||
horizontalBarImage->SetVFlip(flipY);
|
||||
|
||||
r->RenderQuad( horizontalBarImage, x, y, 0, width );
|
||||
}
|
||||
|
||||
void SimplePopup::drawVertPole(string imageName, bool flipX = false, bool flipY = false, float x = 0, float y = 0, float height = SCREEN_HEIGHT_F)
|
||||
{
|
||||
JRenderer* r = JRenderer::GetInstance();
|
||||
JQuad *verticalBarImage = resources.RetrieveTempQuad( imageName, TEXTURE_SUB_5551);
|
||||
verticalBarImage->SetHFlip(flipX);
|
||||
verticalBarImage->SetVFlip(flipY);
|
||||
|
||||
r->RenderQuad( verticalBarImage, x, y, 0, 1.0f, height);
|
||||
}
|
||||
|
||||
|
||||
void SimplePopup::Close()
|
||||
{
|
||||
mClosed = true;
|
||||
mCount = 0;
|
||||
}
|
||||
|
||||
SimplePopup::~SimplePopup(void)
|
||||
{
|
||||
mTextFont = NULL;
|
||||
mDeckInformation = NULL;
|
||||
SAFE_DELETE(mStatsWrapper);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user