diff --git a/projects/mtg/include/CardSelector.h b/projects/mtg/include/CardSelector.h index 32cd3e077..82dd4eae1 100644 --- a/projects/mtg/include/CardSelector.h +++ b/projects/mtg/include/CardSelector.h @@ -32,7 +32,6 @@ public: virtual void Add(PlayGuiObject*) = 0; virtual void Remove(PlayGuiObject*) = 0; virtual bool CheckUserInput(JButton key) = 0; - virtual bool CheckUserInput(int x, int y) = 0; virtual void PushLimitor() = 0; virtual void PopLimitor() = 0; virtual void Limit(LimitorFunctor* inLimitor, CardView::SelectorZone inZone) = 0; @@ -75,7 +74,6 @@ public: void Add(PlayGuiObject*); void Remove(PlayGuiObject*); bool CheckUserInput(JButton key); - bool CheckUserInput(int x, int y); void Update(float dt); void Render(); void Push(); diff --git a/projects/mtg/src/CardSelector.cpp b/projects/mtg/src/CardSelector.cpp index 1fa3cc2d0..6ee11ede9 100644 --- a/projects/mtg/src/CardSelector.cpp +++ b/projects/mtg/src/CardSelector.cpp @@ -226,123 +226,68 @@ bool CardSelector::CheckUserInput(JButton key) } } } - if (active != oldactive) + if(key != JGE_BTN_NONE) { - CardView::SelectorZone oldowner, owner; - if (CardView *q = dynamic_cast(oldactive)) - oldowner = q->owner; - else - oldowner = CardView::nullZone; - if (CardView *q = dynamic_cast(active)) - owner = q->owner; - else - owner = CardView::nullZone; - if (oldowner != owner) - { - if (CardView::nullZone != owner) - { - if (PlayGuiObject* old = fetchMemory(lasts[owner])) - switch (key) - { - case JGE_BTN_LEFT: - if (old->x < oldactive->x) - active = old; - break; - case JGE_BTN_RIGHT: - if (old->x > oldactive->x) - active = old; - break; - case JGE_BTN_UP: - if (old->y < oldactive->y) - active = old; - break; - case JGE_BTN_DOWN: - if (old->y > oldactive->y) - active = old; - break; - default: - if (old) - active = old; - break; - } - } - lasts[oldowner] = SelectorMemory(oldactive); - } - } - else - { - // active card hasn't changed - that means we're probably at an edge of the battlefield. - // check if we're not already a selected avatar - if not, select one depending whether we're going up/down. - GuiAvatar* avatar = dynamic_cast (active); - if (!avatar) - { - if (key == JGE_BTN_DOWN) - { - active = duel->GetAvatars()->GetSelf(); - } - else if (key == JGE_BTN_UP) - { - active = duel->GetAvatars()->GetOpponent(); - } - } - } - if (active != oldactive) - { - { - CardView* c = dynamic_cast (oldactive); - if (c) - c->zoom = 1.0f; - } - { - CardView* c = dynamic_cast (active); - if (c) - c->zoom = 1.4f; - } - if (oldactive) - oldactive->Leaving(JGE_BTN_NONE); - if (active) - active->Entering(); - } - return true; -} - -bool CardSelector::CheckUserInput(int x, int y) -{ - if (!active) - { - for (vector::iterator it = cards.begin(); it != cards.end(); ++it) - if ((NULL == limitor) || (limitor->select(*it))) - { - active = *it; - active->Entering(); - return true; - } - return true; - } - Target* oldactive = active; - active = closest (cards, limitor, static_cast (x), static_cast (y)); - - if (active != oldactive) - { - CardView::SelectorZone oldowner, owner; - if (CardView *q = dynamic_cast(oldactive)) - oldowner = q->owner; - else - oldowner = CardView::nullZone; - if (CardView *q = dynamic_cast(active)) - owner = q->owner; - else - owner = CardView::nullZone; - if (oldowner != owner) - { - if (CardView::nullZone != owner) - { - if (PlayGuiObject* old = fetchMemory(lasts[owner])) - if (old) - active = old; - } - lasts[oldowner] = SelectorMemory(oldactive); - } + if (active != oldactive) + { + CardView::SelectorZone oldowner, owner; + if (CardView *q = dynamic_cast(oldactive)) + oldowner = q->owner; + else + oldowner = CardView::nullZone; + if (CardView *q = dynamic_cast(active)) + owner = q->owner; + else + owner = CardView::nullZone; + if (oldowner != owner) + { + if (CardView::nullZone != owner) + { + if (PlayGuiObject* old = fetchMemory(lasts[owner])) + switch (key) + { + case JGE_BTN_LEFT: + if (old->x < oldactive->x) + active = old; + break; + case JGE_BTN_RIGHT: + if (old->x > oldactive->x) + active = old; + break; + case JGE_BTN_UP: + if (old->y < oldactive->y) + active = old; + break; + case JGE_BTN_DOWN: + if (old->y > oldactive->y) + active = old; + break; + default: + if (old) + active = old; + break; + } + } + lasts[oldowner] = SelectorMemory(oldactive); + } + } + else + { + // active card hasn't changed - that means we're probably at an edge of the battlefield. + // check if we're not already a selected avatar - if not, select one depending whether we're going up/down. + GuiAvatar* avatar = dynamic_cast (active); + if (!avatar) + { + if (key == JGE_BTN_DOWN) + { + active = duel->GetAvatars()->GetSelf(); + } + else if (key == JGE_BTN_UP) + { + active = duel->GetAvatars()->GetOpponent(); + } + } + } } if (active != oldactive) {