1st step in refactoring some of the card rendering logic - currently, each 'client' has duplicated code having to deal with how to render the full card graphic vs text mode vs using a 'back' image if a card isn't found. This is a first pass at consolidating some of that logic to one location - the ultimate goal being, eventually, the resource cache will actually own the notion of whether it's handing out a real card image or a default filler if the card isn't available, and the client code rendering the card should be oblivious.

In this change, I made the CardGui's RenderBig() and AlternateRender() functions protected; anyone wanting to render a card simply calls RenderCard(), and the card drawing mode is passed along as a param.
This commit is contained in:
wrenczes@gmail.com
2010-11-14 08:15:26 +00:00
parent e758c7eea1
commit 27fd107208
9 changed files with 125 additions and 110 deletions

View File

@@ -12,9 +12,35 @@
class MTGCardInstance;
class PlayGuiObject;
namespace DrawMode
{
enum
{
kNormal = 0,
kText,
kHidden
};
const int kNumDrawModes = 3;
}
struct CardGui : public PlayGuiObject {
protected:
/*
** Tries to render the Big version of a card picture, backups to text version in case of failure
*/
void RenderBig(const Pos&);
static void RenderBig(MTGCard * card, const Pos& pos);
/*
** Renders Text Version of a card
*/
void AlternateRenderBig(const Pos&);
void RenderCountersBig(const Pos& pos);
static void AlternateRender(MTGCard * card, const Pos& pos);
static void TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad);
public:
static const float Width;
static const float Height;
@@ -25,14 +51,12 @@ struct CardGui : public PlayGuiObject {
CardGui(MTGCardInstance* card, float x, float y);
CardGui(MTGCardInstance* card, const Pos& ref);
virtual void Render();
void RenderBig(const Pos&); //Tries to render the Big version of a card picture, backups to text version in case of failure
static void RenderBig(MTGCard * card, const Pos& pos);
void alternateRenderBig(const Pos&); //Renders Text Version of a card
void renderCountersBig(const Pos& pos);
virtual void Update(float dt);
static void alternateRender(MTGCard * card, const Pos& pos);
static void tinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad);
static JQuad * alternateThumbQuad(MTGCard * card);
void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal);
static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal);
static JQuad * AlternateThumbQuad(MTGCard * card);
virtual ostream& toString(ostream&) const;
};