Fonts can have more than one color. Moved splash to default theme.

This commit is contained in:
emb 2015-02-19 21:59:09 -06:00
parent 750d0c6c7e
commit f858f55bc4
9 changed files with 33 additions and 18 deletions

View File

@ -30,7 +30,7 @@
<!-- Main Menu Background --> <!-- Main Menu Background -->
<!-- Main Menu index 0 --> <!-- Main Menu index 0 -->
<menu type="custom" imageType="logo" orientation="horizontal" x="0" width="center" y="center" yOffset="320" algorithm="easeincircular" speed="0.04" acceleration="0.05"> <menu type="custom" imageType="logo" orientation="horizontal" x="0" width="center" y="center" yOffset="320" algorithm="easeincircular" scrollSpeed="0.250" scrollAcceleration="0.05">
<itemDefaults xOrigin="center" y="center" yOrigin="center" width="300" spacing="10" x="center" yOffset="320" alpha="0.5" fontSize="35" layer="6"/> <itemDefaults xOrigin="center" y="center" yOrigin="center" width="300" spacing="10" x="center" yOffset="320" alpha="0.5" fontSize="35" layer="6"/>
<item xOffset="-1420" alpha="0" /> <item xOffset="-1420" alpha="0" />
<item xOffset="-1060"> <item xOffset="-1060">
@ -124,7 +124,7 @@
<!-- ---------------SUB MENU--------------- --> <!-- ---------------SUB MENU--------------- -->
<!-- Sub Menu index 1 --> <!-- Sub Menu index 1 -->
<menu orientation="horizontal" algorithm="easeincircular" y="75" width="600" height="920" speed="0.5" acceleration="0.05"> <menu orientation="horizontal" algorithm="easeincircular" y="75" width="600" height="920" scrollSpeed="0.250" scrollAcceleration="0.05">
<itemDefaults spacing="5" x="center" height="34" width="600" fontSize="28" alpha="1" xOffset="100" yOrigin="center" xOrigin="left" layer="5"> <itemDefaults spacing="5" x="center" height="34" width="600" fontSize="28" alpha="1" xOffset="100" yOrigin="center" xOrigin="left" layer="5">
<onMenuExit> <onMenuExit>
<set duration=".25"> <set duration=".25">

View File

@ -1,4 +1,4 @@
<layout width="1920" height="1080" font="Age.otf" loadFontSize="32" fontColor="eeeeee"> <layout width="1920" height="1080" font="LoveloBlack.otf" loadFontSize="32" fontColor="eeeeee">
<!-- border for menu --> <!-- border for menu -->
<container backgroundColor="C0392B" backgroundAlpha="1.0" x="0" y="0" height="stretch" width="stretch" layer="0" /> <container backgroundColor="C0392B" backgroundAlpha="1.0" x="0" y="0" height="stretch" width="stretch" layer="0" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

View File

@ -52,11 +52,11 @@ void FontCache::Initialize()
//todo: make bool //todo: make bool
TTF_Init(); TTF_Init();
} }
Font *FontCache::GetFont(std::string fontPath) Font *FontCache::GetFont(std::string fontPath, int fontSize, SDL_Color color)
{ {
Font *t = NULL; Font *t = NULL;
std::map<std::string, Font *>::iterator it = FontFaceMap.find(fontPath); std::map<std::string, Font *>::iterator it = FontFaceMap.find(BuildFontKey(fontPath, fontSize, color));
if(it != FontFaceMap.end()) if(it != FontFaceMap.end())
{ {
@ -66,15 +66,24 @@ Font *FontCache::GetFont(std::string fontPath)
return t; return t;
} }
std::string FontCache::BuildFontKey(std::string font, int fontSize, SDL_Color color)
{
std::stringstream ss;
ss << font << "_SIZE=" << fontSize << " RGB=" << color.r << "." << color.g << "." << color.b;
return ss.str();
}
bool FontCache::LoadFont(std::string fontPath, int fontSize, SDL_Color color) bool FontCache::LoadFont(std::string fontPath, int fontSize, SDL_Color color)
{ {
std::map<std::string, Font *>::iterator it = FontFaceMap.find(fontPath); std::string key = BuildFontKey(fontPath, fontSize, color);
std::map<std::string, Font *>::iterator it = FontFaceMap.find(key);
if(it == FontFaceMap.end()) if(it == FontFaceMap.end())
{ {
Font *f = new Font(); Font *f = new Font();
f->Initialize(fontPath, fontSize, color); f->Initialize(fontPath, fontSize, color);
FontFaceMap[fontPath] = f; FontFaceMap[key] = f;
} }
return true; return true;

View File

@ -26,11 +26,12 @@ public:
void DeInitialize(); void DeInitialize();
FontCache(); FontCache();
bool LoadFont(std::string font, int fontSize, SDL_Color color); bool LoadFont(std::string font, int fontSize, SDL_Color color);
Font *GetFont(std::string font); Font *GetFont(std::string font, int fontSize, SDL_Color color);
virtual ~FontCache(); virtual ~FontCache();
private: private:
std::map<std::string, Font *> FontFaceMap; std::map<std::string, Font *> FontFaceMap;
std::string BuildFontKey(std::string font, int fontSize, SDL_Color color);
}; };

View File

@ -47,8 +47,9 @@ static const int MENU_END = -2; // last item transitions here after it scroll
static const int MENU_CENTER = -4; static const int MENU_CENTER = -4;
//todo: this file is starting to become a god class of building. Consider splitting into sub-builders //todo: this file is starting to become a god class of building. Consider splitting into sub-builders
PageBuilder::PageBuilder(std::string layoutKey, Configuration &c, FontCache *fc) PageBuilder::PageBuilder(std::string layoutKey, std::string layoutPage, Configuration &c, FontCache *fc)
: LayoutKey(layoutKey) : LayoutKey(layoutKey)
, LayoutPage(layoutPage)
, Config(c) , Config(c)
, ScaleX(1) , ScaleX(1)
, ScaleY(1) , ScaleY(1)
@ -77,7 +78,7 @@ Page *PageBuilder::BuildPage()
std::string layoutName = LayoutKey; std::string layoutName = LayoutKey;
LayoutPath = Configuration::GetAbsolutePath() + "/Layouts/" + layoutName; LayoutPath = Configuration::GetAbsolutePath() + "/Layouts/" + layoutName;
layoutFile = LayoutPath + "/Layout.xml"; layoutFile = LayoutPath + "/" + LayoutPage + ".xml";
Logger::Write(Logger::ZONE_INFO, "Layout", "Initializing " + layoutFile); Logger::Write(Logger::ZONE_INFO, "Layout", "Initializing " + layoutFile);
@ -369,7 +370,7 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
else else
{ {
FC->LoadFont(Font, FontSize, FontColor); FC->LoadFont(Font, FontSize, FontColor);
Text *c = new Text(value->value(), FC->GetFont(Font), FontColor, ScaleX, ScaleY); Text *c = new Text(value->value(), FC->GetFont(Font, FontSize, FontColor), FontColor, ScaleX, ScaleY);
ViewInfo *v = c->GetBaseViewInfo(); ViewInfo *v = c->GetBaseViewInfo();
BuildViewInfo(componentXml, v); BuildViewInfo(componentXml, v);
@ -382,7 +383,7 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
for(xml_node<> *componentXml = layout->first_node("statusText"); componentXml; componentXml = componentXml->next_sibling("statusText")) for(xml_node<> *componentXml = layout->first_node("statusText"); componentXml; componentXml = componentXml->next_sibling("statusText"))
{ {
FC->LoadFont(Font, FontSize, FontColor); FC->LoadFont(Font, FontSize, FontColor);
Text *c = new Text("", FC->GetFont(Font), FontColor, ScaleX, ScaleY); Text *c = new Text("", FC->GetFont(Font, FontSize, FontColor), FontColor, ScaleX, ScaleY);
ViewInfo *v = c->GetBaseViewInfo(); ViewInfo *v = c->GetBaseViewInfo();
BuildViewInfo(componentXml, v); BuildViewInfo(componentXml, v);
@ -431,13 +432,13 @@ void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName,
if(type) if(type)
{ {
FC->LoadFont(Font, FontSize, FontColor); FC->LoadFont(Font, FontSize, FontColor);
c = new ReloadableText(type->value(), FC->GetFont(Font), FontColor, LayoutKey, ScaleX, ScaleY); c = new ReloadableText(type->value(), FC->GetFont(Font, FontSize, FontColor), FontColor, LayoutKey, ScaleX, ScaleY);
} }
} }
else else
{ {
FC->LoadFont(Font, FontSize, FontColor); FC->LoadFont(Font, FontSize, FontColor);
c = new ReloadableMedia(Config, type->value(), (tagName == "reloadableVideo"), FC->GetFont(Font), FontColor, ScaleX, ScaleY); c = new ReloadableMedia(Config, type->value(), (tagName == "reloadableVideo"), FC->GetFont(Font, FontSize, FontColor), FontColor, ScaleX, ScaleY);
xml_attribute<> *textFallback = componentXml->first_attribute("textFallback"); xml_attribute<> *textFallback = componentXml->first_attribute("textFallback");
if(textFallback && Utils::ToLower(textFallback->value()) == "true") if(textFallback && Utils::ToLower(textFallback->value()) == "true")
@ -527,7 +528,7 @@ ScrollingList * PageBuilder::BuildMenu(xml_node<> *menuXml)
// on default, text will be rendered to the menu. Preload it into cache. // on default, text will be rendered to the menu. Preload it into cache.
FC->LoadFont(Font, FontSize, FontColor); FC->LoadFont(Font, FontSize, FontColor);
menu = new ScrollingList(Config, ScaleX, ScaleY, FC->GetFont(Font), FontColor, LayoutKey, imageType); menu = new ScrollingList(Config, ScaleX, ScaleY, FC->GetFont(Font, FontSize, FontColor), FontColor, LayoutKey, imageType);
if(scrollTimeXml) if(scrollTimeXml)
{ {

View File

@ -30,12 +30,13 @@ class Configuration;
class PageBuilder class PageBuilder
{ {
public: public:
PageBuilder(std::string layoutKey, Configuration &c, FontCache *fc); PageBuilder(std::string layoutKey, std::string layoutPage, Configuration &c, FontCache *fc);
virtual ~PageBuilder(); virtual ~PageBuilder();
Page *BuildPage(); Page *BuildPage();
private: private:
std::string LayoutKey; std::string LayoutKey;
std::string LayoutPage;
std::string LayoutPath; std::string LayoutPath;
Configuration &Config; Configuration &Config;
float ScaleX; float ScaleX;

View File

@ -452,7 +452,7 @@ Page *RetroFE::LoadPage()
Config.GetProperty("layout", layoutName); Config.GetProperty("layout", layoutName);
PageBuilder pb(layoutName, Config, &FC); PageBuilder pb(layoutName, "Layout", Config, &FC);
Page *page = pb.BuildPage(); Page *page = pb.BuildPage();
if(!page) if(!page)
@ -469,7 +469,10 @@ Page *RetroFE::LoadPage()
Page *RetroFE::LoadSplashPage() Page *RetroFE::LoadSplashPage()
{ {
PageBuilder pb("Splash", Config, &FC); std::string layoutName;
Config.GetProperty("layout", layoutName);
PageBuilder pb(layoutName, "Splash", Config, &FC);
Page * page = pb.BuildPage(); Page * page = pb.BuildPage();
page->Start(); page->Start();