From 57627849a04975ad016bba5e2c7823ce23995416 Mon Sep 17 00:00:00 2001 From: "techdragon.nguyen@gmail.com" Date: Tue, 20 Mar 2012 08:35:38 +0000 Subject: [PATCH] modified font size of text in menus. Adjusted the spacing between menu items on all menus. They were a little too far apart once I modified the font size. fixed Hollowhenge Spirit --- JGE/src/iOS/EAGLView.m | 10 ++-- projects/mtg/bin/Res/sets/primitives/mtg.txt | 2 +- projects/mtg/include/MTGDefinitions.h | 1 + projects/mtg/include/SimpleButton.h | 1 + projects/mtg/src/DeckMenu.cpp | 52 ++++++++++---------- projects/mtg/src/DeckMenuItem.cpp | 9 +++- projects/mtg/src/GameStateShop.cpp | 2 +- projects/mtg/src/SimpleButton.cpp | 5 ++ projects/mtg/src/SimpleMenu.cpp | 22 ++++++--- projects/mtg/src/WGui.cpp | 13 ++++- 10 files changed, 74 insertions(+), 43 deletions(-) diff --git a/JGE/src/iOS/EAGLView.m b/JGE/src/iOS/EAGLView.m index 220916ada..685b540d2 100755 --- a/JGE/src/iOS/EAGLView.m +++ b/JGE/src/iOS/EAGLView.m @@ -636,7 +636,7 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170 newFrame.size = adSize; // ads are 320 x 50 newFrame.origin.x = ( (isLandscape ? screenSize.height : screenSize.width) - adSize.width)/ 2; - newFrame.origin.y = 0; + newFrame.origin.y = ( (isLandscape ? screenSize.width : screenSize.height) - 50); [adWhirlView setFrame: newFrame]; @@ -700,10 +700,14 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170 //(in landscape mode): //Same explanation as the one in the method "adjustAdSize" for the Ad's width int screenWidth = [viewController.parentViewController.view bounds].size.width; + float yOffset = [viewController.parentViewController.view bounds].size.height - 50; if ( isLandscape ) + { + yOffset = screenWidth - 50; screenWidth = [viewController.parentViewController.view bounds].size.height; - - self.adView.frame = CGRectMake((screenWidth - adSize.width) / 2, 0, adSize.width, adSize.height); + } + + self.adView.frame = CGRectMake((screenWidth - adSize.width) / 2, yOffset, adSize.width, adSize.height); //Trying to keep everything inside the Ad bounds self.adView.clipsToBounds = YES; diff --git a/projects/mtg/bin/Res/sets/primitives/mtg.txt b/projects/mtg/bin/Res/sets/primitives/mtg.txt index f653267be..0aa92b1a3 100644 --- a/projects/mtg/bin/Res/sets/primitives/mtg.txt +++ b/projects/mtg/bin/Res/sets/primitives/mtg.txt @@ -35216,7 +35216,7 @@ toughness=5 [card] name=Hollowhenge Spirit abilities=flash,flying -auto=target(creature[attacking]) removefromcombat +auto=target(creature[attacking,blocking]) removefromcombat text=Flash -- Flying -- When Hollowhenge Spirit enters the battlefield, remove target attacking or blocking creature from combat. mana={3}{W} type=Creature diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index c206726c2..0d55fa954 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -4,6 +4,7 @@ const float DEFAULT_MENU_FONT_SCALE = 1.0f; const float DEFAULT_MAIN_FONT_SCALE = 1.0f; const float DEFAULT_TEXT_FONT_SCALE = 1.0f; +const float ACTIVE_MENU_FONT_SCALE = 1.2f; #include using std::string; diff --git a/projects/mtg/include/SimpleButton.h b/projects/mtg/include/SimpleButton.h index 6fc91031b..2775a8370 100644 --- a/projects/mtg/include/SimpleButton.h +++ b/projects/mtg/include/SimpleButton.h @@ -17,6 +17,7 @@ using std::string; #define SCALE_SELECTED 1.2f #define SCALE_NORMAL 1.0f +#define SCALE_SHRINK 0.75f class SimpleButton: public JGuiObject { diff --git a/projects/mtg/src/DeckMenu.cpp b/projects/mtg/src/DeckMenu.cpp index 4ed8f87c1..b011f350c 100644 --- a/projects/mtg/src/DeckMenu.cpp +++ b/projects/mtg/src/DeckMenu.cpp @@ -18,7 +18,7 @@ namespace const float kVerticalMargin = 16; const float kHorizontalMargin = 20; const float kLineHeight = 25; - const float kDescriptionVerticalBoxPadding = 35; + const float kDescriptionVerticalBoxPadding = -5; const float kDescriptionHorizontalBoxPadding = 5; const float kDefaultFontScale = 1.0f; @@ -52,10 +52,10 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc titleY = 15; titleWidth = 180; // width of inner box of title - descX = 260 + kDescriptionVerticalBoxPadding; - descY = 100 + kDescriptionHorizontalBoxPadding; + descX = 260 + kDescriptionHorizontalBoxPadding; + descY = 100 + kDescriptionVerticalBoxPadding; descHeight = 145; - descWidth = 200; + descWidth = 195; detailedInfoBoxX = 400; detailedInfoBoxY = 235; @@ -90,9 +90,9 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc mClosed = false; if (mFont->GetStringWidth(title.c_str()) > titleWidth) - titleFontScale = 0.75f; + titleFontScale = SCALE_SHRINK; else - titleFontScale = 1.0f; + titleFontScale = SCALE_NORMAL; mSelectionTargetY = selectionY = kVerticalMargin; @@ -101,7 +101,9 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc stars->FireAt(mX, mY); const string detailedInfoString = _("Detailed Info"); - float stringWidth = mFont->GetStringWidth(detailedInfoString.c_str()); + WFont *descriptionFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); + + float stringWidth = descriptionFont->GetStringWidth(detailedInfoString.c_str()); float boxStartX = detailedInfoBoxX - stringWidth / 2 + 20; dismissButton = NEW InteractiveButton( this, kDetailedInfoButtonId, Fonts::MAIN_FONT, detailedInfoString, boxStartX, detailedInfoBoxY, JGE_BTN_CANCEL); @@ -258,7 +260,7 @@ void DeckMenu::Render() if (currentMenuItem->hasFocus()) { mSelectedDeck = metaData; - WFont *mainFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); + WFont *descriptionFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT); // display the "more info" button if special condition is met if (showDetailsScreen()) @@ -271,33 +273,27 @@ void DeckMenu::Render() dismissButton->setIsSelectionValid(false); } // display the avatar image - if (currentMenuItem->getImageFilename().size() > 0) + string currentAvatarImageName = currentMenuItem->getImageFilename(); + if (currentAvatarImageName.size() > 0) { - JQuadPtr quad; - if(currentMenuItem->getImageFilename() == "EvilTwinAvatar") + JQuadPtr quad = WResourceManager::Instance()->RetrieveTempQuad(currentAvatarImageName, TEXTURE_SUB_AVATAR); + if(quad.get()) { - quad = WResourceManager::Instance()->RetrieveTempQuad("avatar.jpg", TEXTURE_SUB_AVATAR); - if(quad.get()) + if (currentMenuItem->getText() == "Evil Twin") { JQuad * evil = quad.get(); evil->SetHFlip(true); renderer->RenderQuad(quad.get(), avatarX, avatarY); evil = NULL; } - } - else - { - quad = WResourceManager::Instance()->RetrieveTempQuad(currentMenuItem->getImageFilename(), TEXTURE_SUB_AVATAR); - if (quad.get()) + else renderer->RenderQuad(quad.get(), avatarX, avatarY); - } } // fill in the description part of the screen - string text = wordWrap(_(currentMenuItem->getDescription()), descWidth, mainFont->mFontID ); - mainFont->DrawString(text.c_str(), descX, descY); - mFont->SetColor(ARGB(255,255,255,255)); + string text = wordWrap(_(currentMenuItem->getDescription()), descWidth, descriptionFont->mFontID ); + descriptionFont->DrawString(text.c_str(), descX, descY); // fill in the statistical portion if (currentMenuItem->hasMetaData()) @@ -305,13 +301,14 @@ void DeckMenu::Render() ostringstream oss; oss << _("Deck: ") << currentMenuItem->getDeckName() << endl; oss << currentMenuItem->getDeckStatsSummary(); - mainFont->DrawString(oss.str(), statsX, statsY); + descriptionFont->DrawString(oss.str(), statsX, statsY); } + + // change the font color of the current menu item + mFont->SetColor(ARGB(255,255,255,255)); } - else - { + else // reset the font color to be slightly muted mFont->SetColor(ARGB(150,255,255,255)); - } currentMenuItem->RenderWithOffset(-kLineHeight * startId); } } @@ -348,6 +345,9 @@ void DeckMenu::Update(float dt) float starsX = starsOffsetX + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2); float starsY = selectionY + 5 * cos(selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId; stars->MoveTo(starsX, starsY); + + // + if (timeOpen < 0) { timeOpen += dt * 10; diff --git a/projects/mtg/src/DeckMenuItem.cpp b/projects/mtg/src/DeckMenuItem.cpp index 5052cec1f..ef65d1d67 100644 --- a/projects/mtg/src/DeckMenuItem.cpp +++ b/projects/mtg/src/DeckMenuItem.cpp @@ -63,7 +63,7 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f break; case kEvilTwinMenuID: { - mImageFilename = "EvilTwinAvatar"; + mImageFilename = "avatar.jpg"; break; } default: @@ -99,7 +99,12 @@ void DeckMenuItem::RenderWithOffset(float yOffset) mScrollerOffset = -1 * ( getWidth() - ITEM_PX_WIDTH )/2; float offSet = mScrollerOffset; - mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER, offSet, ITEM_PX_WIDTH); + if (mHasFocus) + mFont->SetScale(SCALE_SELECTED); + else + mFont->SetScale(SCALE_NORMAL); + + mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER, offSet, ITEM_PX_WIDTH); mDisplayInitialized = true; //Render a "new" icon for decks that have never been played yet if (mMetaData && !mMetaData->getGamesPlayed()) diff --git a/projects/mtg/src/GameStateShop.cpp b/projects/mtg/src/GameStateShop.cpp index 9647d83a6..89b789de2 100644 --- a/projects/mtg/src/GameStateShop.cpp +++ b/projects/mtg/src/GameStateShop.cpp @@ -209,7 +209,7 @@ string GameStateShop::descPurchase(int controlId, bool tiny) void GameStateShop::beginPurchase(int controlId) { WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MENU_FONT); - mFont->SetScale(DEFAULT_MENU_FONT_SCALE); + mFont->SetScale(SCALE_NORMAL); SAFE_DELETE(menu); if (mInventory[controlId] <= 0) { diff --git a/projects/mtg/src/SimpleButton.cpp b/projects/mtg/src/SimpleButton.cpp index 61aa0ddd0..58a8a8c5a 100644 --- a/projects/mtg/src/SimpleButton.cpp +++ b/projects/mtg/src/SimpleButton.cpp @@ -50,6 +50,11 @@ void SimpleButton::RenderWithOffset(float yOffset) { mYOffset = yOffset; WFont * mFont = WResourceManager::Instance()->GetWFont(mFontId); + if (mHasFocus) + mFont->SetScale(SCALE_SELECTED); + else + mFont->SetScale(SCALE_NORMAL); + mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER); } diff --git a/projects/mtg/src/SimpleMenu.cpp b/projects/mtg/src/SimpleMenu.cpp index 12e2c9cfa..6bf173e61 100644 --- a/projects/mtg/src/SimpleMenu.cpp +++ b/projects/mtg/src/SimpleMenu.cpp @@ -9,12 +9,12 @@ namespace { const float kPoleWidth = 7; - const float kVerticalMargin = 16; + const float kVerticalMargin = 20; const float kHorizontalMargin = 30; #ifdef TOUCH_ENABLED - const float kLineHeight = 30; + const float kLineHeight = 25; #else const float kLineHeight = 20; #endif @@ -150,7 +150,7 @@ void SimpleMenu::Render() for (int i = 0; i < mCount; ++i) { - float y = mY + kVerticalMargin + i * kLineHeight + 3;//spacing between first object and title bar + float y = mY + kVerticalMargin + i * kLineHeight; SimpleMenuItem * smi = static_cast (mObjects[i]); smi->Relocate(mX + mWidth / 2, y); if (smi->hasFocus()) sY = y; @@ -183,26 +183,32 @@ void SimpleMenu::Render() if (!title.empty()) { - mFont->SetScale(1.5f); + int scaleFactor = titleFont->GetScale(); + titleFont->SetScale(SCALE_NORMAL); titleFont->DrawString(title.c_str(), mX + mWidth / 2, mY - 3, JGETEXT_CENTER); + titleFont->SetScale(scaleFactor); } for (int i = startId; i < startId + maxItems; i++) { if (i > mCount - 1) break; - if ((static_cast (mObjects[i]))->getY() - kLineHeight * startId < mY + height - kLineHeight + 7) + SimpleMenuItem *currentMenuItem = static_cast(mObjects[i]); + float currentY = currentMenuItem->getY() - kLineHeight * startId; + float menuBottomEdge = mY + height - kLineHeight + 7; + if (currentY < menuBottomEdge) { - if (static_cast (mObjects[i])->hasFocus()) + if (currentMenuItem->hasFocus()) { - WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT)->DrawString(static_cast (mObjects[i])->getDescription().c_str(), mX + WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT)->DrawString(currentMenuItem->getDescription().c_str(), mX + mWidth + 10, mY + 15); mFont->SetColor(ARGB(255,255,255,0)); } else + { mFont->SetColor(ARGB(150,255,255,255)); + } (static_cast (mObjects[i]))->RenderWithOffset(-kLineHeight * startId); } } - mFont->SetScale(1.0f); } void SimpleMenu::Update(float dt) diff --git a/projects/mtg/src/WGui.cpp b/projects/mtg/src/WGui.cpp index fc93a6410..2629be237 100644 --- a/projects/mtg/src/WGui.cpp +++ b/projects/mtg/src/WGui.cpp @@ -197,8 +197,12 @@ PIXEL_TYPE WDecoStyled::getColor(int type) void WGuiHeader::Render() { WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); + // save the current scaling factor. We don't want the lists to change font size these lists should stay the same no matter what + int currentScale = mFont->GetScale(); + mFont->SetScale(SCALE_NORMAL); mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->DrawString(_(displayValue).c_str(), x + width / 2, y, JGETEXT_CENTER); + mFont->SetScale(currentScale); } bool WGuiMenu::Leaving(JButton key) @@ -300,13 +304,17 @@ void WGuiList::Render() int adjustedCurrent = 0; int start = 0, nowPos = 0, vHeight = 0; int nbitems = (int) items.size(); - + //List is empty. if (!items.size() && failMsg != "") { WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::OPTION_FONT); + // save the current scaling factor. We don't want the lists to change font size these lists should stay the same no matter what + int fontScaleFactor = mFont->GetScale(); + mFont->SetScale(SCALE_NORMAL); mFont->SetColor(getColor(WGuiColor::TEXT_FAIL)); mFont->DrawString(_(failMsg).c_str(), x + width / 2, y, JGETEXT_RIGHT); + mFont->SetScale(fontScaleFactor); return; } @@ -1967,7 +1975,8 @@ void WGuiFilterItem::updateValue() SAFE_DELETE(mParent->subMenu); mState = STATE_CHOOSE_TYPE; SAFE_DELETE(mParent->subMenu); - mParent->subMenu = NEW SimpleMenu(JGE::GetInstance(), -1234, this, Fonts::MAIN_FONT, 30, 30, "Filter By...", 6); + mParent->subMenu = NEW SimpleMenu(JGE::GetInstance(), -1234, this, Fonts::MENU_FONT, 20, 20, "Filter By...", 6); + if (mParent->isAvailable(FILTER_SET)) { mParent->subMenu->Add(FILTER_SET, "Set");