reformatting code according to guidelines defined at
http://wololo.net/forum/viewtopic.php?f=35&t=2235&start=10
This commit is contained in:
@@ -4,91 +4,87 @@
|
||||
#include "Translate.h"
|
||||
#include "WResourceManager.h"
|
||||
|
||||
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)
|
||||
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)
|
||||
{
|
||||
if (autoTranslate) mText = _(text);
|
||||
else mText = text;
|
||||
mHasFocus = hasFocus;
|
||||
if (autoTranslate)
|
||||
mText = _(text);
|
||||
else
|
||||
mText = text;
|
||||
mHasFocus = hasFocus;
|
||||
|
||||
mScale = 1.0f;
|
||||
mTargetScale = 1.0f;
|
||||
mScale = 1.0f;
|
||||
mTargetScale = 1.0f;
|
||||
|
||||
if (hasFocus)
|
||||
Entering();
|
||||
if (hasFocus) Entering();
|
||||
}
|
||||
|
||||
|
||||
void SimpleMenuItem::RenderWithOffset(float yOffset)
|
||||
{
|
||||
WFont * mFont = resources.GetWFont(fontId);
|
||||
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
|
||||
WFont * mFont = resources.GetWFont(fontId);
|
||||
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
|
||||
}
|
||||
|
||||
void SimpleMenuItem::Render()
|
||||
{
|
||||
RenderWithOffset(0);
|
||||
RenderWithOffset(0);
|
||||
}
|
||||
|
||||
void SimpleMenuItem::Update(float dt)
|
||||
{
|
||||
if (mScale < mTargetScale)
|
||||
{
|
||||
mScale += 8.0f*dt;
|
||||
if (mScale > mTargetScale)
|
||||
mScale = mTargetScale;
|
||||
mScale += 8.0f * dt;
|
||||
if (mScale > mTargetScale) mScale = mTargetScale;
|
||||
}
|
||||
else if (mScale > mTargetScale)
|
||||
else if (mScale > mTargetScale)
|
||||
{
|
||||
mScale -= 8.0f*dt;
|
||||
if (mScale < mTargetScale)
|
||||
mScale = mTargetScale;
|
||||
}
|
||||
mScale -= 8.0f * dt;
|
||||
if (mScale < mTargetScale) mScale = mTargetScale;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SimpleMenuItem::Entering()
|
||||
{
|
||||
mHasFocus = true;
|
||||
parent->selectionTargetY = mY;
|
||||
mHasFocus = true;
|
||||
parent->selectionTargetY = mY;
|
||||
}
|
||||
|
||||
|
||||
bool SimpleMenuItem::Leaving(JButton key)
|
||||
{
|
||||
mHasFocus = false;
|
||||
return true;
|
||||
mHasFocus = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SimpleMenuItem::ButtonPressed()
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SimpleMenuItem::Relocate(float x, float y)
|
||||
{
|
||||
mX = x;
|
||||
mY = y;
|
||||
mX = x;
|
||||
mY = y;
|
||||
}
|
||||
|
||||
float SimpleMenuItem::GetWidth()
|
||||
{
|
||||
WFont * mFont = resources.GetWFont(fontId);
|
||||
mFont->SetScale(1.0);
|
||||
return mFont->GetStringWidth(mText.c_str());
|
||||
WFont * mFont = resources.GetWFont(fontId);
|
||||
mFont->SetScale(1.0);
|
||||
return mFont->GetStringWidth(mText.c_str());
|
||||
}
|
||||
|
||||
bool SimpleMenuItem::hasFocus()
|
||||
{
|
||||
return mHasFocus;
|
||||
return mHasFocus;
|
||||
}
|
||||
|
||||
ostream& SimpleMenuItem::toString(ostream& out) const
|
||||
{
|
||||
return out << "SimpleMenuItem ::: mHasFocus : " << mHasFocus
|
||||
<< " ; parent : " << parent
|
||||
<< " ; mText : " << mText
|
||||
<< " ; mScale : " << mScale
|
||||
<< " ; mTargetScale : " << mTargetScale
|
||||
<< " ; mX,mY : " << mX << "," << mY;
|
||||
return out << "SimpleMenuItem ::: mHasFocus : " << mHasFocus
|
||||
<< " ; parent : " << parent
|
||||
<< " ; mText : " << mText
|
||||
<< " ; mScale : " << mScale
|
||||
<< " ; mTargetScale : " << mTargetScale
|
||||
<< " ; mX,mY : " << mX << "," << mY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user