J :
* New menu style - step one. More improvements are to come, but this should be stable and have a good portion of what is to be done.
This commit is contained in:
@@ -2,41 +2,31 @@
|
||||
#include "../include/SimpleMenuItem.h"
|
||||
|
||||
|
||||
SimpleMenuItem::SimpleMenuItem(int id, JLBFont *font, const char* text, int x, int y, bool hasFocus): JGuiObject(id), mFont(font), mX(x), mY(y)
|
||||
SimpleMenuItem::SimpleMenuItem(SimpleMenu* _parent, int id, JLBFont *font, const char* text, int x, int y, bool hasFocus): JGuiObject(id), parent(_parent), mFont(font), mX(x), mY(y)
|
||||
{
|
||||
|
||||
mText = text;
|
||||
mHasFocus = hasFocus;
|
||||
|
||||
mScale = 1.0f;
|
||||
mTargetScale = 1.0f;
|
||||
|
||||
|
||||
|
||||
if (hasFocus)
|
||||
Entering();
|
||||
mFont->SetScale(1.2f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SimpleMenuItem::RenderWithOffset(float yOffset)
|
||||
{
|
||||
|
||||
mFont->SetScale(mScale);
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
if (mHasFocus)
|
||||
{
|
||||
mFont->SetColor(ARGB(255,255,255,0));
|
||||
}
|
||||
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
|
||||
mFont->SetScale(1.0f);
|
||||
}
|
||||
|
||||
void SimpleMenuItem::Render()
|
||||
{
|
||||
|
||||
RenderWithOffset(0);
|
||||
RenderWithOffset(0);
|
||||
}
|
||||
|
||||
void SimpleMenuItem::Update(float dt)
|
||||
@@ -56,20 +46,16 @@ void SimpleMenuItem::Update(float dt)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void SimpleMenuItem::Entering()
|
||||
{
|
||||
|
||||
mHasFocus = true;
|
||||
mTargetScale = 1.2f;
|
||||
parent->selectionTargetY = mY;
|
||||
}
|
||||
|
||||
|
||||
bool SimpleMenuItem::Leaving(u32 key)
|
||||
{
|
||||
mHasFocus = false;
|
||||
mTargetScale = 1.0f;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -79,3 +65,13 @@ bool SimpleMenuItem::ButtonPressed()
|
||||
return true;
|
||||
}
|
||||
|
||||
void SimpleMenuItem::Relocate(int x, int y)
|
||||
{
|
||||
mX = x;
|
||||
mY = y;
|
||||
}
|
||||
|
||||
int SimpleMenuItem::GetWidth()
|
||||
{
|
||||
return mFont->GetStringWidth(mText.c_str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user