Activated mouse tracking in option and award menus. Activated offset support in SimpleMenu, it should help for issue 674
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -901,14 +901,14 @@ bool WGuiMenu::CheckUserInput(JButton key)
|
||||
{
|
||||
WGuiItem* pItem = (WGuiItem*)items[k];
|
||||
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;
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user