Fixed issue 677

This commit is contained in:
Xawotihs
2011-07-04 19:09:19 +00:00
parent 25be470f4b
commit c25dfe426f
8 changed files with 86 additions and 103 deletions

View File

@@ -23,7 +23,6 @@ public:
void rotateLeft();
void rotateRight();
bool CheckUserInput(JButton key);
bool CheckUserInput(int x, int y);
virtual void Update(float dt);
void Render();
void init(MTGGameZone * zone);

View File

@@ -29,7 +29,6 @@ public:
int receiveEventPlus(WEvent*);
int receiveEventMinus(WEvent*);
bool CheckUserInput(JButton key);
bool CheckUserInput(int x, int y);
float LeftBoundarySelf();
};

View File

@@ -52,7 +52,6 @@ public:
int showCards;
virtual void Render();
virtual bool CheckUserInput(JButton key);
virtual bool CheckUserInput(int x, int y);
virtual void Update(float dt);
GuiGameZone(float x, float y, bool hasFocus, MTGGameZone * zone, GuiAvatars* parent);
~GuiGameZone();

View File

@@ -95,59 +95,6 @@ void CardDisplay::Update(float dt)
if (update) init(zone);
}
bool CardDisplay::CheckUserInput(int x, int y)
{
bool result = false;
unsigned int distance2;
unsigned int minDistance2 = -1;
int n = mCurr;
JButton key;
if (JGE::GetInstance()->GetLeftClickCoordinates(x, y))
{
for (size_t i = 0; i < mObjects.size(); i++)
{
float top, left;
if (mObjects[i]->getTopLeft(top, left))
{
distance2 = static_cast<unsigned int>((top - y) * (top - y) + (left - x) * (left - x));
if (distance2 < minDistance2)
{
minDistance2 = distance2;
n = i;
}
}
}
if (n < mCurr)
key = JGE_BTN_LEFT;
else
key = JGE_BTN_RIGHT;
if (n < start_item)
{
rotateLeft();
}
else if (n >= (int)(mObjects.size()) && mObjects.size())
{
n = mObjects.size() - 1;
}
if (n >= start_item + nb_displayed_items)
{
rotateRight();
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(key))
{
mCurr = n;
mObjects[mCurr]->Entering();
result = true;
}
JGE::GetInstance()->LeftClickedProcessed();
}
return result;
}
bool CardDisplay::CheckUserInput(JButton key)
{
if (JGE_BTN_SEC == key || JGE_BTN_PRI == key || JGE_BTN_UP == key || JGE_BTN_DOWN == key)
@@ -220,11 +167,62 @@ bool CardDisplay::CheckUserInput(JButton key)
mCurr = n;
mObjects[mCurr]->Entering();
}
}
return true;
default:
;
}
default:
{
bool result = false;
unsigned int distance2;
unsigned int minDistance2 = -1;
int n = mCurr;
int x1,y1;
JButton key;
if (JGE::GetInstance()->GetLeftClickCoordinates(x1, y1))
{
for (size_t i = 0; i < mObjects.size(); i++)
{
float top, left;
if (mObjects[i]->getTopLeft(top, left))
{
distance2 = static_cast<unsigned int>((top - y1) * (top - y1) + (left - x1) * (left - x1));
if (distance2 < minDistance2)
{
minDistance2 = distance2;
n = i;
}
}
}
if (n < mCurr)
key = JGE_BTN_LEFT;
else
key = JGE_BTN_RIGHT;
if (n < start_item)
{
rotateLeft();
}
else if (n >= (int)(mObjects.size()) && mObjects.size())
{
n = mObjects.size() - 1;
}
if (n >= start_item + nb_displayed_items)
{
rotateRight();
}
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(key))
{
mCurr = n;
mObjects[mCurr]->Entering();
result = true;
}
JGE::GetInstance()->LeftClickedProcessed();
}
return result;
}
}
return false;
}

View File

@@ -214,7 +214,17 @@ bool CardSelector::CheckUserInput(JButton key)
options[Options::DISABLECARDS].number = 0;
return true;
default:
return false;
{
int x,y;
if(JGE::GetInstance()->GetLeftClickCoordinates(x, y))
{
active = closest<True> (cards, limitor, static_cast<float> (x), static_cast<float> (y));
}
else
{
return false;
}
}
}
if (active != oldactive)
{

View File

@@ -66,34 +66,36 @@ void DuelLayers::CheckUserInput(int isAI)
{
JButton key;
int x, y;
while ((key = JGE::GetInstance()->ReadButton()))
while ((key = JGE::GetInstance()->ReadButton()) || JGE::GetInstance()->GetLeftClickCoordinates(x, y))
{
if ((!isAI) && (0 != key))
if ((!isAI) && ((0 != key) || JGE::GetInstance()->GetLeftClickCoordinates(x, y)))
{
if (stack->CheckUserInput(key))
if (stack->CheckUserInput(key)) {
JGE::GetInstance()->LeftClickedProcessed();
break;
if (combat->CheckUserInput(key))
}
if (combat->CheckUserInput(key)) {
JGE::GetInstance()->LeftClickedProcessed();
break;
if (avatars->CheckUserInput(key))
}
if (avatars->CheckUserInput(key)) {
JGE::GetInstance()->LeftClickedProcessed();
break; //avatars need to check their input before action (CTRL_CROSS)
if (action->CheckUserInput(key))
}
if (action->CheckUserInput(key)) {
JGE::GetInstance()->LeftClickedProcessed();
break;
if (hand->CheckUserInput(key))
}
if (hand->CheckUserInput(key)) {
JGE::GetInstance()->LeftClickedProcessed();
break;
if (CardSelectorSingleton::Instance()->CheckUserInput(key))
}
if (CardSelectorSingleton::Instance()->CheckUserInput(key)) {
JGE::GetInstance()->LeftClickedProcessed();
break;
}
}
}
if ((!isAI) && JGE::GetInstance()->GetLeftClickCoordinates(x, y))
{
if (avatars->CheckUserInput(x, y))
{
JGE::GetInstance()->LeftClickedProcessed();
}
else if (CardSelectorSingleton::Instance()->CheckUserInput(x, y))
{
JGE::GetInstance()->LeftClickedProcessed();
}
JGE::GetInstance()->LeftClickedProcessed();
}
}

View File

@@ -115,23 +115,6 @@ bool GuiAvatars::CheckUserInput(JButton key)
return false;
}
bool GuiAvatars::CheckUserInput(int x, int y)
{
// if (self->CheckUserInput(key)) return true;
// if (opponent->CheckUserInput(key)) return true;
if (selfGraveyard->CheckUserInput(x, y))
return true;
if (opponentGraveyard->CheckUserInput(x, y))
return true;
if (opponentHand->CheckUserInput(x, y))
return true;
if (selfLibrary->CheckUserInput(x, y))
return true;
if (opponentLibrary->CheckUserInput(x, y))
return true;
return false;
}
void GuiAvatars::Update(float dt)
{
self->Update(dt);

View File

@@ -199,13 +199,6 @@ bool GuiGameZone::CheckUserInput(JButton key)
return false;
}
bool GuiGameZone::CheckUserInput(int x, int y)
{
if (showCards)
return cd->CheckUserInput(x, y);
return false;
}
void GuiGameZone::Update(float dt)
{
if (showCards)