J :
* Create selection zones to remember the last card the cursor was on.
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
#ifndef _CARD_GUI_H_
|
||||
#define _CARD_GUI_H_
|
||||
|
||||
#include <hge/hgeparticle.h>
|
||||
#include <JGui.h>
|
||||
#include "Pos.h"
|
||||
#include "PlayGuiObject.h"
|
||||
#include "MTGCardInstance.h"
|
||||
#include <hge/hgeparticle.h>
|
||||
#include "CardSelector.h"
|
||||
|
||||
class MTGCardInstance;
|
||||
class PlayGuiObject;
|
||||
@@ -34,10 +35,11 @@ struct CardGui : public PlayGuiObject {
|
||||
|
||||
class CardView : public CardGui {
|
||||
public:
|
||||
const CardSelector::SelectorZone owner;
|
||||
|
||||
MTGCardInstance* getCard(); // remove this when possible
|
||||
CardView(MTGCardInstance* card, float x, float y);
|
||||
CardView(MTGCardInstance* card, const Pos& ref);
|
||||
CardView(const CardSelector::SelectorZone, MTGCardInstance* card, float x, float y);
|
||||
CardView(const CardSelector::SelectorZone, MTGCardInstance* card, const Pos& ref);
|
||||
void Render(){CardGui::Render();};
|
||||
void Render(JQuad* q){Pos::Render(q);};
|
||||
virtual ostream& toString(ostream&) const;
|
||||
|
||||
@@ -22,6 +22,11 @@ struct LimitorFunctor
|
||||
template <typename T=PlayGuiObject>
|
||||
class ObjectSelector : public GuiLayer
|
||||
{
|
||||
public:
|
||||
typedef enum {
|
||||
nullZone, handZone, playZone
|
||||
} SelectorZone;
|
||||
|
||||
protected:
|
||||
vector<T*> cards;
|
||||
T* active;
|
||||
@@ -29,8 +34,7 @@ class ObjectSelector : public GuiLayer
|
||||
DuelLayers* duel;
|
||||
LimitorFunctor<T>* limitor;
|
||||
Pos bigpos;
|
||||
|
||||
T* handLast; T* playLast;
|
||||
map<const SelectorZone, T*> lasts;
|
||||
|
||||
public:
|
||||
ObjectSelector(DuelLayers*);
|
||||
|
||||
@@ -22,7 +22,7 @@ CardDisplay::CardDisplay(int id, GameObserver* game, int _x, int _y, JGuiListene
|
||||
|
||||
|
||||
void CardDisplay::AddCard(MTGCardInstance * _card){
|
||||
CardGui * card = NEW CardView(_card, x + 5 + (mCount - start_item) * 30, y + 5);
|
||||
CardGui * card = NEW CardView(CardSelector::nullZone, _card, x + 5 + (mCount - start_item) * 30, y + 5);
|
||||
Add(card);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ const float CardGui::BigHeight = 285.0;
|
||||
CardGui::CardGui(MTGCardInstance* card, float x, float y) : PlayGuiObject(Height, x, y, false), card(card) {}
|
||||
CardGui::CardGui(MTGCardInstance* card, const Pos& ref) : PlayGuiObject(Height, ref, false), card(card) {}
|
||||
|
||||
CardView::CardView(MTGCardInstance* card, float x, float y) : CardGui(card, x, y) {
|
||||
CardView::CardView(const CardSelector::SelectorZone owner, MTGCardInstance* card, float x, float y) : CardGui(card, x, y), owner(owner) {
|
||||
const Pos* ref = card->view;
|
||||
while (card)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ CardView::CardView(MTGCardInstance* card, float x, float y) : CardGui(card, x, y
|
||||
}
|
||||
}
|
||||
|
||||
CardView::CardView(MTGCardInstance* card, const Pos& ref) : CardGui(card, ref) {
|
||||
CardView::CardView(const CardSelector::SelectorZone owner, MTGCardInstance* card, const Pos& ref) : CardGui(card, ref), owner(owner) {
|
||||
const Pos* r = card->view;
|
||||
while (card)
|
||||
{
|
||||
|
||||
@@ -94,7 +94,25 @@ bool CardSelector::CheckUserInput(u32 key)
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
if (active != oldactive) { oldactive->Leaving(key); active->Entering(); }
|
||||
if (active != oldactive)
|
||||
{
|
||||
SelectorZone oldowner, owner;
|
||||
if (CardView *q = dynamic_cast<CardView*>(oldactive)) oldowner = q->owner; else oldowner = nullZone;
|
||||
if (CardView *q = dynamic_cast<CardView*>(active)) owner = q->owner; else owner = nullZone;
|
||||
if (oldowner != owner)
|
||||
{
|
||||
if (nullZone != owner)
|
||||
if (PlayGuiObject* old = lasts[owner]) active = old;
|
||||
lasts[oldowner] = oldactive;
|
||||
}
|
||||
}
|
||||
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; }
|
||||
oldactive->Leaving(key);
|
||||
active->Entering();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ static inline Target* closest(vector<Target*>& cards, Limitor* limitor, Target*
|
||||
else
|
||||
card = *it;
|
||||
}
|
||||
{ CardView* c = dynamic_cast<CardView*>(ref); if (c) c->zoom = 1.0; }
|
||||
{ CardView* c = dynamic_cast<CardView*>(card); if (c) c->zoom = 1.4; }
|
||||
return card;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,8 +175,20 @@ bool GuiCombat::CheckUserInput(u32 key)
|
||||
activeAtk = static_cast<AttackerDamaged*>(active);
|
||||
cursor_pos = ATK;
|
||||
break;
|
||||
case ATK : active = closest<Left>(attackers, NULL, static_cast<AttackerDamaged*>(active)); activeAtk = static_cast<AttackerDamaged*>(active); break;
|
||||
case BLK : active = closest<Left>(activeAtk->blockers, NULL, static_cast<DefenserDamaged*>(active)); break;
|
||||
case ATK :
|
||||
{
|
||||
DamagerDamaged* old = active;
|
||||
active = closest<Left>(attackers, NULL, static_cast<AttackerDamaged*>(active)); activeAtk = static_cast<AttackerDamaged*>(active);
|
||||
if (old != active) { if (old) old->zoom = 1.0; if (active) active->zoom = 1.4; }
|
||||
}
|
||||
break;
|
||||
case BLK :
|
||||
{
|
||||
DamagerDamaged* old = active;
|
||||
active = closest<Left>(activeAtk->blockers, NULL, static_cast<DefenserDamaged*>(active));
|
||||
if (old != active) { if (old) old->zoom = 1.0; if (active) active->zoom = 1.4; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PSP_CTRL_RIGHT:
|
||||
@@ -184,10 +196,24 @@ bool GuiCombat::CheckUserInput(u32 key)
|
||||
{
|
||||
case NONE :
|
||||
case OK : break;
|
||||
case BLK : active = closest<Right>(activeAtk->blockers, NULL, static_cast<DefenserDamaged*>(active)); break;
|
||||
case ATK : active = closest<Right>(attackers, NULL, static_cast<AttackerDamaged*>(active));
|
||||
if (active == oldActive) { active = activeAtk = NULL; cursor_pos = OK; }
|
||||
else activeAtk = static_cast<AttackerDamaged*>(active);
|
||||
case BLK :
|
||||
{
|
||||
DamagerDamaged* old = active;
|
||||
active = closest<Right>(activeAtk->blockers, NULL, static_cast<DefenserDamaged*>(active));
|
||||
if (old != active) { if (old) old->zoom = 1.0; if (active) active->zoom = 1.4; }
|
||||
}
|
||||
break;
|
||||
case ATK :
|
||||
{
|
||||
DamagerDamaged* old = active;
|
||||
active = closest<Right>(attackers, NULL, static_cast<AttackerDamaged*>(active));
|
||||
if (active == oldActive) { active = activeAtk = NULL; cursor_pos = OK; }
|
||||
else
|
||||
{
|
||||
if (old != active) { if (old) old->zoom = 1.0; if (active) active->zoom = 1.4; }
|
||||
activeAtk = static_cast<AttackerDamaged*>(active);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -10,7 +10,6 @@ const float GuiHand::RightRowX = 460;
|
||||
const float GuiHand::OpenX = 394;
|
||||
const float GuiHand::ClosedX = 494;
|
||||
|
||||
|
||||
bool HandLimitor::select(Target* t)
|
||||
{
|
||||
if (CardView* c = dynamic_cast<CardView*>(t))
|
||||
@@ -149,9 +148,9 @@ int GuiHandSelf::receiveEventPlus(WEvent* e)
|
||||
{
|
||||
CardView* card;
|
||||
if (event->card->view)
|
||||
card = NEW CardView(event->card, *(event->card->view));
|
||||
card = NEW CardView(CardSelector::handZone, event->card, *(event->card->view));
|
||||
else
|
||||
card = NEW CardView(event->card, ClosedRowX, 0);
|
||||
card = NEW CardView(CardSelector::handZone, event->card, ClosedRowX, 0);
|
||||
card->t = 6*M_PI;
|
||||
cards.push_back(card);
|
||||
cs->Add(card);
|
||||
@@ -187,9 +186,9 @@ int GuiHandOpponent::receiveEventPlus(WEvent* e)
|
||||
{
|
||||
CardView* card;
|
||||
if (event->card->view)
|
||||
card = NEW CardView(event->card, *(event->card->view));
|
||||
card = NEW CardView(CardSelector::handZone, event->card, *(event->card->view));
|
||||
else
|
||||
card = NEW CardView(event->card, ClosedRowX, 0);
|
||||
card = NEW CardView(CardSelector::handZone, event->card, ClosedRowX, 0);
|
||||
card->t = -4*M_PI; card->alpha = 255;
|
||||
cards.push_back(card);
|
||||
return 1;
|
||||
|
||||
@@ -176,9 +176,9 @@ int GuiPlay::receiveEventPlus(WEvent * e)
|
||||
{
|
||||
CardView * card;
|
||||
if (event->card->view)
|
||||
card = NEW CardView(event->card, *(event->card->view));
|
||||
card = NEW CardView(CardSelector::playZone, event->card, *(event->card->view));
|
||||
else
|
||||
card = NEW CardView(event->card, 0, 0);
|
||||
card = NEW CardView(CardSelector::playZone, event->card, 0, 0);
|
||||
cards.push_back(card);
|
||||
card->t = 0; card->alpha = 255;
|
||||
cs->Add(card);
|
||||
|
||||
@@ -160,9 +160,9 @@ int GuiGraveyard::receiveEventPlus(WEvent* e)
|
||||
{
|
||||
CardView* t;
|
||||
if (event->card->view)
|
||||
t = NEW CardView(event->card, *(event->card->view));
|
||||
t = NEW CardView(CardSelector::nullZone, event->card, *(event->card->view));
|
||||
else
|
||||
t = NEW CardView(event->card, x, y);
|
||||
t = NEW CardView(CardSelector::nullZone, event->card, x, y);
|
||||
t->x = x + Width / 2; t->y = y + Height / 2; t->zoom = 0.6; t->alpha = 0;
|
||||
cards.push_back(t);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user