modified font size so deck name fits on screen when selecting deck for game play.
This commit is contained in:
@@ -30,9 +30,7 @@ hgeParticleSystem* DeckMenu::stars = NULL;
|
||||
// * descriptive information 125
|
||||
// *** Need to make this configurable in a file somewhere to allow for class reuse
|
||||
|
||||
DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _title)
|
||||
: JGuiController(id, listener),
|
||||
fontId(fontId) {
|
||||
DeckMenu::DeckMenu(int id, JGuiListener* listener, int fontId, const string _title, const float& mFontScale): JGuiController(id, listener), fontId(fontId), menuFontScale( mFontScale ) {
|
||||
|
||||
backgroundName = "DeckMenuBackdrop";
|
||||
|
||||
@@ -59,7 +57,6 @@ fontId(fontId) {
|
||||
avatarX = 230;
|
||||
avatarY = 8;
|
||||
|
||||
|
||||
menuInitialized = false;
|
||||
|
||||
float scrollerWidth = 80;
|
||||
@@ -73,19 +70,17 @@ fontId(fontId) {
|
||||
title = _(_title);
|
||||
displayTitle = title;
|
||||
mFont = resources.GetWFont(fontId);
|
||||
mTitleFontScale = 1.0f;
|
||||
// determine if scaling is needed to fit the menu title.
|
||||
while ( mFont->GetStringWidth( displayTitle.c_str() ) > titleWidth )
|
||||
{
|
||||
mTitleFontScale -= 0.05f;
|
||||
mFont->SetScale( mTitleFontScale );
|
||||
}
|
||||
|
||||
startId = 0;
|
||||
selectionT = 0;
|
||||
timeOpen = 0;
|
||||
closed = false;
|
||||
|
||||
if ( mFont->GetStringWidth( title.c_str() ) > titleWidth )
|
||||
titleFontScale = 0.75f;
|
||||
else
|
||||
titleFontScale = 1.0f;
|
||||
|
||||
selectionTargetY = selectionY = kVerticalMargin;
|
||||
|
||||
if (NULL == stars)
|
||||
@@ -137,8 +132,6 @@ void DeckMenu::Render()
|
||||
stars->Render();
|
||||
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
mFont->SetScale(1.0f);
|
||||
|
||||
for (int i = startId; i < startId + maxItems ; i++){
|
||||
if (i > mCount-1) break;
|
||||
DeckMenuItem *currentMenuItem = static_cast<DeckMenuItem*>(mObjects[i]);
|
||||
@@ -170,6 +163,7 @@ void DeckMenu::Render()
|
||||
else {
|
||||
mFont->SetColor(ARGB(150,255,255,255));
|
||||
}
|
||||
mFont->SetScale( menuFontScale );
|
||||
currentMenuItem->RenderWithOffset(-kLineHeight*startId);
|
||||
}
|
||||
|
||||
@@ -177,11 +171,10 @@ void DeckMenu::Render()
|
||||
|
||||
if (!title.empty())
|
||||
{
|
||||
float currentFontScale = mFont->GetScale();
|
||||
mFont->SetScale( mTitleFontScale );
|
||||
mFont->SetScale( titleFontScale );
|
||||
mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
|
||||
mFont->SetScale( currentFontScale );
|
||||
}
|
||||
mFont->SetScale( 1.0f );
|
||||
scroller->Render();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
#include "Translate.h"
|
||||
#include "WResourceManager.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
const float kMaxDeckNameWidth = 180; // pixel width
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -34,8 +30,6 @@ void DeckMenuItem::RenderWithOffset(float yOffset)
|
||||
{
|
||||
WFont * mFont = resources.GetWFont(fontId);
|
||||
string displayName = mText;
|
||||
while ( mFont->GetStringWidth( displayName.c_str() ) > kMaxDeckNameWidth )
|
||||
displayName = displayName.substr(0, displayName.size() - 1 );
|
||||
mFont->DrawString(displayName.c_str(), mX, mY + yOffset, JGETEXT_CENTER);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
const float MENU_FONT_SCALE = 0.650f;
|
||||
|
||||
enum ENUM_DUEL_STATE
|
||||
{
|
||||
DUEL_STATE_START,
|
||||
@@ -94,7 +96,7 @@ void GameStateDuel::Start()
|
||||
if (mParent->players[i] == PLAYER_TYPE_HUMAN){
|
||||
decksneeded = 1;
|
||||
|
||||
deckmenu = NEW DeckMenu(DUEL_MENU_CHOOSE_DECK, this, Fonts::OPTION_FONT, "Choose a Deck");
|
||||
deckmenu = NEW DeckMenu(DUEL_MENU_CHOOSE_DECK, this, Fonts::OPTION_FONT, "Choose a Deck", MENU_FONT_SCALE);
|
||||
|
||||
DeckManager *deckManager = DeckManager::GetInstance();
|
||||
vector<DeckMetaData *> playerDeckList = getValidDeckMetaData( options.profileFile() );
|
||||
@@ -238,7 +240,7 @@ bool GameStateDuel::MusicExist(string FileName){
|
||||
|
||||
void GameStateDuel::ensureOpponentMenu(){
|
||||
if (!opponentMenu){
|
||||
opponentMenu = NEW DeckMenu(DUEL_MENU_CHOOSE_OPPONENT, this, Fonts::OPTION_FONT, "Choose Your Opponent");
|
||||
opponentMenu = NEW DeckMenu(DUEL_MENU_CHOOSE_OPPONENT, this, Fonts::OPTION_FONT, "Choose Your Opponent", MENU_FONT_SCALE);
|
||||
opponentMenu->Add( MENUITEM_RANDOM_AI, "Random");
|
||||
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
|
||||
opponentMenu->Add( MENUITEM_EVIL_TWIN, "Evil Twin", _("Can you play against yourself?").c_str());
|
||||
@@ -573,6 +575,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId) {
|
||||
loadPlayer(0,deckNumber);
|
||||
deckmenu->Close();
|
||||
mGamePhase = DUEL_STATE_CHOOSE_DECK1_TO_2;
|
||||
playerDeck = NULL;
|
||||
}else{
|
||||
loadPlayer(1,controlId);
|
||||
deckmenu->Close();
|
||||
|
||||
Reference in New Issue
Block a user