Files
wagic/projects/mtg/include/GameStateShop.h
techdragon.nguyen@gmail.com a2179017d4 Extended Scroll() and OnScroll() to also take in magnitude as one of its parameters. magnitude is currently used in the deck editor to figure out how many cards to rotate around per swipe as function of velocity and the number of cards displayed on the screen.
fixed a compiler warning in SimplePopup in the constructor declaration
===DECK Editor changes ===
Added two touch buttons , one for "Sell Card", the other to switch between Deck and Collection.
changed swipe Left/Right to rotate card collection; removing the previous action which was to swap between deck/collection viewing

Note: GameStateDeckViewer isn't a JGuiController so can't leverage off the mButtons vector.  Thus, the buttons have to be handled by this class separately. (setButtonState, userPressedButton)
2012-01-26 13:53:03 +00:00

124 lines
3.0 KiB
C++

#ifndef _GAME_STATE_SHOP_H_
#define _GAME_STATE_SHOP_H_
#include <JGE.h>
#include "GameState.h"
#include "SimpleMenu.h"
#include "OptionItem.h"
#include "PriceList.h"
#include "PlayerData.h"
#include "CardDisplay.h"
#include "DeckDataWrapper.h"
#include "Tasks.h"
#define STATE_BUY 1
#define STATE_SELL 2
#define STAGE_SHOP_MENU 3
#define STAGE_SHOP_SHOP 4
#define STAGE_SHOP_TASKS 5
#define STAGE_FADE_IN 6
#define STAGE_ASK_ABOUT 7
#define STAGE_SHOP_PURCHASE 8
#define BOOSTER_SLOTS 3
#define SHOP_SLOTS 11
#define SHOP_ITEMS SHOP_SLOTS+1
#define LIST_FADEIN 15
class MTGPack;
class MTGPacks;
class BoosterDisplay: public CardDisplay
{
public:
BoosterDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL,
int nb_displayed_items = 7);
bool CheckUserInput(JButton key);
};
class ShopBooster
{
public:
ShopBooster();
string getName();
void randomize(MTGPacks * packlist);
int basePrice();
int maxInventory();
void addToDeck(MTGDeck * d, WSrcCards * srcCards);
string getSort();
#ifdef TESTSUITE
bool unitTest();
#endif
private:
void randomCustom(MTGPacks * packlist);
void randomStandard();
MTGPack * pack;
MTGSetInfo * mainSet;
MTGSetInfo * altSet;
};
class GameStateShop: public GameState, public JGuiListener
{
private:
JQuadPtr pspIcons[8];
WSrcCards * srcCards;
TaskList * taskList;
float mElapsed;
WGuiMenu * shopMenu;
WGuiFilters * filterMenu; //Filter menu slides in sideways from right, or up from bottom.
WGuiCardImage * bigDisplay;
BoosterDisplay * boosterDisplay;
vector<MTGCardInstance*> subBooster;
MTGDeck * booster;
bool bListCards;
void beginFilters();
void deleteDisplay();
WSyncable bigSync;
SimpleMenu * menu;
PriceList * pricelist;
PlayerData * playerdata;
MTGPacks * packlist;
bool mTouched;
bool needLoad;
int mPrices[SHOP_ITEMS];
int mCounts[SHOP_ITEMS];
int mInventory[SHOP_ITEMS];
int lightAlpha;
int alphaChange;
int mBuying;
DeckDataWrapper * myCollection;
int mStage;
ShopBooster mBooster[BOOSTER_SLOTS];
void load();
void save(bool force = false);
void updateCounts();
void beginPurchase(int controlId);
void purchaseCard(int controlId);
void purchaseBooster(int controlId);
void cancelCard(int controlId);
void cancelBooster(int controlId);
int purchasePrice(int offset);
string descPurchase(int controlId, bool tiny = false);
public:
GameStateShop(GameApp* parent);
virtual ~GameStateShop();
virtual void Start();
virtual void End();
virtual void Create();
virtual void Destroy();
virtual void Update(float dt);
virtual void Render();
virtual void ButtonPressed(int controllerId, int controlId);
virtual void OnScroll(int inXVelocity, int inYVelocity, int magnitude = 0);
static float _x1[], _y1[], _x2[], _y2[], _x3[], _y3[], _x4[], _y4[];
};
#endif