Activated mouse tracking in option and award menus. Activated offset support in SimpleMenu, it should help for issue 674

This commit is contained in:
Xawotihs
2011-06-04 16:22:45 +00:00
parent 715d498bce
commit 4bf255596f
5 changed files with 17 additions and 9 deletions
+2 -1
View File
@@ -20,6 +20,7 @@ private:
string mText; string mText;
float mScale; float mScale;
float mTargetScale; float mTargetScale;
static float mYOffset;
public: public:
string desc; string desc;
@@ -42,7 +43,7 @@ public:
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
virtual bool getTopLeft(float& top, float& left) virtual bool getTopLeft(float& top, float& left)
{ {
top = mY; top = mY + mYOffset;
left = mX; left = mX;
return true; return true;
} }
+3 -2
View File
@@ -175,8 +175,9 @@ void GameStateAwards::Update(float dt)
} }
else else
{ {
JButton key; JButton key = JGE_BTN_NONE;
while ((key = JGE::GetInstance()->ReadButton())) int x, y;
while ((key = JGE::GetInstance()->ReadButton()) || JGE::GetInstance()->GetLeftClickCoordinates(x,y))
{ {
switch (key) switch (key)
{ {
+3 -2
View File
@@ -177,7 +177,8 @@ void GameStateOptions::Update(float dt)
case SHOW_OPTIONS: case SHOW_OPTIONS:
{ {
JGE* j = JGE::GetInstance(); JGE* j = JGE::GetInstance();
JButton key; JButton key = JGE_BTN_NONE;
int x, y;
if (grabber) if (grabber)
{ {
LocalKeySym sym; LocalKeySym sym;
@@ -185,7 +186,7 @@ void GameStateOptions::Update(float dt)
grabber->KeyPressed(sym); grabber->KeyPressed(sym);
} }
else else
while ((key = JGE::GetInstance()->ReadButton())) while ((key = JGE::GetInstance()->ReadButton()) || JGE::GetInstance()->GetLeftClickCoordinates(x,y))
{ {
if (!optionsTabs->CheckUserInput(key) && key == JGE_BTN_MENU) if (!optionsTabs->CheckUserInput(key) && key == JGE_BTN_MENU)
mState = SHOW_OPTIONS_MENU; mState = SHOW_OPTIONS_MENU;
+3
View File
@@ -4,6 +4,8 @@
#include "Translate.h" #include "Translate.h"
#include "WResourceManager.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) : 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) JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y)
{ {
@@ -21,6 +23,7 @@ SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string t
void SimpleMenuItem::RenderWithOffset(float yOffset) void SimpleMenuItem::RenderWithOffset(float yOffset)
{ {
mYOffset = yOffset;
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId); WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER); mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
} }
+4 -2
View File
@@ -901,14 +901,14 @@ bool WGuiMenu::CheckUserInput(JButton key)
{ {
WGuiItem* pItem = (WGuiItem*)items[k]; WGuiItem* pItem = (WGuiItem*)items[k];
distance2 = static_cast<unsigned int>((pItem->getY() - j) * (pItem->getY() - j) + (pItem->getX() - i) * (pItem->getX() - i)); distance2 = static_cast<unsigned int>((pItem->getY() - j) * (pItem->getY() - j) + (pItem->getX() - i) * (pItem->getX() - i));
if (distance2 < minDistance2) if (distance2 < minDistance2 && pItem->Selectable())
{ {
minDistance2 = distance2; minDistance2 = distance2;
n = k; n = k;
} }
} }
if (n != currentItem) if (n != currentItem && items[n]->Selectable())
{ {
setSelected(n); setSelected(n);
mEngine->LeftClickedProcessed(); mEngine->LeftClickedProcessed();
@@ -947,6 +947,8 @@ bool WGuiMenu::CheckUserInput(JButton key)
if (currentItem >= 0 && currentItem < nbitems) result = items[currentItem]->CheckUserInput(key); if (currentItem >= 0 && currentItem < nbitems) result = items[currentItem]->CheckUserInput(key);
mEngine->LeftClickedProcessed();
return result; return result;
} }
void WGuiMenu::syncMove() void WGuiMenu::syncMove()