Forcing LF as the line ending style through SVN properties. No actual code changes here.
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
#pragma once
|
||||
#include "DeckMenu.h"
|
||||
#include "DeckDataWrapper.h"
|
||||
#include "DeckStats.h"
|
||||
|
||||
class DeckEditorMenu: public DeckMenu
|
||||
{
|
||||
protected:
|
||||
string deckTitle;
|
||||
|
||||
private:
|
||||
void drawDeckStatistics();
|
||||
|
||||
DeckDataWrapper *selectedDeck;
|
||||
StatsWrapper *stw;
|
||||
|
||||
public:
|
||||
DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const char * _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL);
|
||||
void Render();
|
||||
~DeckEditorMenu();
|
||||
};
|
||||
#pragma once
|
||||
#include "DeckMenu.h"
|
||||
#include "DeckDataWrapper.h"
|
||||
#include "DeckStats.h"
|
||||
|
||||
class DeckEditorMenu: public DeckMenu
|
||||
{
|
||||
protected:
|
||||
string deckTitle;
|
||||
|
||||
private:
|
||||
void drawDeckStatistics();
|
||||
|
||||
DeckDataWrapper *selectedDeck;
|
||||
StatsWrapper *stw;
|
||||
|
||||
public:
|
||||
DeckEditorMenu(int id, JGuiListener* listener = NULL, int fontId = 1, const char * _title = "", DeckDataWrapper *selectedDeck = NULL, StatsWrapper *stats = NULL);
|
||||
void Render();
|
||||
~DeckEditorMenu();
|
||||
};
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "DeckMetaData.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class DeckManager
|
||||
{
|
||||
private:
|
||||
static bool instanceFlag;
|
||||
static DeckManager *mInstance;
|
||||
DeckManager()
|
||||
{
|
||||
//private constructor
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
vector<DeckMetaData *> playerDeckOrderList;
|
||||
vector<DeckMetaData *> aiDeckOrderList;
|
||||
|
||||
map<string, StatsWrapper *> playerDeckStatsMap;
|
||||
map<string, StatsWrapper *> aiDeckStatsMap;
|
||||
|
||||
void updateMetaDataList(vector<DeckMetaData *>* refList, bool isAI);
|
||||
vector<DeckMetaData *> * getPlayerDeckOrderList();
|
||||
vector<DeckMetaData *> * getAIDeckOrderList();
|
||||
|
||||
DeckMetaData * getDeckMetaDataById( int deckId, bool isAI );
|
||||
StatsWrapper * getExtendedStatsForDeckId( int deckId, MTGAllCards *collection, bool isAI );
|
||||
StatsWrapper * getExtendedDeckStats( DeckMetaData *selectedDeck, MTGAllCards *collection, bool isAI );
|
||||
static DeckManager * GetInstance();
|
||||
static void EndInstance();
|
||||
|
||||
//convenience method to get the difficulty rating between two decks. This should be refined a little more
|
||||
//since the eventual move of all deck meta data should be managed by this class
|
||||
|
||||
static int getDifficultyRating(Player *statsPlayer, Player *player);
|
||||
|
||||
~DeckManager();
|
||||
|
||||
};
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "DeckMetaData.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class DeckManager
|
||||
{
|
||||
private:
|
||||
static bool instanceFlag;
|
||||
static DeckManager *mInstance;
|
||||
DeckManager()
|
||||
{
|
||||
//private constructor
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
vector<DeckMetaData *> playerDeckOrderList;
|
||||
vector<DeckMetaData *> aiDeckOrderList;
|
||||
|
||||
map<string, StatsWrapper *> playerDeckStatsMap;
|
||||
map<string, StatsWrapper *> aiDeckStatsMap;
|
||||
|
||||
void updateMetaDataList(vector<DeckMetaData *>* refList, bool isAI);
|
||||
vector<DeckMetaData *> * getPlayerDeckOrderList();
|
||||
vector<DeckMetaData *> * getAIDeckOrderList();
|
||||
|
||||
DeckMetaData * getDeckMetaDataById( int deckId, bool isAI );
|
||||
StatsWrapper * getExtendedStatsForDeckId( int deckId, MTGAllCards *collection, bool isAI );
|
||||
StatsWrapper * getExtendedDeckStats( DeckMetaData *selectedDeck, MTGAllCards *collection, bool isAI );
|
||||
static DeckManager * GetInstance();
|
||||
static void EndInstance();
|
||||
|
||||
//convenience method to get the difficulty rating between two decks. This should be refined a little more
|
||||
//since the eventual move of all deck meta data should be managed by this class
|
||||
|
||||
static int getDifficultyRating(Player *statsPlayer, Player *player);
|
||||
|
||||
~DeckManager();
|
||||
|
||||
};
|
||||
|
||||
@@ -1,84 +1,84 @@
|
||||
/*
|
||||
A class for menus with a fixed layout
|
||||
*/
|
||||
#ifndef _DeckMenu_H_
|
||||
#define _DeckMenu_H_
|
||||
|
||||
#include <string>
|
||||
#include "WFont.h"
|
||||
#include "hge/hgeparticle.h"
|
||||
#include "DeckMetaData.h"
|
||||
#include "TextScroller.h"
|
||||
|
||||
class DeckMenu: public JGuiController
|
||||
{
|
||||
protected:
|
||||
|
||||
float mHeight, mWidth, mX, mY;
|
||||
float titleX, titleY, titleWidth;
|
||||
float descX, descY, descHeight, descWidth;
|
||||
float statsX, statsY, statsHeight, statsWidth;
|
||||
float avatarX, avatarY;
|
||||
float detailedInfoBoxX, detailedInfoBoxY;
|
||||
float starsOffsetX;
|
||||
|
||||
bool menuInitialized;
|
||||
string backgroundName;
|
||||
|
||||
int fontId;
|
||||
string title;
|
||||
string displayTitle;
|
||||
WFont * mFont;
|
||||
float titleFontScale;
|
||||
|
||||
int maxItems, startId;
|
||||
|
||||
float selectionT, selectionY;
|
||||
float timeOpen;
|
||||
|
||||
static hgeParticleSystem* stars;
|
||||
|
||||
void initMenuItems();
|
||||
string getDescription();
|
||||
string getMetaInformation();
|
||||
DeckMetaData *mSelectedDeck;
|
||||
int mSelectedDeckId;
|
||||
bool mShowDetailsScreen;
|
||||
bool mAlwaysShowDetailsButton;
|
||||
bool mClosed;
|
||||
|
||||
public:
|
||||
VerticalTextScroller * mScroller;
|
||||
bool mAutoTranslate;
|
||||
float mSelectionTargetY;
|
||||
|
||||
//used for detailed info button
|
||||
JQuad * pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
|
||||
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const int& startIndex = 0, bool alwaysShowDetailsButton = false);
|
||||
~DeckMenu();
|
||||
|
||||
DeckMetaData * getSelectedDeck();
|
||||
void enableDisplayDetailsOverride();
|
||||
bool showDetailsScreen();
|
||||
bool isClosed()
|
||||
{
|
||||
return mClosed;
|
||||
}
|
||||
int getSelectedDeckId()
|
||||
{
|
||||
return mSelectedDeckId;
|
||||
}
|
||||
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
|
||||
void Close();
|
||||
void updateScroller();
|
||||
void RenderBackground();
|
||||
|
||||
static void destroy();
|
||||
};
|
||||
|
||||
#endif
|
||||
/*
|
||||
A class for menus with a fixed layout
|
||||
*/
|
||||
#ifndef _DeckMenu_H_
|
||||
#define _DeckMenu_H_
|
||||
|
||||
#include <string>
|
||||
#include "WFont.h"
|
||||
#include "hge/hgeparticle.h"
|
||||
#include "DeckMetaData.h"
|
||||
#include "TextScroller.h"
|
||||
|
||||
class DeckMenu: public JGuiController
|
||||
{
|
||||
protected:
|
||||
|
||||
float mHeight, mWidth, mX, mY;
|
||||
float titleX, titleY, titleWidth;
|
||||
float descX, descY, descHeight, descWidth;
|
||||
float statsX, statsY, statsHeight, statsWidth;
|
||||
float avatarX, avatarY;
|
||||
float detailedInfoBoxX, detailedInfoBoxY;
|
||||
float starsOffsetX;
|
||||
|
||||
bool menuInitialized;
|
||||
string backgroundName;
|
||||
|
||||
int fontId;
|
||||
string title;
|
||||
string displayTitle;
|
||||
WFont * mFont;
|
||||
float titleFontScale;
|
||||
|
||||
int maxItems, startId;
|
||||
|
||||
float selectionT, selectionY;
|
||||
float timeOpen;
|
||||
|
||||
static hgeParticleSystem* stars;
|
||||
|
||||
void initMenuItems();
|
||||
string getDescription();
|
||||
string getMetaInformation();
|
||||
DeckMetaData *mSelectedDeck;
|
||||
int mSelectedDeckId;
|
||||
bool mShowDetailsScreen;
|
||||
bool mAlwaysShowDetailsButton;
|
||||
bool mClosed;
|
||||
|
||||
public:
|
||||
VerticalTextScroller * mScroller;
|
||||
bool mAutoTranslate;
|
||||
float mSelectionTargetY;
|
||||
|
||||
//used for detailed info button
|
||||
JQuad * pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
|
||||
DeckMenu(int id, JGuiListener* listener, int fontId, const string _title = "", const int& startIndex = 0, bool alwaysShowDetailsButton = false);
|
||||
~DeckMenu();
|
||||
|
||||
DeckMetaData * getSelectedDeck();
|
||||
void enableDisplayDetailsOverride();
|
||||
bool showDetailsScreen();
|
||||
bool isClosed()
|
||||
{
|
||||
return mClosed;
|
||||
}
|
||||
int getSelectedDeckId()
|
||||
{
|
||||
return mSelectedDeckId;
|
||||
}
|
||||
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(int id, const char * Text, string desc = "", bool forceFocus = false, DeckMetaData *deckMetaData = NULL);
|
||||
void Close();
|
||||
void updateScroller();
|
||||
void RenderBackground();
|
||||
|
||||
static void destroy();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,109 +1,109 @@
|
||||
#ifndef _DECKSTATS_H_
|
||||
#define _DECKSTATS_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "MTGDefinitions.h"
|
||||
#include <DeckDataWrapper.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Player;
|
||||
class GameObserver;
|
||||
|
||||
class DeckStat
|
||||
{
|
||||
public:
|
||||
DeckStat(int _nbgames = 0, int _victories = 0);
|
||||
|
||||
int nbgames;
|
||||
int victories;
|
||||
int percentVictories();
|
||||
};
|
||||
|
||||
class DeckStats
|
||||
{
|
||||
protected:
|
||||
static DeckStats * mInstance;
|
||||
public:
|
||||
//map<string, DeckStat *> stats; // current set of statistics
|
||||
string currentDeck;
|
||||
map<string, map<string,DeckStat*> > masterDeckStats;
|
||||
|
||||
static DeckStats * GetInstance();
|
||||
static void EndInstance();
|
||||
void saveStats(Player * player, Player * opponent, GameObserver * game);
|
||||
void save(const char * filename);
|
||||
void save(Player * player);
|
||||
void load(const char * filename);
|
||||
void load(Player * player);
|
||||
void cleanStats();
|
||||
~DeckStats();
|
||||
int percentVictories(string opponentsDeckFile);
|
||||
int percentVictories();
|
||||
DeckStat * getDeckStat(string opponentsFile);
|
||||
|
||||
//returns the total number of games played with this deck
|
||||
int nbGames();
|
||||
};
|
||||
|
||||
class StatsWrapper
|
||||
{
|
||||
private:
|
||||
void initValues();
|
||||
|
||||
public:
|
||||
StatsWrapper(int deckId);
|
||||
StatsWrapper(string filename);
|
||||
~StatsWrapper();
|
||||
|
||||
void initStatistics(string deckstats);
|
||||
|
||||
// Stats parameters and status
|
||||
int mDeckId;
|
||||
int currentPage;
|
||||
int pageCount;
|
||||
bool needUpdate;
|
||||
|
||||
// Actual stats
|
||||
int percentVictories;
|
||||
int gamesPlayed;
|
||||
int cardCount;
|
||||
int countLands;
|
||||
int totalPrice;
|
||||
int totalManaCost;
|
||||
float avgManaCost;
|
||||
int totalCreatureCost;
|
||||
float avgCreatureCost;
|
||||
int totalSpellCost;
|
||||
float avgSpellCost;
|
||||
int countManaProducers;
|
||||
|
||||
int countCreatures, countSpells, countInstants, countEnchantments, countSorceries, countArtifacts;
|
||||
|
||||
float noLandsProbInTurn[Constants::STATS_FOR_TURNS];
|
||||
float noCreaturesProbInTurn[Constants::STATS_FOR_TURNS];
|
||||
|
||||
int countCardsPerCost[Constants::STATS_MAX_MANA_COST + 1];
|
||||
int countCardsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||
int countCreaturesPerCost[Constants::STATS_MAX_MANA_COST + 1];
|
||||
int countCreaturesPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||
int countSpellsPerCost[Constants::STATS_MAX_MANA_COST + 1];
|
||||
int countSpellsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||
int countLandsPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int countBasicLandsPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int countNonLandProducersPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int totalCostPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int totalColoredSymbols;
|
||||
|
||||
void updateStats(string filename, MTGAllCards * collection);
|
||||
void updateStats(DeckDataWrapper *mtgDeck);
|
||||
int countCardsByType(const char * _type, DeckDataWrapper * myDeck);
|
||||
float noLuck(int n, int a, int x);
|
||||
|
||||
vector<string> aiDeckNames;
|
||||
vector<DeckStat*> aiDeckStats;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _DECKSTATS_H_
|
||||
#define _DECKSTATS_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "MTGDefinitions.h"
|
||||
#include <DeckDataWrapper.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class Player;
|
||||
class GameObserver;
|
||||
|
||||
class DeckStat
|
||||
{
|
||||
public:
|
||||
DeckStat(int _nbgames = 0, int _victories = 0);
|
||||
|
||||
int nbgames;
|
||||
int victories;
|
||||
int percentVictories();
|
||||
};
|
||||
|
||||
class DeckStats
|
||||
{
|
||||
protected:
|
||||
static DeckStats * mInstance;
|
||||
public:
|
||||
//map<string, DeckStat *> stats; // current set of statistics
|
||||
string currentDeck;
|
||||
map<string, map<string,DeckStat*> > masterDeckStats;
|
||||
|
||||
static DeckStats * GetInstance();
|
||||
static void EndInstance();
|
||||
void saveStats(Player * player, Player * opponent, GameObserver * game);
|
||||
void save(const char * filename);
|
||||
void save(Player * player);
|
||||
void load(const char * filename);
|
||||
void load(Player * player);
|
||||
void cleanStats();
|
||||
~DeckStats();
|
||||
int percentVictories(string opponentsDeckFile);
|
||||
int percentVictories();
|
||||
DeckStat * getDeckStat(string opponentsFile);
|
||||
|
||||
//returns the total number of games played with this deck
|
||||
int nbGames();
|
||||
};
|
||||
|
||||
class StatsWrapper
|
||||
{
|
||||
private:
|
||||
void initValues();
|
||||
|
||||
public:
|
||||
StatsWrapper(int deckId);
|
||||
StatsWrapper(string filename);
|
||||
~StatsWrapper();
|
||||
|
||||
void initStatistics(string deckstats);
|
||||
|
||||
// Stats parameters and status
|
||||
int mDeckId;
|
||||
int currentPage;
|
||||
int pageCount;
|
||||
bool needUpdate;
|
||||
|
||||
// Actual stats
|
||||
int percentVictories;
|
||||
int gamesPlayed;
|
||||
int cardCount;
|
||||
int countLands;
|
||||
int totalPrice;
|
||||
int totalManaCost;
|
||||
float avgManaCost;
|
||||
int totalCreatureCost;
|
||||
float avgCreatureCost;
|
||||
int totalSpellCost;
|
||||
float avgSpellCost;
|
||||
int countManaProducers;
|
||||
|
||||
int countCreatures, countSpells, countInstants, countEnchantments, countSorceries, countArtifacts;
|
||||
|
||||
float noLandsProbInTurn[Constants::STATS_FOR_TURNS];
|
||||
float noCreaturesProbInTurn[Constants::STATS_FOR_TURNS];
|
||||
|
||||
int countCardsPerCost[Constants::STATS_MAX_MANA_COST + 1];
|
||||
int countCardsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||
int countCreaturesPerCost[Constants::STATS_MAX_MANA_COST + 1];
|
||||
int countCreaturesPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||
int countSpellsPerCost[Constants::STATS_MAX_MANA_COST + 1];
|
||||
int countSpellsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1];
|
||||
int countLandsPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int countBasicLandsPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int countNonLandProducersPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int totalCostPerColor[Constants::MTG_NB_COLORS + 1];
|
||||
int totalColoredSymbols;
|
||||
|
||||
void updateStats(string filename, MTGAllCards * collection);
|
||||
void updateStats(DeckDataWrapper *mtgDeck);
|
||||
int countCardsByType(const char * _type, DeckDataWrapper * myDeck);
|
||||
float noLuck(int n, int a, int x);
|
||||
|
||||
vector<string> aiDeckNames;
|
||||
vector<DeckStat*> aiDeckStats;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,153 +1,153 @@
|
||||
#ifndef _EXTRACOST_H_
|
||||
#define _EXTRACOST_H_
|
||||
|
||||
#include <vector>
|
||||
#include "Counters.h"
|
||||
using std::vector;
|
||||
|
||||
class TargetChooser;
|
||||
class MTGCardInstance;
|
||||
class MTGAbility;
|
||||
|
||||
class ExtraCost{
|
||||
public:
|
||||
TargetChooser * tc;
|
||||
MTGCardInstance * source;
|
||||
MTGCardInstance * target;
|
||||
MTGCardInstance * targets[20];
|
||||
std::string mCostRenderString;
|
||||
|
||||
ExtraCost(const std::string& inCostRenderString, TargetChooser *_tc = NULL);
|
||||
virtual ~ExtraCost();
|
||||
virtual int setPayment(MTGCardInstance * card);
|
||||
virtual int isPaymentSet() { return (target != NULL && targets != NULL); }
|
||||
virtual int canPay() { return 1; }
|
||||
virtual int doPay() = 0;
|
||||
virtual void Render();
|
||||
virtual int setSource(MTGCardInstance * _source);
|
||||
virtual ExtraCost* clone() const = 0;
|
||||
};
|
||||
|
||||
class ExtraCosts{
|
||||
public:
|
||||
vector<ExtraCost *>costs;
|
||||
MTGCardInstance * source;
|
||||
MTGAbility * action;
|
||||
ExtraCosts();
|
||||
~ExtraCosts();
|
||||
void Render();
|
||||
int tryToSetPayment(MTGCardInstance * card);
|
||||
int isPaymentSet();
|
||||
int canPay();
|
||||
int doPay();
|
||||
int reset();
|
||||
int setAction(MTGAbility * _action, MTGCardInstance * _source);
|
||||
void Dump();
|
||||
ExtraCosts * clone() const;
|
||||
};
|
||||
|
||||
class SacrificeCost: public ExtraCost{
|
||||
public:
|
||||
SacrificeCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual SacrificeCost * clone() const;
|
||||
};
|
||||
|
||||
//life cost
|
||||
class LifeCost: public ExtraCost{
|
||||
public:
|
||||
LifeCost(TargetChooser *_tc = NULL);
|
||||
|
||||
virtual int doPay();
|
||||
virtual LifeCost * clone() const;
|
||||
};
|
||||
|
||||
//Discard a random card cost
|
||||
class DiscardRandomCost: public ExtraCost{
|
||||
public:
|
||||
DiscardRandomCost(TargetChooser *_tc = NULL);
|
||||
virtual int canPay();
|
||||
virtual int doPay();
|
||||
virtual DiscardRandomCost * clone() const;
|
||||
};
|
||||
|
||||
//a choosen discard
|
||||
class DiscardCost: public ExtraCost{
|
||||
public:
|
||||
DiscardCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual DiscardCost * clone() const;
|
||||
};
|
||||
|
||||
//tolibrary cost
|
||||
class ToLibraryCost: public ExtraCost{
|
||||
public:
|
||||
ToLibraryCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual ToLibraryCost * clone() const;
|
||||
};
|
||||
|
||||
//Millyourself cost
|
||||
class MillCost: public ExtraCost{
|
||||
public:
|
||||
MillCost(TargetChooser *_tc = NULL);
|
||||
virtual int canPay();
|
||||
virtual int doPay();
|
||||
virtual MillCost * clone() const;
|
||||
};
|
||||
|
||||
//Mill to exile yourself cost
|
||||
class MillExileCost: public MillCost{
|
||||
public:
|
||||
MillExileCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
};
|
||||
|
||||
//tap other cost
|
||||
class TapTargetCost: public ExtraCost{
|
||||
public:
|
||||
TapTargetCost(TargetChooser *_tc = NULL);
|
||||
virtual int isPaymentSet();
|
||||
virtual int doPay();
|
||||
virtual TapTargetCost * clone() const;
|
||||
};
|
||||
|
||||
//exile as cost
|
||||
class ExileTargetCost: public ExtraCost{
|
||||
public:
|
||||
ExileTargetCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual ExileTargetCost * clone() const;
|
||||
};
|
||||
|
||||
//bounce cost
|
||||
class BounceTargetCost: public ExtraCost{
|
||||
public:
|
||||
BounceTargetCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual BounceTargetCost * clone() const;
|
||||
};
|
||||
|
||||
//bounce cost
|
||||
class Ninja: public ExtraCost{
|
||||
public:
|
||||
Ninja(TargetChooser *_tc = NULL);
|
||||
virtual int isPaymentSet();
|
||||
virtual int doPay();
|
||||
virtual Ninja * clone() const;
|
||||
};
|
||||
|
||||
class CounterCost: public ExtraCost{
|
||||
public:
|
||||
Counter * counter;
|
||||
int hasCounters;
|
||||
CounterCost(Counter * _counter,TargetChooser *_tc = NULL);
|
||||
~CounterCost();
|
||||
virtual int setPayment(MTGCardInstance * card);
|
||||
virtual int isPaymentSet();
|
||||
virtual int canPay();
|
||||
virtual int doPay();
|
||||
virtual CounterCost * clone() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _EXTRACOST_H_
|
||||
#define _EXTRACOST_H_
|
||||
|
||||
#include <vector>
|
||||
#include "Counters.h"
|
||||
using std::vector;
|
||||
|
||||
class TargetChooser;
|
||||
class MTGCardInstance;
|
||||
class MTGAbility;
|
||||
|
||||
class ExtraCost{
|
||||
public:
|
||||
TargetChooser * tc;
|
||||
MTGCardInstance * source;
|
||||
MTGCardInstance * target;
|
||||
MTGCardInstance * targets[20];
|
||||
std::string mCostRenderString;
|
||||
|
||||
ExtraCost(const std::string& inCostRenderString, TargetChooser *_tc = NULL);
|
||||
virtual ~ExtraCost();
|
||||
virtual int setPayment(MTGCardInstance * card);
|
||||
virtual int isPaymentSet() { return (target != NULL && targets != NULL); }
|
||||
virtual int canPay() { return 1; }
|
||||
virtual int doPay() = 0;
|
||||
virtual void Render();
|
||||
virtual int setSource(MTGCardInstance * _source);
|
||||
virtual ExtraCost* clone() const = 0;
|
||||
};
|
||||
|
||||
class ExtraCosts{
|
||||
public:
|
||||
vector<ExtraCost *>costs;
|
||||
MTGCardInstance * source;
|
||||
MTGAbility * action;
|
||||
ExtraCosts();
|
||||
~ExtraCosts();
|
||||
void Render();
|
||||
int tryToSetPayment(MTGCardInstance * card);
|
||||
int isPaymentSet();
|
||||
int canPay();
|
||||
int doPay();
|
||||
int reset();
|
||||
int setAction(MTGAbility * _action, MTGCardInstance * _source);
|
||||
void Dump();
|
||||
ExtraCosts * clone() const;
|
||||
};
|
||||
|
||||
class SacrificeCost: public ExtraCost{
|
||||
public:
|
||||
SacrificeCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual SacrificeCost * clone() const;
|
||||
};
|
||||
|
||||
//life cost
|
||||
class LifeCost: public ExtraCost{
|
||||
public:
|
||||
LifeCost(TargetChooser *_tc = NULL);
|
||||
|
||||
virtual int doPay();
|
||||
virtual LifeCost * clone() const;
|
||||
};
|
||||
|
||||
//Discard a random card cost
|
||||
class DiscardRandomCost: public ExtraCost{
|
||||
public:
|
||||
DiscardRandomCost(TargetChooser *_tc = NULL);
|
||||
virtual int canPay();
|
||||
virtual int doPay();
|
||||
virtual DiscardRandomCost * clone() const;
|
||||
};
|
||||
|
||||
//a choosen discard
|
||||
class DiscardCost: public ExtraCost{
|
||||
public:
|
||||
DiscardCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual DiscardCost * clone() const;
|
||||
};
|
||||
|
||||
//tolibrary cost
|
||||
class ToLibraryCost: public ExtraCost{
|
||||
public:
|
||||
ToLibraryCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual ToLibraryCost * clone() const;
|
||||
};
|
||||
|
||||
//Millyourself cost
|
||||
class MillCost: public ExtraCost{
|
||||
public:
|
||||
MillCost(TargetChooser *_tc = NULL);
|
||||
virtual int canPay();
|
||||
virtual int doPay();
|
||||
virtual MillCost * clone() const;
|
||||
};
|
||||
|
||||
//Mill to exile yourself cost
|
||||
class MillExileCost: public MillCost{
|
||||
public:
|
||||
MillExileCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
};
|
||||
|
||||
//tap other cost
|
||||
class TapTargetCost: public ExtraCost{
|
||||
public:
|
||||
TapTargetCost(TargetChooser *_tc = NULL);
|
||||
virtual int isPaymentSet();
|
||||
virtual int doPay();
|
||||
virtual TapTargetCost * clone() const;
|
||||
};
|
||||
|
||||
//exile as cost
|
||||
class ExileTargetCost: public ExtraCost{
|
||||
public:
|
||||
ExileTargetCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual ExileTargetCost * clone() const;
|
||||
};
|
||||
|
||||
//bounce cost
|
||||
class BounceTargetCost: public ExtraCost{
|
||||
public:
|
||||
BounceTargetCost(TargetChooser *_tc = NULL);
|
||||
virtual int doPay();
|
||||
virtual BounceTargetCost * clone() const;
|
||||
};
|
||||
|
||||
//bounce cost
|
||||
class Ninja: public ExtraCost{
|
||||
public:
|
||||
Ninja(TargetChooser *_tc = NULL);
|
||||
virtual int isPaymentSet();
|
||||
virtual int doPay();
|
||||
virtual Ninja * clone() const;
|
||||
};
|
||||
|
||||
class CounterCost: public ExtraCost{
|
||||
public:
|
||||
Counter * counter;
|
||||
int hasCounters;
|
||||
CounterCost(Counter * _counter,TargetChooser *_tc = NULL);
|
||||
~CounterCost();
|
||||
virtual int setPayment(MTGCardInstance * card);
|
||||
virtual int isPaymentSet();
|
||||
virtual int canPay();
|
||||
virtual int doPay();
|
||||
virtual CounterCost * clone() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,152 +1,152 @@
|
||||
#ifndef _GAME_STATE_DECK_VIEWER_H_
|
||||
#define _GAME_STATE_DECK_VIEWER_H_
|
||||
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <JGE.h>
|
||||
|
||||
#include "GameState.h"
|
||||
#include "DeckEditorMenu.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "WResourceManager.h"
|
||||
#include "CardGui.h"
|
||||
#include "GameOptions.h"
|
||||
#include "PriceList.h"
|
||||
#include "PlayerData.h"
|
||||
#include "DeckDataWrapper.h"
|
||||
#include "DeckStats.h"
|
||||
#include "WDataSrc.h"
|
||||
#include "WGui.h"
|
||||
|
||||
#define NO_USER_ACTIVITY_HELP_DELAY 10
|
||||
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
|
||||
|
||||
enum
|
||||
{
|
||||
STAGE_TRANSITION_RIGHT = 0,
|
||||
STAGE_TRANSITION_LEFT = 1,
|
||||
STAGE_WAITING = 2,
|
||||
STAGE_TRANSITION_UP = 3,
|
||||
STAGE_TRANSITION_DOWN = 4,
|
||||
STAGE_ONSCREEN_MENU = 5,
|
||||
STAGE_WELCOME = 6,
|
||||
STAGE_MENU = 7,
|
||||
STAGE_FILTERS = 8
|
||||
};
|
||||
|
||||
// TODO: need a better name for MENU_FIRST_MENU, this is reused for the 1st submenu of
|
||||
// available options in the duel menu
|
||||
enum
|
||||
{
|
||||
MENU_CARD_PURCHASE = 2,
|
||||
MENU_DECK_SELECTION = 10,
|
||||
MENU_DECK_BUILDER = 11,
|
||||
MENU_FIRST_DUEL_SUBMENU = 102,
|
||||
MENU_LANGUAGE_SELECTION = 103,
|
||||
};
|
||||
|
||||
// enums for menu options
|
||||
// TODO: make these enums a little more descriptive. (ie should reflect what menu they are attached to )
|
||||
enum DECK_VIEWER_MENU_ITEMS
|
||||
{
|
||||
MENU_ITEM_NEW_DECK = -30,
|
||||
MENU_ITEM_CHEAT_MODE = -12,
|
||||
MENU_ITEM_CANCEL = kCancelMenuID,
|
||||
MENU_ITEM_SAVE_RETURN_MAIN_MENU = 0,
|
||||
MENU_ITEM_SAVE_RENAME = 1,
|
||||
MENU_ITEM_SWITCH_DECKS_NO_SAVE = 2,
|
||||
MENU_ITEM_MAIN_MENU = 3,
|
||||
MENU_ITEM_EDITOR_CANCEL = kCancelMenuID,
|
||||
MENU_ITEM_SAVE_AS_AI_DECK = 5,
|
||||
MENU_ITEM_YES = 20,
|
||||
MENU_ITEM_NO = 21,
|
||||
MENU_ITEM_FILTER_BY = 22,
|
||||
MENUITEM_MORE_INFO = kInfoMenuID
|
||||
|
||||
};
|
||||
|
||||
#define ALL_COLORS -1
|
||||
|
||||
#define ROTATE_LEFT 1;
|
||||
#define ROTATE_RIGHT 0;
|
||||
|
||||
#define HIGH_SPEED 15.0
|
||||
#define MED_SPEED 5.0f
|
||||
#define LOW_SPEED 1.5
|
||||
|
||||
#define MAX_SAVED_FILTERS 8
|
||||
#define CARDS_DISPLAYED 7
|
||||
|
||||
class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
JQuad * mIcons[CARDS_DISPLAYED];
|
||||
JQuad * pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
float last_user_activity;
|
||||
float onScreenTransition;
|
||||
float mRotation;
|
||||
float mSlide;
|
||||
int mAlpha;
|
||||
int mStage;
|
||||
int nbDecks;
|
||||
int deckNum;
|
||||
int useFilter;
|
||||
JMusic * bgMusic;
|
||||
JQuad * backQuad;
|
||||
int lastPos;
|
||||
int lastTotal;
|
||||
|
||||
WGuiFilters * filterMenu;
|
||||
WSrcDeckViewer * source;
|
||||
|
||||
DeckEditorMenu * welcome_menu;
|
||||
SimpleMenu * subMenu;
|
||||
DeckEditorMenu * menu;
|
||||
PriceList* pricelist;
|
||||
PlayerData * playerdata;
|
||||
int price;
|
||||
DeckDataWrapper * displayed_deck;
|
||||
DeckDataWrapper * myDeck;
|
||||
DeckDataWrapper * myCollection;
|
||||
MTGCard * cardIndex[CARDS_DISPLAYED];
|
||||
StatsWrapper *stw;
|
||||
|
||||
int hudAlpha;
|
||||
string newDeckname;
|
||||
bool isAIDeckSave;
|
||||
bool mSwitching;
|
||||
void saveDeck(); //Saves the deck and additional necessary information
|
||||
void saveAsAIDeck(string deckName); // saves deck as an AI Deck
|
||||
int getCurrentPos();
|
||||
pair<float, float> cardsCoordinates[CARDS_DISPLAYED];
|
||||
|
||||
public:
|
||||
GameStateDeckViewer(GameApp* parent);
|
||||
virtual ~GameStateDeckViewer();
|
||||
void updateDecks();
|
||||
void rotateCards(int direction);
|
||||
void loadIndexes();
|
||||
void updateFilters();
|
||||
void rebuildFilters();
|
||||
void switchDisplay();
|
||||
void Start();
|
||||
virtual void End();
|
||||
void addRemove(MTGCard * card);
|
||||
virtual void Update(float dt);
|
||||
void renderOnScreenBasicInfo();
|
||||
void renderSlideBar();
|
||||
void renderDeckBackground();
|
||||
void renderOnScreenMenu();
|
||||
virtual void renderCard(int id, float rotation);
|
||||
virtual void renderCard(int id);
|
||||
virtual void Render();
|
||||
int loadDeck(int deckid);
|
||||
void LoadDeckStatistics(int deckId);
|
||||
|
||||
void buildEditorMenu();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _GAME_STATE_DECK_VIEWER_H_
|
||||
#define _GAME_STATE_DECK_VIEWER_H_
|
||||
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <JGE.h>
|
||||
|
||||
#include "GameState.h"
|
||||
#include "DeckEditorMenu.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "WResourceManager.h"
|
||||
#include "CardGui.h"
|
||||
#include "GameOptions.h"
|
||||
#include "PriceList.h"
|
||||
#include "PlayerData.h"
|
||||
#include "DeckDataWrapper.h"
|
||||
#include "DeckStats.h"
|
||||
#include "WDataSrc.h"
|
||||
#include "WGui.h"
|
||||
|
||||
#define NO_USER_ACTIVITY_HELP_DELAY 10
|
||||
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
|
||||
|
||||
enum
|
||||
{
|
||||
STAGE_TRANSITION_RIGHT = 0,
|
||||
STAGE_TRANSITION_LEFT = 1,
|
||||
STAGE_WAITING = 2,
|
||||
STAGE_TRANSITION_UP = 3,
|
||||
STAGE_TRANSITION_DOWN = 4,
|
||||
STAGE_ONSCREEN_MENU = 5,
|
||||
STAGE_WELCOME = 6,
|
||||
STAGE_MENU = 7,
|
||||
STAGE_FILTERS = 8
|
||||
};
|
||||
|
||||
// TODO: need a better name for MENU_FIRST_MENU, this is reused for the 1st submenu of
|
||||
// available options in the duel menu
|
||||
enum
|
||||
{
|
||||
MENU_CARD_PURCHASE = 2,
|
||||
MENU_DECK_SELECTION = 10,
|
||||
MENU_DECK_BUILDER = 11,
|
||||
MENU_FIRST_DUEL_SUBMENU = 102,
|
||||
MENU_LANGUAGE_SELECTION = 103,
|
||||
};
|
||||
|
||||
// enums for menu options
|
||||
// TODO: make these enums a little more descriptive. (ie should reflect what menu they are attached to )
|
||||
enum DECK_VIEWER_MENU_ITEMS
|
||||
{
|
||||
MENU_ITEM_NEW_DECK = -30,
|
||||
MENU_ITEM_CHEAT_MODE = -12,
|
||||
MENU_ITEM_CANCEL = kCancelMenuID,
|
||||
MENU_ITEM_SAVE_RETURN_MAIN_MENU = 0,
|
||||
MENU_ITEM_SAVE_RENAME = 1,
|
||||
MENU_ITEM_SWITCH_DECKS_NO_SAVE = 2,
|
||||
MENU_ITEM_MAIN_MENU = 3,
|
||||
MENU_ITEM_EDITOR_CANCEL = kCancelMenuID,
|
||||
MENU_ITEM_SAVE_AS_AI_DECK = 5,
|
||||
MENU_ITEM_YES = 20,
|
||||
MENU_ITEM_NO = 21,
|
||||
MENU_ITEM_FILTER_BY = 22,
|
||||
MENUITEM_MORE_INFO = kInfoMenuID
|
||||
|
||||
};
|
||||
|
||||
#define ALL_COLORS -1
|
||||
|
||||
#define ROTATE_LEFT 1;
|
||||
#define ROTATE_RIGHT 0;
|
||||
|
||||
#define HIGH_SPEED 15.0
|
||||
#define MED_SPEED 5.0f
|
||||
#define LOW_SPEED 1.5
|
||||
|
||||
#define MAX_SAVED_FILTERS 8
|
||||
#define CARDS_DISPLAYED 7
|
||||
|
||||
class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
JQuad * mIcons[CARDS_DISPLAYED];
|
||||
JQuad * pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
float last_user_activity;
|
||||
float onScreenTransition;
|
||||
float mRotation;
|
||||
float mSlide;
|
||||
int mAlpha;
|
||||
int mStage;
|
||||
int nbDecks;
|
||||
int deckNum;
|
||||
int useFilter;
|
||||
JMusic * bgMusic;
|
||||
JQuad * backQuad;
|
||||
int lastPos;
|
||||
int lastTotal;
|
||||
|
||||
WGuiFilters * filterMenu;
|
||||
WSrcDeckViewer * source;
|
||||
|
||||
DeckEditorMenu * welcome_menu;
|
||||
SimpleMenu * subMenu;
|
||||
DeckEditorMenu * menu;
|
||||
PriceList* pricelist;
|
||||
PlayerData * playerdata;
|
||||
int price;
|
||||
DeckDataWrapper * displayed_deck;
|
||||
DeckDataWrapper * myDeck;
|
||||
DeckDataWrapper * myCollection;
|
||||
MTGCard * cardIndex[CARDS_DISPLAYED];
|
||||
StatsWrapper *stw;
|
||||
|
||||
int hudAlpha;
|
||||
string newDeckname;
|
||||
bool isAIDeckSave;
|
||||
bool mSwitching;
|
||||
void saveDeck(); //Saves the deck and additional necessary information
|
||||
void saveAsAIDeck(string deckName); // saves deck as an AI Deck
|
||||
int getCurrentPos();
|
||||
pair<float, float> cardsCoordinates[CARDS_DISPLAYED];
|
||||
|
||||
public:
|
||||
GameStateDeckViewer(GameApp* parent);
|
||||
virtual ~GameStateDeckViewer();
|
||||
void updateDecks();
|
||||
void rotateCards(int direction);
|
||||
void loadIndexes();
|
||||
void updateFilters();
|
||||
void rebuildFilters();
|
||||
void switchDisplay();
|
||||
void Start();
|
||||
virtual void End();
|
||||
void addRemove(MTGCard * card);
|
||||
virtual void Update(float dt);
|
||||
void renderOnScreenBasicInfo();
|
||||
void renderSlideBar();
|
||||
void renderDeckBackground();
|
||||
void renderOnScreenMenu();
|
||||
virtual void renderCard(int id, float rotation);
|
||||
virtual void renderCard(int id);
|
||||
virtual void Render();
|
||||
int loadDeck(int deckid);
|
||||
void LoadDeckStatistics(int deckId);
|
||||
|
||||
void buildEditorMenu();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
#ifndef _GAME_STATE_DUEL_H_
|
||||
#define _GAME_STATE_DUEL_H_
|
||||
|
||||
#include "GameState.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "SimplePopup.h"
|
||||
#include "DeckMenu.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "GameObserver.h"
|
||||
|
||||
#define CHOOSE_OPPONENT 7
|
||||
|
||||
#ifdef TESTSUITE
|
||||
class TestSuite;
|
||||
#endif
|
||||
class Credits;
|
||||
class Rules;
|
||||
|
||||
class GameStateDuel: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
#ifdef TESTSUITE
|
||||
TestSuite * testSuite;
|
||||
#endif
|
||||
Credits * credits;
|
||||
int mGamePhase;
|
||||
Player * mCurrentPlayer;
|
||||
Player * mPlayers[2];
|
||||
MTGPlayerCards * deck[2];
|
||||
GameObserver * game;
|
||||
DeckMenu * deckmenu;
|
||||
DeckMenu * opponentMenu;
|
||||
SimpleMenu * menu;
|
||||
SimplePopup * popupScreen; // used for informational screens, modal
|
||||
static int selectedPlayerDeckId;
|
||||
static int selectedAIDeckId;
|
||||
|
||||
bool premadeDeck;
|
||||
int OpponentsDeckid;
|
||||
string musictrack;
|
||||
Rules * rules;
|
||||
|
||||
bool MusicExist(string FileName);
|
||||
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
|
||||
void ConstructOpponentMenu(); //loads the opponentMenu if it doesn't exist
|
||||
void initScroller();
|
||||
|
||||
public:
|
||||
GameStateDuel(GameApp* parent);
|
||||
virtual ~GameStateDuel();
|
||||
#ifdef TESTSUITE
|
||||
void loadTestSuitePlayers();
|
||||
#endif
|
||||
virtual void ButtonPressed(int ControllerId, int ControlId);
|
||||
virtual void Start();
|
||||
virtual void End();
|
||||
virtual void Update(float dt);
|
||||
virtual void Render();
|
||||
void initRand(unsigned seed = 0);
|
||||
|
||||
enum ENUM_DUEL_STATE_MENU_ITEM
|
||||
{
|
||||
MENUITEM_CANCEL = kCancelMenuID,
|
||||
MENUITEM_NEW_DECK = -10,
|
||||
MENUITEM_RANDOM_PLAYER = -11,
|
||||
MENUITEM_RANDOM_AI = -12,
|
||||
MENUITEM_MAIN_MENU = -13,
|
||||
MENUITEM_EVIL_TWIN = -14,
|
||||
MENUITEM_MULLIGAN = -15,
|
||||
MENUITEM_MORE_INFO = kInfoMenuID
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _GAME_STATE_DUEL_H_
|
||||
#define _GAME_STATE_DUEL_H_
|
||||
|
||||
#include "GameState.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "SimplePopup.h"
|
||||
#include "DeckMenu.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "GameObserver.h"
|
||||
|
||||
#define CHOOSE_OPPONENT 7
|
||||
|
||||
#ifdef TESTSUITE
|
||||
class TestSuite;
|
||||
#endif
|
||||
class Credits;
|
||||
class Rules;
|
||||
|
||||
class GameStateDuel: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
#ifdef TESTSUITE
|
||||
TestSuite * testSuite;
|
||||
#endif
|
||||
Credits * credits;
|
||||
int mGamePhase;
|
||||
Player * mCurrentPlayer;
|
||||
Player * mPlayers[2];
|
||||
MTGPlayerCards * deck[2];
|
||||
GameObserver * game;
|
||||
DeckMenu * deckmenu;
|
||||
DeckMenu * opponentMenu;
|
||||
SimpleMenu * menu;
|
||||
SimplePopup * popupScreen; // used for informational screens, modal
|
||||
static int selectedPlayerDeckId;
|
||||
static int selectedAIDeckId;
|
||||
|
||||
bool premadeDeck;
|
||||
int OpponentsDeckid;
|
||||
string musictrack;
|
||||
Rules * rules;
|
||||
|
||||
bool MusicExist(string FileName);
|
||||
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
|
||||
void ConstructOpponentMenu(); //loads the opponentMenu if it doesn't exist
|
||||
void initScroller();
|
||||
|
||||
public:
|
||||
GameStateDuel(GameApp* parent);
|
||||
virtual ~GameStateDuel();
|
||||
#ifdef TESTSUITE
|
||||
void loadTestSuitePlayers();
|
||||
#endif
|
||||
virtual void ButtonPressed(int ControllerId, int ControlId);
|
||||
virtual void Start();
|
||||
virtual void End();
|
||||
virtual void Update(float dt);
|
||||
virtual void Render();
|
||||
void initRand(unsigned seed = 0);
|
||||
|
||||
enum ENUM_DUEL_STATE_MENU_ITEM
|
||||
{
|
||||
MENUITEM_CANCEL = kCancelMenuID,
|
||||
MENUITEM_NEW_DECK = -10,
|
||||
MENUITEM_RANDOM_PLAYER = -11,
|
||||
MENUITEM_RANDOM_AI = -12,
|
||||
MENUITEM_MAIN_MENU = -13,
|
||||
MENUITEM_EVIL_TWIN = -14,
|
||||
MENUITEM_MULLIGAN = -15,
|
||||
MENUITEM_MORE_INFO = kInfoMenuID
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,113 +1,113 @@
|
||||
#ifndef _PLAYER_H_
|
||||
#define _PLAYER_H_
|
||||
|
||||
#include "JGE.h"
|
||||
#include "MTGGameZones.h"
|
||||
#include "Damage.h"
|
||||
#include "Targetable.h"
|
||||
|
||||
class MTGDeck;
|
||||
class MTGPlayerCards;
|
||||
class MTGInPlay;
|
||||
class ManaPool;
|
||||
|
||||
class Player: public Damageable
|
||||
{
|
||||
protected:
|
||||
ManaPool * manaPool;
|
||||
|
||||
public:
|
||||
enum ENUM_PLAY_MODE
|
||||
{
|
||||
MODE_TEST_SUITE,
|
||||
MODE_HUMAN,
|
||||
MODE_AI
|
||||
};
|
||||
|
||||
JTexture * mAvatarTex;
|
||||
JQuad * mAvatar;
|
||||
int playMode;
|
||||
bool canPutLandsIntoPlay;
|
||||
int landsPlayerCanStillPlay;
|
||||
bool nomaxhandsize;
|
||||
int castedspellsthisturn;
|
||||
bool onlyonecast;
|
||||
int castcount;
|
||||
bool nocreatureinstant;
|
||||
bool nospellinstant;
|
||||
bool onlyoneinstant;
|
||||
bool castrestrictedcreature;
|
||||
bool castrestrictedspell;
|
||||
bool onlyoneboth;
|
||||
bool bothrestrictedspell;
|
||||
bool bothrestrictedcreature;
|
||||
bool isPoisoned;
|
||||
MTGPlayerCards * game;
|
||||
string deckFile;
|
||||
string deckFileSmall;
|
||||
string deckName;
|
||||
|
||||
Player(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
virtual ~Player();
|
||||
|
||||
virtual void End();
|
||||
virtual int displayStack()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
const string getDisplayName() const;
|
||||
int typeAsTarget()
|
||||
{
|
||||
return TARGET_PLAYER;
|
||||
}
|
||||
|
||||
int afterDamage();
|
||||
|
||||
int gainLife(int value);
|
||||
int loseLife(int value);
|
||||
int gainOrLoseLife(int value);
|
||||
|
||||
int poisoned();
|
||||
int damaged();
|
||||
int prevented();
|
||||
void unTapPhase();
|
||||
MTGInPlay * inPlay();
|
||||
ManaPool * getManaPool();
|
||||
void cleanupPhase();
|
||||
virtual int Act(float dt)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int isAI()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Player * opponent();
|
||||
int getId();
|
||||
JQuad * getIcon();
|
||||
|
||||
virtual int receiveEvent(WEvent * event)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void Render()
|
||||
{
|
||||
}
|
||||
|
||||
void loadAvatar(string file);
|
||||
};
|
||||
|
||||
class HumanPlayer: public Player
|
||||
{
|
||||
public:
|
||||
HumanPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
HumanPlayer(string deckFile);
|
||||
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream&, const Player&);
|
||||
|
||||
#endif
|
||||
#ifndef _PLAYER_H_
|
||||
#define _PLAYER_H_
|
||||
|
||||
#include "JGE.h"
|
||||
#include "MTGGameZones.h"
|
||||
#include "Damage.h"
|
||||
#include "Targetable.h"
|
||||
|
||||
class MTGDeck;
|
||||
class MTGPlayerCards;
|
||||
class MTGInPlay;
|
||||
class ManaPool;
|
||||
|
||||
class Player: public Damageable
|
||||
{
|
||||
protected:
|
||||
ManaPool * manaPool;
|
||||
|
||||
public:
|
||||
enum ENUM_PLAY_MODE
|
||||
{
|
||||
MODE_TEST_SUITE,
|
||||
MODE_HUMAN,
|
||||
MODE_AI
|
||||
};
|
||||
|
||||
JTexture * mAvatarTex;
|
||||
JQuad * mAvatar;
|
||||
int playMode;
|
||||
bool canPutLandsIntoPlay;
|
||||
int landsPlayerCanStillPlay;
|
||||
bool nomaxhandsize;
|
||||
int castedspellsthisturn;
|
||||
bool onlyonecast;
|
||||
int castcount;
|
||||
bool nocreatureinstant;
|
||||
bool nospellinstant;
|
||||
bool onlyoneinstant;
|
||||
bool castrestrictedcreature;
|
||||
bool castrestrictedspell;
|
||||
bool onlyoneboth;
|
||||
bool bothrestrictedspell;
|
||||
bool bothrestrictedcreature;
|
||||
bool isPoisoned;
|
||||
MTGPlayerCards * game;
|
||||
string deckFile;
|
||||
string deckFileSmall;
|
||||
string deckName;
|
||||
|
||||
Player(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
virtual ~Player();
|
||||
|
||||
virtual void End();
|
||||
virtual int displayStack()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
const string getDisplayName() const;
|
||||
int typeAsTarget()
|
||||
{
|
||||
return TARGET_PLAYER;
|
||||
}
|
||||
|
||||
int afterDamage();
|
||||
|
||||
int gainLife(int value);
|
||||
int loseLife(int value);
|
||||
int gainOrLoseLife(int value);
|
||||
|
||||
int poisoned();
|
||||
int damaged();
|
||||
int prevented();
|
||||
void unTapPhase();
|
||||
MTGInPlay * inPlay();
|
||||
ManaPool * getManaPool();
|
||||
void cleanupPhase();
|
||||
virtual int Act(float dt)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int isAI()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Player * opponent();
|
||||
int getId();
|
||||
JQuad * getIcon();
|
||||
|
||||
virtual int receiveEvent(WEvent * event)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void Render()
|
||||
{
|
||||
}
|
||||
|
||||
void loadAvatar(string file);
|
||||
};
|
||||
|
||||
class HumanPlayer: public Player
|
||||
{
|
||||
public:
|
||||
HumanPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
HumanPlayer(string deckFile);
|
||||
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream&, const Player&);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
#ifndef _REPLACEMENT_EFFECTS_H_
|
||||
#define _REPLACEMENT_EFFECTS_H_
|
||||
|
||||
#include <list>
|
||||
using namespace std;
|
||||
#include "Damage.h"
|
||||
#include "WEvent.h"
|
||||
|
||||
class TargetChooser;
|
||||
class MTGAbility;
|
||||
|
||||
class ReplacementEffect
|
||||
{
|
||||
public:
|
||||
virtual WEvent * replace(WEvent * e)
|
||||
{
|
||||
return e;
|
||||
}
|
||||
;
|
||||
virtual ~ReplacementEffect() {}
|
||||
};
|
||||
|
||||
class REDamagePrevention: public ReplacementEffect
|
||||
{
|
||||
protected:
|
||||
MTGAbility * source;
|
||||
TargetChooser * tcSource;
|
||||
TargetChooser * tcTarget;
|
||||
int damage;
|
||||
bool oneShot;
|
||||
int typeOfDamage;
|
||||
public:
|
||||
REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL, TargetChooser *_tcTarget = NULL, int _damage = -1, bool _oneShot = true, int typeOfDamage = DAMAGE_ALL_TYPES);
|
||||
WEvent * replace(WEvent *e);
|
||||
~REDamagePrevention();
|
||||
};
|
||||
|
||||
class ReplacementEffects
|
||||
{
|
||||
protected:
|
||||
list<ReplacementEffect *> modifiers;
|
||||
public:
|
||||
ReplacementEffects();
|
||||
WEvent * replace(WEvent *e);
|
||||
int add(ReplacementEffect * re);
|
||||
int remove(ReplacementEffect * re);
|
||||
~ReplacementEffects();
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _REPLACEMENT_EFFECTS_H_
|
||||
#define _REPLACEMENT_EFFECTS_H_
|
||||
|
||||
#include <list>
|
||||
using namespace std;
|
||||
#include "Damage.h"
|
||||
#include "WEvent.h"
|
||||
|
||||
class TargetChooser;
|
||||
class MTGAbility;
|
||||
|
||||
class ReplacementEffect
|
||||
{
|
||||
public:
|
||||
virtual WEvent * replace(WEvent * e)
|
||||
{
|
||||
return e;
|
||||
}
|
||||
;
|
||||
virtual ~ReplacementEffect() {}
|
||||
};
|
||||
|
||||
class REDamagePrevention: public ReplacementEffect
|
||||
{
|
||||
protected:
|
||||
MTGAbility * source;
|
||||
TargetChooser * tcSource;
|
||||
TargetChooser * tcTarget;
|
||||
int damage;
|
||||
bool oneShot;
|
||||
int typeOfDamage;
|
||||
public:
|
||||
REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL, TargetChooser *_tcTarget = NULL, int _damage = -1, bool _oneShot = true, int typeOfDamage = DAMAGE_ALL_TYPES);
|
||||
WEvent * replace(WEvent *e);
|
||||
~REDamagePrevention();
|
||||
};
|
||||
|
||||
class ReplacementEffects
|
||||
{
|
||||
protected:
|
||||
list<ReplacementEffect *> modifiers;
|
||||
public:
|
||||
ReplacementEffects();
|
||||
WEvent * replace(WEvent *e);
|
||||
int add(ReplacementEffect * re);
|
||||
int remove(ReplacementEffect * re);
|
||||
~ReplacementEffects();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
/*
|
||||
* SimplePopup.h
|
||||
* Created on: Nov 18, 2010
|
||||
*
|
||||
* Simple popup dialog box for displaying information only.
|
||||
*/
|
||||
|
||||
#ifndef SIMPLEPOPUP_H_
|
||||
#define SIMPLEPOPUP_H_
|
||||
|
||||
#pragma once
|
||||
#include <JGui.h>
|
||||
#include <JTypes.h>
|
||||
#include <WFont.h>
|
||||
#include <DeckMetaData.h>
|
||||
|
||||
class SimplePopup: public JGuiController
|
||||
{
|
||||
|
||||
private:
|
||||
float mWidth, mX, mY;
|
||||
int mMaxLines;
|
||||
int mFontId;
|
||||
DeckMetaData * mDeckInformation;
|
||||
string mTitle;
|
||||
WFont *mTextFont;
|
||||
StatsWrapper *mStatsWrapper;
|
||||
bool mClosed;
|
||||
MTGAllCards * mCollection;
|
||||
|
||||
void drawHorzPole(string imageName, bool flipX, bool flipY, float x, float y, float width);
|
||||
void drawCorner(string imageName, bool flipX, bool flipY, float x, float y);
|
||||
void drawVertPole(string imageName, bool flipX, bool flipY, float x, float y, float height);
|
||||
|
||||
public:
|
||||
bool autoTranslate;
|
||||
|
||||
SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL);
|
||||
~SimplePopup(void);
|
||||
void drawBoundingBox(float x, float y, float width, float height);
|
||||
bool isClosed()
|
||||
{
|
||||
return mClosed;
|
||||
}
|
||||
MTGAllCards* getCollection()
|
||||
{
|
||||
return mCollection;
|
||||
}
|
||||
void Render();
|
||||
void Update(DeckMetaData* deckMetaData);
|
||||
|
||||
string getDetailedInformation(string deckFilename);
|
||||
|
||||
void Update(float dt);
|
||||
void Close();
|
||||
};
|
||||
|
||||
#endif /* SIMPLEPOPUP_H_ */
|
||||
/*
|
||||
* SimplePopup.h
|
||||
* Created on: Nov 18, 2010
|
||||
*
|
||||
* Simple popup dialog box for displaying information only.
|
||||
*/
|
||||
|
||||
#ifndef SIMPLEPOPUP_H_
|
||||
#define SIMPLEPOPUP_H_
|
||||
|
||||
#pragma once
|
||||
#include <JGui.h>
|
||||
#include <JTypes.h>
|
||||
#include <WFont.h>
|
||||
#include <DeckMetaData.h>
|
||||
|
||||
class SimplePopup: public JGuiController
|
||||
{
|
||||
|
||||
private:
|
||||
float mWidth, mX, mY;
|
||||
int mMaxLines;
|
||||
int mFontId;
|
||||
DeckMetaData * mDeckInformation;
|
||||
string mTitle;
|
||||
WFont *mTextFont;
|
||||
StatsWrapper *mStatsWrapper;
|
||||
bool mClosed;
|
||||
MTGAllCards * mCollection;
|
||||
|
||||
void drawHorzPole(string imageName, bool flipX, bool flipY, float x, float y, float width);
|
||||
void drawCorner(string imageName, bool flipX, bool flipY, float x, float y);
|
||||
void drawVertPole(string imageName, bool flipX, bool flipY, float x, float y, float height);
|
||||
|
||||
public:
|
||||
bool autoTranslate;
|
||||
|
||||
SimplePopup(int id, JGuiListener* listener, const int fontId, const char * _title = "", DeckMetaData* deckInfo = NULL, MTGAllCards * collection = NULL);
|
||||
~SimplePopup(void);
|
||||
void drawBoundingBox(float x, float y, float width, float height);
|
||||
bool isClosed()
|
||||
{
|
||||
return mClosed;
|
||||
}
|
||||
MTGAllCards* getCollection()
|
||||
{
|
||||
return mCollection;
|
||||
}
|
||||
void Render();
|
||||
void Update(DeckMetaData* deckMetaData);
|
||||
|
||||
string getDetailedInformation(string deckFilename);
|
||||
|
||||
void Update(float dt);
|
||||
void Close();
|
||||
};
|
||||
|
||||
#endif /* SIMPLEPOPUP_H_ */
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
#ifndef _TEXTSCROLLER_H_
|
||||
#define _TEXTSCROLLER_H_
|
||||
|
||||
class JLBFont;
|
||||
#include <JGui.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
class TextScroller: public JGuiObject
|
||||
{
|
||||
protected:
|
||||
string mText;
|
||||
string tempText;
|
||||
int fontId;
|
||||
float mWidth; // width of the text scroller object
|
||||
float mScrollSpeed;
|
||||
float mX;
|
||||
float mY;
|
||||
float start;
|
||||
int timer;
|
||||
|
||||
vector<string> strings;
|
||||
unsigned int currentId;
|
||||
int mRandom;
|
||||
int scrollDirection;
|
||||
|
||||
public:
|
||||
TextScroller(int fontId, float x, float y, float width, float speed = 30);
|
||||
void Add(string text);
|
||||
void Reset();
|
||||
void setRandom(int mode = 1);
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
};
|
||||
|
||||
class VerticalTextScroller: public TextScroller
|
||||
{
|
||||
private:
|
||||
size_t mNbItemsShown;
|
||||
float mHeight; // maximum height availble for display
|
||||
float mMarginX;
|
||||
float mMarginY; // margin used to allow text to scroll off screen without
|
||||
// affecting look and feel. Should be enough
|
||||
// for at least one line of text ( mY - line height of current font )
|
||||
float mOriginalY; // mY initially, used to restore scroller to original position after update
|
||||
|
||||
public:
|
||||
VerticalTextScroller(int fontId, float x, float y, float width, float height, float scrollSpeed = 30, size_t _minimumItems = 1);
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(string text);
|
||||
};
|
||||
#endif
|
||||
#ifndef _TEXTSCROLLER_H_
|
||||
#define _TEXTSCROLLER_H_
|
||||
|
||||
class JLBFont;
|
||||
#include <JGui.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
class TextScroller: public JGuiObject
|
||||
{
|
||||
protected:
|
||||
string mText;
|
||||
string tempText;
|
||||
int fontId;
|
||||
float mWidth; // width of the text scroller object
|
||||
float mScrollSpeed;
|
||||
float mX;
|
||||
float mY;
|
||||
float start;
|
||||
int timer;
|
||||
|
||||
vector<string> strings;
|
||||
unsigned int currentId;
|
||||
int mRandom;
|
||||
int scrollDirection;
|
||||
|
||||
public:
|
||||
TextScroller(int fontId, float x, float y, float width, float speed = 30);
|
||||
void Add(string text);
|
||||
void Reset();
|
||||
void setRandom(int mode = 1);
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
};
|
||||
|
||||
class VerticalTextScroller: public TextScroller
|
||||
{
|
||||
private:
|
||||
size_t mNbItemsShown;
|
||||
float mHeight; // maximum height availble for display
|
||||
float mMarginX;
|
||||
float mMarginY; // margin used to allow text to scroll off screen without
|
||||
// affecting look and feel. Should be enough
|
||||
// for at least one line of text ( mY - line height of current font )
|
||||
float mOriginalY; // mY initially, used to restore scroller to original position after update
|
||||
|
||||
public:
|
||||
VerticalTextScroller(int fontId, float x, float y, float width, float height, float scrollSpeed = 30, size_t _minimumItems = 1);
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(string text);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef _TOKEN_H_
|
||||
#define _TOKEN_H_
|
||||
|
||||
#include "MTGCardInstance.h"
|
||||
|
||||
class Token: public MTGCardInstance
|
||||
{
|
||||
MTGCardInstance * tokenSource;
|
||||
public:
|
||||
Token(string _name, MTGCardInstance * source, int _power = 0, int _toughness = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _TOKEN_H_
|
||||
#define _TOKEN_H_
|
||||
|
||||
#include "MTGCardInstance.h"
|
||||
|
||||
class Token: public MTGCardInstance
|
||||
{
|
||||
MTGCardInstance * tokenSource;
|
||||
public:
|
||||
Token(string _name, MTGCardInstance * source, int _power = 0, int _toughness = 0);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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
File diff suppressed because it is too large
Load Diff
@@ -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
Reference in New Issue
Block a user