Forcing LF as the line ending style through SVN properties. No actual code changes here.

This commit is contained in:
wrenczes@gmail.com
2011-01-28 06:00:51 +00:00
parent 8156619d49
commit 32cabc15c2
20 changed files with 6391 additions and 6391 deletions
+100 -100
View File
@@ -1,100 +1,100 @@
#include "PrecompiledHeader.h"
#include "DeckEditorMenu.h"
#include "DeckDataWrapper.h"
#include "DeckStats.h"
#include "JTypes.h"
#include "GameApp.h"
#include <iomanip>
DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const char * _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) :
DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats)
{
backgroundName = "DeckEditorMenuBackdrop";
mShowDetailsScreen = false;
deckTitle = selectedDeck ? selectedDeck->parent->meta_name : "";
mX = 123;
mY = 70;
starsOffsetX = 50;
titleX = 110; // center point in title box
titleY = 25;
titleWidth = 180; // width of inner box of title
descX = 275;
descY = 80;
descHeight = 154;
descWidth = 175;
statsHeight = 50;
statsWidth = 185;
statsX = 280;
statsY = 12;
avatarX = 222;
avatarY = 8;
float scrollerWidth = 80;
SAFE_DELETE(mScroller); // need to delete the scroller init in the base class
mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100);
}
void DeckEditorMenu::Render()
{
JRenderer *r = JRenderer::GetInstance();
r->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(200,0,0,0));
DeckMenu::Render();
if (deckTitle.size() > 0)
{
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);
DWORD currentColor = mainFont->GetColor();
mainFont->SetColor(ARGB(255,255,255,255));
mainFont->DrawString(deckTitle.c_str(), statsX + (statsWidth / 2), statsHeight / 2, JGETEXT_CENTER);
mainFont->SetColor(currentColor);
}
if (stw && selectedDeck) drawDeckStatistics();
}
void DeckEditorMenu::drawDeckStatistics()
{
ostringstream deckStatsString;
deckStatsString
<< "------- 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
<< "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
<< " --- Card color count --- " << endl
<< "A: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_ARTIFACT) << " "
<< "G: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_GREEN) << " "
<< "U: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLUE) << " "
<< "R: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_RED) << " "
<< "B: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLACK) << " "
<< "W: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_WHITE) << endl
<< " --- Average Cost --- " << endl
<< "Creature: "<< setprecision(2) << stw->avgCreatureCost << endl
<< "Mana: " << setprecision(2) << stw->avgManaCost << " "
<< "Spell: " << setprecision(2) << stw->avgSpellCost << endl;
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
mainFont->DrawString(deckStatsString.str().c_str(), descX, descY + 25);
}
DeckEditorMenu::~DeckEditorMenu()
{
SAFE_DELETE( mScroller );
}
#include "PrecompiledHeader.h"
#include "DeckEditorMenu.h"
#include "DeckDataWrapper.h"
#include "DeckStats.h"
#include "JTypes.h"
#include "GameApp.h"
#include <iomanip>
DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const char * _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) :
DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats)
{
backgroundName = "DeckEditorMenuBackdrop";
mShowDetailsScreen = false;
deckTitle = selectedDeck ? selectedDeck->parent->meta_name : "";
mX = 123;
mY = 70;
starsOffsetX = 50;
titleX = 110; // center point in title box
titleY = 25;
titleWidth = 180; // width of inner box of title
descX = 275;
descY = 80;
descHeight = 154;
descWidth = 175;
statsHeight = 50;
statsWidth = 185;
statsX = 280;
statsY = 12;
avatarX = 222;
avatarY = 8;
float scrollerWidth = 80;
SAFE_DELETE(mScroller); // need to delete the scroller init in the base class
mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 40, 230, scrollerWidth, 100);
}
void DeckEditorMenu::Render()
{
JRenderer *r = JRenderer::GetInstance();
r->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(200,0,0,0));
DeckMenu::Render();
if (deckTitle.size() > 0)
{
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT);
DWORD currentColor = mainFont->GetColor();
mainFont->SetColor(ARGB(255,255,255,255));
mainFont->DrawString(deckTitle.c_str(), statsX + (statsWidth / 2), statsHeight / 2, JGETEXT_CENTER);
mainFont->SetColor(currentColor);
}
if (stw && selectedDeck) drawDeckStatistics();
}
void DeckEditorMenu::drawDeckStatistics()
{
ostringstream deckStatsString;
deckStatsString
<< "------- 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
<< "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
<< " --- Card color count --- " << endl
<< "A: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_ARTIFACT) << " "
<< "G: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_GREEN) << " "
<< "U: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLUE) << " "
<< "R: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_RED) << " "
<< "B: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_BLACK) << " "
<< "W: " << setw(2) << left << selectedDeck->getCount(Constants::MTG_COLOR_WHITE) << endl
<< " --- Average Cost --- " << endl
<< "Creature: "<< setprecision(2) << stw->avgCreatureCost << endl
<< "Mana: " << setprecision(2) << stw->avgManaCost << " "
<< "Spell: " << setprecision(2) << stw->avgSpellCost << endl;
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
mainFont->DrawString(deckStatsString.str().c_str(), descX, descY + 25);
}
DeckEditorMenu::~DeckEditorMenu()
{
SAFE_DELETE( mScroller );
}
+337 -337
View File
@@ -1,337 +1,337 @@
#include "PrecompiledHeader.h"
#include "DeckMenu.h"
#include "DeckMenuItem.h"
#include "DeckMetaData.h"
#include "JTypes.h"
#include "GameApp.h"
#include "Translate.h"
#include "TextScroller.h"
#include "Tasks.h"
#include <iomanip>
namespace
{
const float kVerticalMargin = 16;
const float kHorizontalMargin = 20;
const float kLineHeight = 20;
const float kDescriptionVerticalBoxPadding = 5;
const float kDescriptionHorizontalBoxPadding = 5;
const float kDefaultFontScale = 1.0f;
const float kVerticalScrollSpeed = 7.0f;
const int DETAILED_INFO_THRESHOLD = 20;
}
hgeParticleSystem* DeckMenu::stars = NULL;
//
// For the additional info window, maximum characters per line is roughly 30 characters across.
// TODO:
// *** 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, bool showDetailsOverride) :
JGuiController(id, listener), fontId(fontId), mShowDetailsScreen( showDetailsOverride )
{
backgroundName = "DeckMenuBackdrop";
mAlwaysShowDetailsButton = false;
mSelectedDeck = NULL;
mY = 50;
mWidth = 176;
mX = 115;
titleX = 110; // center point in title box
titleY = 15;
titleWidth = 180; // width of inner box of title
descX = 260 + kDescriptionVerticalBoxPadding;
descY = 100 + kDescriptionHorizontalBoxPadding;
descHeight = 145;
descWidth = 200;
detailedInfoBoxX = 400;
detailedInfoBoxY = 235;
starsOffsetX = 50;
statsX = 300;
statsY = 15;
statsHeight = 50;
statsWidth = 227;
mSelectedDeckId = startIndex;
avatarX = 232;
avatarY = 11;
menuInitialized = false;
float scrollerWidth = 200.0f;
float scrollerHeight = 28.0f;
mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 14, 235, scrollerWidth, scrollerHeight, kVerticalScrollSpeed);
mAutoTranslate = true;
maxItems = 7;
mHeight = 2 * kVerticalMargin + (maxItems * kLineHeight);
// we want to cap the deck titles to 15 characters to avoid overflowing deck names
title = _(_title);
displayTitle = title;
mFont = WResourceManager::Instance()->GetWFont(fontId);
startId = 0;
selectionT = 0;
timeOpen = 0;
mClosed = false;
if (mFont->GetStringWidth(title.c_str()) > titleWidth)
titleFontScale = 0.75f;
else
titleFontScale = 1.0f;
mSelectionTargetY = selectionY = kVerticalMargin;
if (NULL == stars)
stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars")));
stars->FireAt(mX, mY);
updateScroller();
}
void DeckMenu::RenderBackground()
{
ostringstream bgFilename;
bgFilename << backgroundName << ".png";
static bool loadBackground = true;
if (loadBackground)
{
JQuad *background = WResourceManager::Instance()->RetrieveTempQuad(bgFilename.str(), TEXTURE_SUB_5551);
if (background)
JRenderer::GetInstance()->RenderQuad(background, 0, 0);
else
loadBackground = false;
}
}
DeckMetaData * DeckMenu::getSelectedDeck()
{
if (mSelectedDeck) return mSelectedDeck;
return NULL;
}
void DeckMenu::enableDisplayDetailsOverride()
{
mAlwaysShowDetailsButton = true;
}
bool DeckMenu::showDetailsScreen()
{
DeckMetaData * currentMenuItem = getSelectedDeck();
if (currentMenuItem)
{
if (mAlwaysShowDetailsButton) return true;
if (mShowDetailsScreen && currentMenuItem->getVictories() > DETAILED_INFO_THRESHOLD) return true;
}
return false;
}
void DeckMenu::initMenuItems()
{
float sY = mY + kVerticalMargin;
for (int i = startId; i < mCount; ++i)
{
float y = mY + kVerticalMargin + i * kLineHeight;
DeckMenuItem * currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
currentMenuItem->Relocate(mX, y);
if (currentMenuItem->hasFocus()) sY = y;
}
mSelectionTargetY = selectionY = sY;
//Grab a texture in VRAM.
pspIconsTexture = WResourceManager::Instance()->RetrieveTexture("iconspsp.png", RETRIEVE_LOCK);
char buf[512];
for (int i = 0; i < 8; i++)
{
sprintf(buf, "iconspsp%d", i);
pspIcons[i] = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, buf);
pspIcons[i]->SetHotSpot(16, 16);
}
}
void DeckMenu::Render()
{
JRenderer * renderer = JRenderer::GetInstance();
float height = mHeight;
if (!menuInitialized)
{
initMenuItems();
stars->Fire();
timeOpen = 0;
menuInitialized = true;
}
if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen;
for (int i = startId; i < startId + maxItems; i++)
{
if (i > mCount - 1) break;
DeckMenuItem *currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
if (currentMenuItem->mY - kLineHeight * startId < mY + height - kLineHeight + 7)
{
if (currentMenuItem->hasFocus())
{
mSelectedDeckId = i;
mSelectedDeck = currentMenuItem->meta;
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
// display the "more info" button if special condition is met
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( 255, 0, 0, 0) );
renderer->RenderQuad(pspIcons[5], detailedInfoBoxX, detailedInfoBoxY + 2, 0, pspIconsSize, pspIconsSize);
mainFont->SetColor(currentColor);
mainFont->DrawString(detailedInfoString, boxStartX, detailedInfoBoxY + 10);
}
// display the avatar image
if (currentMenuItem->imageFilename.size() > 0)
{
JQuad * quad = WResourceManager::Instance()->RetrieveTempQuad(currentMenuItem->imageFilename, TEXTURE_SUB_AVATAR);
if (quad) renderer->RenderQuad(quad, avatarX, avatarY);
}
// fill in the description part of the screen
string text = wordWrap(currentMenuItem->desc, descWidth, mainFont->mFontID );
mainFont->DrawString(text.c_str(), descX, descY);
mFont->SetColor(ARGB(255,255,255,255));
// fill in the statistical portion
if (currentMenuItem->meta)
{
ostringstream oss;
oss << "Deck: " << currentMenuItem->meta->getName() << endl;
oss << currentMenuItem->meta->getStatsSummary();
mainFont->DrawString(oss.str(), statsX, statsY);
}
}
else
{
mFont->SetColor(ARGB(150,255,255,255));
}
currentMenuItem->RenderWithOffset(-kLineHeight * startId);
}
}
if (!title.empty())
{
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
}
mScroller->Render();
RenderBackground();
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
stars->Render();
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
}
void DeckMenu::Update(float dt)
{
JGuiController::Update(dt);
if (mCurr > startId + maxItems - 1)
startId = mCurr - maxItems + 1;
else if (mCurr < startId) startId = mCurr;
stars->Update(dt);
selectionT += 3 * 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;
stars->MoveTo(starsX, starsY);
if (timeOpen < 0)
{
timeOpen += dt * 10;
if (timeOpen >= 0)
{
timeOpen = 0;
mClosed = true;
stars->FireAt(mX, mY);
}
}
else
{
mClosed = false;
timeOpen += dt * 10;
}
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), mAutoTranslate, deckMetaData);
Translator * t = Translator::GetInstance();
map<string, string>::iterator it = t->deckValues.find(text);
if (it != t->deckValues.end()) //translate decks desc
menuItem->desc = it->second;
else
menuItem->desc = deckMetaData ? deckMetaData->getDescription() : desc;
JGuiController::Add(menuItem);
if (mCount <= maxItems) mHeight += kLineHeight;
if (forceFocus)
{
mObjects[mCurr]->Leaving(JGE_BTN_DOWN);
mCurr = mCount - 1;
menuItem->Entering();
}
}
void DeckMenu::updateScroller()
{
// add all the items from the Tasks db.
TaskList taskList;
mScroller->Reset();
for (vector<Task*>::iterator it = taskList.tasks.begin(); it != taskList.tasks.end(); it++)
{
ostringstream taskDescription;
taskDescription << "Credits: " << setw(4) << (*it)->getReward() << " / "
<< "Days Left: " << (*it)->getExpiration() << endl
<< (*it)->getDesc() << endl << endl;
mScroller->Add(taskDescription.str());
}
}
void DeckMenu::Close()
{
timeOpen = -1.0;
stars->Stop(true);
}
void DeckMenu::destroy()
{
SAFE_DELETE(DeckMenu::stars);
}
DeckMenu::~DeckMenu()
{
WResourceManager::Instance()->Release(pspIconsTexture);
SAFE_DELETE(mScroller);
}
#include "PrecompiledHeader.h"
#include "DeckMenu.h"
#include "DeckMenuItem.h"
#include "DeckMetaData.h"
#include "JTypes.h"
#include "GameApp.h"
#include "Translate.h"
#include "TextScroller.h"
#include "Tasks.h"
#include <iomanip>
namespace
{
const float kVerticalMargin = 16;
const float kHorizontalMargin = 20;
const float kLineHeight = 20;
const float kDescriptionVerticalBoxPadding = 5;
const float kDescriptionHorizontalBoxPadding = 5;
const float kDefaultFontScale = 1.0f;
const float kVerticalScrollSpeed = 7.0f;
const int DETAILED_INFO_THRESHOLD = 20;
}
hgeParticleSystem* DeckMenu::stars = NULL;
//
// For the additional info window, maximum characters per line is roughly 30 characters across.
// TODO:
// *** 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, bool showDetailsOverride) :
JGuiController(id, listener), fontId(fontId), mShowDetailsScreen( showDetailsOverride )
{
backgroundName = "DeckMenuBackdrop";
mAlwaysShowDetailsButton = false;
mSelectedDeck = NULL;
mY = 50;
mWidth = 176;
mX = 115;
titleX = 110; // center point in title box
titleY = 15;
titleWidth = 180; // width of inner box of title
descX = 260 + kDescriptionVerticalBoxPadding;
descY = 100 + kDescriptionHorizontalBoxPadding;
descHeight = 145;
descWidth = 200;
detailedInfoBoxX = 400;
detailedInfoBoxY = 235;
starsOffsetX = 50;
statsX = 300;
statsY = 15;
statsHeight = 50;
statsWidth = 227;
mSelectedDeckId = startIndex;
avatarX = 232;
avatarY = 11;
menuInitialized = false;
float scrollerWidth = 200.0f;
float scrollerHeight = 28.0f;
mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 14, 235, scrollerWidth, scrollerHeight, kVerticalScrollSpeed);
mAutoTranslate = true;
maxItems = 7;
mHeight = 2 * kVerticalMargin + (maxItems * kLineHeight);
// we want to cap the deck titles to 15 characters to avoid overflowing deck names
title = _(_title);
displayTitle = title;
mFont = WResourceManager::Instance()->GetWFont(fontId);
startId = 0;
selectionT = 0;
timeOpen = 0;
mClosed = false;
if (mFont->GetStringWidth(title.c_str()) > titleWidth)
titleFontScale = 0.75f;
else
titleFontScale = 1.0f;
mSelectionTargetY = selectionY = kVerticalMargin;
if (NULL == stars)
stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars")));
stars->FireAt(mX, mY);
updateScroller();
}
void DeckMenu::RenderBackground()
{
ostringstream bgFilename;
bgFilename << backgroundName << ".png";
static bool loadBackground = true;
if (loadBackground)
{
JQuad *background = WResourceManager::Instance()->RetrieveTempQuad(bgFilename.str(), TEXTURE_SUB_5551);
if (background)
JRenderer::GetInstance()->RenderQuad(background, 0, 0);
else
loadBackground = false;
}
}
DeckMetaData * DeckMenu::getSelectedDeck()
{
if (mSelectedDeck) return mSelectedDeck;
return NULL;
}
void DeckMenu::enableDisplayDetailsOverride()
{
mAlwaysShowDetailsButton = true;
}
bool DeckMenu::showDetailsScreen()
{
DeckMetaData * currentMenuItem = getSelectedDeck();
if (currentMenuItem)
{
if (mAlwaysShowDetailsButton) return true;
if (mShowDetailsScreen && currentMenuItem->getVictories() > DETAILED_INFO_THRESHOLD) return true;
}
return false;
}
void DeckMenu::initMenuItems()
{
float sY = mY + kVerticalMargin;
for (int i = startId; i < mCount; ++i)
{
float y = mY + kVerticalMargin + i * kLineHeight;
DeckMenuItem * currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
currentMenuItem->Relocate(mX, y);
if (currentMenuItem->hasFocus()) sY = y;
}
mSelectionTargetY = selectionY = sY;
//Grab a texture in VRAM.
pspIconsTexture = WResourceManager::Instance()->RetrieveTexture("iconspsp.png", RETRIEVE_LOCK);
char buf[512];
for (int i = 0; i < 8; i++)
{
sprintf(buf, "iconspsp%d", i);
pspIcons[i] = WResourceManager::Instance()->RetrieveQuad("iconspsp.png", (float) i * 32, 0, 32, 32, buf);
pspIcons[i]->SetHotSpot(16, 16);
}
}
void DeckMenu::Render()
{
JRenderer * renderer = JRenderer::GetInstance();
float height = mHeight;
if (!menuInitialized)
{
initMenuItems();
stars->Fire();
timeOpen = 0;
menuInitialized = true;
}
if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen;
for (int i = startId; i < startId + maxItems; i++)
{
if (i > mCount - 1) break;
DeckMenuItem *currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
if (currentMenuItem->mY - kLineHeight * startId < mY + height - kLineHeight + 7)
{
if (currentMenuItem->hasFocus())
{
mSelectedDeckId = i;
mSelectedDeck = currentMenuItem->meta;
WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
// display the "more info" button if special condition is met
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( 255, 0, 0, 0) );
renderer->RenderQuad(pspIcons[5], detailedInfoBoxX, detailedInfoBoxY + 2, 0, pspIconsSize, pspIconsSize);
mainFont->SetColor(currentColor);
mainFont->DrawString(detailedInfoString, boxStartX, detailedInfoBoxY + 10);
}
// display the avatar image
if (currentMenuItem->imageFilename.size() > 0)
{
JQuad * quad = WResourceManager::Instance()->RetrieveTempQuad(currentMenuItem->imageFilename, TEXTURE_SUB_AVATAR);
if (quad) renderer->RenderQuad(quad, avatarX, avatarY);
}
// fill in the description part of the screen
string text = wordWrap(currentMenuItem->desc, descWidth, mainFont->mFontID );
mainFont->DrawString(text.c_str(), descX, descY);
mFont->SetColor(ARGB(255,255,255,255));
// fill in the statistical portion
if (currentMenuItem->meta)
{
ostringstream oss;
oss << "Deck: " << currentMenuItem->meta->getName() << endl;
oss << currentMenuItem->meta->getStatsSummary();
mainFont->DrawString(oss.str(), statsX, statsY);
}
}
else
{
mFont->SetColor(ARGB(150,255,255,255));
}
currentMenuItem->RenderWithOffset(-kLineHeight * startId);
}
}
if (!title.empty())
{
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
}
mScroller->Render();
RenderBackground();
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
stars->Render();
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
}
void DeckMenu::Update(float dt)
{
JGuiController::Update(dt);
if (mCurr > startId + maxItems - 1)
startId = mCurr - maxItems + 1;
else if (mCurr < startId) startId = mCurr;
stars->Update(dt);
selectionT += 3 * 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;
stars->MoveTo(starsX, starsY);
if (timeOpen < 0)
{
timeOpen += dt * 10;
if (timeOpen >= 0)
{
timeOpen = 0;
mClosed = true;
stars->FireAt(mX, mY);
}
}
else
{
mClosed = false;
timeOpen += dt * 10;
}
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), mAutoTranslate, deckMetaData);
Translator * t = Translator::GetInstance();
map<string, string>::iterator it = t->deckValues.find(text);
if (it != t->deckValues.end()) //translate decks desc
menuItem->desc = it->second;
else
menuItem->desc = deckMetaData ? deckMetaData->getDescription() : desc;
JGuiController::Add(menuItem);
if (mCount <= maxItems) mHeight += kLineHeight;
if (forceFocus)
{
mObjects[mCurr]->Leaving(JGE_BTN_DOWN);
mCurr = mCount - 1;
menuItem->Entering();
}
}
void DeckMenu::updateScroller()
{
// add all the items from the Tasks db.
TaskList taskList;
mScroller->Reset();
for (vector<Task*>::iterator it = taskList.tasks.begin(); it != taskList.tasks.end(); it++)
{
ostringstream taskDescription;
taskDescription << "Credits: " << setw(4) << (*it)->getReward() << " / "
<< "Days Left: " << (*it)->getExpiration() << endl
<< (*it)->getDesc() << endl << endl;
mScroller->Add(taskDescription.str());
}
}
void DeckMenu::Close()
{
timeOpen = -1.0;
stars->Stop(true);
}
void DeckMenu::destroy()
{
SAFE_DELETE(DeckMenu::stars);
}
DeckMenu::~DeckMenu()
{
WResourceManager::Instance()->Release(pspIconsTexture);
SAFE_DELETE(mScroller);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1237 -1237
View File
File diff suppressed because it is too large Load Diff
+64 -64
View File
@@ -1,64 +1,64 @@
#include "PrecompiledHeader.h"
#include "MTGGamePhase.h"
MTGGamePhase::MTGGamePhase(int id) :
ActionElement(id)
{
animation = 0;
currentState = -1;
mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); // using 2nd font
}
void MTGGamePhase::Update(float dt)
{
int newState = GameObserver::GetInstance()->getCurrentGamePhase();
if (newState != currentState)
{
activeState = ACTIVE;
animation = 4;
currentState = newState;
}
if (animation > 0)
{
animation--;
}
else
{
activeState = INACTIVE;
animation = 0;
}
}
bool MTGGamePhase::CheckUserInput(JButton key)
{
GameObserver * game = GameObserver::GetInstance();
if (activeState == INACTIVE)
{
JButton trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
if ((trigger == key) && game->currentActionPlayer == game->currentlyActing())
{
activeState = ACTIVE;
game->userRequestNextGamePhase();
return true;
}
}
return false;
}
MTGGamePhase * MTGGamePhase::clone() const
{
MTGGamePhase * a = NEW MTGGamePhase(*this);
a->isClone = 1;
return a;
}
ostream& MTGGamePhase::toString(ostream& out) const
{
return out << "MTGGamePhase ::: animation " << animation << " ; currentState : " << currentState;
}
#include "PrecompiledHeader.h"
#include "MTGGamePhase.h"
MTGGamePhase::MTGGamePhase(int id) :
ActionElement(id)
{
animation = 0;
currentState = -1;
mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
mFont->SetBase(0); // using 2nd font
}
void MTGGamePhase::Update(float dt)
{
int newState = GameObserver::GetInstance()->getCurrentGamePhase();
if (newState != currentState)
{
activeState = ACTIVE;
animation = 4;
currentState = newState;
}
if (animation > 0)
{
animation--;
}
else
{
activeState = INACTIVE;
animation = 0;
}
}
bool MTGGamePhase::CheckUserInput(JButton key)
{
GameObserver * game = GameObserver::GetInstance();
if (activeState == INACTIVE)
{
JButton trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
if ((trigger == key) && game->currentActionPlayer == game->currentlyActing())
{
activeState = ACTIVE;
game->userRequestNextGamePhase();
return true;
}
}
return false;
}
MTGGamePhase * MTGGamePhase::clone() const
{
MTGGamePhase * a = NEW MTGGamePhase(*this);
a->isClone = 1;
return a;
}
ostream& MTGGamePhase::toString(ostream& out) const
{
return out << "MTGGamePhase ::: animation " << animation << " ; currentState : " << currentState;
}
File diff suppressed because it is too large Load Diff