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.
There is also a `<fastSelectFont>` 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:**
`<listFont>` - font to use for the game list.
`<descriptionFont>` - font to use for description text.
`<fastSelectFont>` - font to use for the fast select letter.
Audio
=====

View file

@ -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.

View file

@ -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<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));
if(mLetterID == std::string::npos)
@ -18,6 +18,7 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* 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)

View file

@ -11,7 +11,7 @@
class GuiFastSelect : GuiComponent
{
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();
void onRender();
@ -38,6 +38,7 @@ private:
bool mScrolling;
Sound* mScrollSound;
Font* mFont;
};
#endif

View file

@ -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)

View file

@ -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);

View file

@ -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