Adding a item path property and setting default path for if baseItemPath did not exist.

This commit is contained in:
emb 2015-01-17 13:04:54 -06:00
parent b19dd4b822
commit 5c48661f7b
5 changed files with 24 additions and 41 deletions

View File

@ -107,18 +107,8 @@ bool CollectionInfoBuilder::ImportCollection(std::string name)
std::string metadataType;
std::string metadataPath;
if(!Conf.GetPropertyAbsolutePath(listItemsPathKey, listItemsPath))
{
Logger::Write(Logger::ZONE_INFO, "Collections", "Property \"" + listItemsPathKey + "\" does not exist. Assuming \"" + name + "\" is a menu");
return false;
}
if(!Conf.GetProperty(extensionsKey, extensions))
{
Logger::Write(Logger::ZONE_INFO, "Collections", "Property \"" + extensionsKey + "\" does not exist. Assuming \"" + name + "\" is a menu");
return false;
}
Conf.GetCollectionAbsolutePath(name, listItemsPath);
(void)Conf.GetProperty(extensionsKey, extensions);
(void)Conf.GetProperty(metadataTypeKey, metadataType);
(void)Conf.GetProperty(metadataPathKey, metadataPath);

View File

@ -340,6 +340,22 @@ void Configuration::GetMediaPropertyAbsolutePath(std::string collectionName, std
}
}
void Configuration::GetCollectionAbsolutePath(std::string collectionName, std::string &value)
{
std::string key = "collections" + collectionName + ".list.path";
if(!GetPropertyAbsolutePath(key, value))
{
std::string baseItemPath;
if(!GetPropertyAbsolutePath("baseItemPath", baseItemPath))
{
baseItemPath = "Assets";
}
value = baseItemPath + "/" + collectionName;
}
}
void Configuration::SetAbsolutePath(std::string absolutePath)
{

View File

@ -30,6 +30,7 @@ public:
bool PropertyPrefixExists(std::string key);
bool GetPropertyAbsolutePath(std::string key, std::string &value);
void GetMediaPropertyAbsolutePath(std::string collectionName, std::string mediaType, std::string &value);
void GetCollectionAbsolutePath(std::string collectionName, std::string &value);
bool IsVerbose() const;
void SetVerbose(bool verbose);
std::string Translate(std::string str);

View File

@ -265,18 +265,11 @@ bool Launcher::GetExtensions(std::string &extensions, std::string collection)
bool Launcher::GetCollectionDirectory(std::string &directory, std::string collection)
{
std::string itemsPathKey = "collections." + collection + ".list.path";
std::string itemsPathValue;
// find the items path folder (i.e. ROM path)
if(!Config.GetPropertyAbsolutePath(itemsPathKey, itemsPathValue))
{
directory = "";
}
else
{
directory += itemsPathValue + "/";
}
Config.GetCollectionAbsolutePath(collection, itemsPathValue);
directory += itemsPathValue + "/";
return true;
}

View File

@ -410,30 +410,13 @@ 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))
{
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");
}
Config.GetMediaPropertyAbsolutePath(Collection, type->value(), reloadableImagePath);
std::string configVideoPath = "collections." + Collection + ".media.video";
if(!Config.GetPropertyAbsolutePath(configVideoPath, reloadableVideoPath))
{
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");
}
Config.GetMediaPropertyAbsolutePath(Collection, "video", reloadableVideoPath);
}