Support to display a reloadable image for the currently selected collection.

This commit is contained in:
emb
2015-02-27 22:23:26 -06:00
parent 86e37ab230
commit c7dccd7109
3 changed files with 47 additions and 10 deletions

View File

@@ -28,8 +28,9 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
ReloadableMedia::ReloadableMedia(Configuration &config, std::string type, bool isVideo, Font *font, float scaleX, float scaleY) ReloadableMedia::ReloadableMedia(Configuration &config, bool systemMode, std::string type, bool isVideo, Font *font, float scaleX, float scaleY)
: Config(config) : Config(config)
, SystemMode(systemMode)
, LoadedComponent(NULL) , LoadedComponent(NULL)
, ReloadRequested(false) , ReloadRequested(false)
, FirstLoad(true) , FirstLoad(true)
@@ -61,7 +62,10 @@ void ReloadableMedia::Update(float dt)
{ {
if(NewItemSelected) if(NewItemSelected)
{ {
ReloadRequested = true; if(!SystemMode || (SystemMode && CurrentCollection != Config.GetCurrentCollection()))
{
ReloadRequested = true;
}
} }
// wait for the right moment to reload the image // wait for the right moment to reload the image
if (ReloadRequested && (HighlightExitComplete || FirstLoad)) if (ReloadRequested && (HighlightExitComplete || FirstLoad))
@@ -140,6 +144,8 @@ void ReloadableMedia::ReloadTexture()
Item *selectedItem = GetSelectedItem(); Item *selectedItem = GetSelectedItem();
CurrentCollection = Config.GetCurrentCollection();
if (selectedItem != NULL) if (selectedItem != NULL)
{ {
if(IsVideo) if(IsVideo)
@@ -157,11 +163,19 @@ void ReloadableMedia::ReloadTexture()
{ {
VideoBuilder videoBuild; VideoBuilder videoBuild;
std::string videoPath; std::string videoPath;
Config.GetMediaPropertyAbsolutePath(GetCollectionName(), "video", false, videoPath);
LoadedComponent = videoBuild.CreateVideo(videoPath, names[n], ScaleX, ScaleY); if(SystemMode)
{
Config.GetMediaPropertyAbsolutePath(GetCollectionName(), "video", true, videoPath);
LoadedComponent = videoBuild.CreateVideo(videoPath, "video", ScaleX, ScaleY);
}
else
{
Config.GetMediaPropertyAbsolutePath(GetCollectionName(), "video", false, videoPath);
LoadedComponent = videoBuild.CreateVideo(videoPath, names[n], ScaleX, ScaleY);
}
if(!LoadedComponent) if(!LoadedComponent && !SystemMode)
{ {
Config.GetMediaPropertyAbsolutePath(names[n], Type, true, videoPath); Config.GetMediaPropertyAbsolutePath(names[n], Type, true, videoPath);
LoadedComponent = videoBuild.CreateVideo(videoPath, "video", ScaleX, ScaleY); LoadedComponent = videoBuild.CreateVideo(videoPath, "video", ScaleX, ScaleY);
@@ -205,13 +219,21 @@ void ReloadableMedia::ReloadTexture()
if(!LoadedComponent) if(!LoadedComponent)
{ {
std::string imagePath; std::string imagePath;
Config.GetMediaPropertyAbsolutePath(GetCollectionName(), Type, false, imagePath);
ImageBuilder imageBuild; ImageBuilder imageBuild;
LoadedComponent = imageBuild.CreateImage(imagePath, imageBasename, ScaleX, ScaleY); if(SystemMode)
{
Config.GetMediaPropertyAbsolutePath(GetCollectionName(), Type, true, imagePath);
LoadedComponent = imageBuild.CreateImage(imagePath, Type, ScaleX, ScaleY);
}
else
{
Config.GetMediaPropertyAbsolutePath(GetCollectionName(), Type, false, imagePath);
LoadedComponent = imageBuild.CreateImage(imagePath, imageBasename, ScaleX, ScaleY);
}
if(!LoadedComponent) if(!LoadedComponent && !SystemMode)
{ {
Config.GetMediaPropertyAbsolutePath(imageBasename, Type, true, imagePath); Config.GetMediaPropertyAbsolutePath(imageBasename, Type, true, imagePath);
LoadedComponent = imageBuild.CreateImage(imagePath, Type, ScaleX, ScaleY); LoadedComponent = imageBuild.CreateImage(imagePath, Type, ScaleX, ScaleY);

View File

@@ -27,7 +27,7 @@ class Image;
class ReloadableMedia : public Component class ReloadableMedia : public Component
{ {
public: public:
ReloadableMedia(Configuration &config, std::string type, bool isVideo, Font *font, float scaleX, float scaleY); ReloadableMedia(Configuration &config, bool systemMode, std::string type, bool isVideo, Font *font, float scaleX, float scaleY);
virtual ~ReloadableMedia(); virtual ~ReloadableMedia();
void Update(float dt); void Update(float dt);
void Draw(); void Draw();
@@ -40,6 +40,7 @@ public:
private: private:
void ReloadTexture(); void ReloadTexture();
Configuration &Config; Configuration &Config;
bool SystemMode;
Component *LoadedComponent; Component *LoadedComponent;
bool ReloadRequested; bool ReloadRequested;
bool FirstLoad; bool FirstLoad;
@@ -50,4 +51,5 @@ private:
std::string Type; std::string Type;
float ScaleX; float ScaleX;
float ScaleY; float ScaleY;
std::string CurrentCollection;
}; };

View File

@@ -400,17 +400,21 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName, Page *page) void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName, Page *page)
{ {
for(xml_node<> *componentXml = layout->first_node(tagName.c_str()); componentXml; componentXml = componentXml->next_sibling(tagName.c_str())) for(xml_node<> *componentXml = layout->first_node(tagName.c_str()); componentXml; componentXml = componentXml->next_sibling(tagName.c_str()))
{ {
std::string reloadableImagePath; std::string reloadableImagePath;
std::string reloadableVideoPath; std::string reloadableVideoPath;
xml_attribute<> *type = componentXml->first_attribute("type"); xml_attribute<> *type = componentXml->first_attribute("type");
xml_attribute<> *mode = componentXml->first_attribute("mode");
bool systemMode = false;
if(tagName == "reloadableVideo") if(tagName == "reloadableVideo")
{ {
type = componentXml->first_attribute("imageType"); type = componentXml->first_attribute("imageType");
} }
if(!type && tagName == "reloadableVideo") if(!type && tagName == "reloadableVideo")
{ {
Logger::Write(Logger::ZONE_WARNING, "Layout", "<reloadableImage> component in layout does not specify an imageType for when the video does not exist"); Logger::Write(Logger::ZONE_WARNING, "Layout", "<reloadableImage> component in layout does not specify an imageType for when the video does not exist");
@@ -421,6 +425,15 @@ void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName,
} }
if(mode)
{
std::string sysMode = mode->value();
if(sysMode == "system")
{
systemMode = true;
}
}
Component *c = NULL; Component *c = NULL;
@@ -435,7 +448,7 @@ void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName,
else else
{ {
Font *font = AddFont(componentXml, NULL); Font *font = AddFont(componentXml, NULL);
c = new ReloadableMedia(Config, type->value(), (tagName == "reloadableVideo"), font, ScaleX, ScaleY); c = new ReloadableMedia(Config, systemMode, type->value(), (tagName == "reloadableVideo"), font, 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")