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
+4 -14
View File
@@ -377,7 +377,7 @@ CardZone* LandCardZone::EnterZone(JButton inDirection)
** Constructor. All the navigation logic is initialized here, by pairing up each card zone with a set of neighbours.
*/
Navigator::Navigator(DuelLayers* inDuelLayers)
: CardSelectorBase(BIG_MODE_SHOW), mDrawPosition(kDefaultCardPosition), mDuelLayers(inDuelLayers), mLimitorEnabled(false)
: mDrawPosition(kDefaultCardPosition), mDuelLayers(inDuelLayers), mLimitorEnabled(false)
{
assert(mDuelLayers);
@@ -506,8 +506,8 @@ bool Navigator::CheckUserInput(JButton inKey)
HandleKeyStroke(inKey);
break;
case JGE_BTN_CANCEL:
mDrawMode = (mDrawMode+1) % NB_BIG_MODES;
if(mDrawMode == BIG_MODE_TEXT)
mDrawMode = (mDrawMode+1) % DrawMode::kNumDrawModes;
if(mDrawMode == DrawMode::kText)
options[Options::DISABLECARDS].number = 1;
else
options[Options::DISABLECARDS].number = 0;
@@ -568,17 +568,7 @@ void Navigator::Render()
CardView* card = dynamic_cast<CardView*>(GetCurrentCard());
if (card)
{
switch(mDrawMode)
{
case BIG_MODE_SHOW:
card->RenderBig(mDrawPosition);
break;
case BIG_MODE_TEXT:
card->alternateRenderBig(mDrawPosition);
break;
default:
break;
}
card->DrawCard(mDrawPosition, mDrawMode);
}
}
}