Added configuration parameter to include items from include.txt even if the rom does not exist.

This commit is contained in:
emb 2015-03-10 23:03:33 -05:00
parent 563446e5ee
commit baaa537490
4 changed files with 45 additions and 9 deletions

View File

@ -8,6 +8,13 @@
############################################################################### ###############################################################################
#list.path = %BASE_ITEM_PATH%/%ITEM_COLLECTION_NAME%/roms #list.path = %BASE_ITEM_PATH%/%ITEM_COLLECTION_NAME%/roms
###############################################################################
# If a game is specified in include.txt then it will be included in the list
# regardless of if the rom actually exists or not. Set this variable to false
# to exclude any items that cannot be found.
###############################################################################
list.includeMissingItems = true
############################################################################### ###############################################################################
# Extensions are comma separated without spaces # Extensions are comma separated without spaces
############################################################################### ###############################################################################

View File

@ -9,6 +9,13 @@
############################################################################### ###############################################################################
# list.path = %BASE_ITEM_PATH%/%ITEM_COLLECTION_NAME%/roms # list.path = %BASE_ITEM_PATH%/%ITEM_COLLECTION_NAME%/roms
###############################################################################
# If a game is specified in include.txt then it will be included in the list
# regardless of if the rom actually exists or not. Set this variable to false
# to exclude any items that cannot be found.
###############################################################################
list.includeMissingItems = true
############################################################################### ###############################################################################
# Extensions are comma separated without spaces # Extensions are comma separated without spaces
############################################################################### ###############################################################################

View File

@ -114,6 +114,7 @@ bool CollectionInfoBuilder::CreateCollectionDirectory(std::string name)
settingsFile << "# Uncomment and edit the following line to use a different ROM path." << std::endl; settingsFile << "# Uncomment and edit the following line to use a different ROM path." << std::endl;
settingsFile << "#list.path = %BASE_ITEM_PATH%/%ITEM_COLLECTION_NAME%/roms" << std::endl; settingsFile << "#list.path = %BASE_ITEM_PATH%/%ITEM_COLLECTION_NAME%/roms" << std::endl;
settingsFile << "list.includeMissingItems = true" << std::endl;
settingsFile << "list.extensions = zip" << std::endl; settingsFile << "list.extensions = zip" << std::endl;
settingsFile << "launcher = mame" << std::endl; settingsFile << "launcher = mame" << std::endl;
settingsFile << "metadata.type = MAME" << std::endl; settingsFile << "metadata.type = MAME" << std::endl;
@ -193,7 +194,7 @@ CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name)
} }
bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::string file, std::map<std::string, Item *> &list) bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::string file, std::string launcher, std::map<std::string, Item *> &list)
{ {
std::ifstream includeStream(file.c_str()); std::ifstream includeStream(file.c_str());
@ -214,6 +215,10 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo * /*info*/, std::stri
line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() ); line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() );
i->SetFullTitle(line); i->SetFullTitle(line);
i->SetName(line);
i->SetFullTitle(line);
i->SetTitle(line);
i->SetLauncher(launcher);
list[line] = i; list[line] = i;
} }
@ -232,17 +237,19 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
std::string includeFile = Configuration::GetAbsolutePath() + "/collections/" + info->GetName() + "/include.txt"; std::string includeFile = Configuration::GetAbsolutePath() + "/collections/" + info->GetName() + "/include.txt";
std::string excludeFile = Configuration::GetAbsolutePath() + "/collections/" + info->GetName() + "/exclude.txt"; std::string excludeFile = Configuration::GetAbsolutePath() + "/collections/" + info->GetName() + "/exclude.txt";
std::string launcher; std::string launcher;
bool showMissing = true;
(void)Conf.GetProperty("collections." + info->GetName() + ".launcher", launcher);
(void)Conf.GetProperty("collections." + info->GetName() + ".list.includeMissingItems", showMissing);
ImportBasicList(info, includeFile, launcher, includeFilter);
ImportBasicList(info, includeFile, includeFilter); ImportBasicList(info, excludeFile, launcher, excludeFilter);
ImportBasicList(info, excludeFile, excludeFilter);
std::vector<std::string> extensions; std::vector<std::string> extensions;
std::vector<std::string>::iterator extensionsIt; std::vector<std::string>::iterator extensionsIt;
info->GetExtensions(extensions); info->GetExtensions(extensions);
(void)Conf.GetProperty("collections." + info->GetName() + ".launcher", launcher);
Logger::Write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + includeFile + "\""); Logger::Write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + includeFile + "\"");
dp = opendir(path.c_str()); dp = opendir(path.c_str());
@ -253,6 +260,17 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
return false; return false;
} }
if(showMissing)
{
for(std::map<std::string, Item *>::iterator it = includeFilter.begin(); it != includeFilter.end(); it++)
{
if(excludeFilter.find(it->first) == excludeFilter.end())
{
info->GetItems()->push_back(it->second);
}
}
}
while((dirp = readdir(dp)) != NULL) while((dirp = readdir(dp)) != NULL)
{ {
std::string file = dirp->d_name; std::string file = dirp->d_name;
@ -292,12 +310,14 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
info->SortItems(); info->SortItems();
MetaDB.InjectMetadata(info);
while(includeFilter.size() > 0) while(includeFilter.size() > 0)
{ {
std::map<std::string, Item *>::iterator it = includeFilter.begin(); std::map<std::string, Item *>::iterator it = includeFilter.begin();
delete it->second; // delete the unused items if they were never pushed to the main collection
if(!showMissing)
{
delete it->second;
}
includeFilter.erase(it); includeFilter.erase(it);
} }
while(excludeFilter.size() > 0) while(excludeFilter.size() > 0)
@ -307,5 +327,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info)
excludeFilter.erase(it); excludeFilter.erase(it);
} }
MetaDB.InjectMetadata(info);
return true; return true;
} }

View File

@ -35,6 +35,6 @@ public:
private: private:
Configuration &Conf; Configuration &Conf;
MetadataDatabase &MetaDB; MetadataDatabase &MetaDB;
bool ImportBasicList(CollectionInfo *info, std::string file, std::map<std::string, Item *> &list); bool ImportBasicList(CollectionInfo *info, std::string file, std::string launcher, std::map<std::string, Item *> &list);
bool ImportDirectory(CollectionInfo *info); bool ImportDirectory(CollectionInfo *info);
}; };