Fix for issue 29, please review both code and result, thanks :)

This commit is contained in:
wagic.the.homebrew@gmail.com
2009-10-05 12:07:38 +00:00
parent 7184adba67
commit 2c863867d2
4 changed files with 62 additions and 19 deletions

View File

@@ -22,6 +22,7 @@ class GuiAvatars : public GuiLayer
~GuiAvatars();
// virtual void Render();
void Update(float dt);
void Render();
void Activate(PlayGuiObject* c);
void Deactivate(PlayGuiObject* c);
int receiveEventPlus(WEvent*);

View File

@@ -37,10 +37,9 @@ void DuelLayers::init(){
Add(action);
Add(cs);
Add(hand = NEW GuiHandSelf(cs, go->players[0]->game->hand));
Add(avatars = NEW GuiAvatars(cs));
Add(NEW GuiHandOpponent(cs, go->players[1]->game->hand));
Add(NEW GuiPlay(go, cs));
Add(avatars = NEW GuiAvatars(cs));
Add(NEW GuiPhaseBar());
Add(NEW GuiFrame());
Add(NEW GuiBackground());

View File

@@ -8,14 +8,15 @@ GuiAvatars::GuiAvatars(CardSelector* cs) : cs(cs), active(NULL)
{
Add(self = NEW GuiAvatar (SCREEN_WIDTH, SCREEN_HEIGHT, false,
GameObserver::GetInstance()->players[0], GuiAvatar::BOTTOM_RIGHT, this));
Add(selfGraveyard = NEW GuiGraveyard(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width/2, SCREEN_HEIGHT - GuiAvatar::Height - 10, false,
Add(selfGraveyard = NEW GuiGraveyard(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width/2 - 5, SCREEN_HEIGHT - GuiAvatar::Height - 5, false,
GameObserver::GetInstance()->players[0], this));
Add(selfLibrary = NEW GuiLibrary (SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width/2, SCREEN_HEIGHT - GuiAvatar::Height - 10 + GuiGameZone::Height + 5, false,
Add(selfLibrary = NEW GuiLibrary (SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width/2 - 5 , SCREEN_HEIGHT - GuiAvatar::Height - 5 + GuiGameZone::Height + 5, false,
GameObserver::GetInstance()->players[0], this));
Add(opponent = NEW GuiAvatar (0, 0, false, GameObserver::GetInstance()->players[1], GuiAvatar::TOP_LEFT, this));
Add(opponentGraveyard = NEW GuiGraveyard(GuiAvatar::Width - GuiGameZone::Width / 2, 5, false, GameObserver::GetInstance()->players[1], this));
Add(opponentLibrary = NEW GuiLibrary (GuiAvatar::Width - GuiGameZone::Width / 2, 5 + GuiGameZone::Height + 5, false, GameObserver::GetInstance()->players[1], this));
opponent->zoom = 0.9;
Add(opponentGraveyard = NEW GuiGraveyard(5 + GuiAvatar::Width * 1.2 - GuiGameZone::Width / 2, 5, false, GameObserver::GetInstance()->players[1], this));
Add(opponentLibrary = NEW GuiLibrary (5 + GuiAvatar::Width *1.2 - GuiGameZone::Width / 2, 5 + GuiGameZone::Height + 5, false, GameObserver::GetInstance()->players[1], this));
cs->Add(self); cs->Add(selfGraveyard); cs->Add(selfLibrary);
cs->Add(opponent); cs->Add(opponentGraveyard); cs->Add(opponentLibrary);
@@ -32,15 +33,21 @@ GuiAvatars::~GuiAvatars()
void GuiAvatars::Activate(PlayGuiObject* c)
{
c->zoom = 1.2;
c->mHasFocus = true;
if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponent == c))
{ opponentGraveyard->alpha = opponentLibrary->alpha = 255; active = opponent; }
{ opponentGraveyard->alpha = opponentLibrary->alpha = 128; active = opponent; opponent->zoom = 1.2;}
else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c))
{ selfGraveyard->alpha = selfLibrary->alpha = 255; self->zoom = 1.0; active = self; }
{ selfGraveyard->alpha = selfLibrary->alpha = 128; self->zoom = 1.0; active = self; }
if (opponent != c && self != c) c->alpha = 255;
}
void GuiAvatars::Deactivate(PlayGuiObject* c)
{
c->zoom = 1.0;
c->mHasFocus = false;
if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponent == c))
{ opponentGraveyard->alpha = opponentLibrary->alpha = 0; }
{ opponentGraveyard->alpha = opponentLibrary->alpha = 0; opponent->zoom = 0.9;}
else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c))
{ selfGraveyard->alpha = selfLibrary->alpha = 0; self->zoom = 0.3; }
active = NULL;
@@ -77,3 +84,16 @@ void GuiAvatars::Update(float dt)
selfLibrary->Update(dt);
opponentLibrary->Update(dt);
}
void GuiAvatars::Render()
{
JRenderer * r = JRenderer::GetInstance();
float w = 50;
float h = 60;
if (opponent == active){
r->FillRect(opponent->actX, opponent->actY, w * opponent->actZ , h * opponent->actZ, ARGB(200,0,0,0));
}else if (self == active){
r->FillRect(self->actX - w * self->actZ, self->actY - h * self->actZ, w * self->actZ , h * self->actZ, ARGB(200,0,0,0));
}
GuiLayer::Render();
}

View File

@@ -32,7 +32,7 @@ void GuiAvatar::Render()
}
currentLife = life;
r->FillRect(actX+2, actY+2, Width, Height, ARGB((int)(actA / 2), 0, 0, 0));
r->FillRect(actX+2, actY+2, Width * actZ, Height *actZ, ARGB((int)(actA / 2), 0, 0, 0));
JQuad * quad = player->mAvatar;
if (quad)
@@ -44,6 +44,17 @@ void GuiAvatar::Render()
}
quad->SetColor(ARGB((int)actA, 255, avatarRed, avatarRed));
r->RenderQuad(quad, actX, actY, actT, actZ, actZ);
if (mHasFocus){
switch (corner)
{
case TOP_LEFT :
r->FillRect(actX,actY,quad->mWidth * actZ,quad->mHeight * actZ, ARGB(abs(128 - wave),255,255,255));
break;
case BOTTOM_RIGHT :
r->FillRect(actX - quad->mWidth * actZ,actY - quad->mHeight * actZ,quad->mWidth * actZ,quad->mHeight * actZ, ARGB(abs(128 - wave),255,255,255));
break;
}
}
}
if (avatarRed < 255){
@@ -52,11 +63,13 @@ void GuiAvatar::Render()
avatarRed = 255;
}
if (game->currentPlayer == player)
r->DrawRect(actX-1, actY-1, 37, 52, ARGB((int)actA, 0, 255, 0));
r->DrawRect(actX-1, actY-1, 37 * actZ, 52*actZ, ARGB((int)actA, 0, 255, 0));
else if (game->currentActionPlayer == player)
r->DrawRect(actX, actY, 35, 50, ARGB((int)actA, 0, 0, 255));
r->DrawRect(actX, actY, 35 *actZ, 50 * actZ, ARGB((int)actA, 0, 0, 255));
if (game->isInterrupting == player)
r->DrawRect(actX, actY, 35, 50, ARGB((int)actA, 255, 0, 0));
r->DrawRect(actX, actY, 35 * actZ, 50*actZ, ARGB((int)actA, 255, 0, 0));
//Life
char buffer[5];
@@ -100,19 +113,29 @@ void GuiGameZone::Render(){
//Texture
JQuad * quad = resources.GetQuad("back_thumb");
float scale = defaultHeight / quad->mHeight;
quad->SetColor(ARGB((int)(actA/2),255,255,255));
quad->SetColor(ARGB((int)(actA),255,255,255));
JRenderer::GetInstance()->RenderQuad(quad, actX, actY, 0.0, scale, scale);
JRenderer::GetInstance()->RenderQuad(quad, actX, actY, 0.0, scale * actZ, scale * actZ);
float x0 = actX;
if (x0 < SCREEN_WIDTH/2) {
x0+=7;
}
if (mHasFocus)
JRenderer::GetInstance()->FillRect(actX,actY,quad->mWidth * scale * actZ,quad->mHeight *scale * actZ, ARGB(abs(128 - wave),255,255,255));
//Number of cards
JLBFont * mFont = resources.GetJLBFont(Constants::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[11];
sprintf(buffer,"%i", zone->nb_cards);
mFont->SetColor(ARGB((int)(actA/4),0,0,0));
mFont->DrawString(buffer, actX+1, actY+1);
mFont->SetColor(ARGB((int)actA,255,255,255));
mFont->DrawString(buffer, actX, actY);
mFont->SetColor(ARGB((int)(actA),0,0,0));
mFont->DrawString(buffer, x0+1, actY+1);
mFont->SetColor(ARGB(actA > 120 ? 255: (int)(actA),255,255,255));
mFont->DrawString(buffer, x0, actY);
if (showCards) cd->Render();
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)