mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-28 09:38:52 +01:00
Add support to predict the media path if not specified in Settings.conf files. uses %baseMediaPath%
This commit is contained in:
parent
50f8375a0b
commit
b19dd4b822
@ -324,6 +324,23 @@ bool Configuration::GetPropertyAbsolutePath(std::string key, std::string &value)
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void Configuration::GetMediaPropertyAbsolutePath(std::string collectionName, std::string mediaType, std::string &value)
|
||||
{
|
||||
std::string key = "media." + collectionName + "." + mediaType;
|
||||
|
||||
if(!GetPropertyAbsolutePath(key, value))
|
||||
{
|
||||
std::string baseMediaPath;
|
||||
if(!GetPropertyAbsolutePath("baseMediaPath", baseMediaPath))
|
||||
{
|
||||
baseMediaPath = "Media";
|
||||
}
|
||||
|
||||
value = baseMediaPath + "/" + collectionName + "/" + Utils::UppercaseFirst(Utils::ToLower(mediaType));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Configuration::SetAbsolutePath(std::string absolutePath)
|
||||
{
|
||||
AbsolutePath = absolutePath;
|
||||
|
||||
@ -29,6 +29,7 @@ public:
|
||||
bool PropertyExists(std::string key);
|
||||
bool PropertyPrefixExists(std::string key);
|
||||
bool GetPropertyAbsolutePath(std::string key, std::string &value);
|
||||
void GetMediaPropertyAbsolutePath(std::string collectionName, std::string mediaType, std::string &value);
|
||||
bool IsVerbose() const;
|
||||
void SetVerbose(bool verbose);
|
||||
std::string Translate(std::string str);
|
||||
|
||||
@ -433,7 +433,6 @@ void ScrollingList::AllocateTexture(ComponentItemBinding *s)
|
||||
//todo: will create a runtime fault if not of the right type
|
||||
//todo: remove coupling from knowing the collection name
|
||||
|
||||
std::string collectionKey ="collections." + CollectionName + ".media." + ImageType;
|
||||
std::string videoKey ="collections." + CollectionName + ".media.video";
|
||||
std::string imagePath;
|
||||
std::string videoPath;
|
||||
@ -447,9 +446,11 @@ void ScrollingList::AllocateTexture(ComponentItemBinding *s)
|
||||
t = new VideoComponent(videoPath, item->GetFullTitle(), ScaleX, ScaleY);
|
||||
}
|
||||
*/
|
||||
if(!t && Config.GetPropertyAbsolutePath(collectionKey, imagePath))
|
||||
if(!t)
|
||||
{
|
||||
|
||||
ImageBuilder imageBuild;
|
||||
Config.GetMediaPropertyAbsolutePath(CollectionName, ImageType, imagePath);
|
||||
t = imageBuild.CreateImage(imagePath, item->GetName(), ScaleX, ScaleY);
|
||||
|
||||
if(!t && item->GetTitle() != item->GetFullTitle())
|
||||
|
||||
@ -401,7 +401,6 @@ void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName,
|
||||
type = componentXml->first_attribute("imageType");
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
@ -411,19 +410,29 @@ void PageBuilder::LoadReloadableImages(xml_node<> *layout, std::string tagName,
|
||||
Logger::Write(Logger::ZONE_ERROR, "Layout", "Image component in layout does not specify a source image file");
|
||||
}
|
||||
|
||||
Logger::Write(Logger::ZONE_INFO, "Layout", " INFO TEST!!");
|
||||
if(type && (tagName == "reloadableVideo" || tagName == "reloadableImage"))
|
||||
{
|
||||
std::string configImagePath = "collections." + Collection + ".media." + type->value();
|
||||
|
||||
if(!Config.GetPropertyAbsolutePath(configImagePath, reloadableImagePath))
|
||||
{
|
||||
Logger::Write(Logger::ZONE_ERROR, "Layout", "Cannot process reloadable images because property \"" + configImagePath + "\" does not exist");
|
||||
std::string baseMediaPath;
|
||||
Config.GetPropertyAbsolutePath("baseMediaPath", baseMediaPath);
|
||||
|
||||
reloadableImagePath = baseMediaPath + "/" + Collection + "/" + Utils::UppercaseFirst(Utils::ToLower(type->value()));
|
||||
Logger::Write(Logger::ZONE_INFO, "Layout", "Collection config has not overridden " + configImagePath + ". Using the default path \"" + reloadableImagePath + "\" instead");
|
||||
}
|
||||
|
||||
std::string configVideoPath = "collections." + Collection + ".media.video";
|
||||
|
||||
if(!Config.GetPropertyAbsolutePath(configVideoPath, reloadableVideoPath))
|
||||
{
|
||||
Logger::Write(Logger::ZONE_WARNING, "Layout", "Could not find videos folder as \"" + configVideoPath + "\" does not exist");
|
||||
std::string baseMediaPath;
|
||||
Config.GetPropertyAbsolutePath("baseMediaPath", baseMediaPath);
|
||||
reloadableVideoPath = baseMediaPath + "/" + Collection + "/Video";
|
||||
Logger::Write(Logger::ZONE_INFO, "Layout", "Collection config has not overridden " + configVideoPath + ". Using the default path \"" + reloadableVideoPath + "\" instead");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,6 +43,17 @@ std::string Utils::ToLower(std::string str)
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string Utils::UppercaseFirst(std::string str)
|
||||
{
|
||||
if(str.length() > 0)
|
||||
{
|
||||
std::locale loc;
|
||||
str[0] = std::tolower(str[0], loc);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bool Utils::FindMatchingFile(std::string prefix, std::vector<std::string> &extensions, std::string &file)
|
||||
{
|
||||
for(unsigned int i = 0; i < extensions.size(); ++i)
|
||||
|
||||
@ -20,6 +20,7 @@ public:
|
||||
static std::string GetFileName(std::string filePath);
|
||||
static bool FindMatchingFile(std::string prefix, std::vector<std::string> &extensions, std::string &file);
|
||||
static std::string ToLower(std::string str);
|
||||
static std::string UppercaseFirst(std::string str);
|
||||
private:
|
||||
Utils();
|
||||
virtual ~Utils();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user