diff --git a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp index aa5a6fc..d1b6efc 100644 --- a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp +++ b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp @@ -171,18 +171,12 @@ CollectionInfo *CollectionInfoBuilder::buildCollection(std::string name) std::string metadataPath; std::string mergedCollectionName; - // temporarily set currentCollection in case this is a subcollection - conf_.getProperty("currentCollection", mergedCollectionName); - conf_.setProperty("currentCollection", name); conf_.getCollectionAbsolutePath(name, listItemsPath); (void)conf_.getProperty(extensionsKey, extensions); (void)conf_.getProperty(metadataTypeKey, metadataType); (void)conf_.getProperty(metadataPathKey, metadataPath); - // restore old collection name - conf_.setProperty("currentCollection", mergedCollectionName); - if(!conf_.getProperty(launcherKey, launcherName)) { std::stringstream ss; diff --git a/RetroFE/Source/Database/Configuration.cpp b/RetroFE/Source/Database/Configuration.cpp index ff8c92b..e95a196 100644 --- a/RetroFE/Source/Database/Configuration.cpp +++ b/RetroFE/Source/Database/Configuration.cpp @@ -70,6 +70,11 @@ void Configuration::initialize() } bool Configuration::import(std::string keyPrefix, std::string file) +{ + return import("", keyPrefix, file); +} + +bool Configuration::import(std::string collection, std::string keyPrefix, std::string file) { bool retVal = true; int lineCount = 0; @@ -89,7 +94,7 @@ bool Configuration::import(std::string keyPrefix, std::string file) while (std::getline (ifs, line)) { lineCount++; - retVal = retVal && parseLine(keyPrefix, line, lineCount); + retVal = retVal && parseLine(collection, keyPrefix, line, lineCount); } ifs.close(); @@ -97,7 +102,8 @@ bool Configuration::import(std::string keyPrefix, std::string file) return retVal; } -bool Configuration::parseLine(std::string keyPrefix, std::string line, int lineCount) + +bool Configuration::parseLine(std::string collection, std::string keyPrefix, std::string line, int lineCount) { bool retVal = false; std::string key; @@ -127,6 +133,7 @@ bool Configuration::parseLine(std::string keyPrefix, std::string line, int lineC value = line.substr(position + delimiter.length(), line.length()); value = trimEnds(value); + value = Utils::replace(value, "%ITEM_COLLECTION_NAME%", collection); properties_.insert(PropertiesPair(key, value)); @@ -181,15 +188,12 @@ bool Configuration::getProperty(std::string key, std::string &value) std::string baseMediaPath = absolutePath; std::string baseItemPath = absolutePath; - std::string collectionName; - getRawProperty("currentCollection", collectionName); getRawProperty("baseMediaPath", baseMediaPath); getRawProperty("baseItemPath", baseItemPath); value = Utils::replace(value, "%BASE_MEDIA_PATH%", baseMediaPath); value = Utils::replace(value, "%BASE_ITEM_PATH%", baseItemPath); - value = Utils::replace(value, "%ITEM_COLLECTION_NAME%", collectionName); return retVal; } diff --git a/RetroFE/Source/Database/Configuration.h b/RetroFE/Source/Database/Configuration.h index 05a3ae1..0344ce5 100644 --- a/RetroFE/Source/Database/Configuration.h +++ b/RetroFE/Source/Database/Configuration.h @@ -28,6 +28,7 @@ public: static std::string convertToAbsolutePath(std::string prefix, std::string path); // gets the global configuration bool import(std::string keyPrefix, std::string file); + bool import(std::string collection, std::string keyPrefix, std::string file); bool getProperty(std::string key, std::string &value); bool getProperty(std::string key, int &value); bool getProperty(std::string key, bool &value); @@ -43,7 +44,7 @@ public: private: bool getRawProperty(std::string key, std::string &value); - bool parseLine(std::string keyPrefix, std::string line, int lineCount); + bool parseLine(std::string collection, std::string keyPrefix, std::string line, int lineCount); std::string trimEnds(std::string str); typedef std::map PropertiesType; typedef std::pair PropertiesPair; diff --git a/RetroFE/Source/Execute/Launcher.cpp b/RetroFE/Source/Execute/Launcher.cpp index ad92095..8c307ba 100644 --- a/RetroFE/Source/Execute/Launcher.cpp +++ b/RetroFE/Source/Execute/Launcher.cpp @@ -274,17 +274,10 @@ bool Launcher::collectionDirectory(std::string &directory, std::string collectio std::string itemsPathValue; std::string mergedCollectionName; - // temporarily set currentCollection in case this is a subcollection - config_.getProperty("currentCollection", mergedCollectionName); - config_.setProperty("currentCollection", collection); - // find the items path folder (i.e. ROM path) config_.getCollectionAbsolutePath(collection, itemsPathValue); directory += itemsPathValue + Utils::pathSeparator; - // restore old collection name - config_.setProperty("currentCollection", mergedCollectionName); - return true; } diff --git a/RetroFE/Source/Main.cpp b/RetroFE/Source/Main.cpp index 36d4dc6..d14bb6a 100644 --- a/RetroFE/Source/Main.cpp +++ b/RetroFE/Source/Main.cpp @@ -137,14 +137,14 @@ bool ImportConfiguration(Configuration *c) while((dirp = readdir(dp)) != NULL) { - std::string dirName = (dirp->d_name); - if (dirp->d_type == DT_DIR && dirName != "." && dirName != ".." && dirName.length() > 0 && dirName[0] != '_') + std::string collection = (dirp->d_name); + if (dirp->d_type == DT_DIR && collection != "." && collection != ".." && collection.length() > 0 && collection[0] != '_') { - std::string prefix = "collections." + std::string(dirp->d_name); + std::string prefix = "collections." + collection; - std::string settingsFile = Utils::combinePath(collectionsPath, std::string(dirp->d_name), "settings.conf"); + std::string settingsFile = Utils::combinePath(collectionsPath, collection, "settings.conf"); - if(!c->import(prefix, settingsFile)) + if(!c->import(collection, prefix, settingsFile)) { Logger::write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + settingsFile + "\""); closedir(dp);