Erwan
- trim long deck names in deck editor/ deck selection - fixed a bug were the background was rendered in the items loop of the deck selection screen
This commit is contained in:
@@ -8,10 +8,6 @@
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
#define SCALE_SELECTED 1.2f
|
|
||||||
#define SCALE_NORMAL 1.0f
|
|
||||||
|
|
||||||
|
|
||||||
class DeckMenuItem: public JGuiObject
|
class DeckMenuItem: public JGuiObject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -172,17 +172,20 @@ void DeckMenu::Render()
|
|||||||
mFont->SetScale( menuFontScale );
|
mFont->SetScale( menuFontScale );
|
||||||
currentMenuItem->RenderWithOffset(-kLineHeight*startId);
|
currentMenuItem->RenderWithOffset(-kLineHeight*startId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RenderBackground();
|
RenderBackground();
|
||||||
|
|
||||||
|
|
||||||
if (!title.empty())
|
if (!title.empty())
|
||||||
{
|
{
|
||||||
|
mFont->SetColor(ARGB(255,255,255,255));
|
||||||
mFont->SetScale( titleFontScale );
|
mFont->SetScale( titleFontScale );
|
||||||
mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
|
mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
|
||||||
}
|
}
|
||||||
mFont->SetScale( 1.0f );
|
mFont->SetScale( 1.0f );
|
||||||
scroller->Render();
|
scroller->Render();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckMenu::Update(float dt){
|
void DeckMenu::Update(float dt){
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Translate.h"
|
#include "Translate.h"
|
||||||
#include "WResourceManager.h"
|
#include "WResourceManager.h"
|
||||||
|
|
||||||
|
#define ITEM_PX_WIDTH 190.f
|
||||||
|
|
||||||
DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus, bool autoTranslate, DeckMetaData *deckMetaData)
|
DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus, bool autoTranslate, DeckMetaData *deckMetaData)
|
||||||
: JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y)
|
: JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y)
|
||||||
@@ -12,8 +13,14 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f
|
|||||||
mText = _(text);
|
mText = _(text);
|
||||||
else
|
else
|
||||||
mText = text;
|
mText = text;
|
||||||
mHasFocus = hasFocus;
|
|
||||||
|
|
||||||
|
//trim the string so that its width fits in the background.
|
||||||
|
//in the future we might want to replace this with a horizontal scrolling of long strings
|
||||||
|
WFont * mFont = resources.GetWFont(fontId);
|
||||||
|
while (mFont->GetStringWidth(mText.c_str()) > ITEM_PX_WIDTH)
|
||||||
|
mText.erase(mText.size()-1);
|
||||||
|
|
||||||
|
mHasFocus = hasFocus;
|
||||||
if (hasFocus)
|
if (hasFocus)
|
||||||
Entering();
|
Entering();
|
||||||
|
|
||||||
@@ -29,8 +36,7 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f
|
|||||||
void DeckMenuItem::RenderWithOffset(float yOffset)
|
void DeckMenuItem::RenderWithOffset(float yOffset)
|
||||||
{
|
{
|
||||||
WFont * mFont = resources.GetWFont(fontId);
|
WFont * mFont = resources.GetWFont(fontId);
|
||||||
string displayName = mText;
|
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
|
||||||
mFont->DrawString(displayName.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckMenuItem::Render()
|
void DeckMenuItem::Render()
|
||||||
|
|||||||
Reference in New Issue
Block a user