* 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:
jean.chalard
2008-12-30 05:24:38 +00:00
parent 3e9ff2b580
commit a82d4b51bb
19 changed files with 367 additions and 192 deletions
+13 -17
View File
@@ -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());
}