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:
Tobias Loose
2013-12-07 12:58:20 +01:00
parent 4514725aba
commit 14c164364e
10 changed files with 167 additions and 150 deletions

View File

@@ -7,6 +7,9 @@
class CarouselDeckView : public DeckView
{
private:
static const float max_scale;
static const float x_center;
static const float right_border;
static const float slide_animation_duration;
public:

View File

@@ -9,15 +9,11 @@
#include "WResourceManager.h"
#include "Pos.h"
#define NO_USER_ACTIVITY_HELP_DELAY 10
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
class DeckView
{
protected:
static const float max_scale;
static const float x_center;
static const float right_border;
static const float no_user_activity_show_card_delay;
public:
struct CardRep{
@@ -36,6 +32,13 @@ public:
//advances the view and card representations
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 MTGCard * Click(int x, int y) = 0;
@@ -43,24 +46,15 @@ public:
virtual MTGCard *getActiveCard() = 0;
virtual void changePosition(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:
float last_user_activity;
int mFilter;
DeckDataWrapper *mCurrentDeck;
vector<CardRep> mCards;
CardRep& getCardRep(unsigned int index);
void renderCard(int index, int alpha, bool asThumbnail = false);
int getCardIndexNextTo(int x, int y);
vector<CardRep> mCards;
private:
virtual void UpdateViewState(float dt) = 0;
virtual void UpdateCardPosition(CardRep& rep, int index) = 0;

View File

@@ -68,7 +68,6 @@ private:
JTexture * pspIconsTexture;
float last_user_activity;
float onScreenTransition;
int mAlpha;
DeckViewerStages mStage;
JMusic * bgMusic;
@@ -79,13 +78,12 @@ private:
DeckEditorMenu * welcome_menu;
SimpleMenu * subMenu;
DeckEditorMenu * menu;
DeckEditorMenu * deckMenu;
PriceList* pricelist;
PlayerData * playerdata;
int price;
DeckDataWrapper * myDeck;
DeckDataWrapper * myCollection;
StatsWrapper *stw;
StatsWrapper * mStatsWrapper;
int hudAlpha;
string newDeckname;
@@ -111,7 +109,6 @@ public:
GameStateDeckViewer(GameApp* parent);
virtual ~GameStateDeckViewer();
void updateDecks();
void rotateCards(int direction);
void updateFilters();
void rebuildFilters();
void toggleCollection();

View File

@@ -20,16 +20,18 @@ public:
~PriceList();
int save();
int getSellPrice(int cardid);
int getSellPrice(MTGCard* card);
int getPurchasePrice(int cardid);
int getPrice(MTGCard *card);
int getPrice(int cardId);
int setPrice(int cardId, int price);
int setPrice(MTGCard *card, int price);
int getOtherPrice(int amt);
static float difficultyScalar(float price, int cardid = 0);
static void updateKey()
{
randomKey = rand();
}
;
};
#endif