Render small cards as thumbnails
This commit is contained in:
@@ -33,7 +33,7 @@ protected:
|
||||
/*
|
||||
** 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);
|
||||
static void RenderBig(MTGCard * card, const Pos& pos, bool thumb = false);
|
||||
|
||||
static void RenderCountersBig(MTGCard * card, const Pos& pos, int drawMode = DrawMode::kNormal);
|
||||
static void AlternateRender(MTGCard * card, const Pos& pos);
|
||||
@@ -55,8 +55,8 @@ public:
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal);
|
||||
static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal);
|
||||
void DrawCard(const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false);
|
||||
static void DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode = DrawMode::kNormal, bool thumb = false);
|
||||
|
||||
static JQuadPtr AlternateThumbQuad(MTGCard * card);
|
||||
virtual ostream& toString(ostream&) const;
|
||||
|
||||
@@ -57,7 +57,7 @@ protected:
|
||||
DeckDataWrapper *mCurrentDeck;
|
||||
|
||||
CardRep& getCardRep(unsigned int index);
|
||||
void renderCard(int index, int alpha);
|
||||
void renderCard(int index, int alpha, bool asThumbnail = false);
|
||||
int getCardIndexNextTo(int x, int y);
|
||||
|
||||
vector<CardRep> mCards;
|
||||
|
||||
@@ -111,17 +111,17 @@ void CardGui::Update(float dt)
|
||||
PlayGuiObject::Update(dt);
|
||||
}
|
||||
|
||||
void CardGui::DrawCard(const Pos& inPosition, int inMode)
|
||||
void CardGui::DrawCard(const Pos& inPosition, int inMode, bool thumb)
|
||||
{
|
||||
DrawCard(card, inPosition, inMode);
|
||||
DrawCard(card, inPosition, inMode, thumb);
|
||||
}
|
||||
|
||||
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode)
|
||||
void CardGui::DrawCard(MTGCard* inCard, const Pos& inPosition, int inMode, bool thumb)
|
||||
{
|
||||
switch (inMode)
|
||||
{
|
||||
case DrawMode::kNormal:
|
||||
RenderBig(inCard, inPosition);
|
||||
RenderBig(inCard, inPosition, thumb);
|
||||
break;
|
||||
case DrawMode::kText:
|
||||
AlternateRender(inCard, inPosition);
|
||||
@@ -958,7 +958,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
|
||||
void CardGui::RenderBig(MTGCard* card, const Pos& pos)
|
||||
void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb)
|
||||
{
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
//GameObserver * game = GameObserver::GetInstance();
|
||||
@@ -967,7 +967,8 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos)
|
||||
//i want this but ai targets cards so quickly that it can crash the game.
|
||||
float x = pos.actX;
|
||||
|
||||
JQuadPtr quad = WResourceManager::Instance()->RetrieveCard(card);
|
||||
JQuadPtr quad = thumb ? WResourceManager::Instance()->RetrieveCard(card, RETRIEVE_THUMB)
|
||||
: WResourceManager::Instance()->RetrieveCard(card);
|
||||
MTGCardInstance * kcard = dynamic_cast<MTGCardInstance*>(card);
|
||||
if(kcard && !kcard->isToken && kcard->name != kcard->model->data->name)
|
||||
{
|
||||
|
||||
@@ -94,9 +94,12 @@ int DeckView::filter()
|
||||
|
||||
void DeckView::reloadIndexes() //fixme: feels ugly. check if we can remove this
|
||||
{
|
||||
for (unsigned int i = 0; i < mCards.size(); i++)
|
||||
if(deck() != NULL)
|
||||
{
|
||||
mCards[i].card = deck()->getCard(i);
|
||||
for (unsigned int i = 0; i < mCards.size(); i++)
|
||||
{
|
||||
mCards[i].card = deck()->getCard(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +108,7 @@ DeckView::CardRep& DeckView::getCardRep(unsigned int index)
|
||||
return mCards[index];
|
||||
}
|
||||
|
||||
void DeckView::renderCard(int index, int alpha)
|
||||
void DeckView::renderCard(int index, int alpha, bool asThumbnail)
|
||||
{
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||
|
||||
@@ -146,13 +149,13 @@ void DeckView::renderCard(int index, int alpha)
|
||||
else
|
||||
{
|
||||
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(cardPosition.card, pos);
|
||||
CardGui::DrawCard(cardPosition.card, pos, asThumbnail);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(cardPosition.card, pos, DrawMode::kText);
|
||||
CardGui::DrawCard(cardPosition.card, pos, DrawMode::kText, asThumbnail);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -160,7 +163,7 @@ void DeckView::renderCard(int index, int alpha)
|
||||
int mode = !options[Options::DISABLECARDS].number ? DrawMode::kNormal : DrawMode::kText;
|
||||
|
||||
Pos pos = Pos(cardPosition.x, cardPosition.y, cardPosition.scale * 285 / 250, 0.0, 255);
|
||||
CardGui::DrawCard(cardPosition.card, pos, mode);
|
||||
CardGui::DrawCard(cardPosition.card, pos, mode, asThumbnail);
|
||||
}
|
||||
|
||||
int quadAlpha = alpha;
|
||||
|
||||
@@ -108,22 +108,43 @@ void GridDeckView::UpdateCardPosition(CardRep &rep, int index)
|
||||
|
||||
void GridDeckView::Render()
|
||||
{
|
||||
for(int i = 0; i < int(mCards.size()); ++i)
|
||||
int firstVisibleCard = 2;
|
||||
int lastVisibleCard = mCards.size() - 2;
|
||||
|
||||
if(!mScrollOffset.finished())
|
||||
{
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(i).card);
|
||||
if(mScrollOffset.delta_value < 0){
|
||||
firstVisibleCard = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastVisibleCard = mCards.size();
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = firstVisibleCard; i < lastVisibleCard; ++i)
|
||||
{
|
||||
|
||||
if(mCurrentSelection != i)
|
||||
{
|
||||
renderCard(i, 255);
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(i).card, RETRIEVE_THUMB);
|
||||
}
|
||||
renderCard(i, 255, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
WResourceManager::Instance()->RetrieveCard(getCardRep(i).card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(2 <= mCurrentSelection && mCurrentSelection < 12)
|
||||
{
|
||||
renderCard(mCurrentSelection, 255);
|
||||
renderCard(mCurrentSelection, 255, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user