when ingame, try finding the quad

for copier/cloner when copying token generated cards...
This commit is contained in:
Anthony Calosa
2016-08-06 19:41:34 +08:00
parent 88f0202b16
commit d43693fef0
4 changed files with 21 additions and 17 deletions

View File

@@ -33,7 +33,7 @@ protected:
/* /*
** Tries to render the Big version of a card picture, backups to text version in case of failure ** 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, bool thumb = false, bool noborder = false, bool smallerscale = false); static void RenderBig(MTGCard * card, const Pos& pos, bool thumb = false, bool noborder = false, bool smallerscale = false, bool ingame = false);
static void RenderCountersBig(MTGCard * card, const Pos& pos, int drawMode = DrawMode::kNormal); static void RenderCountersBig(MTGCard * card, const Pos& pos, int drawMode = DrawMode::kNormal);
static void AlternateRender(MTGCard * card, const Pos& pos); static void AlternateRender(MTGCard * card, const Pos& pos);
@@ -55,8 +55,8 @@ public:
virtual void Render(); virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);
bool isBlackBorder(string set); bool isBlackBorder(string set);
void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false, bool noborder = false, bool smallscale = false); void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false, bool noborder = false, bool smallscale = false, bool ingame = false);
static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false, bool noborder = false, bool smallscale = false); static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false, bool noborder = false, bool smallscale = false, bool ingame = false);
static void DrawBorder(string setname, const Pos& inPosition, float x, bool noborder = false, bool smallscale = false); static void DrawBorder(string setname, const Pos& inPosition, float x, bool noborder = false, bool smallscale = false);
static JQuadPtr AlternateThumbQuad(MTGCard * card); static JQuadPtr AlternateThumbQuad(MTGCard * card);
virtual ostream& toString(ostream&) const; virtual ostream& toString(ostream&) const;

View File

@@ -132,7 +132,8 @@ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string
{ {
Pos pos = Pos(CardGui::BigWidth / 2, CardGui::BigHeight / 2 - 10, 0.80f, 0.0, 220); Pos pos = Pos(CardGui::BigWidth / 2, CardGui::BigHeight / 2 - 10, 0.80f, 0.0, 220);
pos.actY = 142;//adjust y a little bit pos.actY = 142;//adjust y a little bit
CardGui::DrawCard(source, pos, observer->getCardSelector()->GetDrawMode()); bool ingame = observer?true:false;
CardGui::DrawCard(source, pos, observer->getCardSelector()->GetDrawMode(),false,false,false,ingame);
} }
if (targetQuad) if (targetQuad)

View File

@@ -271,8 +271,8 @@ void CardDisplay::Render()
if (x < (CardGui::BigWidth / 2)) pos.actX = SCREEN_WIDTH - 10 - CardGui::BigWidth / 2; if (x < (CardGui::BigWidth / 2)) pos.actX = SCREEN_WIDTH - 10 - CardGui::BigWidth / 2;
drawMode = observer->getCardSelector()->GetDrawMode(); drawMode = observer->getCardSelector()->GetDrawMode();
} }
bool ingame = observer?true:false;
cardg->DrawCard(pos, drawMode); cardg->DrawCard(pos, drawMode, 0, false, false,ingame);
} }
} }

View File

@@ -111,17 +111,17 @@ void CardGui::Update(float dt)
PlayGuiObject::Update(dt); PlayGuiObject::Update(dt);
} }
void CardGui::DrawCard(const Pos& inPosition, int inMode, bool thumb, bool noborder, bool smallerscale) void CardGui::DrawCard(const Pos& inPosition, int inMode, bool thumb, bool noborder, bool smallerscale, bool ingame)
{ {
DrawCard(card, inPosition, inMode, thumb, noborder, smallerscale); DrawCard(card, inPosition, inMode, thumb, noborder, smallerscale, ingame);
} }
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode, bool thumb, bool noborder, bool smallerscale) void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode, bool thumb, bool noborder, bool smallerscale, bool ingame)
{ {
switch (inMode) switch (inMode)
{ {
case DrawMode::kNormal: case DrawMode::kNormal:
RenderBig(inCard, inPosition, thumb, noborder, smallerscale); RenderBig(inCard, inPosition, thumb, noborder, smallerscale, ingame);
break; break;
case DrawMode::kText: case DrawMode::kText:
AlternateRender(inCard, inPosition); AlternateRender(inCard, inPosition);
@@ -1135,7 +1135,7 @@ void CardGui::TinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad)
} }
//Renders a big card on screen. Defaults to the "alternate" rendering if no image is found //Renders a big card on screen. Defaults to the "alternate" rendering if no image is found
void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder, bool smallerscale) void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder, bool smallerscale, bool ingame)
{ {
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
//GameObserver * game = GameObserver::GetInstance(); //GameObserver * game = GameObserver::GetInstance();
@@ -1152,13 +1152,16 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder
{ {
MTGCard * fcard = MTGCollection()->getCardByName(kcard->name); MTGCard * fcard = MTGCollection()->getCardByName(kcard->name);
quad = WResourceManager::Instance()->RetrieveCard(fcard); quad = WResourceManager::Instance()->RetrieveCard(fcard);
}/* }
if (kcard->hasCopiedToken && !quad.get()) if(ingame)
{ {
MTGCard * tcard = MTGCollection()->getCardById(abs(kcard->copiedID)); if (kcard->hasCopiedToken && kcard->getObserver() && !quad.get())
quad = thumb ? WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_THUMB, 1, abs(kcard->copiedID)) {
: WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_NORMAL, 1, abs(kcard->copiedID)); MTGCard * tcard = MTGCollection()->getCardById(abs(kcard->copiedID));
}*///temporary disabled this so it will not crash, this must be called when ingame -kevlahnota quad = thumb ? WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_THUMB, 1, abs(kcard->copiedID))
: WResourceManager::Instance()->RetrieveCardToken(tcard, RETRIEVE_NORMAL, 1, abs(kcard->copiedID));
}
}
if (quad.get()) if (quad.get())
{ {
if (quad->mHeight < quad->mWidth) if (quad->mHeight < quad->mWidth)