From 34c3d607b5d1cf78827d44e4bc747a0ef1599876 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Sun, 17 Mar 2013 12:16:40 -0500 Subject: [PATCH] Added fast select font tag. --- THEMES.md | 4 ++++ changelog.txt | 3 +++ src/components/GuiFastSelect.cpp | 5 +++-- src/components/GuiFastSelect.h | 3 ++- src/components/GuiGameList.cpp | 2 +- src/components/GuiTheme.cpp | 18 ++++++++++++++++++ src/components/GuiTheme.h | 2 ++ 7 files changed, 33 insertions(+), 4 deletions(-) diff --git a/THEMES.md b/THEMES.md index 5818b9378..3348cc88b 100644 --- a/THEMES.md +++ b/THEMES.md @@ -140,6 +140,7 @@ Display tags define some "meta" display attributes about your theme. Display tag `` - path to the "top left corner" image file. It will be flipped for the top right, bottom right, and bottom left corners. ~ and . are expanded. +There is also a `` font tag (see the Fonts section for more info). Fonts @@ -156,12 +157,15 @@ Fonts are defined like so: You can leave off any tags you don't want to use, and they'll use the default. Size is defined as a percentage of the screen height. "." and "~" are expanded for paths. +NOTE: If your font size is too big, it'll overrun the maximum texture size. + **Font tags:** `` - font to use for the game list. `` - font to use for description text. +`` - font to use for the fast select letter. Audio ===== diff --git a/changelog.txt b/changelog.txt index d1951cb7f..327598a6d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +March 17, 2013 +-Added Fast Select font tag. + January 26, 2013 -Added "Reload" option to the menu. This option reloads all game data. diff --git a/src/components/GuiFastSelect.cpp b/src/components/GuiFastSelect.cpp index f8dfff002..261c8430b 100644 --- a/src/components/GuiFastSelect.cpp +++ b/src/components/GuiFastSelect.cpp @@ -6,7 +6,7 @@ const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const int GuiFastSelect::SCROLLSPEED = 100; const int GuiFastSelect::SCROLLDELAY = 507; -GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound) +GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound, Font* font) { mLetterID = LETTERS.find(toupper(startLetter)); if(mLetterID == std::string::npos) @@ -18,6 +18,7 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList* list, cha mParent = parent; mList = list; mScrollSound = scrollsound; + mFont = font; mScrolling = false; mScrollTimer = 0; @@ -51,7 +52,7 @@ void GuiFastSelect::onRender() mBox->render(); - Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (Renderer::getDefaultFont(Renderer::LARGE)->getHeight() * 0.5), mTextColor, Renderer::getDefaultFont(Renderer::LARGE)); + Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (mFont->getHeight() * 0.5), mTextColor, mFont); } void GuiFastSelect::onInput(InputManager::InputButton button, bool keyDown) diff --git a/src/components/GuiFastSelect.h b/src/components/GuiFastSelect.h index f63afec8e..b46a86cb3 100644 --- a/src/components/GuiFastSelect.h +++ b/src/components/GuiFastSelect.h @@ -11,7 +11,7 @@ class GuiFastSelect : GuiComponent { public: - GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound); + GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound, Font* font); ~GuiFastSelect(); void onRender(); @@ -38,6 +38,7 @@ private: bool mScrolling; Sound* mScrollSound; + Font* mFont; }; #endif diff --git a/src/components/GuiGameList.cpp b/src/components/GuiGameList.cpp index a0f990569..8f97464f5 100644 --- a/src/components/GuiGameList.cpp +++ b/src/components/GuiGameList.cpp @@ -170,7 +170,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown) //open the fast select menu if(button == InputManager::SELECT && keyDown) { - new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getColor("fastSelect"), mTheme->getSound("menuScroll")); + new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getColor("fastSelect"), mTheme->getSound("menuScroll"), mTheme->getFastSelectFont()); } if(mDetailed) diff --git a/src/components/GuiTheme.cpp b/src/components/GuiTheme.cpp index 0e9a6b100..874946926 100644 --- a/src/components/GuiTheme.cpp +++ b/src/components/GuiTheme.cpp @@ -51,6 +51,14 @@ Font* GuiTheme::getDescriptionFont() return mDescFont; } +Font* GuiTheme::getFastSelectFont() +{ + if(mFastSelectFont == NULL) + return Renderer::getDefaultFont(Renderer::LARGE); + else + return mFastSelectFont; +} + GuiTheme::GuiTheme(bool detailed, std::string path) { mDetailed = detailed; @@ -62,6 +70,7 @@ GuiTheme::GuiTheme(bool detailed, std::string path) mListFont = NULL; mDescFont = NULL; + mFastSelectFont = NULL; setDefaults(); @@ -122,6 +131,11 @@ void GuiTheme::setDefaults() delete mDescFont; mDescFont = NULL; } + if(mFastSelectFont != NULL) + { + delete mFastSelectFont; + mFastSelectFont = NULL; + } } void GuiTheme::deleteComponents() @@ -134,6 +148,9 @@ void GuiTheme::deleteComponents() mComponentVector.clear(); clearChildren(); + + //deletes fonts if any were created + setDefaults(); } @@ -234,6 +251,7 @@ void GuiTheme::readXML(std::string path) //fonts mListFont = resolveFont(root.child("listFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::MEDIUM)->getSize()); mDescFont = resolveFont(root.child("descriptionFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::SMALL)->getSize()); + mFastSelectFont = resolveFont(root.child("fastSelectFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::LARGE)->getSize()); //actually read the components createComponentChildren(root, this); diff --git a/src/components/GuiTheme.h b/src/components/GuiTheme.h index 3f1b1b0b3..9e9fbc8ae 100644 --- a/src/components/GuiTheme.h +++ b/src/components/GuiTheme.h @@ -26,6 +26,7 @@ public: Font* getListFont(); Font* getDescriptionFont(); + Font* getFastSelectFont(); private: void setDefaults(); void deleteComponents(); @@ -53,6 +54,7 @@ private: GuiBoxData mBoxData; Font* mListFont; Font* mDescFont; + Font* mFastSelectFont; }; #endif