* 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.
This commit is contained in:
jean.chalard
2010-01-11 16:36:58 +00:00
parent 26aecc8224
commit edad6a5c97
+16 -5
View File
@@ -58,7 +58,7 @@ void CardSelector::Remove(CardSelector::Target* card)
} }
} }
template <> template<>
CardSelector::Target* CardSelector::fetchMemory(SelectorMemory& memory) CardSelector::Target* CardSelector::fetchMemory(SelectorMemory& memory)
{ {
if (NULL == memory.object) return NULL; 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 // 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. // it is there but it is now refused by the limitor.
return closest<True>(cards, limitor, memory.x, memory.y); PlayGuiObject* x = closest<True>(cards, limitor, memory.x, memory.y);
CardView* c = dynamic_cast<CardView*>(x);
return x;
} }
template<> template<>
void CardSelector::Push() void CardSelector::Push()
@@ -155,15 +157,24 @@ bool CardSelector::CheckUserInput(u32 key)
if (oldowner != owner) if (oldowner != owner)
{ {
if (nullZone != owner) if (nullZone != owner)
{
if (PlayGuiObject* old = fetchMemory(lasts[owner])) if (PlayGuiObject* old = fetchMemory(lasts[owner]))
active = old; 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); lasts[oldowner] = SelectorMemory(oldactive);
} }
} }
if (active != oldactive) if (active != oldactive)
{ {
{ 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*>(oldactive); if (c) c->zoom = 1.0; }
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; } //Is this needed, I think it is one in Entering() ? { CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; }
if (oldactive) oldactive->Leaving(0); if (oldactive) oldactive->Leaving(0);
if (active) active->Entering(); if (active) active->Entering();
} }