From edad6a5c970749cd436878a87cb8585f78d75b02 Mon Sep 17 00:00:00 2001 From: "jean.chalard" Date: Mon, 11 Jan 2010 16:36:58 +0000 Subject: [PATCH] J : * Fix a bug where the closest card to the old coordinates of a no more inplay card would be chosen regardless of whether it complies with the user's request. --- projects/mtg/src/CardSelector.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/projects/mtg/src/CardSelector.cpp b/projects/mtg/src/CardSelector.cpp index 096d56771..600c769a5 100644 --- a/projects/mtg/src/CardSelector.cpp +++ b/projects/mtg/src/CardSelector.cpp @@ -58,7 +58,7 @@ void CardSelector::Remove(CardSelector::Target* card) } } -template <> +template<> CardSelector::Target* CardSelector::fetchMemory(SelectorMemory& memory) { if (NULL == memory.object) return NULL; @@ -73,7 +73,9 @@ CardSelector::Target* CardSelector::fetchMemory(SelectorMemory& memory) } // We come here if the card is not in the selector any more, or if // it is there but it is now refused by the limitor. - return closest(cards, limitor, memory.x, memory.y); + PlayGuiObject* x = closest(cards, limitor, memory.x, memory.y); + CardView* c = dynamic_cast(x); + return x; } template<> void CardSelector::Push() @@ -138,7 +140,7 @@ bool CardSelector::CheckUserInput(u32 key) active = closest(cards, limitor, active); break; case PSP_CTRL_TRIANGLE: - bigMode = (bigMode+1) % NB_BIG_MODES; + bigMode = (bigMode+1) % NB_BIG_MODES; if(bigMode == BIG_MODE_TEXT) options[Options::DISABLECARDS].number = 1; else @@ -155,15 +157,24 @@ bool CardSelector::CheckUserInput(u32 key) if (oldowner != owner) { if (nullZone != owner) - if (PlayGuiObject* old = fetchMemory(lasts[owner])) - active = old; + { + if (PlayGuiObject* old = fetchMemory(lasts[owner])) + switch (key) + { + case PSP_CTRL_LEFT: if (old->x < oldactive->x) active = old; break; + case PSP_CTRL_RIGHT: if (old->x > oldactive->x) active = old; break; + case PSP_CTRL_UP: if (old->y < oldactive->y) active = old; break; + case PSP_CTRL_DOWN: if (old->y > oldactive->y) active = old; break; + default: if (old) active = old; break; + } + } lasts[oldowner] = SelectorMemory(oldactive); } } if (active != oldactive) { - { CardView* c = dynamic_cast(oldactive); if (c) c->zoom = 1.0; } //Is this needed, I think it is one in Leaving(0) ? - { CardView* c = dynamic_cast(active); if (c) c->zoom = 1.4; } //Is this needed, I think it is one in Entering() ? + { CardView* c = dynamic_cast(oldactive); if (c) c->zoom = 1.0; } + { CardView* c = dynamic_cast(active); if (c) c->zoom = 1.4; } if (oldactive) oldactive->Leaving(0); if (active) active->Entering(); }