enabled touch code for handling choosign blockers on touch interface.
TODO: Please have somebody test on non-Touch device. I don't have one anymore. If it breaks it let me know and I'll make it a compile time option. Seems to work with 2 and 3 blockers. I couldn't get the game to get 4 blockers on the screen, but I think it should work the same. This should be cross platform and not iOS specific
This commit is contained in:
@@ -28,6 +28,8 @@ protected:
|
|||||||
void addOne(DefenserDamaged* blocker, CombatStep);
|
void addOne(DefenserDamaged* blocker, CombatStep);
|
||||||
void removeOne(DefenserDamaged* blocker, CombatStep);
|
void removeOne(DefenserDamaged* blocker, CombatStep);
|
||||||
void remaskBlkViews(AttackerDamaged* before, AttackerDamaged* after);
|
void remaskBlkViews(AttackerDamaged* before, AttackerDamaged* after);
|
||||||
|
void shiftLeft( DamagerDamaged* oldActive );
|
||||||
|
void shiftRight( DamagerDamaged* oldActive );
|
||||||
int resolve();
|
int resolve();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -43,7 +45,6 @@ public:
|
|||||||
virtual bool CheckUserInput(JButton key);
|
virtual bool CheckUserInput(JButton key);
|
||||||
virtual int receiveEventPlus(WEvent* e);
|
virtual int receiveEventPlus(WEvent* e);
|
||||||
virtual int receiveEventMinus(WEvent* e);
|
virtual int receiveEventMinus(WEvent* e);
|
||||||
|
|
||||||
typedef vector<AttackerDamaged*>::iterator inner_iterator;
|
typedef vector<AttackerDamaged*>::iterator inner_iterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+117
-10
@@ -197,26 +197,133 @@ bool GuiCombat::clickOK()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiCombat::shiftLeft( DamagerDamaged* oldActive)
|
||||||
|
{
|
||||||
|
switch (cursor_pos)
|
||||||
|
{
|
||||||
|
case NONE:
|
||||||
|
break;
|
||||||
|
case OK:
|
||||||
|
for (vector<AttackerDamaged*>::reverse_iterator it = attackers.rbegin(); it != attackers.rend(); ++it)
|
||||||
|
if ((*it)->show)
|
||||||
|
{
|
||||||
|
active = *it;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
activeAtk = static_cast<AttackerDamaged*> (active);
|
||||||
|
cursor_pos = ATK;
|
||||||
|
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 = kZoom_none;
|
||||||
|
if (active)
|
||||||
|
active->zoom = kZoom_level1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BLK:
|
||||||
|
{
|
||||||
|
DamagerDamaged* old = active;
|
||||||
|
active = closest<Left> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
|
||||||
|
if (old != active)
|
||||||
|
{
|
||||||
|
if (old)
|
||||||
|
old->zoom = kZoom_none;
|
||||||
|
if (active)
|
||||||
|
active->zoom = kZoom_level1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
void GuiCombat::shiftRight( DamagerDamaged* oldActive )
|
||||||
|
{
|
||||||
|
switch (cursor_pos)
|
||||||
|
{
|
||||||
|
case NONE:
|
||||||
|
case OK:
|
||||||
|
break;
|
||||||
|
case BLK:
|
||||||
|
{
|
||||||
|
DamagerDamaged* old = active;
|
||||||
|
active = closest<Right> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
|
||||||
|
if (old != active)
|
||||||
|
{
|
||||||
|
if (old)
|
||||||
|
old->zoom = kZoom_none;
|
||||||
|
if (active)
|
||||||
|
active->zoom = kZoom_level1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 = kZoom_none;
|
||||||
|
if (active)
|
||||||
|
active->zoom = kZoom_level1;
|
||||||
|
}
|
||||||
|
activeAtk = static_cast<AttackerDamaged*> (active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GuiCombat::CheckUserInput(JButton key)
|
bool GuiCombat::CheckUserInput(JButton key)
|
||||||
{
|
{
|
||||||
if (NONE == cursor_pos)
|
if (NONE == cursor_pos)
|
||||||
return false;
|
return false;
|
||||||
DamagerDamaged* oldActive = active;
|
DamagerDamaged* oldActive = active;
|
||||||
/*
|
|
||||||
int x,y;
|
int x,y;
|
||||||
if(observer->getInput()->GetLeftClickCoordinates(x, y))
|
if(observer->getInput()->GetLeftClickCoordinates(x, y) && (BLK == cursor_pos))
|
||||||
{
|
{
|
||||||
DamagerDamaged* old = active;
|
DamagerDamaged* selectedCard = closest<True> (activeAtk->blockers, NULL, static_cast<float> (x), static_cast<float> (y));
|
||||||
active = closest<True> (activeAtk->blockers, NULL, static_cast<float> (x), static_cast<float> (y));
|
// find the index into the vector where the current selected card is.
|
||||||
if (old != active)
|
int c1 = 0, c2 = 0;
|
||||||
|
int i = 0;
|
||||||
|
for ( vector<DamagerDamaged*>::iterator it = activeAtk->blockers.begin(); it != activeAtk->blockers.end(); ++it)
|
||||||
{
|
{
|
||||||
if (old)
|
if ( *it == selectedCard )
|
||||||
old->zoom = kZoom_none;
|
c2 = i;
|
||||||
if (active)
|
else if ( *it == active)
|
||||||
active->zoom = kZoom_level1;
|
c1 = i;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
// simulate pressing the "Left/Right D-Pad" control c1 - c2 times
|
||||||
|
if ( c1 > c2 ) // card selected is to the left of the current active card
|
||||||
|
{
|
||||||
|
for (int x = 0; x < c1 - c2; x++)
|
||||||
|
shiftLeft( oldActive );
|
||||||
|
}
|
||||||
|
else if ( c1 < c2 )
|
||||||
|
{
|
||||||
|
for (int x = 0; x < c2 - c1; x++)
|
||||||
|
shiftRight( oldActive );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case JGE_BTN_OK:
|
case JGE_BTN_OK:
|
||||||
|
|||||||
Reference in New Issue
Block a user