diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index d0cecf4..f7a8426 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -17,6 +17,7 @@ #include "ReloadableMedia.h" #include "ImageBuilder.h" #include "VideoBuilder.h" +#include "ReloadableText.h" #include "../ViewInfo.h" #include "../../Video/VideoFactory.h" #include "../../Database/Configuration.h" @@ -27,13 +28,16 @@ #include #include -ReloadableMedia::ReloadableMedia(Configuration &config, std::string type, bool isVideo, float scaleX, float scaleY) +ReloadableMedia::ReloadableMedia(Configuration &config, std::string type, bool isVideo, Font *font, SDL_Color fontColor, float scaleX, float scaleY) : Config(config) , LoadedComponent(NULL) , ReloadRequested(false) , FirstLoad(true) , Type(type) , IsVideo(isVideo) + , FontInst(font) + , FontColor(fontColor) + , TextFallback(false) , ScaleX(scaleX) , ScaleY(scaleY) { @@ -48,6 +52,11 @@ ReloadableMedia::~ReloadableMedia() } } +void ReloadableMedia::EnableTextFallback(bool value) +{ + TextFallback = value; +} + void ReloadableMedia::Update(float dt) { if(NewItemSelected) @@ -162,18 +171,37 @@ void ReloadableMedia::ReloadTexture() } } + std::string imageBasename = selectedItem->GetFullTitle(); + + std::string typeLC = Utils::ToLower(Type); + + if(typeLC == "numberButtons") + { + imageBasename = selectedItem->GetNumberButtons(); + } + else if(typeLC == "numberPlayers") + { + imageBasename = selectedItem->GetNumberPlayers(); + } + else if(typeLC == "year") + { + imageBasename = selectedItem->GetYear(); + } + else if(typeLC == "title") + { + imageBasename = selectedItem->GetTitle(); + } + else if(typeLC == "manufacturer") + { + imageBasename = selectedItem->GetManufacturer(); + } + if(!LoadedComponent) { std::string imagePath; Config.GetMediaPropertyAbsolutePath(GetCollectionName(), Type, imagePath); ImageBuilder imageBuild; - std::string imageBasename = selectedItem->GetFullTitle(); - - if(Utils::ToLower(Type) == "manufacturer") - { - imageBasename = selectedItem->GetManufacturer(); - } LoadedComponent = imageBuild.CreateImage(imagePath, imageBasename, ScaleX, ScaleY); @@ -184,6 +212,13 @@ void ReloadableMedia::ReloadTexture() GetBaseViewInfo()->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight()); } } + + if(!LoadedComponent && TextFallback) + { + LoadedComponent = new Text(imageBasename, FontInst, FontColor, ScaleX, ScaleY); + GetBaseViewInfo()->SetImageWidth(LoadedComponent->GetBaseViewInfo()->GetImageWidth()); + GetBaseViewInfo()->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight()); + } } } diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.h b/RetroFE/Source/Graphics/Component/ReloadableMedia.h index 79c63f9..d7bdb40 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.h +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.h @@ -15,6 +15,7 @@ */ #pragma once #include "Component.h" +#include "ReloadableText.h" #include "../../Video/IVideo.h" #include "../../Collection/Item.h" #include @@ -26,7 +27,7 @@ class Image; class ReloadableMedia : public Component { public: - ReloadableMedia(Configuration &config, std::string type, bool isVideo, float scaleX, float scaleY); + ReloadableMedia(Configuration &config, std::string type, bool isVideo, Font *font, SDL_Color fontColor, float scaleX, float scaleY); virtual ~ReloadableMedia(); void Update(float dt); void Draw(); @@ -34,6 +35,7 @@ public: void AllocateGraphicsMemory(); void LaunchEnter(); void LaunchExit(); + void EnableTextFallback(bool value); private: void ReloadTexture(); @@ -42,8 +44,10 @@ private: bool ReloadRequested; bool FirstLoad; IVideo *VideoInst; - bool IsVideo; + Font *FontInst; + SDL_Color FontColor; + bool TextFallback; std::string Type; float ScaleX; float ScaleY; diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 320d96a..a3924aa 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -436,7 +436,18 @@ void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName, } else { - c = new ReloadableMedia(Config, type->value(), (tagName == "reloadableVideo"), ScaleX, ScaleY); + FC->LoadFont(Font, FontSize, FontColor); + c = new ReloadableMedia(Config, type->value(), (tagName == "reloadableVideo"), FC->GetFont(Font), FontColor, ScaleX, ScaleY); + xml_attribute<> *textFallback = componentXml->first_attribute("textFallback"); + + if(textFallback && Utils::ToLower(textFallback->value()) == "true") + { + static_cast(c)->EnableTextFallback(true); + } + else + { + static_cast(c)->EnableTextFallback(false); + } } if(c)