Erwan
- a few graphical fixes in shop and DeckViewer
This commit is contained in:
@@ -28,7 +28,7 @@ struct CardGui : public PlayGuiObject {
|
||||
virtual void Render() = 0;
|
||||
void RenderBig(const Pos&);
|
||||
virtual void Update(float dt) = 0;
|
||||
|
||||
static void alternateRender(MTGCard * card, JQuad ** manaIcons, const Pos& pos);
|
||||
virtual ostream& toString(ostream&) const;
|
||||
};
|
||||
|
||||
@@ -70,7 +70,7 @@ class CardGui: public PlayGuiObject{
|
||||
float Width();
|
||||
|
||||
void RenderBig(float x=-1, float y = -1, int alternate = 0);
|
||||
static void alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float y, float rotation= 0, float scale=1);
|
||||
|
||||
~CardGui();
|
||||
};
|
||||
*/
|
||||
|
||||
@@ -70,7 +70,6 @@ class GameApp: public JApp
|
||||
int players[2];
|
||||
MTGAllCards * collection;
|
||||
int gameType;
|
||||
TexturesCache * cache;
|
||||
CardEffect *effect;
|
||||
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",mParent->collection);
|
||||
playerdata = NEW PlayerData(mParent->collection);
|
||||
sellMenu = NULL;
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(RESPATH"/player/collection.dat", mParent->cache,mParent->collection));
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(RESPATH"/player/collection.dat", &cache,mParent->collection));
|
||||
displayed_deck = myCollection;
|
||||
myDeck = NULL;
|
||||
menuFont = GameApp::CommonRes->GetJLBFont(Constants::MENU_FONT);
|
||||
@@ -607,9 +607,9 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
|
||||
float x_center = x_center_0 + cos((rotation + 8 - id)*M_PI/12)*(right_border-x_center_0);
|
||||
float scale = max_scale/ 1.12 * cos((x_center-x_center_0)*1.5/(right_border - x_center_0) ) + 0.2 * max_scale * cos (cos((x_center-x_center_0)*0.15/(right_border - x_center_0) ));
|
||||
float x = x_center - 100*scale;
|
||||
float x = x_center; // ;
|
||||
|
||||
float y = (SCREEN_HEIGHT - 285*scale)/2 + SCREEN_HEIGHT*mSlide*(scale+0.2);
|
||||
float y = (SCREEN_HEIGHT)/2 + SCREEN_HEIGHT*mSlide*(scale+0.2);
|
||||
|
||||
int alpha = (int) (255 * (scale + 1.0 - max_scale));
|
||||
|
||||
@@ -617,7 +617,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
JQuad * quad = backQuad;
|
||||
|
||||
int showName = 1;
|
||||
if (mParent->cache->isInCache(card) || last_user_activity > (abs(2-id) + 1)* NO_USER_ACTIVITY_SHOWCARD_DELAY){
|
||||
if (cache.isInCache(card) || last_user_activity > (abs(2-id) + 1)* NO_USER_ACTIVITY_SHOWCARD_DELAY){
|
||||
quad = cache.getQuad(card);
|
||||
showName = 0;
|
||||
}
|
||||
@@ -635,7 +635,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
sprintf(buffer, "%s", _(card->getName()).c_str());
|
||||
float scaleBackup = mFont->GetScale();
|
||||
mFont->SetScale(scale);
|
||||
mFont->DrawString(buffer,x,y);
|
||||
mFont->DrawString(buffer,x - 100*scale ,y - 145*scale);
|
||||
mFont->SetScale(scaleBackup);
|
||||
}
|
||||
}else{
|
||||
@@ -649,8 +649,8 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
}
|
||||
if (last_user_activity < 3){
|
||||
int fontAlpha = alpha;
|
||||
float qtY = y + 0 * scale;
|
||||
float qtX = x + 120*scale;
|
||||
float qtY = y -135*scale;
|
||||
float qtX = x + 40*scale;
|
||||
char buffer[4096];
|
||||
sprintf(buffer, "x%i", displayed_deck->cards[card]);
|
||||
JLBFont * font = mFont;
|
||||
@@ -725,12 +725,12 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
|
||||
int loadDeck(int deckid){
|
||||
SAFE_DELETE(myCollection);
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(RESPATH"/player/collection.dat", mParent->cache,mParent->collection));
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck(RESPATH"/player/collection.dat", &cache,mParent->collection));
|
||||
displayed_deck = myCollection;
|
||||
char filename[4096];
|
||||
sprintf(filename, RESPATH"/player/deck%i.txt", deckid);
|
||||
SAFE_DELETE(myDeck);
|
||||
myDeck = NEW DeckDataWrapper(NEW MTGDeck(filename, mParent->cache,mParent->collection));
|
||||
myDeck = NEW DeckDataWrapper(NEW MTGDeck(filename, &cache,mParent->collection));
|
||||
MTGCard * current = myDeck->getNext();
|
||||
while (current){
|
||||
int howmanyinDeck = myDeck->cards[current];
|
||||
|
||||
@@ -29,6 +29,7 @@ void CardView::Update(float dt)
|
||||
PlayGuiObject::Update(dt);
|
||||
}
|
||||
|
||||
|
||||
void CardView::Render()
|
||||
{
|
||||
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
|
||||
@@ -102,29 +103,11 @@ void CardView::Render()
|
||||
PlayGuiObject::Render();
|
||||
}
|
||||
|
||||
void CardGui::RenderBig(const Pos& pos){
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
|
||||
if (quad){
|
||||
quad->SetColor(ARGB((int)pos.actA,255,255,255));
|
||||
float scale = pos.actZ * 257.f / quad->mHeight;
|
||||
renderer->RenderQuad(quad, pos.actX, pos.actY, pos.actT, scale, scale);
|
||||
return;
|
||||
}
|
||||
|
||||
JQuad * q;
|
||||
if ((q = cache.getThumb(card)))
|
||||
{
|
||||
float scale = pos.actZ * 250 / q->mHeight;
|
||||
q->SetColor(ARGB((int)pos.actA,255,255,255));
|
||||
renderer->RenderQuad(q, pos.actX, pos.actY, pos.actT, scale, scale);
|
||||
return;
|
||||
}
|
||||
|
||||
// If we come here, we do not have the picture.
|
||||
|
||||
void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, const Pos& pos){
|
||||
// Draw the "unknown" card model
|
||||
MTGCard * mtgcard = card->model;
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
JQuad * q;
|
||||
switch(card->getColor())
|
||||
{
|
||||
case Constants::MTG_COLOR_GREEN: q = GameApp::CommonRes->GetQuad("green"); break;
|
||||
@@ -165,7 +148,7 @@ void CardGui::RenderBig(const Pos& pos){
|
||||
if (card->isCreature())
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%i/%i", card->power, card->life);
|
||||
sprintf(buffer, "%i/%i", card->power, card->toughness);
|
||||
float w = font->GetStringWidth(buffer) * 0.8;
|
||||
font->DrawString(buffer, pos.actX + 65 - w / 2, pos.actY + 106);
|
||||
}
|
||||
@@ -225,6 +208,30 @@ void CardGui::RenderBig(const Pos& pos){
|
||||
font->SetScale(backup_scale);
|
||||
}
|
||||
|
||||
void CardGui::RenderBig(const Pos& pos){
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
|
||||
if (quad){
|
||||
quad->SetColor(ARGB((int)pos.actA,255,255,255));
|
||||
float scale = pos.actZ * 257.f / quad->mHeight;
|
||||
renderer->RenderQuad(quad, pos.actX, pos.actY, pos.actT, scale, scale);
|
||||
return;
|
||||
}
|
||||
|
||||
JQuad * q;
|
||||
if ((q = cache.getThumb(card)))
|
||||
{
|
||||
float scale = pos.actZ * 250 / q->mHeight;
|
||||
q->SetColor(ARGB((int)pos.actA,255,255,255));
|
||||
renderer->RenderQuad(q, pos.actX, pos.actY, pos.actT, scale, scale);
|
||||
return;
|
||||
}
|
||||
|
||||
// If we come here, we do not have the picture.
|
||||
MTGCard * mtgcard = card->model;
|
||||
alternateRender(card,manaIcons,pos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
MTGCardInstance* CardView::getCard() { return card; }
|
||||
|
||||
@@ -43,8 +43,6 @@ GameApp::GameApp(): JApp()
|
||||
players[0] = 0;
|
||||
players[1] = 0;
|
||||
gameType = GAME_TYPE_CLASSIC;
|
||||
//gameType = GAME_TYPE_MOMIR;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -97,6 +95,8 @@ void GameApp::Create()
|
||||
|
||||
CommonRes->CreateTexture("sets/back.jpg");
|
||||
CommonRes->CreateQuad("back", "sets/back.jpg", 0, 0, 200, 285);
|
||||
CommonRes->GetQuad("back")->SetHotSpot(100, 145);
|
||||
|
||||
CommonRes->CreateTexture("sets/back_thumb.jpg");
|
||||
CommonRes->CreateQuad("back_thumb", "sets/back_thumb.jpg", 0, 0, MTG_MINIIMAGE_WIDTH, MTG_MINIIMAGE_HEIGHT);
|
||||
|
||||
@@ -166,8 +166,7 @@ void GameApp::Create()
|
||||
//CommonRes->CreateTexture("graphics/interrupt.png");
|
||||
//CommonRes->CreateQuad("interrupt", "graphics/interrupt.png", 0, 0, 256, 128);
|
||||
|
||||
cache = NEW TexturesCache();
|
||||
collection = NEW MTGAllCards(cache);
|
||||
collection = NEW MTGAllCards(&cache);
|
||||
|
||||
|
||||
Particles[0] = NEW hgeParticleSystem("graphics/particle1.psi", CommonRes->GetQuad("particles"));
|
||||
@@ -233,7 +232,6 @@ void GameApp::Destroy()
|
||||
collection->destroyAllCards();
|
||||
SAFE_DELETE(collection);
|
||||
}
|
||||
SAFE_DELETE(cache);
|
||||
SampleCache::DestroyInstance();
|
||||
delete(DeckStats::GetInstance());
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ void GameStateMenu::fillScroller(){
|
||||
scroller->Add(buff2);
|
||||
|
||||
|
||||
DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(RESPATH"/player/collection.dat", mParent->cache,mParent->collection));
|
||||
DeckDataWrapper* ddw = NEW DeckDataWrapper(NEW MTGDeck(RESPATH"/player/collection.dat", &cache,mParent->collection));
|
||||
int totalCards = ddw->getCount();
|
||||
if (totalCards){
|
||||
sprintf(buff2, _("You have a total of %i cards in your collection").c_str(),totalCards);
|
||||
@@ -401,7 +401,7 @@ void GameStateMenu::createUsersFirstDeck(int setId){
|
||||
sprintf(buf, "setID: %i", setId);
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
MTGDeck *mCollection = NEW MTGDeck(RESPATH"/player/collection.dat", mParent->cache, mParent->collection);
|
||||
MTGDeck *mCollection = NEW MTGDeck(RESPATH"/player/collection.dat", &cache, mParent->collection);
|
||||
//10 lands of each
|
||||
int sets[] = {setId};
|
||||
if (!mCollection->addRandomCards(10, sets,1, Constants::RARITY_L,"Forest")){
|
||||
|
||||
@@ -68,9 +68,10 @@ ShopItem::ShopItem(int id, JLBFont *font, int _cardid, float _xy[], bool hasFocu
|
||||
quantity = 1 + (rand() % 4);
|
||||
if (card->getRarity() == Constants::RARITY_L) quantity = 50;
|
||||
quad = NULL;
|
||||
// thumb = card->getThumb();
|
||||
// if (!thumb)
|
||||
thumb = GameApp::CommonRes->GetQuad("back_thumb");
|
||||
|
||||
thumb = cache.getThumb(card);
|
||||
|
||||
if (!thumb) thumb = GameApp::CommonRes->GetQuad("back_thumb");
|
||||
if (thumb){
|
||||
mesh=NEW hgeDistortionMesh(2,2);
|
||||
mesh->SetTexture(thumb->mTex);
|
||||
@@ -158,9 +159,9 @@ void ShopItem::Render(){
|
||||
if (card) quad = cache.getQuad(card);
|
||||
if (quad){
|
||||
quad->SetColor(ARGB(255,255,255,255));
|
||||
renderer->RenderQuad(quad,SCREEN_WIDTH/2 + 50,5,0, 0.9f,0.9f);
|
||||
renderer->RenderQuad(quad,SCREEN_WIDTH - 105,SCREEN_HEIGHT/2 - 5,0, 0.9f,0.9f);
|
||||
}else{
|
||||
// if (card) CardGui::alternateRender(card,NULL,SCREEN_WIDTH/2 + 100 + 20,133,0, 0.9f);
|
||||
//if (card) CardGui::alternateRender(card,NULL,SCREEN_WIDTH/2 + 100 + 20,133,0, 0.9f);
|
||||
}
|
||||
mFont->DrawString(mText.c_str(), SCREEN_WIDTH/2 - 50, SCREEN_HEIGHT - 16,JGETEXT_CENTER);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user