- fix issue 22 (Graveyard display messed up)
- fix issue 38 (graveyard and library unusable)
- fix issue 59 (can't cancel a spell with a target)
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-09-26 10:03:52 +00:00
parent 9a6f85ecab
commit 833fbba6c2
13 changed files with 2310 additions and 2254 deletions
+23 -1
View File
@@ -11,6 +11,7 @@ CardDisplay::CardDisplay() : mId(0), game(GameObserver::GetInstance()) {
start_item = 0;
x= 0;
y= 0;
zone = NULL;
}
CardDisplay::CardDisplay(int id, GameObserver* game, int _x, int _y, JGuiListener * _listener, TargetChooser * _tc, int _nb_displayed_items ) : mId(id), game(game), x(_x), y(_y) {
@@ -18,21 +19,26 @@ CardDisplay::CardDisplay(int id, GameObserver* game, int _x, int _y, JGuiListene
listener = _listener;
nb_displayed_items = _nb_displayed_items;
start_item = 0;
if (x + nb_displayed_items * 30 + 25 > SCREEN_WIDTH) x = SCREEN_WIDTH - (nb_displayed_items * 30 + 25);
if (y + 55 > SCREEN_HEIGHT) y = SCREEN_HEIGHT - 55;
zone = NULL;
}
void CardDisplay::AddCard(MTGCardInstance * _card){
CardGui * card = NEW CardView(CardSelector::nullZone, _card, x + 5 + (mCount - start_item) * 30, y + 5);
CardGui * card = NEW CardView(CardSelector::nullZone, _card, x + 20 + (mCount - start_item) * 30, y + 25);
Add(card);
}
void CardDisplay::init(MTGGameZone * zone){
resetObjects();
if (!zone) return;
start_item = 0;
for (int i= 0; i< zone->nb_cards; i++){
AddCard(zone->cards[i]);
}
if (mObjects[0]) mObjects[0]->Entering();
}
void CardDisplay::rotateLeft(){
@@ -54,6 +60,22 @@ void CardDisplay::rotateRight(){
}
void CardDisplay::Update(float dt){
bool update = false;
if (zone){
size_t size = zone->cards.size();
for (int i = start_item; i< start_item + nb_displayed_items && i < mCount; i++){
if (i > size - 1) {update = true; break;}
CardGui * cardg = (CardGui *)mObjects[i];
if (cardg->card != zone->cards[i]) update = true;
}
}
PlayGuiObjectController::Update(dt);
if (update) init(zone);
}
bool CardDisplay::CheckUserInput(u32 key){
if (PSP_CTRL_CROSS == key)
{
+7 -4
View File
@@ -99,8 +99,8 @@ void CardSelector::Pop()
}
if (active != oldactive)
{
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; }
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; }
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; } //Is this needed, I think it is one in Leaving(0) ?
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; } //Is this needed, I think it is one in Entering() ?
if (oldactive) oldactive->Leaving(0);
if (active) active->Entering();
}
@@ -123,6 +123,9 @@ bool CardSelector::CheckUserInput(u32 key)
Target* oldactive = active;
switch (key)
{
case PSP_CTRL_CROSS:
GameObserver::GetInstance()->cancelCurrentAction();
return true;
case PSP_CTRL_CIRCLE:
GameObserver::GetInstance()->ButtonPressed(active);
return true;
@@ -160,8 +163,8 @@ bool CardSelector::CheckUserInput(u32 key)
}
if (active != oldactive)
{
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; }
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; }
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; } //Is this needed, I think it is one in Leaving(0) ?
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; } //Is this needed, I think it is one in Entering() ?
if (oldactive) oldactive->Leaving(0);
if (active) active->Entering();
}
+2 -1
View File
@@ -39,7 +39,7 @@ void DuelLayers::init(){
Add(NEW GuiHandOpponent(cs, go->players[1]->game->hand));
Add(NEW GuiPlay(go, cs));
Add(NEW GuiAvatars(cs));
Add(avatars = NEW GuiAvatars(cs));
Add(NEW GuiPhaseBar());
Add(NEW GuiFrame());
Add(NEW GuiBackground());
@@ -53,6 +53,7 @@ void DuelLayers::CheckUserInput(int isAI){
if (stack->CheckUserInput(key)) break;
if (combat->CheckUserInput(key)) break;
if (action->CheckUserInput(key)) break;
if (avatars->CheckUserInput(key)) break;
if (hand->CheckUserInput(key)) break;
if (cs->CheckUserInput(key)) break;
}
+11
View File
@@ -2,6 +2,8 @@
#include "../include/GameApp.h"
#include "../include/GuiAvatars.h"
#define LIB_GRAVE_OFFSET 230
GuiAvatars::GuiAvatars(CardSelector* cs) : cs(cs), active(NULL)
{
Add(self = NEW GuiAvatar (SCREEN_WIDTH, SCREEN_HEIGHT, false,
@@ -52,6 +54,15 @@ int GuiAvatars::receiveEventMinus(WEvent* e)
return 1;
}
bool GuiAvatars::CheckUserInput(u32 key){
if (self->CheckUserInput(key)) return true;
if (opponent->CheckUserInput(key)) return true;
if (selfGraveyard->CheckUserInput(key)) return true;
if (opponentGraveyard->CheckUserInput(key)) return true;
if (selfLibrary->CheckUserInput(key)) return true;
if (opponentLibrary->CheckUserInput(key)) return true;
return false;
}
void GuiAvatars::Update(float dt)
{
+6
View File
@@ -124,6 +124,11 @@ void GuiGameZone::ButtonPressed(int controllerId, int controlId){
GameObserver::GetInstance()->ButtonPressed(this);
}
bool GuiGameZone::CheckUserInput(u32 key){
if (showCards) return cd->CheckUserInput(key);
return false;
}
void GuiGameZone::Update(float dt){
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
(*it)->Update(dt);
@@ -133,6 +138,7 @@ void GuiGameZone::Update(float dt){
GuiGameZone::GuiGameZone(float x, float y, bool hasFocus, MTGGameZone* zone, GuiAvatars* parent): GuiStatic(GuiGameZone::Height, x, y, hasFocus, parent), zone(zone){
cd = NEW CardDisplay(0, GameObserver::GetInstance(), x, y, this);
cd->zone = zone;
showCards = 0;
}
+1 -4
View File
@@ -54,15 +54,12 @@ void MTGCardInstance::copy(MTGCardInstance * card){
text = source->text;
name = source->name;
//strcpy(image_name, source->image_name);
//rarity = source->rarity;
power = source->power;
toughness = source->toughness;
life = toughness;
lifeOrig = life;
//mtgid = source->mtgid;
//setId = source->setId;
magicText = source->magicText;
spellTargetType = source->spellTargetType;
alias = source->alias;