diff --git a/projects/mtg/include/WGui.h b/projects/mtg/include/WGui.h index 7b066bbf4..7b447d75c 100644 --- a/projects/mtg/include/WGui.h +++ b/projects/mtg/include/WGui.h @@ -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; diff --git a/projects/mtg/src/WGui.cpp b/projects/mtg/src/WGui.cpp index dbf306d60..3fecd6c5d 100644 --- a/projects/mtg/src/WGui.cpp +++ b/projects/mtg/src/WGui.cpp @@ -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() { diff --git a/projects/mtg/wagic.pro b/projects/mtg/wagic.pro index 2113a6a4f..e51d5588c 100644 --- a/projects/mtg/wagic.pro +++ b/projects/mtg/wagic.pro @@ -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\