* Add the Trash facility and use it for CardViews.
* Fix a graphical bug with card shadows.
* Fix a graphical bug with limitors.
* Enhance the graphical appearance of cards going to graveyard.
This commit is contained in:
jean.chalard
2009-09-05 11:44:34 +00:00
parent 44738399dc
commit b6781e82f1
8 changed files with 78 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardSelector.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/SimplePad.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o objs/WResourceManager.o
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardSelector.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/SimplePad.o objs/Token.o objs/Translate.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)

View File

@@ -0,0 +1,21 @@
#ifndef _TRASH_H_
#define _TRASH_H_
#include <vector>
#include "Pos.h"
#include "WEvent.h"
void trash(Pos*);
class Trash
{
std::vector<Pos*> bin;
void put_out();
int receiveEvent(WEvent* e);
friend void trash(Pos*);
public:
static void cleanup();
};
#endif // _TRASH_H_

View File

@@ -51,17 +51,18 @@ void CardGui::Render()
if (game) tc = game->getCurrentTargetChooser();
JQuad * quad = resources.RetrieveCard(card,CACHE_THUMB);
JQuad* shadow = resources.GetQuad("shadow");
if (quad) {
const float scale = actZ * 40 / quad->mHeight;
renderer->RenderQuad(resources.GetQuad("shadow"), actX + (scale-1)*15, actY + (scale-1)*15, actT, 28*scale, 40*scale);
renderer->RenderQuad(shadow, actX + (scale-1)*15, actY + (scale-1)*15, actT, 28*scale, 40*scale);
quad->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
renderer->RenderQuad(quad, actX, actY, actT, scale, scale);
}
else {
const float scale = actZ;
renderer->RenderQuad(resources.GetQuad("shadow"), actX + (scale-1)*15, actY + (scale-1)*15, actT, 28*scale, 40*scale);
shadow->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
renderer->RenderQuad(shadow, actX + scale*2, actY + scale*2, actT, 28*scale, 40*scale);
mFont->SetColor(ARGB(static_cast<unsigned char>(actA), 0, 0, 0));
JQuad * icon = NULL;
@@ -86,7 +87,11 @@ void CardGui::Render()
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.5 * actZ);
mFont->DrawString(card->getName().c_str(), actX - actZ * Width / 2 + 1, actY - actZ * Height / 2 + 1);
if (icon) { icon->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255)); renderer->RenderQuad(icon, actX, actY, 0); }
if (tc && !tc->canTarget(card)) renderer->FillRect(actX - actZ*Width/2, actY - actZ*Height/2, actZ*Width, actZ*Height, ARGB((static_cast<unsigned char>(actA*0.75)),0,0,0));
if (tc && !tc->canTarget(card))
{
shadow->SetColor(ARGB(static_cast<unsigned char>(actA),128,92,92));
renderer->RenderQuad(shadow, actX, actY, actT, 28*scale, 40*scale);
}
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
}

View File

@@ -1,5 +1,4 @@
#include "../include/config.h"
#include "../include/DuelLayers.h"
#include "../include/MTGRules.h"
#include "../include/GuiCombat.h"
#include "../include/GuiBackground.h"
@@ -9,6 +8,8 @@
#include "../include/GuiHand.h"
#include "../include/GuiPlay.h"
#include "../include/GuiMana.h"
#include "../include/Trash.h"
#include "../include/DuelLayers.h"
void DuelLayers::init(){
@@ -78,9 +79,9 @@ DuelLayers::DuelLayers() : nbitems(0) {}
DuelLayers::~DuelLayers(){
for (int i = 0; i < nbitems; ++i) delete objects[i];
for (size_t i = 0; i < waiters.size(); ++i){
for (size_t i = 0; i < waiters.size(); ++i)
delete(waiters[i]);
}
Trash::cleanup();
}
int DuelLayers::unstoppableRenderInProgress(){
@@ -150,6 +151,11 @@ int DuelLayers::receiveEvent(WEvent * e){
}
for (int i = 0; i < nbitems; ++i)
objects[i]->receiveEventMinus(e);
if (WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e))
if (Constants::MTG_PHASE_BEFORE_BEGIN == event->to->id)
Trash::cleanup();
return 1;
}

View File

@@ -1,5 +1,6 @@
#include "../include/config.h"
#include "../include/GameApp.h"
#include "../include/Trash.h"
#include "../include/GuiHand.h"
const float GuiHand::ClosedRowX = 459;
@@ -164,7 +165,7 @@ int GuiHandSelf::receiveEventMinus(WEvent* e)
cs->Remove(cv);
Repos();
cards.erase(it);
delete cv;
trash(cv);
return 1;
}
return 1;
@@ -198,7 +199,7 @@ int GuiHandOpponent::receiveEventMinus(WEvent* e)
{
CardView* cv = *it;
cards.erase(it);
delete cv;
trash(cv);
return 1;
}
return 0;

View File

@@ -1,6 +1,7 @@
#include "../include/config.h"
#include "../include/GameApp.h"
#include "../include/GuiPlay.h"
#include "../include/Trash.h"
#define CARD_WIDTH (31)
@@ -219,8 +220,7 @@ int GuiPlay::receiveEventMinus(WEvent * e)
CardView* cv = *it;
cs->Remove(cv);
cards.erase(it);
cv->card->view = NULL;
delete cv;
trash(cv);
Replace();
return 1;
}

View File

@@ -1,4 +1,5 @@
#include "../include/config.h"
#include "../include/Trash.h"
#include "../include/GuiStatic.h"
GuiStatic::GuiStatic(float desiredHeight, float x, float y, bool hasFocus, GuiAvatars* parent) : PlayGuiObject(desiredHeight, x, y, hasFocus), parent(parent) {}
@@ -162,7 +163,7 @@ int GuiGraveyard::receiveEventPlus(WEvent* e)
t = NEW CardView(event->card, *(event->card->view));
else
t = NEW CardView(event->card, x, y);
t->x = x + Width / 2; t->y = y + Height / 2; t->zoom = 0.3; t->alpha = 0;
t->x = x + Width / 2; t->y = y + Height / 2; t->zoom = 0.6; t->alpha = 0;
cards.push_back(t);
return 1;
}
@@ -178,7 +179,7 @@ int GuiGraveyard::receiveEventMinus(WEvent* e)
{
CardView* cv = *it;
cards.erase(it);
delete cv;
trash(cv);
return 1;
}
return 0;

View File

@@ -0,0 +1,30 @@
#include <iostream>
#include "../include/MTGDefinitions.h"
#include "../include/Pos.h"
#include "../include/CardGui.h"
#include "../include/Trash.h"
void Trash::put_out()
{
for (std::vector<Pos*>::iterator it = bin.begin(); it != bin.end(); ++it)
{
std::cout << "DELETE " << *it << std::endl;
if (CardView *c = dynamic_cast<CardView*>(*it))
SAFE_DELETE(c);
else
SAFE_DELETE(*it);
}
bin.clear();
}
static Trash PosTrash;
void Trash::cleanup()
{
PosTrash.put_out();
}
void trash(Pos* garbage)
{
PosTrash.bin.push_back(garbage);
}