applied logic used for deck selection to popup menus as well
This commit is contained in:
@@ -23,9 +23,18 @@ public:
|
||||
string desc;
|
||||
float mScrollerOffset;
|
||||
DeckMetaData *meta;
|
||||
|
||||
virtual bool hasFocus();
|
||||
|
||||
void Relocate(float x, float y);
|
||||
float GetWidth();
|
||||
virtual void Relocate(float x, float y);
|
||||
virtual float GetWidth();
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
virtual bool getTopLeft(float& top, float& left)
|
||||
{
|
||||
return SimpleMenuItem::getTopLeft(top, left);
|
||||
}
|
||||
|
||||
string GetText()
|
||||
{
|
||||
@@ -35,25 +44,15 @@ public:
|
||||
{
|
||||
return desc;
|
||||
}
|
||||
bool hasFocus();
|
||||
|
||||
DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus = false, bool autoTranslate = false, DeckMetaData *meta = NULL);
|
||||
~DeckMenuItem();
|
||||
|
||||
void RenderWithOffset(float yOffset);
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
virtual void Entering();
|
||||
virtual bool Leaving(JButton key);
|
||||
virtual bool ButtonPressed();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual bool getTopLeft(float& top, float& left)
|
||||
{
|
||||
top = mY + mYOffset;
|
||||
left = mX;
|
||||
return true;
|
||||
}
|
||||
;
|
||||
virtual void RenderWithOffset(float yOffset);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,9 +38,12 @@ public:
|
||||
float mX;
|
||||
float mY;
|
||||
|
||||
void Relocate(float x, float y);
|
||||
float GetWidth();
|
||||
bool hasFocus();
|
||||
|
||||
|
||||
virtual void Relocate(float x, float y);
|
||||
virtual float GetWidth();
|
||||
|
||||
virtual bool hasFocus();
|
||||
|
||||
void RenderWithOffset(float yOffset);
|
||||
virtual void Render();
|
||||
|
||||
@@ -21,7 +21,6 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int iFontId, string text,
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
meta = deckMetaData;
|
||||
mText = trim(text);
|
||||
SimpleMenuItem::mIsValidSelection = false;
|
||||
|
||||
if (autoTranslate)
|
||||
mText = _(mText);
|
||||
@@ -77,7 +76,6 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int iFontId, string text,
|
||||
|
||||
}
|
||||
|
||||
|
||||
mDisplayInitialized = false;
|
||||
|
||||
}
|
||||
@@ -118,38 +116,35 @@ void DeckMenuItem::RenderWithOffset(float yOffset)
|
||||
}
|
||||
}
|
||||
|
||||
void DeckMenuItem::Render()
|
||||
void DeckMenuItem::Render()
|
||||
{
|
||||
RenderWithOffset(0);
|
||||
}
|
||||
|
||||
|
||||
void DeckMenuItem::Entering()
|
||||
{
|
||||
SimpleMenuItem::checkUserClick();
|
||||
mHasFocus = true;
|
||||
parent->mSelectionTargetY = mY;
|
||||
}
|
||||
|
||||
bool DeckMenuItem::Leaving(JButton key)
|
||||
{
|
||||
// check to see if the user clicked on the object, if so return true.
|
||||
SimpleMenuItem::checkUserClick();
|
||||
mHasFocus = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeckMenuItem::ButtonPressed()
|
||||
{
|
||||
return SimpleMenuItem::mIsValidSelection;
|
||||
}
|
||||
|
||||
void DeckMenuItem::Relocate(float x, float y)
|
||||
{
|
||||
mX = x;
|
||||
mY = y;
|
||||
}
|
||||
|
||||
void DeckMenuItem::Entering()
|
||||
{
|
||||
checkUserClick();
|
||||
mHasFocus = true;
|
||||
parent->mSelectionTargetY = mY;
|
||||
}
|
||||
|
||||
|
||||
bool DeckMenuItem::Leaving(JButton key)
|
||||
{
|
||||
return SimpleMenuItem::Leaving(key);
|
||||
}
|
||||
|
||||
bool DeckMenuItem::ButtonPressed()
|
||||
{
|
||||
return SimpleMenuItem::ButtonPressed();
|
||||
}
|
||||
|
||||
float DeckMenuItem::GetWidth()
|
||||
{
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
|
||||
@@ -8,7 +8,7 @@ float SimpleMenuItem::mYOffset = 0;
|
||||
|
||||
SimpleMenuItem::SimpleMenuItem(int id): JGuiObject(id)
|
||||
{
|
||||
|
||||
mIsValidSelection = false;
|
||||
}
|
||||
|
||||
SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus, bool autoTranslate) :
|
||||
@@ -24,7 +24,12 @@ SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, int fontId, string t
|
||||
mTargetScale = 1.0f;
|
||||
|
||||
mXOffset = mX;
|
||||
if (hasFocus) Entering();
|
||||
|
||||
if (hasFocus)
|
||||
{
|
||||
mIsValidSelection = true;
|
||||
Entering();
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleMenuItem::RenderWithOffset(float yOffset)
|
||||
@@ -59,7 +64,7 @@ void SimpleMenuItem::checkUserClick()
|
||||
if (mEngine->GetLeftClickCoordinates(x1, y1))
|
||||
{
|
||||
mIsValidSelection = false;
|
||||
int x2 = mXOffset, y2 = static_cast<int>(mY + mYOffset);
|
||||
int x2 = static_cast<int>(mXOffset), y2 = static_cast<int>(mY + mYOffset);
|
||||
if ( (x1 >= x2) && (x1 <= (x2 + 200)) && (y1 >= y2) && (y1 < (y2 + 30)))
|
||||
mIsValidSelection = true;
|
||||
}
|
||||
@@ -69,23 +74,27 @@ void SimpleMenuItem::checkUserClick()
|
||||
|
||||
void SimpleMenuItem::Entering()
|
||||
{
|
||||
checkUserClick();
|
||||
mHasFocus = true;
|
||||
parent->selectionTargetY = mY;
|
||||
}
|
||||
|
||||
bool SimpleMenuItem::Leaving(JButton key)
|
||||
{
|
||||
checkUserClick();
|
||||
mHasFocus = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SimpleMenuItem::ButtonPressed()
|
||||
{
|
||||
return true;
|
||||
return mIsValidSelection;
|
||||
}
|
||||
|
||||
|
||||
void SimpleMenuItem::Relocate(float x, float y)
|
||||
{
|
||||
mXOffset = x;
|
||||
mX = x;
|
||||
mY = y;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user