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
+31 -7
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;
};
+1 -9
View File
@@ -12,14 +12,6 @@ using std::vector;
class PlayGuiObject;
class DuelLayers;
enum {
BIG_MODE_SHOW = 0,
BIG_MODE_TEXT = 1,
BIG_MODE_HIDE = 2,
NB_BIG_MODES = 3
};
template <typename T>
struct LimitorFunctor
{
@@ -32,7 +24,7 @@ class CardSelectorBase : public GuiLayer
{
public:
CardSelectorBase(int inDrawMode) : mDrawMode(inDrawMode) {};
CardSelectorBase(int inDrawMode = DrawMode::kNormal) : mDrawMode(inDrawMode) {};
virtual void Add(PlayGuiObject*) = 0;
virtual void Remove(PlayGuiObject*) = 0;
virtual bool CheckUserInput(JButton key) = 0;