diff --git a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp index c816296..43a4703 100644 --- a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp +++ b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp @@ -21,7 +21,7 @@ #include "../Database/DB.h" #include "../Utility/Log.h" #include "../Utility/Utils.h" -#include +#include #include #include @@ -78,79 +78,81 @@ CollectionInfo *CollectionInfoBuilder::BuildCollection(std::string name) return collection; } -bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info) -{ - DIR *dp; - struct dirent *dirp; - std::string path = info->GetListPath(); - std::map includeFilter; - std::map excludeFilter; - bool retVal = true; - std::string includeFile = Configuration::GetAbsolutePath() + "/Collections/" + info->GetName() + "/Include.txt"; - std::string excludeFile = Configuration::GetAbsolutePath() + "/Collections/" + info->GetName() + "/Exclude.txt"; - std::string launcher; - - (void)Conf.GetProperty("collections." + info->GetName() + ".launcher", launcher); - - dp = opendir(path.c_str()); - std::vector extensions; - info->GetExtensions(extensions); - std::vector::iterator extensionsIt; - - if(dp == NULL) - { - Logger::Write(Logger::ZONE_ERROR, "CollectionInfoBuilder", "Could not read directory \"" + path + "\""); - //todo: store into a database - } - else - { - while((dirp = readdir(dp)) != NULL) - { - std::string file = dirp->d_name; - - Utils::NormalizeBackSlashes(file); - size_t position = file.find_last_of("."); - std::string basename = (std::string::npos == position)? file : file.substr(0, position); - - if((includeFilter.size() == 0 || includeFilter.find(basename) != includeFilter.end()) && - (excludeFilter.size() == 0 || excludeFilter.find(basename) == excludeFilter.end())) - { - for(extensionsIt = extensions.begin(); extensionsIt != extensions.end(); ++extensionsIt) - { - std::string comparator = "." + *extensionsIt; - int start = file.length() - comparator.length() + 1; - - if(start >= 0) - { - if(file.compare(start, comparator.length(), *extensionsIt) == 0) - { - Item *i = new Item(); - i->SetName(basename); - i->SetFullTitle(basename); - i->SetTitle(basename); - i->SetLauncher(launcher); - info->GetItems()->push_back(i); - } - } - } - } - } - } - - MetaDB.InjectMetadata(info); - - while(includeFilter.size() > 0) - { - std::map::iterator it = includeFilter.begin(); - delete it->second; - includeFilter.erase(it); - } - while(excludeFilter.size() > 0) - { - std::map::iterator it = excludeFilter.begin(); - delete it->second; - excludeFilter.erase(it); - } - - return true; -} \ No newline at end of file +bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info) +{ + DIR *dp; + struct dirent *dirp; + std::string path = info->GetListPath(); + std::map includeFilter; + std::map excludeFilter; + bool retVal = true; + std::string includeFile = Configuration::GetAbsolutePath() + "/Collections/" + info->GetName() + "/Include.txt"; + std::string excludeFile = Configuration::GetAbsolutePath() + "/Collections/" + info->GetName() + "/Exclude.txt"; + std::string launcher; + + std::vector extensions; + std::vector::iterator extensionsIt; + + info->GetExtensions(extensions); + + (void)Conf.GetProperty("collections." + info->GetName() + ".launcher", launcher); + + dp = opendir(path.c_str()); + + if(dp == NULL) + { + Logger::Write(Logger::ZONE_ERROR, "CollectionInfoBuilder", "Could not read directory \"" + path + "\""); + return false; + } + + while((dirp = readdir(dp)) != NULL) + { + std::string file = dirp->d_name; + + Utils::NormalizeBackSlashes(file); + size_t position = file.find_last_of("."); + std::string basename = (std::string::npos == position)? file : file.substr(0, position); + + if((includeFilter.size() == 0 || includeFilter.find(basename) != includeFilter.end()) && + (excludeFilter.size() == 0 || excludeFilter.find(basename) == excludeFilter.end())) + { + for(extensionsIt = extensions.begin(); extensionsIt != extensions.end(); ++extensionsIt) + { + std::string comparator = "." + *extensionsIt; + int start = file.length() - comparator.length() + 1; + + if(start >= 0) + { + if(file.compare(start, comparator.length(), *extensionsIt) == 0) + { + Item *i = new Item(); + i->SetName(basename); + i->SetFullTitle(basename); + i->SetTitle(basename); + i->SetLauncher(launcher); + info->GetItems()->push_back(i); + } + } + } + } + } + + closedir(dp); + + MetaDB.InjectMetadata(info); + + while(includeFilter.size() > 0) + { + std::map::iterator it = includeFilter.begin(); + delete it->second; + includeFilter.erase(it); + } + while(excludeFilter.size() > 0) + { + std::map::iterator it = excludeFilter.begin(); + delete it->second; + excludeFilter.erase(it); + } + + return true; +} diff --git a/RetroFE/Source/Collection/MenuParser.cpp b/RetroFE/Source/Collection/MenuParser.cpp index 7eda450..9088966 100644 --- a/RetroFE/Source/Collection/MenuParser.cpp +++ b/RetroFE/Source/Collection/MenuParser.cpp @@ -75,34 +75,32 @@ bool MenuParser::GetMenuItems(CollectionInfo *collection) Logger::Write(Logger::ZONE_ERROR, "Menu", "Menu item tag is missing collection attribute"); break; } + //todo: too much nesting! Ack! + std::string import; + if(importAttribute) + { + import = importAttribute->value(); + } + + if(import != "true") + { + //todo, check for empty string + std::string title = collectionAttribute->value(); + Item *item = new Item(); + item->SetTitle(title); + item->SetFullTitle(title); + item->SetName(collectionAttribute->value()); + item->SetIsLeaf(false); + collection->GetItems()->push_back(item); + + } else { - //todo: too much nesting! Ack! - std::string import; - if(importAttribute) - { - import = importAttribute->value(); - } - if(import != "true") - { - //todo, check for empty string - std::string title = collectionAttribute->value(); - Item *item = new Item(); - item->SetTitle(title); - item->SetFullTitle(title); - item->SetName(collectionAttribute->value()); - item->SetIsLeaf(false); - collection->GetItems()->push_back(item); + std::string collectionName = collectionAttribute->value(); + Logger::Write(Logger::ZONE_INFO, "Menu", "Loading collection into menu: " + collectionName); - } - else - { - std::string collectionName = collectionAttribute->value(); - Logger::Write(Logger::ZONE_INFO, "Menu", "Loading collection into menu: " + collectionName); - - //todo: unsupported option with this refactor - // need to append the collection - } + //todo: unsupported option with this refactor + // need to append the collection } } diff --git a/RetroFE/Source/Database/MetadataDatabase.cpp b/RetroFE/Source/Database/MetadataDatabase.cpp index 167c48a..1994472 100644 --- a/RetroFE/Source/Database/MetadataDatabase.cpp +++ b/RetroFE/Source/Database/MetadataDatabase.cpp @@ -114,51 +114,68 @@ bool MetadataDatabase::ImportDirectory() dp = opendir(hyperListPath.c_str()); - while((dirp = readdir(dp)) != NULL) + if(dp == NULL) { - if (dirp->d_type != DT_DIR && std::string(dirp->d_name) != "." && std::string(dirp->d_name) != "..") + Logger::Write(Logger::ZONE_INFO, "MetadataDatabase", "Could not read directory \"" + hyperListPath + "\""); + } + else + { + while((dirp = readdir(dp)) != NULL) { - - std::string basename = dirp->d_name; - - std::string extension = basename.substr(basename.find_last_of("."), basename.size()-1); - basename = basename.substr(0, basename.find_last_of(".")); - std::string collectionName = basename.substr(0, basename.find_first_of(".")); - - - if(extension == ".xml") + if (dirp->d_type != DT_DIR && std::string(dirp->d_name) != "." && std::string(dirp->d_name) != "..") { - std::string importFile = Configuration::GetAbsolutePath() + "/" + hyperListPath + "/" + dirp->d_name; - Logger::Write(Logger::ZONE_INFO, "Metadata", "Importing hyperlist: " + importFile); - ImportHyperList(importFile, collectionName); + + std::string basename = dirp->d_name; + + std::string extension = basename.substr(basename.find_last_of("."), basename.size()-1); + basename = basename.substr(0, basename.find_last_of(".")); + std::string collectionName = basename.substr(0, basename.find_first_of(".")); + + + if(extension == ".xml") + { + std::string importFile = Configuration::GetAbsolutePath() + "/" + hyperListPath + "/" + dirp->d_name; + Logger::Write(Logger::ZONE_INFO, "Metadata", "Importing hyperlist: " + importFile); + ImportHyperList(importFile, collectionName); + } } } + + closedir(dp); } dp = opendir(mameListPath.c_str()); - - while((dirp = readdir(dp)) != NULL) + + if(dp == NULL) { - if (dirp->d_type != DT_DIR && std::string(dirp->d_name) != "." && std::string(dirp->d_name) != "..") - { - - std::string basename = dirp->d_name; - - std::string extension = basename.substr(basename.find_last_of("."), basename.size()-1); - basename = basename.substr(0, basename.find_last_of(".")); - std::string collectionName = basename.substr(0, basename.find_first_of(".")); - - - if(extension == ".xml") - { - std::string importFile = Configuration::GetAbsolutePath() + "/" + mameListPath + "/" + dirp->d_name; - Logger::Write(Logger::ZONE_INFO, "Metadata", "Importing mamelist: " + importFile); - Config.SetStatus("Scraping data from " + importFile); - ImportMameList(importFile, collectionName); - } - } + Logger::Write(Logger::ZONE_ERROR, "CollectionInfoBuilder", "Could not read directory \"" + mameListPath + "\""); } + else + { + while((dirp = readdir(dp)) != NULL) + { + if (dirp->d_type != DT_DIR && std::string(dirp->d_name) != "." && std::string(dirp->d_name) != "..") + { + std::string basename = dirp->d_name; + + std::string extension = basename.substr(basename.find_last_of("."), basename.size()-1); + basename = basename.substr(0, basename.find_last_of(".")); + std::string collectionName = basename.substr(0, basename.find_first_of(".")); + + + if(extension == ".xml") + { + std::string importFile = Configuration::GetAbsolutePath() + "/" + mameListPath + "/" + dirp->d_name; + Logger::Write(Logger::ZONE_INFO, "Metadata", "Importing mamelist: " + importFile); + Config.SetStatus("Scraping data from " + importFile); + ImportMameList(importFile, collectionName); + } + } + } + + closedir(dp); + } return true; } diff --git a/RetroFE/Source/Graphics/Animate/TweenSet.cpp b/RetroFE/Source/Graphics/Animate/TweenSet.cpp index 2b3a4f1..41e6d42 100644 --- a/RetroFE/Source/Graphics/Animate/TweenSet.cpp +++ b/RetroFE/Source/Graphics/Animate/TweenSet.cpp @@ -13,3 +13,40 @@ * You should have received a copy of the GNU General Public License * along with RetroFE. If not, see . */ + +#include "TweenSet.h" + + +TweenSets *TweenSet::GetOnEnterTweens() +{ + return &OnEnterTweens; +} +TweenSets *TweenSet::GetOnExitTweens() +{ + return &OnExitTweens; +} +TweenSets *TweenSet::GetOnIdleTweens() +{ + return &OnIdleTweens; +} +TweenSets *TweenSet::GetOnHighlightEnterTweens() +{ + return &OnHighlightEnterTweens; +} +TweenSets *TweenSet::GetOnHighlightExitTweens() +{ + return &OnHighlightExitTweens; +} +TweenSets *TweenSet::GetOnMenuEnterTweens() +{ + return &OnMenuEnterTweens; +} +TweenSets *TweenSet::GetOnMenuScrollTweens() +{ + return &OnMenuScrollTweens; +} +TweenSets *TweenSet::GetOnMenuExitTweens() +{ + return &OnMenuExitTweens; +} + diff --git a/RetroFE/Source/Graphics/Animate/TweenSet.h b/RetroFE/Source/Graphics/Animate/TweenSet.h index 35a5dfd..c95ff80 100644 --- a/RetroFE/Source/Graphics/Animate/TweenSet.h +++ b/RetroFE/Source/Graphics/Animate/TweenSet.h @@ -28,38 +28,14 @@ public: //todo: delete the tweens in a destructor - TweenSets *GetOnEnterTweens() - { - return &OnEnterTweens; - } - TweenSets *GetOnExitTweens() - { - return &OnExitTweens; - } - TweenSets *GetOnIdleTweens() - { - return &OnIdleTweens; - } - TweenSets *GetOnHighlightEnterTweens() - { - return &OnHighlightEnterTweens; - } - TweenSets *GetOnHighlightExitTweens() - { - return &OnHighlightExitTweens; - } - TweenSets *GetOnMenuEnterTweens() - { - return &OnMenuEnterTweens; - } - TweenSets *GetOnMenuScrollTweens() - { - return &OnMenuScrollTweens; - } - TweenSets *GetOnMenuExitTweens() - { - return &OnMenuExitTweens; - } + TweenSets *GetOnEnterTweens(); + TweenSets *GetOnExitTweens(); + TweenSets *GetOnIdleTweens(); + TweenSets *GetOnHighlightEnterTweens(); + TweenSets *GetOnHighlightExitTweens(); + TweenSets *GetOnMenuEnterTweens(); + TweenSets *GetOnMenuScrollTweens(); + TweenSets *GetOnMenuExitTweens(); private: TweenSets OnEnterTweens; @@ -71,4 +47,4 @@ private: TweenSets OnMenuScrollTweens; TweenSets OnMenuExitTweens; -}; \ No newline at end of file +}; diff --git a/RetroFE/Source/Graphics/Font.cpp b/RetroFE/Source/Graphics/Font.cpp index b3a0718..68d90d7 100644 --- a/RetroFE/Source/Graphics/Font.cpp +++ b/RetroFE/Source/Graphics/Font.cpp @@ -70,7 +70,7 @@ bool Font::Initialize(std::string fontPath, int fontSize, SDL_Color color) for(unsigned short int i = 32; i < 128; ++i) { GlyphInfoBuild *info = new GlyphInfoBuild; - memset(info, sizeof(GlyphInfoBuild), 0); + memset(info, 0, sizeof(GlyphInfoBuild)); color.a = 255; info->Surface = TTF_RenderGlyph_Blended(font, i, color); diff --git a/RetroFE/Source/Main.cpp b/RetroFE/Source/Main.cpp index 57e7dd3..bfb9237 100644 --- a/RetroFE/Source/Main.cpp +++ b/RetroFE/Source/Main.cpp @@ -103,6 +103,7 @@ bool ImportConfiguration(Configuration *c) if(!c->Import(prefix, importFile)) { Logger::Write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + importFile + "\""); + closedir(dp); return false; } } @@ -110,6 +111,8 @@ bool ImportConfiguration(Configuration *c) } } + closedir(dp); + dp = opendir(collectionsPath.c_str()); if(dp == NULL) @@ -129,10 +132,13 @@ bool ImportConfiguration(Configuration *c) if(!c->Import(prefix, settingsFile)) { Logger::Write(Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + settingsFile + "\""); + closedir(dp); return false; } } } + + closedir(dp); Logger::Write(Logger::ZONE_INFO, "RetroFE", "Imported configuration");