diff --git a/projects/mtg/include/SimpleMenuItem.h b/projects/mtg/include/SimpleMenuItem.h index c162731ae..50e5978d1 100644 --- a/projects/mtg/include/SimpleMenuItem.h +++ b/projects/mtg/include/SimpleMenuItem.h @@ -20,6 +20,7 @@ private: string mText; float mScale; float mTargetScale; + static float mYOffset; public: string desc; @@ -42,7 +43,7 @@ public: virtual ostream& toString(ostream& out) const; virtual bool getTopLeft(float& top, float& left) { - top = mY; + top = mY + mYOffset; left = mX; return true; } diff --git a/projects/mtg/src/GameStateAwards.cpp b/projects/mtg/src/GameStateAwards.cpp index 98dd1c2b7..2a03488cb 100644 --- a/projects/mtg/src/GameStateAwards.cpp +++ b/projects/mtg/src/GameStateAwards.cpp @@ -175,8 +175,9 @@ void GameStateAwards::Update(float dt) } else { - JButton key; - while ((key = JGE::GetInstance()->ReadButton())) + JButton key = JGE_BTN_NONE; + int x, y; + while ((key = JGE::GetInstance()->ReadButton()) || JGE::GetInstance()->GetLeftClickCoordinates(x,y)) { switch (key) { diff --git a/projects/mtg/src/GameStateOptions.cpp b/projects/mtg/src/GameStateOptions.cpp index 438e92961..ac4ed8d3f 100644 --- a/projects/mtg/src/GameStateOptions.cpp +++ b/projects/mtg/src/GameStateOptions.cpp @@ -177,7 +177,8 @@ void GameStateOptions::Update(float dt) case SHOW_OPTIONS: { JGE* j = JGE::GetInstance(); - JButton key; + JButton key = JGE_BTN_NONE; + int x, y; if (grabber) { LocalKeySym sym; @@ -185,7 +186,7 @@ void GameStateOptions::Update(float dt) grabber->KeyPressed(sym); } else - while ((key = JGE::GetInstance()->ReadButton())) + while ((key = JGE::GetInstance()->ReadButton()) || JGE::GetInstance()->GetLeftClickCoordinates(x,y)) { if (!optionsTabs->CheckUserInput(key) && key == JGE_BTN_MENU) mState = SHOW_OPTIONS_MENU; diff --git a/projects/mtg/src/SimpleMenuItem.cpp b/projects/mtg/src/SimpleMenuItem.cpp index 0ec23036b..3500dec9f 100644 --- a/projects/mtg/src/SimpleMenuItem.cpp +++ b/projects/mtg/src/SimpleMenuItem.cpp @@ -4,6 +4,8 @@ #include "Translate.h" #include "WResourceManager.h" +float SimpleMenuItem::mYOffset = 0; + SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus, bool autoTranslate) : JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y) { @@ -21,8 +23,9 @@ SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string t void SimpleMenuItem::RenderWithOffset(float yOffset) { - WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); - mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER); + mYOffset = yOffset; + WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); + mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER); } void SimpleMenuItem::Render() diff --git a/projects/mtg/src/WGui.cpp b/projects/mtg/src/WGui.cpp index 8c6d99e6a..b9614250d 100644 --- a/projects/mtg/src/WGui.cpp +++ b/projects/mtg/src/WGui.cpp @@ -901,14 +901,14 @@ bool WGuiMenu::CheckUserInput(JButton key) { WGuiItem* pItem = (WGuiItem*)items[k]; distance2 = static_cast((pItem->getY() - j) * (pItem->getY() - j) + (pItem->getX() - i) * (pItem->getX() - i)); - if (distance2 < minDistance2) + if (distance2 < minDistance2 && pItem->Selectable()) { minDistance2 = distance2; n = k; } } - if (n != currentItem) + if (n != currentItem && items[n]->Selectable()) { setSelected(n); mEngine->LeftClickedProcessed(); @@ -947,6 +947,8 @@ bool WGuiMenu::CheckUserInput(JButton key) if (currentItem >= 0 && currentItem < nbitems) result = items[currentItem]->CheckUserInput(key); + mEngine->LeftClickedProcessed(); + return result; } void WGuiMenu::syncMove()