From 5c48661f7bded0ab01a23ebe1e782b0896cf4bb0 Mon Sep 17 00:00:00 2001 From: emb <> Date: Sat, 17 Jan 2015 13:04:54 -0600 Subject: [PATCH] Adding a item path property and setting default path for if baseItemPath did not exist. --- .../Collection/CollectionInfoBuilder.cpp | 14 ++----------- RetroFE/Source/Database/Configuration.cpp | 16 ++++++++++++++ RetroFE/Source/Database/Configuration.h | 1 + RetroFE/Source/Execute/Launcher.cpp | 13 +++--------- RetroFE/Source/Graphics/PageBuilder.cpp | 21 ++----------------- 5 files changed, 24 insertions(+), 41 deletions(-) diff --git a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp index 1be5f92..5c669a1 100644 --- a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp +++ b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp @@ -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); diff --git a/RetroFE/Source/Database/Configuration.cpp b/RetroFE/Source/Database/Configuration.cpp index c18edb6..f970ca0 100644 --- a/RetroFE/Source/Database/Configuration.cpp +++ b/RetroFE/Source/Database/Configuration.cpp @@ -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) { diff --git a/RetroFE/Source/Database/Configuration.h b/RetroFE/Source/Database/Configuration.h index 4c36d71..0a1f03d 100644 --- a/RetroFE/Source/Database/Configuration.h +++ b/RetroFE/Source/Database/Configuration.h @@ -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); diff --git a/RetroFE/Source/Execute/Launcher.cpp b/RetroFE/Source/Execute/Launcher.cpp index 2e42141..b27872b 100644 --- a/RetroFE/Source/Execute/Launcher.cpp +++ b/RetroFE/Source/Execute/Launcher.cpp @@ -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; } diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 8027210..22e5e3a 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -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); }