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
+4 -1
View File
@@ -171,7 +171,10 @@ public:
WGuiCardDistort(WDataSource * wds, bool _thumb=false, WDataSource * _distort=NULL); WGuiCardDistort(WDataSource * wds, bool _thumb=false, WDataSource * _distort=NULL);
~WGuiCardDistort(); ~WGuiCardDistort();
virtual void Render(); 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: protected:
hgeDistortionMesh* mesh; hgeDistortionMesh* mesh;
WDataSource * distortSrc; WDataSource * distortSrc;
+34 -2
View File
@@ -878,6 +878,7 @@ void WGuiMenu::Add(WGuiBase * it)
} }
bool WGuiMenu::CheckUserInput(JButton key) bool WGuiMenu::CheckUserInput(JButton key)
{ {
bool result = false;
bool kidModal = false; bool kidModal = false;
bool handledInput = false; bool handledInput = false;
int nbitems = (int) items.size(); 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() void WGuiMenu::syncMove()
{ {
-3
View File
@@ -230,7 +230,6 @@ HEADERS += \
include/GuiStatic.h\ include/GuiStatic.h\
include/ShopItem.h\ include/ShopItem.h\
include/Effects.h\ include/Effects.h\
include/Logger.h\
include/StyleManager.h\ include/StyleManager.h\
include/WFont.h\ include/WFont.h\
include/DeckManager.h\ include/DeckManager.h\
@@ -250,7 +249,6 @@ SOURCES += \
../../JGE/src/JGE.cpp\ ../../JGE/src/JGE.cpp\
../../JGE/src/JGui.cpp\ ../../JGE/src/JGui.cpp\
../../JGE/src/JLBFont.cpp\ ../../JGE/src/JLBFont.cpp\
../../JGE/src/JLogger.cpp\
../../JGE/src/JMD2Model.cpp\ ../../JGE/src/JMD2Model.cpp\
../../JGE/src/JOBJModel.cpp\ ../../JGE/src/JOBJModel.cpp\
../../JGE/src/JParticle.cpp\ ../../JGE/src/JParticle.cpp\
@@ -293,7 +291,6 @@ HEADERS += \
../../JGE/include/JGE.h\ ../../JGE/include/JGE.h\
../../JGE/include/JGui.h\ ../../JGE/include/JGui.h\
../../JGE/include/JLBFont.h\ ../../JGE/include/JLBFont.h\
../../JGE/include/JLogger.h\
../../JGE/include/JMD2Model.h\ ../../JGE/include/JMD2Model.h\
../../JGE/include/JMP3.h\ ../../JGE/include/JMP3.h\
../../JGE/include/JNetwork.h\ ../../JGE/include/JNetwork.h\