Added fast select font tag.

This commit is contained in:
Aloshi 2013-03-17 12:16:40 -05:00
parent fa7f0a488c
commit 34c3d607b5
7 changed files with 33 additions and 4 deletions

View file

@ -140,6 +140,7 @@ Display tags define some "meta" display attributes about your theme. Display tag
`<boxCorner>` - 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. `<boxCorner>` - 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 `<fastSelectFont>` font tag (see the Fonts section for more info).
Fonts 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. 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 tags:**
`<listFont>` - font to use for the game list. `<listFont>` - font to use for the game list.
`<descriptionFont>` - font to use for description text. `<descriptionFont>` - font to use for description text.
`<fastSelectFont>` - font to use for the fast select letter.
Audio Audio
===== =====

View file

@ -1,3 +1,6 @@
March 17, 2013
-Added Fast Select font tag.
January 26, 2013 January 26, 2013
-Added "Reload" option to the menu. This option reloads all game data. -Added "Reload" option to the menu. This option reloads all game data.

View file

@ -6,7 +6,7 @@ const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int GuiFastSelect::SCROLLSPEED = 100; const int GuiFastSelect::SCROLLSPEED = 100;
const int GuiFastSelect::SCROLLDELAY = 507; const int GuiFastSelect::SCROLLDELAY = 507;
GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound) GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound, Font* font)
{ {
mLetterID = LETTERS.find(toupper(startLetter)); mLetterID = LETTERS.find(toupper(startLetter));
if(mLetterID == std::string::npos) if(mLetterID == std::string::npos)
@ -18,6 +18,7 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, cha
mParent = parent; mParent = parent;
mList = list; mList = list;
mScrollSound = scrollsound; mScrollSound = scrollsound;
mFont = font;
mScrolling = false; mScrolling = false;
mScrollTimer = 0; mScrollTimer = 0;
@ -51,7 +52,7 @@ void GuiFastSelect::onRender()
mBox->render(); 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) void GuiFastSelect::onInput(InputManager::InputButton button, bool keyDown)

View file

@ -11,7 +11,7 @@
class GuiFastSelect : GuiComponent class GuiFastSelect : GuiComponent
{ {
public: public:
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound); GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor, Sound* scrollsound, Font* font);
~GuiFastSelect(); ~GuiFastSelect();
void onRender(); void onRender();
@ -38,6 +38,7 @@ private:
bool mScrolling; bool mScrolling;
Sound* mScrollSound; Sound* mScrollSound;
Font* mFont;
}; };
#endif #endif

View file

@ -170,7 +170,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
//open the fast select menu //open the fast select menu
if(button == InputManager::SELECT && keyDown) 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) if(mDetailed)

View file

@ -51,6 +51,14 @@ Font* GuiTheme::getDescriptionFont()
return mDescFont; return mDescFont;
} }
Font* GuiTheme::getFastSelectFont()
{
if(mFastSelectFont == NULL)
return Renderer::getDefaultFont(Renderer::LARGE);
else
return mFastSelectFont;
}
GuiTheme::GuiTheme(bool detailed, std::string path) GuiTheme::GuiTheme(bool detailed, std::string path)
{ {
mDetailed = detailed; mDetailed = detailed;
@ -62,6 +70,7 @@ GuiTheme::GuiTheme(bool detailed, std::string path)
mListFont = NULL; mListFont = NULL;
mDescFont = NULL; mDescFont = NULL;
mFastSelectFont = NULL;
setDefaults(); setDefaults();
@ -122,6 +131,11 @@ void GuiTheme::setDefaults()
delete mDescFont; delete mDescFont;
mDescFont = NULL; mDescFont = NULL;
} }
if(mFastSelectFont != NULL)
{
delete mFastSelectFont;
mFastSelectFont = NULL;
}
} }
void GuiTheme::deleteComponents() void GuiTheme::deleteComponents()
@ -134,6 +148,9 @@ void GuiTheme::deleteComponents()
mComponentVector.clear(); mComponentVector.clear();
clearChildren(); clearChildren();
//deletes fonts if any were created
setDefaults();
} }
@ -234,6 +251,7 @@ void GuiTheme::readXML(std::string path)
//fonts //fonts
mListFont = resolveFont(root.child("listFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::MEDIUM)->getSize()); mListFont = resolveFont(root.child("listFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::MEDIUM)->getSize());
mDescFont = resolveFont(root.child("descriptionFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::SMALL)->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 //actually read the components
createComponentChildren(root, this); createComponentChildren(root, this);

View file

@ -26,6 +26,7 @@ public:
Font* getListFont(); Font* getListFont();
Font* getDescriptionFont(); Font* getDescriptionFont();
Font* getFastSelectFont();
private: private:
void setDefaults(); void setDefaults();
void deleteComponents(); void deleteComponents();
@ -53,6 +54,7 @@ private:
GuiBoxData mBoxData; GuiBoxData mBoxData;
Font* mListFont; Font* mListFont;
Font* mDescFont; Font* mDescFont;
Font* mFastSelectFont;
}; };
#endif #endif