Mouse support in Shop

This commit is contained in:
Xawotihs
2010-11-20 17:46:53 +00:00
parent bf3d01ae74
commit 048ecb3324
3 changed files with 38 additions and 6 deletions

View File

@@ -171,7 +171,10 @@ public:
WGuiCardDistort(WDataSource * wds, bool _thumb=false, WDataSource * _distort=NULL);
~WGuiCardDistort();
virtual void Render();
WDistort xy;
WDistort xy;
/* we assume first xy is the top left of the distorted card */
virtual float getX() {return xy[0];};
virtual float getY() {return xy[1];};
protected:
hgeDistortionMesh* mesh;
WDataSource * distortSrc;

View File

@@ -878,6 +878,7 @@ void WGuiMenu::Add(WGuiBase * it)
}
bool WGuiMenu::CheckUserInput(JButton key)
{
bool result = false;
bool kidModal = false;
bool handledInput = false;
int nbitems = (int) items.size();
@@ -914,9 +915,40 @@ bool WGuiMenu::CheckUserInput(JButton key)
}
}
if (currentItem >= 0 && currentItem < nbitems) return items[currentItem]->CheckUserInput(key);
if (currentItem >= 0 && currentItem < nbitems) result = items[currentItem]->CheckUserInput(key);
return false;
if(result == false)
{ // a dude may have clicked somewhere, we're gonna select the closest object from where he clicked
int x, y;
unsigned int distance2;
unsigned int minDistance2 = -1;
int n = currentItem;
if (mEngine->GetLeftClickCoordinates(x, y))
{
for(int i=0; i < items.size(); i++)
{
WGuiItem* pItem = (WGuiItem*)items[i];
distance2 = (pItem-> getY() - y) * (pItem-> getY() - y) + (pItem-> getX() - x) * (pItem-> getX() - x);
if (distance2 < minDistance2)
{
minDistance2 = distance2;
n = i;
}
}
if (n != currentItem && items[currentItem] != NULL && items[currentItem]->Leaving(JGE_BTN_DOWN))
{
currentItem = n;
items[currentItem]->Entering(JGE_BTN_DOWN);
if (sync) syncMove();
}
mEngine->LeftClickedProcessed();
return true;
}
}
return result;
}
void WGuiMenu::syncMove()
{

View File

@@ -230,7 +230,6 @@ HEADERS += \
include/GuiStatic.h\
include/ShopItem.h\
include/Effects.h\
include/Logger.h\
include/StyleManager.h\
include/WFont.h\
include/DeckManager.h\
@@ -250,7 +249,6 @@ SOURCES += \
../../JGE/src/JGE.cpp\
../../JGE/src/JGui.cpp\
../../JGE/src/JLBFont.cpp\
../../JGE/src/JLogger.cpp\
../../JGE/src/JMD2Model.cpp\
../../JGE/src/JOBJModel.cpp\
../../JGE/src/JParticle.cpp\
@@ -293,7 +291,6 @@ HEADERS += \
../../JGE/include/JGE.h\
../../JGE/include/JGui.h\
../../JGE/include/JLBFont.h\
../../JGE/include/JLogger.h\
../../JGE/include/JMD2Model.h\
../../JGE/include/JMP3.h\
../../JGE/include/JNetwork.h\