mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-13 10:18:53 +01:00
Fonts can have more than one color. Moved splash to default theme.
This commit is contained in:
parent
750d0c6c7e
commit
f858f55bc4
@ -30,7 +30,7 @@
|
||||
<!-- Main Menu Background -->
|
||||
|
||||
<!-- 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"/>
|
||||
<item xOffset="-1420" alpha="0" />
|
||||
<item xOffset="-1060">
|
||||
@ -124,7 +124,7 @@
|
||||
<!-- ---------------SUB MENU--------------- -->
|
||||
|
||||
<!-- 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">
|
||||
<onMenuExit>
|
||||
<set duration=".25">
|
||||
|
||||
@ -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 -->
|
||||
<container backgroundColor="C0392B" backgroundAlpha="1.0" x="0" y="0" height="stretch" width="stretch" layer="0" />
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 8.8 KiB |
@ -52,11 +52,11 @@ void FontCache::Initialize()
|
||||
//todo: make bool
|
||||
TTF_Init();
|
||||
}
|
||||
Font *FontCache::GetFont(std::string fontPath)
|
||||
Font *FontCache::GetFont(std::string fontPath, int fontSize, SDL_Color color)
|
||||
{
|
||||
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())
|
||||
{
|
||||
@ -66,15 +66,24 @@ Font *FontCache::GetFont(std::string fontPath)
|
||||
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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
Font *f = new Font();
|
||||
f->Initialize(fontPath, fontSize, color);
|
||||
FontFaceMap[fontPath] = f;
|
||||
FontFaceMap[key] = f;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -26,11 +26,12 @@ public:
|
||||
void DeInitialize();
|
||||
FontCache();
|
||||
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();
|
||||
private:
|
||||
std::map<std::string, Font *> FontFaceMap;
|
||||
std::string BuildFontKey(std::string font, int fontSize, SDL_Color color);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -47,8 +47,9 @@ static const int MENU_END = -2; // last item transitions here after it scroll
|
||||
static const int MENU_CENTER = -4;
|
||||
|
||||
//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)
|
||||
, LayoutPage(layoutPage)
|
||||
, Config(c)
|
||||
, ScaleX(1)
|
||||
, ScaleY(1)
|
||||
@ -77,7 +78,7 @@ Page *PageBuilder::BuildPage()
|
||||
std::string layoutName = LayoutKey;
|
||||
|
||||
LayoutPath = Configuration::GetAbsolutePath() + "/Layouts/" + layoutName;
|
||||
layoutFile = LayoutPath + "/Layout.xml";
|
||||
layoutFile = LayoutPath + "/" + LayoutPage + ".xml";
|
||||
|
||||
Logger::Write(Logger::ZONE_INFO, "Layout", "Initializing " + layoutFile);
|
||||
|
||||
@ -369,7 +370,7 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
|
||||
else
|
||||
{
|
||||
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();
|
||||
|
||||
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"))
|
||||
{
|
||||
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();
|
||||
|
||||
BuildViewInfo(componentXml, v);
|
||||
@ -431,13 +432,13 @@ void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName,
|
||||
if(type)
|
||||
{
|
||||
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
|
||||
{
|
||||
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");
|
||||
|
||||
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.
|
||||
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)
|
||||
{
|
||||
|
||||
@ -30,12 +30,13 @@ class Configuration;
|
||||
class PageBuilder
|
||||
{
|
||||
public:
|
||||
PageBuilder(std::string layoutKey, Configuration &c, FontCache *fc);
|
||||
PageBuilder(std::string layoutKey, std::string layoutPage, Configuration &c, FontCache *fc);
|
||||
virtual ~PageBuilder();
|
||||
Page *BuildPage();
|
||||
|
||||
private:
|
||||
std::string LayoutKey;
|
||||
std::string LayoutPage;
|
||||
std::string LayoutPath;
|
||||
Configuration &Config;
|
||||
float ScaleX;
|
||||
|
||||
@ -452,7 +452,7 @@ Page *RetroFE::LoadPage()
|
||||
|
||||
Config.GetProperty("layout", layoutName);
|
||||
|
||||
PageBuilder pb(layoutName, Config, &FC);
|
||||
PageBuilder pb(layoutName, "Layout", Config, &FC);
|
||||
Page *page = pb.BuildPage();
|
||||
|
||||
if(!page)
|
||||
@ -469,7 +469,10 @@ Page *RetroFE::LoadPage()
|
||||
|
||||
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->Start();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user