mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-31 12:05:37 +01:00
Added load font size option for quality purposes. Added showcase theme (requires artwork, working on licensing before adding to repo).
This commit is contained in:
parent
e8653d2b71
commit
f823d497a9
BIN
Package/Environment/Common/Layouts/Default 16x9/Age.otf
Normal file
BIN
Package/Environment/Common/Layouts/Default 16x9/Age.otf
Normal file
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
<layout width="1920" height="1080" font="Roboto-Bold.ttf" fontColor="c0842b">
|
||||
<layout width="1920" height="1080" font="Age.otf" loadFontSize="32" fontColor="eeeeee">
|
||||
<sound type="load" src="load.wav" />
|
||||
<sound type="unload" src="unload.wav" />
|
||||
<sound type="highlight" src="highlight.wav" />
|
||||
@ -7,14 +7,14 @@
|
||||
<!-- background -->
|
||||
<container backgroundColor="C0392B" backgroundAlpha="1.0" x="0" y="0" height="stretch" width="stretch" layer="0"/>
|
||||
|
||||
<menu orientation="horizontal" algorithm="easeincircular" xOffset="500" y="0" width="center" height="stretch" speed="0.05" acceleration="0.05" layer="3">
|
||||
<itemDefaults spacing="10" x="center" height="30" font-size="30" alpha="0.5" xOffset="20" yOrigin="center" />
|
||||
<!-- menu -->
|
||||
<menu orientation="horizontal" algorithm="easeincircular" xOffset="500" y="10" width="center" height="1040" speed="0.05" acceleration="0.05">
|
||||
<itemDefaults spacing="10" x="center" height="35" fontSize="35" alpha="0.5" xOffset="20" yOrigin="center" layer="3"/>
|
||||
<item index="start" height="0" spacing="0" alpha="0"/>
|
||||
<item index="2" spacing="0" height="50" fontSize="50" alpha="1" selected="true"/>
|
||||
<item index="2" spacing="0" height="60" fontSize="60" alpha="1" selected="true"/>
|
||||
<item index="end" height="0" spacing="0" alpha="0"/>
|
||||
</menu>
|
||||
|
||||
|
||||
<!-- logo -->
|
||||
<image x="30" y="20" height="80" src="logo.png" layer="1" alpha="0.3">
|
||||
<onEnter>
|
||||
@ -30,12 +30,9 @@
|
||||
</set>
|
||||
</onExit>
|
||||
</image>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- video (or snapshot if video doesn't exist)-->
|
||||
|
||||
<reloadableVideo imageType="snap" x="480" y="170" xOrigin="center" height="480" width="640" layer="5">
|
||||
<onHighlightEnter>
|
||||
<set duration=".4">
|
||||
@ -52,7 +49,6 @@
|
||||
|
||||
|
||||
<!-- boxart -->
|
||||
<!--
|
||||
<reloadableImage type="box" x="480" y="750" xOrigin="center" height="240" layer="4">
|
||||
<onHighlightEnter>
|
||||
<set duration=".4">
|
||||
@ -66,34 +62,13 @@
|
||||
</onHighlightExit>
|
||||
|
||||
</reloadableImage>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<reloadableText type="title" x="0" y="bottom" xOffset="20" yOrigin="center" yOffset="-175" height="150" width="stretch" layer="1" fontSize="50">
|
||||
<onHighlightEnter>
|
||||
<set duration=".2">
|
||||
<animate type="x" from="right" to="0" algorithm="easeinquadratic"/>
|
||||
<animate type="xOrigin" from="right" to="left" algorithm="easeinquadratic"/>
|
||||
</set>
|
||||
</onHighlightEnter>
|
||||
<onHighlightExit>
|
||||
<set duration=".2">
|
||||
<animate type="x" from="0" to="left" algorithm="easeinquadratic"/>
|
||||
<animate type="xOrigin" from="left" to="right" algorithm="easeinquadratic"/>
|
||||
</set>
|
||||
</onHighlightExit>
|
||||
</reloadableText>
|
||||
|
||||
<reloadableText type="manufacturer" x="left" y="bottom" xOrigin="left" yOrigin="bottom" xOffset="10" yOffset="-10" fontSize="20" layer="0">
|
||||
</reloadableText>
|
||||
|
||||
<reloadableText type="year" x="left" y="bottom" xOrigin="left" yOrigin="bottom" xOffset="10" yOffset="-30" fontSize="20" layer="0">
|
||||
</reloadableText>
|
||||
<reloadableText type="numberPlayers" x="left" y="bottom" xOrigin="left" yOrigin="bottom" xOffset="10" yOffset="-70" fontSize="20" layer="0">
|
||||
</reloadableText>
|
||||
|
||||
<reloadableText type="numberButtons" x="left" y="bottom" xOrigin="left" yOrigin="bottom" xOffset="10" yOffset="-90" fontSize="20" layer="0">
|
||||
</reloadableText>
|
||||
<reloadableText type="title" x="0" y="bottom" xOffset="20" yOrigin="center" yOffset="-175" height="150" width="stretch" layer="1" fontSize="50" />
|
||||
<reloadableText type="manufacturer" x="left" y="bottom" xOrigin="left" yOrigin="bottom" xOffset="10" yOffset="-10" fontSize="20" layer="0" />
|
||||
<reloadableText type="year" x="left" y="bottom" xOrigin="left" yOrigin="bottom" xOffset="10" yOffset="-30" fontSize="20" layer="0" />
|
||||
<reloadableText type="numberPlayers" x="left" y="bottom" xOrigin="left" yOrigin="bottom" xOffset="10" yOffset="-70" fontSize="20" layer="0" />
|
||||
<reloadableText type="numberButtons" x="left" y="bottom" xOrigin="left" yOrigin="bottom" xOffset="10" yOffset="-90" fontSize="20" layer="0" />
|
||||
-->
|
||||
</layout>
|
||||
|
||||
|
||||
BIN
Package/Environment/Common/Layouts/Showcase 16x9/Age.otf
Normal file
BIN
Package/Environment/Common/Layouts/Showcase 16x9/Age.otf
Normal file
Binary file not shown.
38
Package/Environment/Common/Layouts/Showcase 16x9/Layout.xml
Normal file
38
Package/Environment/Common/Layouts/Showcase 16x9/Layout.xml
Normal file
@ -0,0 +1,38 @@
|
||||
<layout width="1920" height="1080" font="Age.otf" loadFontSize="32" fontColor="eeeeee">
|
||||
<sound type="load" src="load.wav" />
|
||||
<sound type="unload" src="unload.wav" />
|
||||
<sound type="highlight" src="highlight.wav" />
|
||||
<sound type="select" src="select.wav" />
|
||||
|
||||
<!-- background -->
|
||||
<container backgroundColor="C0392B" backgroundAlpha="1.0" x="0" y="0" height="stretch" width="stretch" layer="0"/>
|
||||
|
||||
<!-- Item name and border -->
|
||||
<container backgroundColor="FFFFFF" backgroundAlpha="0.3" x="0" y="bottom" yOrigin="center" yOffset="-100" height="100" width="stretch" layer="4"/>
|
||||
<reloadableText type="title" x="20" y="bottom" yOrigin="center" yOffset="-90" height="80" layer="5">
|
||||
<onHighlightEnter>
|
||||
<set duration=".2">
|
||||
<animate type="x" from="right" to="20" algorithm="easeinquadratic"/>
|
||||
<animate type="xOrigin" from="right" to="left" algorithm="easeinquadratic"/>
|
||||
</set>
|
||||
</onHighlightEnter>
|
||||
<onHighlightExit>
|
||||
<set duration=".2">
|
||||
<animate type="x" from="20" to="left" algorithm="easeinquadratic"/>
|
||||
<animate type="xOrigin" from="left" to="right" algorithm="easeinquadratic"/>
|
||||
</set>
|
||||
</onHighlightExit>
|
||||
</reloadableText>
|
||||
|
||||
<!-- menu -->
|
||||
<menu type="custom" imageType="title" orientation="horizontal" algorithm="easeincircular" xOffset="500" y="10" width="center" height="1040" speed="0.05" acceleration="0.05">
|
||||
<itemDefaults spacing="10" y="center" yOrigin="center" fontSize="35" alpha="0.5" layer="5"/>
|
||||
<item alpha="0" xOrigin="left" x="right" />
|
||||
<item alpha="1" x="center" xOrigin="center" selected="true" height="700"/>
|
||||
<item alpha="0" xOrigin="right" x="left" />
|
||||
</menu>
|
||||
</layout>
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
Package/Environment/Common/Layouts/Showcase 16x9/highlight.wav
Normal file
BIN
Package/Environment/Common/Layouts/Showcase 16x9/highlight.wav
Normal file
Binary file not shown.
BIN
Package/Environment/Common/Layouts/Showcase 16x9/load.wav
Normal file
BIN
Package/Environment/Common/Layouts/Showcase 16x9/load.wav
Normal file
Binary file not shown.
BIN
Package/Environment/Common/Layouts/Showcase 16x9/select.wav
Normal file
BIN
Package/Environment/Common/Layouts/Showcase 16x9/select.wav
Normal file
Binary file not shown.
BIN
Package/Environment/Common/Layouts/Showcase 16x9/unload.wav
Normal file
BIN
Package/Environment/Common/Layouts/Showcase 16x9/unload.wav
Normal file
Binary file not shown.
Binary file not shown.
@ -1,7 +1,11 @@
|
||||
<layout width="1920" height="1080" font="Age.otf" fontColor="ecf0f1">
|
||||
<layout width="1920" height="1080">
|
||||
<sound type="load" src="load.wav" />
|
||||
<sound type="unload" src="unload.wav" />
|
||||
<sound type="highlight" src="highlight.wav" />
|
||||
<sound type="select" src="select.wav" />
|
||||
|
||||
<!-- border for menu -->
|
||||
<container backgroundColor="c0392b" backgroundAlpha="99" x="0" y="0" height="stretch" width="stretch" layer="0" alpha="0.3" />
|
||||
<container backgroundColor="C0392B" backgroundAlpha="1.0" x="0" y="0" height="stretch" width="stretch" layer="0" />
|
||||
|
||||
<!-- logo -->
|
||||
<image x="center" y="center" height="150" xOrigin="center" yOrigin="center" src="logo.png" layer="1" alpha="1">
|
||||
|
||||
@ -100,11 +100,6 @@ void Text::Draw()
|
||||
rect.w = static_cast<int>(w);
|
||||
rect.y = static_cast<int>(yOrigin);
|
||||
|
||||
SDL_LockMutex(SDL::GetMutex());
|
||||
SDL_SetTextureBlendMode(t, SDL_BLENDMODE_ADD);
|
||||
SDL_SetTextureColorMod(t, FontColor.r, FontColor.g, FontColor.b);
|
||||
SDL_UnlockMutex(SDL::GetMutex());
|
||||
|
||||
SDL::RenderCopy(t, static_cast<char>(info->GetAlpha() * 255), &charRect, &rect, info->GetAngle());
|
||||
rect.x += static_cast<int>(glyph.Advance * scale);
|
||||
}
|
||||
|
||||
@ -50,46 +50,9 @@ bool Font::GetRect(unsigned int charCode, GlyphInfo &glyph)
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetSurfaceAlpha (SDL_Surface *surface, Uint8 alpha)
|
||||
bool Font::Initialize(std::string fontPath, int fontSize, SDL_Color color)
|
||||
{
|
||||
SDL_PixelFormat* fmt = surface->format;
|
||||
|
||||
// If surface has no alpha channel, just set the surface alpha.
|
||||
if( fmt->Amask == 0 ) {
|
||||
SDL_SetSurfaceAlphaMod( surface, alpha );
|
||||
}
|
||||
// Else change the alpha of each pixel.
|
||||
else {
|
||||
unsigned bpp = fmt->BytesPerPixel;
|
||||
// Scaling factor to clamp alpha to [0, alpha].
|
||||
float scale = alpha / 255.0f;
|
||||
|
||||
SDL_LockSurface(surface);
|
||||
|
||||
for (int y = 0; y < surface->h; ++y)
|
||||
for (int x = 0; x < surface->w; ++x) {
|
||||
// Get a pointer to the current pixel.
|
||||
Uint32* pixel_ptr = (Uint32 *)(
|
||||
(Uint8 *)surface->pixels
|
||||
+ y * surface->pitch
|
||||
+ x * bpp
|
||||
);
|
||||
|
||||
// Get the old pixel components.
|
||||
Uint8 r, g, b, a;
|
||||
SDL_GetRGBA( *pixel_ptr, fmt, &r, &g, &b, &a );
|
||||
|
||||
// Set the pixel with the new alpha.
|
||||
*pixel_ptr = SDL_MapRGBA( fmt, r, g, b, (Uint8)(scale * a) );
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
}
|
||||
|
||||
bool Font::Initialize(std::string fontPath, SDL_Color color)
|
||||
{
|
||||
TTF_Font *font = TTF_OpenFont(fontPath.c_str(), 128);
|
||||
TTF_Font *font = TTF_OpenFont(fontPath.c_str(), fontSize);
|
||||
|
||||
if (!font)
|
||||
{
|
||||
|
||||
@ -22,7 +22,7 @@ public:
|
||||
|
||||
Font();
|
||||
virtual ~Font();
|
||||
bool Initialize(std::string fontPath, SDL_Color color);
|
||||
bool Initialize(std::string fontPath, int fontSize, SDL_Color color);
|
||||
void DeInitialize();
|
||||
SDL_Texture *GetTexture();
|
||||
bool GetRect(unsigned int charCode, GlyphInfo &glyph);
|
||||
|
||||
@ -66,14 +66,14 @@ Font *FontCache::GetFont(std::string fontPath)
|
||||
return t;
|
||||
}
|
||||
|
||||
bool FontCache::LoadFont(std::string fontPath, SDL_Color color)
|
||||
bool FontCache::LoadFont(std::string fontPath, int fontSize, SDL_Color color)
|
||||
{
|
||||
std::map<std::string, Font *>::iterator it = FontFaceMap.find(fontPath);
|
||||
|
||||
if(it == FontFaceMap.end())
|
||||
{
|
||||
Font *f = new Font();
|
||||
f->Initialize(fontPath, color);
|
||||
f->Initialize(fontPath, fontSize, color);
|
||||
FontFaceMap[fontPath] = f;
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ public:
|
||||
void Initialize();
|
||||
void DeInitialize();
|
||||
FontCache();
|
||||
bool LoadFont(std::string font, SDL_Color color);
|
||||
bool LoadFont(std::string font, int fontSize, SDL_Color color);
|
||||
Font *GetFont(std::string font);
|
||||
|
||||
virtual ~FontCache();
|
||||
|
||||
@ -54,12 +54,13 @@ PageBuilder::PageBuilder(std::string layoutKey, std::string collection, Configur
|
||||
, ScaleY(1)
|
||||
, ScreenHeight(0)
|
||||
, ScreenWidth(0)
|
||||
, FontSize(24)
|
||||
, FC(fc)
|
||||
{
|
||||
ScreenWidth = SDL::GetWindowWidth();
|
||||
ScreenHeight = SDL::GetWindowHeight();
|
||||
FontColor.a = 255;
|
||||
FontColor.r = 255;
|
||||
FontColor.r = 0;
|
||||
FontColor.g = 0;
|
||||
FontColor.b = 0;
|
||||
}
|
||||
@ -110,6 +111,8 @@ Page *PageBuilder::BuildPage()
|
||||
xml_attribute<> *layoutHeightXml = root->first_attribute("height");
|
||||
xml_attribute<> *fontXml = root->first_attribute("font");
|
||||
xml_attribute<> *fontColorXml = root->first_attribute("fontColor");
|
||||
xml_attribute<> *fontSizeXml = root->first_attribute("loadFontSize");
|
||||
|
||||
int layoutHeight;
|
||||
int layoutWidth;
|
||||
if(!layoutWidthXml || !layoutHeightXml)
|
||||
@ -119,7 +122,6 @@ Page *PageBuilder::BuildPage()
|
||||
}
|
||||
if(fontXml)
|
||||
{
|
||||
//todo: reuse from ComponentBuilder. Not sure how since it relies on knowing the collection
|
||||
std::string fontPropertyKey = "layouts." + LayoutKey + ".font";
|
||||
Config.SetProperty(fontPropertyKey, fontXml->value());
|
||||
|
||||
@ -145,6 +147,11 @@ Page *PageBuilder::BuildPage()
|
||||
FontColor.r = intColor & 0xFF;
|
||||
}
|
||||
|
||||
if(fontSizeXml)
|
||||
{
|
||||
FontSize = Utils::ConvertInt(fontSizeXml->value());
|
||||
}
|
||||
|
||||
layoutWidth = Utils::ConvertInt(layoutWidthXml->value());
|
||||
layoutHeight = Utils::ConvertInt(layoutHeightXml->value());
|
||||
|
||||
@ -363,7 +370,7 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
|
||||
}
|
||||
else
|
||||
{
|
||||
FC->LoadFont(Font, FontColor);
|
||||
FC->LoadFont(Font, FontSize, FontColor);
|
||||
Text *c = new Text(value->value(), FC->GetFont(Font), FontColor, ScaleX, ScaleY);
|
||||
ViewInfo *v = c->GetBaseViewInfo();
|
||||
|
||||
@ -427,7 +434,7 @@ void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName,
|
||||
{
|
||||
if(type)
|
||||
{
|
||||
FC->LoadFont(Font, FontColor);
|
||||
FC->LoadFont(Font, FontSize, FontColor);
|
||||
c = new ReloadableText(type->value(), FC->GetFont(Font), FontColor, LayoutKey, Collection, ScaleX, ScaleY);
|
||||
}
|
||||
}
|
||||
@ -500,7 +507,7 @@ ScrollingList * PageBuilder::BuildMenu(xml_node<> *menuXml)
|
||||
}
|
||||
|
||||
// on default, text will be rendered to the menu. Preload it into cache.
|
||||
FC->LoadFont(Font, FontColor);
|
||||
FC->LoadFont(Font, FontSize, FontColor);
|
||||
|
||||
menu = new ScrollingList(Config, ScaleX, ScaleY, FC->GetFont(Font), FontColor, LayoutKey, Collection, imageType);
|
||||
|
||||
@ -765,7 +772,7 @@ void PageBuilder::BuildViewInfo(xml_node<> *componentXml, ViewInfo *info, xml_no
|
||||
|
||||
if(backgroundAlpha)
|
||||
{
|
||||
info->SetBackgroundAlpha( alpha ? Utils::ConvertFloat(backgroundAlpha->value()) : 1);
|
||||
info->SetBackgroundAlpha( backgroundAlpha ? Utils::ConvertFloat(backgroundAlpha->value()) : 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ private:
|
||||
int ScreenWidth;
|
||||
SDL_Color FontColor;
|
||||
std::string Font;
|
||||
int FontSize;
|
||||
FontCache *FC; //todo: don't need Font itself, just need cache instances
|
||||
void LoadReloadableImages(rapidxml::xml_node<> *layout, std::string tagName, Page *page);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user