Cleanups and state reduction.
This mainly moves datamembers around and tries to avoid caching of results of calculations when the calculations are cheap.
This commit is contained in:
@@ -7,6 +7,9 @@
|
|||||||
class CarouselDeckView : public DeckView
|
class CarouselDeckView : public DeckView
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
static const float max_scale;
|
||||||
|
static const float x_center;
|
||||||
|
static const float right_border;
|
||||||
static const float slide_animation_duration;
|
static const float slide_animation_duration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -9,15 +9,11 @@
|
|||||||
#include "WResourceManager.h"
|
#include "WResourceManager.h"
|
||||||
#include "Pos.h"
|
#include "Pos.h"
|
||||||
|
|
||||||
#define NO_USER_ACTIVITY_HELP_DELAY 10
|
|
||||||
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
|
|
||||||
|
|
||||||
class DeckView
|
class DeckView
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
static const float max_scale;
|
static const float no_user_activity_show_card_delay;
|
||||||
static const float x_center;
|
|
||||||
static const float right_border;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct CardRep{
|
struct CardRep{
|
||||||
@@ -36,6 +32,13 @@ public:
|
|||||||
|
|
||||||
//advances the view and card representations
|
//advances the view and card representations
|
||||||
void Update(float dt);
|
void Update(float dt);
|
||||||
|
virtual void SetDeck(DeckDataWrapper *toShow);
|
||||||
|
DeckDataWrapper *deck();
|
||||||
|
void SwitchFilter(int delta);
|
||||||
|
void SwitchPosition(int delta);
|
||||||
|
int filter();
|
||||||
|
void reloadIndexes();
|
||||||
|
int getPosition();
|
||||||
|
|
||||||
virtual void Render() = 0;
|
virtual void Render() = 0;
|
||||||
virtual MTGCard * Click(int x, int y) = 0;
|
virtual MTGCard * Click(int x, int y) = 0;
|
||||||
@@ -43,24 +46,15 @@ public:
|
|||||||
virtual MTGCard *getActiveCard() = 0;
|
virtual MTGCard *getActiveCard() = 0;
|
||||||
virtual void changePosition(int offset) = 0;
|
virtual void changePosition(int offset) = 0;
|
||||||
virtual void changeFilter(int offset) = 0;
|
virtual void changeFilter(int offset) = 0;
|
||||||
|
|
||||||
virtual void SetDeck(DeckDataWrapper *toShow);
|
|
||||||
DeckDataWrapper *deck();
|
|
||||||
void SwitchFilter(int delta);
|
|
||||||
int filter();
|
|
||||||
void reloadIndexes();
|
|
||||||
int getPosition();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float last_user_activity;
|
float last_user_activity;
|
||||||
int mFilter;
|
int mFilter;
|
||||||
DeckDataWrapper *mCurrentDeck;
|
DeckDataWrapper *mCurrentDeck;
|
||||||
|
vector<CardRep> mCards;
|
||||||
|
|
||||||
CardRep& getCardRep(unsigned int index);
|
CardRep& getCardRep(unsigned int index);
|
||||||
void renderCard(int index, int alpha, bool asThumbnail = false);
|
void renderCard(int index, int alpha, bool asThumbnail = false);
|
||||||
int getCardIndexNextTo(int x, int y);
|
int getCardIndexNextTo(int x, int y);
|
||||||
|
|
||||||
vector<CardRep> mCards;
|
|
||||||
private:
|
private:
|
||||||
virtual void UpdateViewState(float dt) = 0;
|
virtual void UpdateViewState(float dt) = 0;
|
||||||
virtual void UpdateCardPosition(CardRep& rep, int index) = 0;
|
virtual void UpdateCardPosition(CardRep& rep, int index) = 0;
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ private:
|
|||||||
JTexture * pspIconsTexture;
|
JTexture * pspIconsTexture;
|
||||||
float last_user_activity;
|
float last_user_activity;
|
||||||
float onScreenTransition;
|
float onScreenTransition;
|
||||||
int mAlpha;
|
|
||||||
DeckViewerStages mStage;
|
DeckViewerStages mStage;
|
||||||
JMusic * bgMusic;
|
JMusic * bgMusic;
|
||||||
|
|
||||||
@@ -79,13 +78,12 @@ private:
|
|||||||
|
|
||||||
DeckEditorMenu * welcome_menu;
|
DeckEditorMenu * welcome_menu;
|
||||||
SimpleMenu * subMenu;
|
SimpleMenu * subMenu;
|
||||||
DeckEditorMenu * menu;
|
DeckEditorMenu * deckMenu;
|
||||||
PriceList* pricelist;
|
PriceList* pricelist;
|
||||||
PlayerData * playerdata;
|
PlayerData * playerdata;
|
||||||
int price;
|
|
||||||
DeckDataWrapper * myDeck;
|
DeckDataWrapper * myDeck;
|
||||||
DeckDataWrapper * myCollection;
|
DeckDataWrapper * myCollection;
|
||||||
StatsWrapper *stw;
|
StatsWrapper * mStatsWrapper;
|
||||||
|
|
||||||
int hudAlpha;
|
int hudAlpha;
|
||||||
string newDeckname;
|
string newDeckname;
|
||||||
@@ -111,7 +109,6 @@ public:
|
|||||||
GameStateDeckViewer(GameApp* parent);
|
GameStateDeckViewer(GameApp* parent);
|
||||||
virtual ~GameStateDeckViewer();
|
virtual ~GameStateDeckViewer();
|
||||||
void updateDecks();
|
void updateDecks();
|
||||||
void rotateCards(int direction);
|
|
||||||
void updateFilters();
|
void updateFilters();
|
||||||
void rebuildFilters();
|
void rebuildFilters();
|
||||||
void toggleCollection();
|
void toggleCollection();
|
||||||
|
|||||||
@@ -20,16 +20,18 @@ public:
|
|||||||
~PriceList();
|
~PriceList();
|
||||||
int save();
|
int save();
|
||||||
int getSellPrice(int cardid);
|
int getSellPrice(int cardid);
|
||||||
|
int getSellPrice(MTGCard* card);
|
||||||
int getPurchasePrice(int cardid);
|
int getPurchasePrice(int cardid);
|
||||||
|
int getPrice(MTGCard *card);
|
||||||
int getPrice(int cardId);
|
int getPrice(int cardId);
|
||||||
int setPrice(int cardId, int price);
|
int setPrice(int cardId, int price);
|
||||||
|
int setPrice(MTGCard *card, int price);
|
||||||
int getOtherPrice(int amt);
|
int getOtherPrice(int amt);
|
||||||
static float difficultyScalar(float price, int cardid = 0);
|
static float difficultyScalar(float price, int cardid = 0);
|
||||||
static void updateKey()
|
static void updateKey()
|
||||||
{
|
{
|
||||||
randomKey = rand();
|
randomKey = rand();
|
||||||
}
|
}
|
||||||
;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
#include "CarouselDeckView.h"
|
#include "CarouselDeckView.h"
|
||||||
|
|
||||||
|
const float CarouselDeckView::max_scale = 0.96f;
|
||||||
|
const float CarouselDeckView::x_center = 180;
|
||||||
|
const float CarouselDeckView::right_border = SCREEN_WIDTH + 180;
|
||||||
const float CarouselDeckView::slide_animation_duration = 0.6f;
|
const float CarouselDeckView::slide_animation_duration = 0.6f;
|
||||||
|
|
||||||
CarouselDeckView::CarouselDeckView() :
|
CarouselDeckView::CarouselDeckView() :
|
||||||
@@ -18,15 +21,13 @@ void CarouselDeckView::UpdateViewState(float dt)
|
|||||||
|
|
||||||
if(mScrollOffset <= -1.0f)
|
if(mScrollOffset <= -1.0f)
|
||||||
{
|
{
|
||||||
|
SwitchPosition(-1);
|
||||||
mScrollEasing.translate(1.0f);
|
mScrollEasing.translate(1.0f);
|
||||||
deck()->prev();
|
|
||||||
reloadIndexes();
|
|
||||||
}
|
}
|
||||||
else if(mScrollOffset >= 1.0f)
|
else if(mScrollOffset >= 1.0f)
|
||||||
{
|
{
|
||||||
|
SwitchPosition(1);
|
||||||
mScrollEasing.translate(-1.0f);
|
mScrollEasing.translate(-1.0f);
|
||||||
deck()->next();
|
|
||||||
reloadIndexes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dirtyCardPos = true;
|
dirtyCardPos = true;
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
#include "GameOptions.h"
|
#include "GameOptions.h"
|
||||||
#include "CardGui.h"
|
#include "CardGui.h"
|
||||||
|
|
||||||
const float DeckView::max_scale = 0.96f;
|
const float DeckView::no_user_activity_show_card_delay = 0.1f;
|
||||||
const float DeckView::x_center = 180;
|
|
||||||
const float DeckView::right_border = SCREEN_WIDTH + 180;
|
|
||||||
|
|
||||||
DeckView::DeckView(int numberOfCards)
|
DeckView::DeckView(int numberOfCards)
|
||||||
: dirtyFilters(true), dirtyCardPos(true), last_user_activity(0.0f), mFilter(0), mCurrentDeck(NULL)
|
: dirtyFilters(true), dirtyCardPos(true), last_user_activity(0.0f), mFilter(0), mCurrentDeck(NULL)
|
||||||
@@ -87,14 +85,29 @@ void DeckView::SwitchFilter(int delta)
|
|||||||
dirtyFilters = true;
|
dirtyFilters = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeckView::SwitchPosition(int delta)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < delta; ++i)
|
||||||
|
{
|
||||||
|
mCurrentDeck->next();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i > delta; --i)
|
||||||
|
{
|
||||||
|
mCurrentDeck->prev();
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadIndexes();
|
||||||
|
}
|
||||||
|
|
||||||
int DeckView::filter()
|
int DeckView::filter()
|
||||||
{
|
{
|
||||||
return mFilter;
|
return mFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckView::reloadIndexes() //fixme: feels ugly. check if we can remove this
|
void DeckView::reloadIndexes()
|
||||||
{
|
{
|
||||||
if(deck() != NULL)
|
if(mCurrentDeck != NULL)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < mCards.size(); i++)
|
for (unsigned int i = 0; i < mCards.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -129,7 +142,7 @@ void DeckView::renderCard(int index, int alpha, bool asThumbnail)
|
|||||||
cacheError = WResourceManager::Instance()->RetrieveError();
|
cacheError = WResourceManager::Instance()->RetrieveError();
|
||||||
if (!quad.get() && cacheError != CACHE_ERROR_404)
|
if (!quad.get() && cacheError != CACHE_ERROR_404)
|
||||||
{
|
{
|
||||||
if (last_user_activity > (abs(2 - index) + 1) * NO_USER_ACTIVITY_SHOWCARD_DELAY)
|
if (last_user_activity > (abs(2 - index) + 1) * no_user_activity_show_card_delay)
|
||||||
quad = WResourceManager::Instance()->RetrieveCard(cardPosition.card);
|
quad = WResourceManager::Instance()->RetrieveCard(cardPosition.card);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "CarouselDeckView.h"
|
#include "CarouselDeckView.h"
|
||||||
#include "GridDeckView.h"
|
#include "GridDeckView.h"
|
||||||
|
|
||||||
|
#define NO_USER_ACTIVITY_HELP_DELAY 10
|
||||||
|
|
||||||
GameStateDeckViewer::GameStateDeckViewer(GameApp* parent) :
|
GameStateDeckViewer::GameStateDeckViewer(GameApp* parent) :
|
||||||
GameState(parent, "deckeditor"), mView(NULL), mCurrentView(CAROUSEL_VIEW)
|
GameState(parent, "deckeditor"), mView(NULL), mCurrentView(CAROUSEL_VIEW)
|
||||||
@@ -40,9 +41,8 @@ GameStateDeckViewer::GameStateDeckViewer(GameApp* parent) :
|
|||||||
source = NULL;
|
source = NULL;
|
||||||
hudAlpha = 0;
|
hudAlpha = 0;
|
||||||
subMenu = NULL;
|
subMenu = NULL;
|
||||||
mAlpha = 255;
|
deckMenu = NULL;
|
||||||
menu = NULL;
|
mStatsWrapper = NULL;
|
||||||
stw = NULL;
|
|
||||||
|
|
||||||
statsPrevButton = NEW InteractiveButton(NULL, kPrevStatsButtonId, Fonts::MAIN_FONT, "Stats", SCREEN_WIDTH_F - 50, SCREEN_HEIGHT_F - 20, JGE_BTN_PREV);
|
statsPrevButton = NEW InteractiveButton(NULL, kPrevStatsButtonId, Fonts::MAIN_FONT, "Stats", SCREEN_WIDTH_F - 50, SCREEN_HEIGHT_F - 20, JGE_BTN_PREV);
|
||||||
toggleDeckButton = NEW InteractiveButton(NULL, kToggleDeckActionId, Fonts::MAIN_FONT, "View Deck", 10, SCREEN_HEIGHT_F - 20, JGE_BTN_PRI);
|
toggleDeckButton = NEW InteractiveButton(NULL, kToggleDeckActionId, Fonts::MAIN_FONT, "View Deck", 10, SCREEN_HEIGHT_F - 20, JGE_BTN_PRI);
|
||||||
@@ -86,8 +86,8 @@ void GameStateDeckViewer::rebuildFilters()
|
|||||||
filterMenu->Finish(true);
|
filterMenu->Finish(true);
|
||||||
|
|
||||||
// no stats need updating if there isn't a deck to update
|
// no stats need updating if there isn't a deck to update
|
||||||
if (stw && myDeck)
|
if (mStatsWrapper && myDeck)
|
||||||
stw->updateStats( myDeck );;
|
mStatsWrapper->updateStats( myDeck );;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateDeckViewer::updateFilters()
|
void GameStateDeckViewer::updateFilters()
|
||||||
@@ -96,7 +96,7 @@ void GameStateDeckViewer::updateFilters()
|
|||||||
|
|
||||||
filterMenu->recolorFilter(mView->filter() - 1);
|
filterMenu->recolorFilter(mView->filter() - 1);
|
||||||
filterMenu->Finish(true);
|
filterMenu->Finish(true);
|
||||||
stw->updateStats( myDeck );;
|
mStatsWrapper->updateStats( myDeck );;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,44 +116,39 @@ void GameStateDeckViewer::toggleCollection()
|
|||||||
updateFilters();
|
updateFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//after renaming and on the first start.
|
||||||
|
//reloadWelcomeMenu
|
||||||
void GameStateDeckViewer::updateDecks()
|
void GameStateDeckViewer::updateDecks()
|
||||||
{
|
{
|
||||||
SAFE_DELETE(welcome_menu);
|
SAFE_DELETE(welcome_menu);
|
||||||
welcome_menu = NEW DeckEditorMenu(MENU_DECK_SELECTION, this, Fonts::OPTION_FONT, "Choose Deck To Edit");
|
welcome_menu = NEW DeckEditorMenu(MENU_DECK_SELECTION, this, Fonts::OPTION_FONT, "Choose Deck To Edit");
|
||||||
DeckManager * deckManager = DeckManager::GetInstance();
|
|
||||||
vector<DeckMetaData *> playerDeckList = fillDeckMenu(welcome_menu, options.profileFile());
|
vector<DeckMetaData *> playerDeckList = fillDeckMenu(welcome_menu, options.profileFile());
|
||||||
|
|
||||||
newDeckname = "";
|
newDeckname = "";
|
||||||
welcome_menu->Add(MENU_ITEM_NEW_DECK, "--NEW--");
|
welcome_menu->Add(MENU_ITEM_NEW_DECK, "--NEW--");
|
||||||
if (options[Options::CHEATMODE].number && (!myCollection || myCollection->getCount(WSrcDeck::UNFILTERED_MIN_COPIES) < 4)) welcome_menu->Add(
|
if (options[Options::CHEATMODE].number && (!myCollection || myCollection->getCount(WSrcDeck::UNFILTERED_MIN_COPIES) < 4))
|
||||||
MENU_ITEM_CHEAT_MODE, "--UNLOCK CARDS--");
|
{
|
||||||
|
welcome_menu->Add(MENU_ITEM_CHEAT_MODE, "--UNLOCK CARDS--");
|
||||||
|
}
|
||||||
welcome_menu->Add(MENU_ITEM_CANCEL, "Cancel");
|
welcome_menu->Add(MENU_ITEM_CANCEL, "Cancel");
|
||||||
|
|
||||||
// update the deckmanager with the latest information
|
// update the deckmanager with the latest information
|
||||||
deckManager->updateMetaDataList(&playerDeckList, false);
|
DeckManager::GetInstance()->updateMetaDataList(&playerDeckList, false);
|
||||||
// is this necessary to ensure no memory leaks?
|
|
||||||
playerDeckList.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateDeckViewer::buildEditorMenu()
|
void GameStateDeckViewer::buildEditorMenu()
|
||||||
{
|
{
|
||||||
ostringstream deckSummaryInformation;
|
SAFE_DELETE(deckMenu);
|
||||||
deckSummaryInformation << _("All changes are final.").c_str() << endl;
|
|
||||||
|
|
||||||
if (menu)
|
deckMenu = NEW DeckEditorMenu(MENU_DECK_BUILDER, this, Fonts::OPTION_FONT, "Deck Editor", myDeck, mStatsWrapper);
|
||||||
SAFE_DELETE( menu );
|
|
||||||
//Build menu.
|
|
||||||
JRenderer::GetInstance()->FillRoundRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 100, ARGB(0, 0, 0, 0) );
|
|
||||||
menu = NEW DeckEditorMenu(MENU_DECK_BUILDER, this, Fonts::OPTION_FONT, "Deck Editor", myDeck, stw);
|
|
||||||
|
|
||||||
menu->Add(MENU_ITEM_FILTER_BY, _("Filter By...").c_str(), _("Narrow down the list of cards. ").c_str());
|
|
||||||
menu->Add(MENU_ITEM_SWITCH_DECKS_NO_SAVE, _("Switch Decks").c_str(), _("Do not make any changes. View another deck.").c_str());
|
|
||||||
menu->Add(MENU_ITEM_SAVE_RENAME, _("Rename Deck").c_str(), _("Change the name of the deck").c_str());
|
|
||||||
menu->Add(MENU_ITEM_SAVE_RETURN_MAIN_MENU, _("Save & Quit Editor").c_str(), _("Save changes. Return to the main menu").c_str());
|
|
||||||
menu->Add(MENU_ITEM_SAVE_AS_AI_DECK, _("Save As AI Deck").c_str(), deckSummaryInformation.str());
|
|
||||||
menu->Add(MENU_ITEM_MAIN_MENU, _("Quit Editor").c_str(), _("Do not make any changes to deck. Return to the main menu.").c_str());
|
|
||||||
menu->Add(MENU_ITEM_EDITOR_CANCEL, _("Cancel").c_str(), _("Close menu.").c_str());
|
|
||||||
|
|
||||||
|
deckMenu->Add(MENU_ITEM_FILTER_BY, _("Filter By..."), _("Narrow down the list of cards. "));
|
||||||
|
deckMenu->Add(MENU_ITEM_SWITCH_DECKS_NO_SAVE, _("Switch Decks"), _("Do not make any changes. View another deck."));
|
||||||
|
deckMenu->Add(MENU_ITEM_SAVE_RENAME, _("Rename Deck"), _("Change the name of the deck"));
|
||||||
|
deckMenu->Add(MENU_ITEM_SAVE_RETURN_MAIN_MENU, _("Save & Quit Editor"), _("Save changes. Return to the main menu"));
|
||||||
|
deckMenu->Add(MENU_ITEM_SAVE_AS_AI_DECK, _("Save As AI Deck"), _("All changes are final."));
|
||||||
|
deckMenu->Add(MENU_ITEM_MAIN_MENU, _("Quit Editor"), _("Do not make any changes to deck. Return to the main menu."));
|
||||||
|
deckMenu->Add(MENU_ITEM_EDITOR_CANCEL, _("Cancel"), _("Close menu."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStateDeckViewer::Start()
|
void GameStateDeckViewer::Start()
|
||||||
@@ -164,7 +159,6 @@ void GameStateDeckViewer::Start()
|
|||||||
myDeck = NULL;
|
myDeck = NULL;
|
||||||
mStage = STAGE_WELCOME;
|
mStage = STAGE_WELCOME;
|
||||||
|
|
||||||
mAlpha = 255;
|
|
||||||
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
||||||
onScreenTransition = 0;
|
onScreenTransition = 0;
|
||||||
|
|
||||||
@@ -201,7 +195,6 @@ void GameStateDeckViewer::Start()
|
|||||||
|
|
||||||
GameApp::playMusic("Track1.mp3");
|
GameApp::playMusic("Track1.mp3");
|
||||||
|
|
||||||
mView->reloadIndexes();
|
|
||||||
mEngine->ResetInput();
|
mEngine->ResetInput();
|
||||||
JRenderer::GetInstance()->EnableVSync(true);
|
JRenderer::GetInstance()->EnableVSync(true);
|
||||||
}
|
}
|
||||||
@@ -211,7 +204,7 @@ void GameStateDeckViewer::End()
|
|||||||
JRenderer::GetInstance()->EnableVSync(false);
|
JRenderer::GetInstance()->EnableVSync(false);
|
||||||
|
|
||||||
SAFE_DELETE(welcome_menu);
|
SAFE_DELETE(welcome_menu);
|
||||||
SAFE_DELETE(menu);
|
SAFE_DELETE(deckMenu);
|
||||||
SAFE_DELETE(subMenu);
|
SAFE_DELETE(subMenu);
|
||||||
|
|
||||||
WResourceManager::Instance()->Release(pspIconsTexture);
|
WResourceManager::Instance()->Release(pspIconsTexture);
|
||||||
@@ -247,7 +240,7 @@ void GameStateDeckViewer::addRemove(MTGCard * card)
|
|||||||
}
|
}
|
||||||
myCollection->validate();
|
myCollection->validate();
|
||||||
myDeck->validate();
|
myDeck->validate();
|
||||||
stw->needUpdate = true;
|
mStatsWrapper->needUpdate = true;
|
||||||
mView->reloadIndexes();
|
mView->reloadIndexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +289,7 @@ void GameStateDeckViewer::sellCard()
|
|||||||
MTGCard * card = mView->getActiveCard();
|
MTGCard * card = mView->getActiveCard();
|
||||||
if (card && mView->deck()->count(card))
|
if (card && mView->deck()->count(card))
|
||||||
{
|
{
|
||||||
price = pricelist->getSellPrice(card->getMTGId());
|
int price = pricelist->getSellPrice(card);
|
||||||
sprintf(buffer, "%s : %i %s", _(card->data->getName()).c_str(), price, _("credits").c_str());
|
sprintf(buffer, "%s : %i %s", _(card->data->getName()).c_str(), price, _("credits").c_str());
|
||||||
const float menuXOffset = SCREEN_WIDTH_F - 300;
|
const float menuXOffset = SCREEN_WIDTH_F - 300;
|
||||||
const float menuYOffset = SCREEN_HEIGHT_F / 2;
|
const float menuYOffset = SCREEN_HEIGHT_F / 2;
|
||||||
@@ -305,7 +298,7 @@ void GameStateDeckViewer::sellCard()
|
|||||||
subMenu->Add(MENU_ITEM_NO, "No", "", true);
|
subMenu->Add(MENU_ITEM_NO, "No", "", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stw->needUpdate = true;
|
mStatsWrapper->needUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameStateDeckViewer::userPressedButton()
|
bool GameStateDeckViewer::userPressedButton()
|
||||||
@@ -489,12 +482,12 @@ void GameStateDeckViewer::Update(float dt)
|
|||||||
case JGE_BTN_PREV:
|
case JGE_BTN_PREV:
|
||||||
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY)
|
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY)
|
||||||
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
||||||
else if ((mStage == STAGE_ONSCREEN_MENU) && (--stw->currentPage < 0)) stw->currentPage = stw->pageCount;
|
else if ((mStage == STAGE_ONSCREEN_MENU) && (--mStatsWrapper->currentPage < 0)) mStatsWrapper->currentPage = mStatsWrapper->pageCount;
|
||||||
break;
|
break;
|
||||||
case JGE_BTN_NEXT:
|
case JGE_BTN_NEXT:
|
||||||
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY)
|
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY)
|
||||||
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
||||||
else if ((mStage == STAGE_ONSCREEN_MENU) && (++stw->currentPage > stw->pageCount)) stw->currentPage = 0;
|
else if ((mStage == STAGE_ONSCREEN_MENU) && (++mStatsWrapper->currentPage > mStatsWrapper->pageCount)) mStatsWrapper->currentPage = 0;
|
||||||
break;
|
break;
|
||||||
default: // no keypress
|
default: // no keypress
|
||||||
if (last_user_activity > NO_USER_ACTIVITY_HELP_DELAY)
|
if (last_user_activity > NO_USER_ACTIVITY_HELP_DELAY)
|
||||||
@@ -531,7 +524,7 @@ void GameStateDeckViewer::Update(float dt)
|
|||||||
if (mStage == STAGE_WELCOME)
|
if (mStage == STAGE_WELCOME)
|
||||||
welcome_menu->Update(dt);
|
welcome_menu->Update(dt);
|
||||||
else if (mStage == STAGE_MENU)
|
else if (mStage == STAGE_MENU)
|
||||||
menu->Update(dt);
|
deckMenu->Update(dt);
|
||||||
else if (mStage == STAGE_FILTERS)
|
else if (mStage == STAGE_FILTERS)
|
||||||
{
|
{
|
||||||
JButton key = mEngine->ReadButton();
|
JButton key = mEngine->ReadButton();
|
||||||
@@ -681,7 +674,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
bool renderPSPIcons = true;
|
bool renderPSPIcons = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (stw->currentPage == 0)
|
if (mStatsWrapper->currentPage == 0)
|
||||||
{
|
{
|
||||||
//FillRects
|
//FillRects
|
||||||
r->FillRect(0 - (onScreenTransition * 84), 0, 84, SCREEN_HEIGHT, ARGB(128,0,0,0));
|
r->FillRect(0 - (onScreenTransition * 84), 0, 84, SCREEN_HEIGHT, ARGB(128,0,0,0));
|
||||||
@@ -782,7 +775,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stw->updateStats( myDeck );;
|
mStatsWrapper->updateStats( myDeck );;
|
||||||
|
|
||||||
char buffer[300];
|
char buffer[300];
|
||||||
|
|
||||||
@@ -804,16 +797,16 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
graphColor = ARGB(200, 155, 155, 155);
|
graphColor = ARGB(200, 155, 155, 155);
|
||||||
string STATS_TITLE_FORMAT = _("%i: %s");
|
string STATS_TITLE_FORMAT = _("%i: %s");
|
||||||
|
|
||||||
switch (stw->currentPage)
|
switch (mStatsWrapper->currentPage)
|
||||||
{
|
{
|
||||||
case 1: // Counts, price
|
case 1: // Counts, price
|
||||||
// Title
|
// Title
|
||||||
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), stw->currentPage, _("Statistics Summary").c_str());
|
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), mStatsWrapper->currentPage, _("Statistics Summary").c_str());
|
||||||
font->DrawString(buffer, 10 + leftTransition, 10);
|
font->DrawString(buffer, 10 + leftTransition, 10);
|
||||||
|
|
||||||
posY = 30;
|
posY = 30;
|
||||||
posX = 180;
|
posX = 180;
|
||||||
sprintf(buffer, _("Your Deck: %i cards").c_str(), stw->cardCount);
|
sprintf(buffer, _("Your Deck: %i cards").c_str(), mStatsWrapper->cardCount);
|
||||||
font->DrawString(buffer, 20 + leftTransition, posY);
|
font->DrawString(buffer, 20 + leftTransition, posY);
|
||||||
posY += 10;
|
posY += 10;
|
||||||
|
|
||||||
@@ -845,34 +838,34 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
||||||
|
|
||||||
font->DrawString(_("Lands"), 20 + leftTransition, posY);
|
font->DrawString(_("Lands"), 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw->countLands);
|
sprintf(buffer, _("%i").c_str(), mStatsWrapper->countLands);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 14;
|
posY += 14;
|
||||||
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
||||||
font->DrawString(_("Creatures"), 20 + leftTransition, posY);
|
font->DrawString(_("Creatures"), 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw->countCreatures);
|
sprintf(buffer, _("%i").c_str(), mStatsWrapper->countCreatures);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 14;
|
posY += 14;
|
||||||
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
||||||
font->DrawString(_("Spells"), 20 + leftTransition, posY);
|
font->DrawString(_("Spells"), 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw->countSpells);
|
sprintf(buffer, _("%i").c_str(), mStatsWrapper->countSpells);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
font->DrawString(_("Instants"), 30 + leftTransition, posY);
|
font->DrawString(_("Instants"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw->countInstants);
|
sprintf(buffer, _("%i").c_str(), mStatsWrapper->countInstants);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
font->DrawString(_("Enchantments"), 30 + leftTransition, posY);
|
font->DrawString(_("Enchantments"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw->countEnchantments);
|
sprintf(buffer, _("%i").c_str(), mStatsWrapper->countEnchantments);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
font->DrawString(_("Sorceries"), 30 + leftTransition, posY);
|
font->DrawString(_("Sorceries"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw->countSorceries);
|
sprintf(buffer, _("%i").c_str(), mStatsWrapper->countSorceries);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
//sprintf(buffer, "Artifacts: %i", stw->countArtifacts);
|
//sprintf(buffer, "Artifacts: %i", stw->countArtifacts);
|
||||||
//mFont->DrawString(buffer, 20, 123);
|
//mFont->DrawString(buffer, 20, 123);
|
||||||
@@ -881,7 +874,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
||||||
|
|
||||||
font->DrawString(_("Average converted mana cost"), 20 + leftTransition, posY);
|
font->DrawString(_("Average converted mana cost"), 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%2.2f").c_str(), stw->avgManaCost);
|
sprintf(buffer, _("%2.2f").c_str(), mStatsWrapper->avgManaCost);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 14;
|
posY += 14;
|
||||||
@@ -890,17 +883,17 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
font->DrawString(_("No land in 1st hand"), 30 + leftTransition, posY);
|
font->DrawString(_("No land in 1st hand"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%2.2f%%").c_str(), stw->noLandsProbInTurn[0]);
|
sprintf(buffer, _("%2.2f%%").c_str(), mStatsWrapper->noLandsProbInTurn[0]);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
font->DrawString(_("No land in 9 cards"), 30 + leftTransition, posY);
|
font->DrawString(_("No land in 9 cards"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%2.2f%%").c_str(), stw->noLandsProbInTurn[2]);
|
sprintf(buffer, _("%2.2f%%").c_str(), mStatsWrapper->noLandsProbInTurn[2]);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
font->DrawString(_("No creatures in 1st hand"), 30 + leftTransition, posY);
|
font->DrawString(_("No creatures in 1st hand"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%2.2f%%").c_str(), stw->noCreaturesProbInTurn[0]);
|
sprintf(buffer, _("%2.2f%%").c_str(), mStatsWrapper->noCreaturesProbInTurn[0]);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
// Playgame Statistics
|
// Playgame Statistics
|
||||||
@@ -910,25 +903,25 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
font->DrawString(_("Games played"), 30 + leftTransition, posY);
|
font->DrawString(_("Games played"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i").c_str(), stw->gamesPlayed);
|
sprintf(buffer, _("%i").c_str(), mStatsWrapper->gamesPlayed);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 10;
|
posY += 10;
|
||||||
font->DrawString(_("Victory ratio"), 30 + leftTransition, posY);
|
font->DrawString(_("Victory ratio"), 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i%%").c_str(), stw->percentVictories);
|
sprintf(buffer, _("%i%%").c_str(), mStatsWrapper->percentVictories);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
|
|
||||||
posY += 15;
|
posY += 15;
|
||||||
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
r->DrawLine(20 + leftTransition, posY - 1, posX + 40 + leftTransition, posY - 1, ARGB(128, 255, 255, 255));
|
||||||
font->DrawString(_("Total price (credits)"), 20 + leftTransition, posY);
|
font->DrawString(_("Total price (credits)"), 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%i ").c_str(), stw->totalPrice);
|
sprintf(buffer, _("%i ").c_str(), mStatsWrapper->totalPrice);
|
||||||
font->DrawString(buffer, posX + leftTransition, posY);
|
font->DrawString(buffer, posX + leftTransition, posY);
|
||||||
r->DrawLine(20 + leftTransition, posY + 13, posX + 40 + leftTransition, posY + 13, ARGB(128, 255, 255, 255));
|
r->DrawLine(20 + leftTransition, posY + 13, posX + 40 + leftTransition, posY + 13, ARGB(128, 255, 255, 255));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: // Land statistics
|
case 5: // Land statistics
|
||||||
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), stw->currentPage, _("Mana production").c_str());
|
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), mStatsWrapper->currentPage, _("Mana production").c_str());
|
||||||
font->DrawString(buffer, 10 + leftTransition, 10);
|
font->DrawString(buffer, 10 + leftTransition, 10);
|
||||||
|
|
||||||
font->DrawString(_("Counts of manasources per type and color:"), 20 + leftTransition, 30);
|
font->DrawString(_("Counts of manasources per type and color:"), 20 + leftTransition, 30);
|
||||||
@@ -969,7 +962,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
|
|
||||||
for (int j = 0; j < Constants::NB_Colors - 1; j++)
|
for (int j = 0; j < Constants::NB_Colors - 1; j++)
|
||||||
{
|
{
|
||||||
curCount = stw->countBasicLandsPerColor[j];
|
curCount = mStatsWrapper->countBasicLandsPerColor[j];
|
||||||
if(curCount == 0) {
|
if(curCount == 0) {
|
||||||
sprintf(buffer, ".");
|
sprintf(buffer, ".");
|
||||||
} else {
|
} else {
|
||||||
@@ -977,7 +970,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
}
|
}
|
||||||
font->DrawString(buffer, 49 + leftTransition + j * 15, posY);
|
font->DrawString(buffer, 49 + leftTransition + j * 15, posY);
|
||||||
|
|
||||||
curCount = stw->countLandsPerColor[j];
|
curCount = mStatsWrapper->countLandsPerColor[j];
|
||||||
if(curCount == 0) {
|
if(curCount == 0) {
|
||||||
sprintf(buffer, ".");
|
sprintf(buffer, ".");
|
||||||
} else {
|
} else {
|
||||||
@@ -985,7 +978,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
}
|
}
|
||||||
font->DrawString(buffer, 49 + leftTransition + j * 15, posY + 10);
|
font->DrawString(buffer, 49 + leftTransition + j * 15, posY + 10);
|
||||||
|
|
||||||
curCount = stw->countNonLandProducersPerColor[j];
|
curCount = mStatsWrapper->countNonLandProducersPerColor[j];
|
||||||
if(curCount == 0) {
|
if(curCount == 0) {
|
||||||
sprintf(buffer, ".");
|
sprintf(buffer, ".");
|
||||||
} else {
|
} else {
|
||||||
@@ -993,7 +986,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
}
|
}
|
||||||
font->DrawString(buffer, 49 + leftTransition + j * 15, posY + 20);
|
font->DrawString(buffer, 49 + leftTransition + j * 15, posY + 20);
|
||||||
|
|
||||||
curCount = stw->countLandsPerColor[j] + stw->countBasicLandsPerColor[j] + stw->countNonLandProducersPerColor[j];
|
curCount = mStatsWrapper->countLandsPerColor[j] + mStatsWrapper->countBasicLandsPerColor[j] + mStatsWrapper->countNonLandProducersPerColor[j];
|
||||||
if(curCount == 0) {
|
if(curCount == 0) {
|
||||||
sprintf(buffer, ".");
|
sprintf(buffer, ".");
|
||||||
} else {
|
} else {
|
||||||
@@ -1014,7 +1007,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: // Land statistics - in symbols
|
case 6: // Land statistics - in symbols
|
||||||
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), stw->currentPage, _("Mana production - in mana symbols").c_str());
|
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), mStatsWrapper->currentPage, _("Mana production - in mana symbols").c_str());
|
||||||
font->DrawString(buffer, 10 + leftTransition, 10);
|
font->DrawString(buffer, 10 + leftTransition, 10);
|
||||||
font->DrawString(_("Total colored manasymbols in lands' production:"), 20 + leftTransition, 30);
|
font->DrawString(_("Total colored manasymbols in lands' production:"), 20 + leftTransition, 30);
|
||||||
|
|
||||||
@@ -1022,25 +1015,25 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
totalProducedSymbols = 0;
|
totalProducedSymbols = 0;
|
||||||
for (int i = 1; i < Constants::NB_Colors - 1; i++)
|
for (int i = 1; i < Constants::NB_Colors - 1; i++)
|
||||||
{
|
{
|
||||||
totalProducedSymbols += stw->countLandsPerColor[i] + stw->countBasicLandsPerColor[i]; //!! Move to updatestats!
|
totalProducedSymbols += mStatsWrapper->countLandsPerColor[i] + mStatsWrapper->countBasicLandsPerColor[i]; //!! Move to updatestats!
|
||||||
}
|
}
|
||||||
|
|
||||||
posY = 50;
|
posY = 50;
|
||||||
for (int i = 1; i < Constants::NB_Colors - 1; i++)
|
for (int i = 1; i < Constants::NB_Colors - 1; i++)
|
||||||
{
|
{
|
||||||
if (stw->countLandsPerColor[i] + stw->countBasicLandsPerColor[i] > 0)
|
if (mStatsWrapper->countLandsPerColor[i] + mStatsWrapper->countBasicLandsPerColor[i] > 0)
|
||||||
{
|
{
|
||||||
sprintf(buffer, _("%i").c_str(), stw->countLandsPerColor[i] + stw->countBasicLandsPerColor[i]);
|
sprintf(buffer, _("%i").c_str(), mStatsWrapper->countLandsPerColor[i] + mStatsWrapper->countBasicLandsPerColor[i]);
|
||||||
font->DrawString(buffer, 20 + leftTransition, posY);
|
font->DrawString(buffer, 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("(%i%%)").c_str(), (int) (100 * (float) (stw->countLandsPerColor[i]
|
sprintf(buffer, _("(%i%%)").c_str(), (int) (100 * (float) (mStatsWrapper->countLandsPerColor[i]
|
||||||
+ stw->countBasicLandsPerColor[i]) / totalProducedSymbols));
|
+ mStatsWrapper->countBasicLandsPerColor[i]) / totalProducedSymbols));
|
||||||
font->DrawString(buffer, 33 + leftTransition, posY);
|
font->DrawString(buffer, 33 + leftTransition, posY);
|
||||||
posX = 72;
|
posX = 72;
|
||||||
for (int j = 0; j < stw->countLandsPerColor[i] + stw->countBasicLandsPerColor[i]; j++)
|
for (int j = 0; j < mStatsWrapper->countLandsPerColor[i] + mStatsWrapper->countBasicLandsPerColor[i]; j++)
|
||||||
{
|
{
|
||||||
r->RenderQuad(mIcons[i].get(), posX + leftTransition, posY + 6, 0, 0.5, 0.5);
|
r->RenderQuad(mIcons[i].get(), posX + leftTransition, posY + 6, 0, 0.5, 0.5);
|
||||||
posX += ((j + 1) % 10 == 0) ? 17 : 13;
|
posX += ((j + 1) % 10 == 0) ? 17 : 13;
|
||||||
if ((((j + 1) % 30) == 0) && (j < stw->countLandsPerColor[i] + stw->countBasicLandsPerColor[i] - 1))
|
if ((((j + 1) % 30) == 0) && (j < mStatsWrapper->countLandsPerColor[i] + mStatsWrapper->countBasicLandsPerColor[i] - 1))
|
||||||
{
|
{
|
||||||
posX = 72;
|
posX = 72;
|
||||||
posY += 15;
|
posY += 15;
|
||||||
@@ -1059,34 +1052,34 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
int (*countPerCostAndColor)[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
int (*countPerCostAndColor)[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||||
float avgCost;
|
float avgCost;
|
||||||
|
|
||||||
switch (stw->currentPage)
|
switch (mStatsWrapper->currentPage)
|
||||||
{ // Nested switch on the same variable. Oh yes.
|
{ // Nested switch on the same variable. Oh yes.
|
||||||
case 2: // Total counts
|
case 2: // Total counts
|
||||||
// Title
|
// Title
|
||||||
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), stw->currentPage, _("Mana cost detail").c_str());
|
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), mStatsWrapper->currentPage, _("Mana cost detail").c_str());
|
||||||
font->DrawString(buffer, 10 + leftTransition, 10);
|
font->DrawString(buffer, 10 + leftTransition, 10);
|
||||||
font->DrawString(_("Card counts per mana cost:"), 20 + leftTransition, 30);
|
font->DrawString(_("Card counts per mana cost:"), 20 + leftTransition, 30);
|
||||||
avgCost = stw->avgManaCost;
|
avgCost = mStatsWrapper->avgManaCost;
|
||||||
countPerCost = &stw->countCardsPerCost;
|
countPerCost = &mStatsWrapper->countCardsPerCost;
|
||||||
countPerCostAndColor = &stw->countCardsPerCostAndColor;
|
countPerCostAndColor = &mStatsWrapper->countCardsPerCostAndColor;
|
||||||
break;
|
break;
|
||||||
case 3: // Creature counts
|
case 3: // Creature counts
|
||||||
// Title
|
// Title
|
||||||
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), stw->currentPage, _("Mana cost detail - Creatures").c_str());
|
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), mStatsWrapper->currentPage, _("Mana cost detail - Creatures").c_str());
|
||||||
font->DrawString(buffer, 10 + leftTransition, 10);
|
font->DrawString(buffer, 10 + leftTransition, 10);
|
||||||
font->DrawString(_("Creature counts per mana cost:"), 20 + leftTransition, 30);
|
font->DrawString(_("Creature counts per mana cost:"), 20 + leftTransition, 30);
|
||||||
avgCost = stw->avgCreatureCost;
|
avgCost = mStatsWrapper->avgCreatureCost;
|
||||||
countPerCost = &stw->countCreaturesPerCost;
|
countPerCost = &mStatsWrapper->countCreaturesPerCost;
|
||||||
countPerCostAndColor = &stw->countCreaturesPerCostAndColor;
|
countPerCostAndColor = &mStatsWrapper->countCreaturesPerCostAndColor;
|
||||||
break;
|
break;
|
||||||
case 4: // Spell counts
|
case 4: // Spell counts
|
||||||
// Title
|
// Title
|
||||||
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), stw->currentPage, _("Mana cost detail - Spells").c_str());
|
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), mStatsWrapper->currentPage, _("Mana cost detail - Spells").c_str());
|
||||||
font->DrawString(buffer, 10 + leftTransition, 10);
|
font->DrawString(buffer, 10 + leftTransition, 10);
|
||||||
font->DrawString(_("Non-creature spell counts per mana cost:"), 20 + leftTransition, 30);
|
font->DrawString(_("Non-creature spell counts per mana cost:"), 20 + leftTransition, 30);
|
||||||
avgCost = stw->avgSpellCost;
|
avgCost = mStatsWrapper->avgSpellCost;
|
||||||
countPerCost = &stw->countSpellsPerCost;
|
countPerCost = &mStatsWrapper->countSpellsPerCost;
|
||||||
countPerCostAndColor = &stw->countSpellsPerCostAndColor;
|
countPerCostAndColor = &mStatsWrapper->countSpellsPerCostAndColor;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
countPerCost = NULL;
|
countPerCost = NULL;
|
||||||
@@ -1155,13 +1148,13 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
// Title
|
// Title
|
||||||
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), stw->currentPage, _("Probabilities").c_str());
|
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), mStatsWrapper->currentPage, _("Probabilities").c_str());
|
||||||
font->DrawString(buffer, 10 + leftTransition, 10);
|
font->DrawString(buffer, 10 + leftTransition, 10);
|
||||||
|
|
||||||
// No lands detail
|
// No lands detail
|
||||||
float graphScale, graphWidth;
|
float graphScale, graphWidth;
|
||||||
graphWidth = 100;
|
graphWidth = 100;
|
||||||
graphScale = (stw->noLandsProbInTurn[0] == 0) ? 0 : (graphWidth / stw->noLandsProbInTurn[0]);
|
graphScale = (mStatsWrapper->noLandsProbInTurn[0] == 0) ? 0 : (graphWidth / mStatsWrapper->noLandsProbInTurn[0]);
|
||||||
font->DrawString(_("No lands in first n cards:"), 20 + leftTransition, 30);
|
font->DrawString(_("No lands in first n cards:"), 20 + leftTransition, 30);
|
||||||
|
|
||||||
posY = 50;
|
posY = 50;
|
||||||
@@ -1169,9 +1162,9 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
{
|
{
|
||||||
sprintf(buffer, _("%i:").c_str(), i + 7);
|
sprintf(buffer, _("%i:").c_str(), i + 7);
|
||||||
font->DrawString(buffer, 30 + leftTransition, posY);
|
font->DrawString(buffer, 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%2.2f%%").c_str(), stw->noLandsProbInTurn[i]);
|
sprintf(buffer, _("%2.2f%%").c_str(), mStatsWrapper->noLandsProbInTurn[i]);
|
||||||
font->DrawString(buffer, 45 + leftTransition, posY);
|
font->DrawString(buffer, 45 + leftTransition, posY);
|
||||||
r->FillRect(84 + leftTransition, posY + 2, graphScale * stw->noLandsProbInTurn[i], 8, graphColor);
|
r->FillRect(84 + leftTransition, posY + 2, graphScale * mStatsWrapper->noLandsProbInTurn[i], 8, graphColor);
|
||||||
posY += 10;
|
posY += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1179,15 +1172,15 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
posY += 10;
|
posY += 10;
|
||||||
font->DrawString(_("No creatures in first n cards:"), 20 + leftTransition, posY);
|
font->DrawString(_("No creatures in first n cards:"), 20 + leftTransition, posY);
|
||||||
posY += 20;
|
posY += 20;
|
||||||
graphScale = (stw->noCreaturesProbInTurn[0] == 0) ? 0 : (graphWidth / stw->noCreaturesProbInTurn[0]);
|
graphScale = (mStatsWrapper->noCreaturesProbInTurn[0] == 0) ? 0 : (graphWidth / mStatsWrapper->noCreaturesProbInTurn[0]);
|
||||||
|
|
||||||
for (int i = 0; i < Constants::STATS_FOR_TURNS; i++)
|
for (int i = 0; i < Constants::STATS_FOR_TURNS; i++)
|
||||||
{
|
{
|
||||||
sprintf(buffer, _("%i:").c_str(), i + 7);
|
sprintf(buffer, _("%i:").c_str(), i + 7);
|
||||||
font->DrawString(buffer, 30 + leftTransition, posY);
|
font->DrawString(buffer, 30 + leftTransition, posY);
|
||||||
sprintf(buffer, _("%2.2f%%").c_str(), stw->noCreaturesProbInTurn[i]);
|
sprintf(buffer, _("%2.2f%%").c_str(), mStatsWrapper->noCreaturesProbInTurn[i]);
|
||||||
font->DrawString(buffer, 45 + leftTransition, posY);
|
font->DrawString(buffer, 45 + leftTransition, posY);
|
||||||
r->FillRect(84 + leftTransition, posY + 2, graphScale * stw->noCreaturesProbInTurn[i], 8, graphColor);
|
r->FillRect(84 + leftTransition, posY + 2, graphScale * mStatsWrapper->noCreaturesProbInTurn[i], 8, graphColor);
|
||||||
posY += 10;
|
posY += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1195,7 +1188,7 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
|
|
||||||
case 7: // Total mana cost per color
|
case 7: // Total mana cost per color
|
||||||
// Title
|
// Title
|
||||||
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), stw->currentPage, _("Mana cost per color").c_str());
|
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), mStatsWrapper->currentPage, _("Mana cost per color").c_str());
|
||||||
font->DrawString(buffer, 10 + leftTransition, 10);
|
font->DrawString(buffer, 10 + leftTransition, 10);
|
||||||
|
|
||||||
font->DrawString(_("Total colored manasymbols in cards' casting costs:"), 20 + leftTransition, 30);
|
font->DrawString(_("Total colored manasymbols in cards' casting costs:"), 20 + leftTransition, 30);
|
||||||
@@ -1203,18 +1196,18 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
posY = 50;
|
posY = 50;
|
||||||
for (int i = 1; i < Constants::NB_Colors - 1; i++)
|
for (int i = 1; i < Constants::NB_Colors - 1; i++)
|
||||||
{
|
{
|
||||||
if (stw->totalCostPerColor[i] > 0)
|
if (mStatsWrapper->totalCostPerColor[i] > 0)
|
||||||
{
|
{
|
||||||
sprintf(buffer, _("%i").c_str(), stw->totalCostPerColor[i]);
|
sprintf(buffer, _("%i").c_str(), mStatsWrapper->totalCostPerColor[i]);
|
||||||
font->DrawString(buffer, 20 + leftTransition, posY);
|
font->DrawString(buffer, 20 + leftTransition, posY);
|
||||||
sprintf(buffer, _("(%i%%)").c_str(), (int) (100 * (float) stw->totalCostPerColor[i] / stw->totalColoredSymbols));
|
sprintf(buffer, _("(%i%%)").c_str(), (int) (100 * (float) mStatsWrapper->totalCostPerColor[i] / mStatsWrapper->totalColoredSymbols));
|
||||||
font->DrawString(buffer, 33 + leftTransition, posY);
|
font->DrawString(buffer, 33 + leftTransition, posY);
|
||||||
posX = 72;
|
posX = 72;
|
||||||
for (int j = 0; j < stw->totalCostPerColor[i]; j++)
|
for (int j = 0; j < mStatsWrapper->totalCostPerColor[i]; j++)
|
||||||
{
|
{
|
||||||
r->RenderQuad(mIcons[i].get(), posX + leftTransition, posY + 6, 0, 0.5, 0.5);
|
r->RenderQuad(mIcons[i].get(), posX + leftTransition, posY + 6, 0, 0.5, 0.5);
|
||||||
posX += ((j + 1) % 10 == 0) ? 17 : 13;
|
posX += ((j + 1) % 10 == 0) ? 17 : 13;
|
||||||
if ((((j + 1) % 30) == 0) && (j < stw->totalCostPerColor[i] - 1))
|
if ((((j + 1) % 30) == 0) && (j < mStatsWrapper->totalCostPerColor[i] - 1))
|
||||||
{
|
{
|
||||||
posX = 72;
|
posX = 72;
|
||||||
posY += 15;
|
posY += 15;
|
||||||
@@ -1227,14 +1220,14 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
|
|
||||||
case 9: // Victory statistics
|
case 9: // Victory statistics
|
||||||
// Title
|
// Title
|
||||||
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), stw->currentPage, _("Victory statistics").c_str());
|
sprintf(buffer, STATS_TITLE_FORMAT.c_str(), mStatsWrapper->currentPage, _("Victory statistics").c_str());
|
||||||
font->DrawString(buffer, 10 + leftTransition, 10);
|
font->DrawString(buffer, 10 + leftTransition, 10);
|
||||||
|
|
||||||
font->DrawString(_("Victories against AI:"), 20 + leftTransition, 30);
|
font->DrawString(_("Victories against AI:"), 20 + leftTransition, 30);
|
||||||
|
|
||||||
sprintf(buffer, _("Games played: %i").c_str(), stw->gamesPlayed);
|
sprintf(buffer, _("Games played: %i").c_str(), mStatsWrapper->gamesPlayed);
|
||||||
font->DrawString(buffer, 20 + leftTransition, 45);
|
font->DrawString(buffer, 20 + leftTransition, 45);
|
||||||
sprintf(buffer, _("Victory ratio: %i%%").c_str(), stw->percentVictories);
|
sprintf(buffer, _("Victory ratio: %i%%").c_str(), mStatsWrapper->percentVictories);
|
||||||
font->DrawString(buffer, 20 + leftTransition, 55);
|
font->DrawString(buffer, 20 + leftTransition, 55);
|
||||||
|
|
||||||
int AIsPerColumn = 19;
|
int AIsPerColumn = 19;
|
||||||
@@ -1242,13 +1235,13 @@ void GameStateDeckViewer::renderOnScreenMenu()
|
|||||||
posX = 20;
|
posX = 20;
|
||||||
|
|
||||||
// ToDo: Multiple pages when too many AI decks are present
|
// ToDo: Multiple pages when too many AI decks are present
|
||||||
for (int i = 0; i < (int) stw->aiDeckStats.size(); i++)
|
for (int i = 0; i < (int) mStatsWrapper->aiDeckStats.size(); i++)
|
||||||
{
|
{
|
||||||
sprintf(buffer, _("%.14s").c_str(), stw->aiDeckNames.at(i).c_str());
|
sprintf(buffer, _("%.14s").c_str(), mStatsWrapper->aiDeckNames.at(i).c_str());
|
||||||
font->DrawString(buffer, posX + (i < 2 * AIsPerColumn ? leftTransition : rightTransition), posY);
|
font->DrawString(buffer, posX + (i < 2 * AIsPerColumn ? leftTransition : rightTransition), posY);
|
||||||
sprintf(buffer, _("%i/%i").c_str(), stw->aiDeckStats.at(i)->victories, stw->aiDeckStats.at(i)->nbgames);
|
sprintf(buffer, _("%i/%i").c_str(), mStatsWrapper->aiDeckStats.at(i)->victories, mStatsWrapper->aiDeckStats.at(i)->nbgames);
|
||||||
font->DrawString(buffer, posX + (i < AIsPerColumn ? leftTransition : rightTransition) + 80, posY);
|
font->DrawString(buffer, posX + (i < AIsPerColumn ? leftTransition : rightTransition) + 80, posY);
|
||||||
sprintf(buffer, _("%i%%").c_str(), stw->aiDeckStats.at(i)->percentVictories());
|
sprintf(buffer, _("%i%%").c_str(), mStatsWrapper->aiDeckStats.at(i)->percentVictories());
|
||||||
font->DrawString(buffer, posX + (i < AIsPerColumn ? leftTransition : rightTransition) + 110, posY);
|
font->DrawString(buffer, posX + (i < AIsPerColumn ? leftTransition : rightTransition) + 110, posY);
|
||||||
posY += 10;
|
posY += 10;
|
||||||
if (((i + 1) % AIsPerColumn) == 0)
|
if (((i + 1) % AIsPerColumn) == 0)
|
||||||
@@ -1299,7 +1292,7 @@ void GameStateDeckViewer::Render()
|
|||||||
if (mStage == STAGE_MENU)
|
if (mStage == STAGE_MENU)
|
||||||
{
|
{
|
||||||
setButtonState(false);
|
setButtonState(false);
|
||||||
menu->Render();
|
deckMenu->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subMenu) subMenu->Render();
|
if (subMenu) subMenu->Render();
|
||||||
@@ -1318,15 +1311,15 @@ void GameStateDeckViewer::Render()
|
|||||||
int GameStateDeckViewer::loadDeck(int deckid)
|
int GameStateDeckViewer::loadDeck(int deckid)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!stw)
|
if (!mStatsWrapper)
|
||||||
{
|
{
|
||||||
DeckManager *deckManager = DeckManager::GetInstance();
|
DeckManager *deckManager = DeckManager::GetInstance();
|
||||||
stw = deckManager->getExtendedStatsForDeckId( deckid, MTGCollection(), false );
|
mStatsWrapper = deckManager->getExtendedStatsForDeckId( deckid, MTGCollection(), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
stw->currentPage = 0;
|
mStatsWrapper->currentPage = 0;
|
||||||
stw->pageCount = 9;
|
mStatsWrapper->pageCount = 9;
|
||||||
stw->needUpdate = true;
|
mStatsWrapper->needUpdate = true;
|
||||||
|
|
||||||
if (!playerdata) playerdata = NEW PlayerData(MTGCollection());
|
if (!playerdata) playerdata = NEW PlayerData(MTGCollection());
|
||||||
SAFE_DELETE(myCollection);
|
SAFE_DELETE(myCollection);
|
||||||
@@ -1496,13 +1489,14 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
|
|||||||
if (card)
|
if (card)
|
||||||
{
|
{
|
||||||
int rnd = (rand() % 25);
|
int rnd = (rand() % 25);
|
||||||
|
int price = pricelist->getSellPrice(card);
|
||||||
playerdata->credits += price;
|
playerdata->credits += price;
|
||||||
price = price - (rnd * price) / 100;
|
price = price - (rnd * price) / 100;
|
||||||
pricelist->setPrice(card->getMTGId(), price);
|
pricelist->setPrice(card->getMTGId(), price);
|
||||||
playerdata->collection->remove(card->getMTGId());
|
playerdata->collection->remove(card->getMTGId());
|
||||||
mView->deck()->Remove(card, 1);
|
mView->deck()->Remove(card, 1);
|
||||||
mView->deck()->validate();
|
mView->deck()->validate();
|
||||||
stw->needUpdate = true;
|
mStatsWrapper->needUpdate = true;
|
||||||
mView->reloadIndexes();
|
mView->reloadIndexes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,8 +259,8 @@ void GameStateShop::cancelCard(int controlId)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
price = price - (rnd * price) / 100;
|
price = price - (rnd * price) / 100;
|
||||||
if (price < pricelist->getPrice(c->getMTGId())) //filters have a tendancy to increase the price instead of lowering it!
|
if (price < pricelist->getPrice(c)) //filters have a tendancy to increase the price instead of lowering it!
|
||||||
pricelist->setPrice(c->getMTGId(), price);
|
pricelist->setPrice(c, price);
|
||||||
//Prices do not immediately go down when you ignore something.
|
//Prices do not immediately go down when you ignore something.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,18 +35,14 @@ void GridDeckView::UpdateViewState(float dt)
|
|||||||
|
|
||||||
if(mScrollOffset <= -1.0f)
|
if(mScrollOffset <= -1.0f)
|
||||||
{
|
{
|
||||||
deck()->next();
|
SwitchPosition(2);
|
||||||
deck()->next();
|
|
||||||
mScrollEasing.translate(1.0f);
|
mScrollEasing.translate(1.0f);
|
||||||
reloadIndexes();
|
|
||||||
mCurrentSelection = (mCurrentSelection >= 6) ? mCurrentSelection - 2 : -1;
|
mCurrentSelection = (mCurrentSelection >= 6) ? mCurrentSelection - 2 : -1;
|
||||||
}
|
}
|
||||||
else if(mScrollOffset >= 1.0f)
|
else if(mScrollOffset >= 1.0f)
|
||||||
{
|
{
|
||||||
deck()->prev();
|
SwitchPosition(-2);
|
||||||
deck()->prev();
|
|
||||||
mScrollEasing.translate(-1.0f);
|
mScrollEasing.translate(-1.0f);
|
||||||
reloadIndexes();
|
|
||||||
mCurrentSelection = (mCurrentSelection >= 0 && mCurrentSelection < 10) ? mCurrentSelection + 2 : -1;
|
mCurrentSelection = (mCurrentSelection >= 0 && mCurrentSelection < 10) ? mCurrentSelection + 2 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,12 +47,12 @@ int PriceList::save()
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int PriceList::getPrice(int cardId)
|
int PriceList::getPrice(MTGCard * card)
|
||||||
{
|
{
|
||||||
map<int, int>::iterator it = prices.find(cardId);
|
map<int, int>::iterator it = prices.find(card->getId());
|
||||||
if (it != prices.end()) return (*it).second;
|
if (it != prices.end()) return (*it).second;
|
||||||
|
|
||||||
char rarity = collection->getCardById(cardId)->getRarity();
|
char rarity = card->getRarity();
|
||||||
switch (rarity)
|
switch (rarity)
|
||||||
{
|
{
|
||||||
case Constants::RARITY_M:
|
case Constants::RARITY_M:
|
||||||
@@ -77,7 +77,11 @@ int PriceList::getPrice(int cardId)
|
|||||||
return Constants::PRICE_1C;
|
return Constants::PRICE_1C;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int PriceList::getPrice(int cardId)
|
||||||
|
{
|
||||||
|
return getPrice(collection->getCardById(cardId));
|
||||||
}
|
}
|
||||||
|
|
||||||
int PriceList::setPrice(int cardId, int price)
|
int PriceList::setPrice(int cardId, int price)
|
||||||
@@ -85,10 +89,23 @@ int PriceList::setPrice(int cardId, int price)
|
|||||||
prices[cardId] = price;
|
prices[cardId] = price;
|
||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PriceList::setPrice(MTGCard * card, int price)
|
||||||
|
{
|
||||||
|
prices[card->getId()] = price;
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
int PriceList::getSellPrice(int cardid)
|
int PriceList::getSellPrice(int cardid)
|
||||||
{
|
{
|
||||||
return getPrice(cardid);
|
return getPrice(collection->getCardById(cardid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PriceList::getSellPrice(MTGCard *card)
|
||||||
|
{
|
||||||
|
return getPrice(card);
|
||||||
|
}
|
||||||
|
|
||||||
float PriceList::difficultyScalar(float price, int cardid)
|
float PriceList::difficultyScalar(float price, int cardid)
|
||||||
{
|
{
|
||||||
float badluck = (float) (abs(cardid + randomKey) % 201) / 100; //Float between 0 and 2.
|
float badluck = (float) (abs(cardid + randomKey) % 201) / 100; //Float between 0 and 2.
|
||||||
|
|||||||
Reference in New Issue
Block a user