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:
@@ -34,7 +34,7 @@ CardSelector::SelectorMemory::SelectorMemory(PlayGuiObject* object) : object(obj
|
||||
CardSelector::SelectorMemory::SelectorMemory() { object = NULL; x = y = 0; }
|
||||
|
||||
|
||||
CardSelector::CardSelector(DuelLayers* duel) : CardSelectorBase(BIG_MODE_SHOW), active(NULL), duel(duel), limitor(NULL), bigpos(300, 150, 1.0, 0.0, 220) {}
|
||||
CardSelector::CardSelector(DuelLayers* duel) : active(NULL), duel(duel), limitor(NULL), bigpos(300, 150, 1.0, 0.0, 220) {}
|
||||
|
||||
void CardSelector::Add(CardSelector::Target* target)
|
||||
{
|
||||
@@ -132,8 +132,8 @@ bool CardSelector::CheckUserInput(JButton key)
|
||||
active = closest<Down>(cards, limitor, active);
|
||||
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;
|
||||
@@ -236,17 +236,9 @@ void CardSelector::Update(float dt) {
|
||||
void CardSelector::Render() {
|
||||
if (active) {
|
||||
active->Render();
|
||||
if (CardView* c = dynamic_cast<CardView*>(active)) {
|
||||
switch(mDrawMode) {
|
||||
case BIG_MODE_SHOW:
|
||||
c->RenderBig(bigpos);
|
||||
break;
|
||||
case BIG_MODE_TEXT:
|
||||
c->alternateRenderBig(bigpos);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (CardView* card = dynamic_cast<CardView*>(active))
|
||||
{
|
||||
card->DrawCard(bigpos, mDrawMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user