fixed some click issues found with iOS port.

This commit is contained in:
techdragon.nguyen@gmail.com
2012-01-07 16:35:39 +00:00
parent a28c90dacf
commit 436f95dfec
4 changed files with 19 additions and 16 deletions

View File

@@ -150,7 +150,7 @@ bool JGuiController::CheckUserInput(JButton key)
}
else
{ // a dude may have clicked somewhere, we're gonna select the closest object from where he clicked
int x, y;
int x = -1, y = -1;
unsigned int distance2;
unsigned int minDistance2 = -1;
int n = mCurr;
@@ -175,6 +175,11 @@ bool JGuiController::CheckUserInput(JButton key)
mCurr = n;
mObjects[mCurr]->Entering();
}
// if the same object was selected process click
else if (n == mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(JGE_BTN_OK))
{
mObjects[mCurr]->Entering();
}
mEngine->LeftClickedProcessed();
return true;
}

View File

@@ -405,6 +405,7 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
// we want to differentiate between a pan motion vs a flick gesture.
if (!(( ((int)abs( (int) velocity.x)) > 300) || ((int) (abs( (int) velocity.y)) > 300)))
{
g_engine->LeftClicked(newLocation.x, newLocation.y);
g_engine->HoldKey_NoRepeat( JGE_BTN_OK );
}
else
@@ -433,7 +434,6 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
int actualWidth = (int) JRenderer::GetInstance()->GetActualWidth();
CGPoint newCoordinates = [self normalizeClickCoordinatesWithPoint: currentLocation];
g_engine->LeftClicked( newCoordinates.x, newCoordinates.y);
g_engine->HoldKey_NoRepeat(JGE_BTN_NONE);
@@ -444,7 +444,8 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
if (clickedWithinGameArea)
{
// we want some delay for the left click to take place before clicking on OK.
[self performSelector: @selector(handleOK:) withObject: nil afterDelay: 0.25];
g_engine->LeftClicked( newCoordinates.x, newCoordinates.y);
[self performSelector: @selector(handleOK:) withObject: recognizer afterDelay: 0.25];
}
else if(currentLocation.y < es2renderer.viewPort.top) {

View File

@@ -1,4 +1,4 @@
#include "PrecompiledHeader.h"
#include "PrecompiledHeader.h"
#include "DeckMenuItem.h"
#include "Translate.h"
@@ -7,7 +7,7 @@
#define ITEM_PX_WIDTH 190.0f
#define kItemXOffset 22
#define kItemYHeight 20
#define kItemYHeight 30
const int kHorizontalScrollSpeed = 30; // higher numbers mean faster scrolling
@@ -43,8 +43,11 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f
mScrollerOffset = 0.0f;
if (hasFocus)
{
mIsValidSelection = true;
Entering();
}
if (meta && meta->getAvatarFilename().size() > 0)
this->imageFilename = meta->getAvatarFilename();
else
@@ -120,19 +123,17 @@ void DeckMenuItem::Render()
void DeckMenuItem::checkUserClick()
{
#ifdef IOS
int x1 = 0, y1 = 0;
if ( mEngine->GetLeftClickCoordinates(x1, y1))
int x1 = -1, y1 = -1;
if (mEngine->GetLeftClickCoordinates(x1, y1))
{
mIsValidSelection = false;
int x2 = kItemXOffset, y2 = static_cast<int>(mY + mYOffset);
if ( (x1 >= x2) && (x1 <= (x2 + ITEM_PX_WIDTH)) && (y1 >= y2) && (y1 < (y2 + kItemYHeight)))
mIsValidSelection = true;
}
else
#else
mIsValidSelection = true;
#endif
{
mIsValidSelection = true;
}
}
@@ -158,7 +159,6 @@ bool DeckMenuItem::ButtonPressed()
void DeckMenuItem::Relocate(float x, float y)
{
checkUserClick();
mX = x;
mY = y;
}

View File

@@ -1774,9 +1774,6 @@ void GameObserver::loadPlayer(int playerId, Player* player)
void GameObserver::loadPlayer(int playerId, PlayerType playerType, int decknb, bool premadeDeck)
{
if (decknb)
{
if (playerType == PLAYER_TYPE_HUMAN)