merged last commit 720e4b1 with new MacOS build

This commit is contained in:
RetroPrime 2016-12-22 05:07:53 -05:00
commit bff4aaa745
11 changed files with 192 additions and 93 deletions

View File

@ -45,7 +45,7 @@ exitOnFirstPageBack = yes
attractModeTime = 45 attractModeTime = 45
# remember the last highlighted menu when re-entering a menu # remember the last highlighted menu when re-entering a menu
rememberMenu = no rememberMenu = yes
####################################### #######################################
# Base folders of media and ROM files # Base folders of media and ROM files

View File

@ -95,7 +95,7 @@ Compile RetroFE and create a full environment (ensure --os=mac !):
python Scripts/Package.py --os=mac --build=full python Scripts/Package.py --os=mac --build=full
Copy your live RetroFE system to any folder of your choosing: Copy your live RetroFE system to any folder of your choosing:
cp -r Artifacts/linux/RetroFE /your/ideal/retrofe/path cp -r Artifacts/mac/RetroFE /your/ideal/retrofe/path
# Compiling and installing on Ubuntu Linux (10.04 or newer) # # Compiling and installing on Ubuntu Linux (10.04 or newer) #

View File

@ -69,9 +69,9 @@ bool CollectionInfoBuilder::createCollectionDirectory(std::string name)
std::cout << "Creating folder \"" << *it << "\"" << std::endl; std::cout << "Creating folder \"" << *it << "\"" << std::endl;
#if defined(_WIN32) && !defined(__GNUC__) #if defined(_WIN32) && !defined(__GNUC__)
if(!CreateDirectory(it->c_str(), NULL)) if (!CreateDirectory(it->c_str(), NULL))
{ {
if(ERROR_ALREADY_EXISTS != GetLastError()) if (ERROR_ALREADY_EXISTS != GetLastError())
{ {
std::cout << "Could not create folder \"" << *it << "\"" << std::endl; std::cout << "Could not create folder \"" << *it << "\"" << std::endl;
return false; return false;
@ -79,9 +79,9 @@ bool CollectionInfoBuilder::createCollectionDirectory(std::string name)
} }
#else #else
#if defined(__MINGW32__) #if defined(__MINGW32__)
if(mkdir(it->c_str()) == -1) if (mkdir(it->c_str()) == -1)
#else #else
if(mkdir(it->c_str(), 0755) == -1) if (mkdir(it->c_str(), 0755) == -1)
#endif #endif
{ {
std::cout << "Could not create folder \"" << *it << "\":" << errno << std::endl; std::cout << "Could not create folder \"" << *it << "\":" << errno << std::endl;
@ -171,7 +171,7 @@ CollectionInfo *CollectionInfoBuilder::buildCollection(std::string name, std::st
(void)conf_.getProperty(metadataTypeKey, metadataType); (void)conf_.getProperty(metadataTypeKey, metadataType);
(void)conf_.getProperty(metadataPathKey, metadataPath); (void)conf_.getProperty(metadataPathKey, metadataPath);
if(!conf_.getProperty(launcherKey, launcherName)) if (!conf_.getProperty(launcherKey, launcherName))
{ {
std::stringstream ss; std::stringstream ss;
ss << "\"" ss << "\""
@ -209,7 +209,7 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo *info, std::string fi
{ {
line = Utils::filterComments(line); line = Utils::filterComments(line);
if(!line.empty() && list.find(line) == list.end()) if (!line.empty() && list.find(line) == list.end())
{ {
Item *i = new Item(); Item *i = new Item();
@ -227,11 +227,57 @@ bool CollectionInfoBuilder::ImportBasicList(CollectionInfo *info, std::string fi
return true; return true;
} }
bool CollectionInfoBuilder::ImportBasicList(CollectionInfo *info, std::string file, std::vector<Item *> &list)
{
std::ifstream includeStream(file.c_str());
if (!includeStream.good())
{
return false;
}
std::string line;
while(std::getline(includeStream, line))
{
line = Utils::filterComments(line);
if (!line.empty())
{
bool found = false;
for (std::vector<Item *>::iterator it = list.begin(); it != list.end(); ++it)
{
if (line == (*it)->name)
{
found = true;
}
}
if (!found)
{
Item *i = new Item();
line.erase( std::remove(line.begin(), line.end(), '\r'), line.end() );
i->fullTitle = line;
i->name = line;
i->title = line;
i->collectionInfo = info;
list.push_back(i);
}
}
}
return true;
}
bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string mergedCollectionName) bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string mergedCollectionName)
{ {
DIR *dp;
struct dirent *dirp;
std::string path = info->listpath; std::string path = info->listpath;
std::vector<Item *> includeFilterUnsorted;
std::map<std::string, Item *> includeFilter; std::map<std::string, Item *> includeFilter;
std::map<std::string, Item *> excludeFilter; std::map<std::string, Item *> excludeFilter;
std::string includeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "include.txt"); std::string includeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "include.txt");
@ -240,12 +286,13 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
std::string launcher; std::string launcher;
bool showMissing = false; bool showMissing = false;
if(mergedCollectionName != "") if (mergedCollectionName != "")
{ {
std::string mergedFile = Utils::combinePath(Configuration::absolutePath, "collections", mergedCollectionName, info->name + ".sub"); std::string mergedFile = Utils::combinePath(Configuration::absolutePath, "collections", mergedCollectionName, info->name + ".sub");
Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + mergedFile + "\""); Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + mergedFile + "\"");
(void)conf_.getProperty("collections." + mergedCollectionName + ".list.includeMissingItems", showMissing); (void)conf_.getProperty("collections." + mergedCollectionName + ".list.includeMissingItems", showMissing);
ImportBasicList(info, mergedFile, includeFilterUnsorted);
ImportBasicList(info, mergedFile, includeFilter); ImportBasicList(info, mergedFile, includeFilter);
} }
@ -253,82 +300,36 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
// If no merged file exists, or it is empty, attempt to use the include and exclude from the subcollection // If no merged file exists, or it is empty, attempt to use the include and exclude from the subcollection
// If this not a merged collection, the size will be 0 anyways and the code below will still execute // If this not a merged collection, the size will be 0 anyways and the code below will still execute
if(includeFilter.size() == 0) if (includeFilter.size() == 0)
{ {
Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + includeFile + "\""); Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + includeFile + "\"");
ImportBasicList(info, includeFile, includeFilterUnsorted);
ImportBasicList(info, includeFile, includeFilter); ImportBasicList(info, includeFile, includeFilter);
ImportBasicList(info, excludeFile, excludeFilter); ImportBasicList(info, excludeFile, excludeFilter);
} }
std::vector<std::string> extensions; if (showMissing)
std::vector<std::string>::iterator extensionsIt;
info->extensionList(extensions);
dp = opendir(path.c_str());
Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Scanning directory \"" + path + "\"");
if(dp == NULL)
{ {
Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Could not read directory \"" + path + "\". Ignore if this is a menu."); for(std::vector<Item *>::iterator it = includeFilterUnsorted.begin(); it != includeFilterUnsorted.end(); ++it)
}
if(showMissing)
{
for(std::map<std::string, Item *>::iterator it = includeFilter.begin(); it != includeFilter.end(); it++)
{ {
if(excludeFilter.find(it->first) == excludeFilter.end()) if (excludeFilter.find((*it)->name) == excludeFilter.end())
{ {
info->items.push_back(it->second); info->items.push_back(*it);
} }
} }
} }
while(dp != NULL && (dirp = readdir(dp)) != NULL) // Read ROM directory if showMissing is false
if (!showMissing || includeFilter.size() == 0)
{ {
std::string file = dirp->d_name; ImportRomDirectory(path, info, includeFilter, excludeFilter);
size_t position = file.find_last_of(".");
std::string basename = (std::string::npos == position)? file : file.substr(0, position);
// if there is an include list, only include roms that are found and are in the include list
// if there is an exclude list, exclude those roms
if((includeFilter.size() == 0 || (!showMissing && includeFilter.find(basename) != includeFilter.end())) &&
(excludeFilter.size() == 0 || excludeFilter.find(basename) == excludeFilter.end()))
{
// iterate through all known file extensions
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->name = basename;
i->fullTitle = basename;
i->title = basename;
i->collectionInfo = info;
info->items.push_back(i);
}
}
}
}
}
if(dp != NULL)
{
closedir(dp);
} }
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 the unused items if they were never pushed to the main collection // delete the unused items if they were never pushed to the main collection
if(!showMissing) if (!showMissing)
{ {
delete it->second; delete it->second;
} }
@ -372,7 +373,7 @@ void CollectionInfoBuilder::addFavorites(CollectionInfo *info)
for(std::vector<Item *>::iterator it = info->items.begin(); it != info->items.end(); it++) for(std::vector<Item *>::iterator it = info->items.begin(); it != info->items.end(); it++)
{ {
if( (*it)->name == itemName && (*it)->collectionInfo->name == collectionName) if ( (*it)->name == itemName && (*it)->collectionInfo->name == collectionName)
{ {
info->playlists["favorites"]->push_back((*it)); info->playlists["favorites"]->push_back((*it));
} }
@ -383,6 +384,78 @@ void CollectionInfoBuilder::addFavorites(CollectionInfo *info)
} }
void CollectionInfoBuilder::ImportRomDirectory(std::string path, CollectionInfo *info, std::map<std::string, Item *> includeFilter, std::map<std::string, Item *> excludeFilter)
{
DIR *dp;
struct dirent *dirp;
std::vector<std::string> extensions;
std::vector<std::string>::iterator extensionsIt;
info->extensionList(extensions);
dp = opendir(path.c_str());
Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Scanning directory \"" + path + "\"");
if (dp == NULL)
{
Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Could not read directory \"" + path + "\". Ignore if this is a menu.");
}
while(dp != NULL && (dirp = readdir(dp)) != NULL)
{
std::string file = dirp->d_name;
// Check if the file is a directory or a file
struct stat sb;
if (file != "." && file != ".." && stat( Utils::combinePath( path, file ).c_str(), &sb ) == 0 && S_ISDIR( sb.st_mode ))
{
ImportRomDirectory( Utils::combinePath( path, file ), info, includeFilter, excludeFilter );
}
else if (file != "." && file != "..")
{
size_t position = file.find_last_of(".");
std::string basename = (std::string::npos == position)? file : file.substr(0, position);
// if there is an include list, only include roms that are found and are in the include list
// if there is an exclude list, exclude those roms
if ((includeFilter.size() == 0 || (includeFilter.find(basename) != includeFilter.end())) &&
(excludeFilter.size() == 0 || excludeFilter.find(basename) == excludeFilter.end()))
{
// iterate through all known file extensions
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->name = basename;
i->fullTitle = basename;
i->title = basename;
i->collectionInfo = info;
i->filepath = path + Utils::pathSeparator;
info->items.push_back(i);
}
}
}
}
}
}
if (dp != NULL)
{
closedir(dp);
}
return;
}
void CollectionInfoBuilder::injectMetadata(CollectionInfo *info) void CollectionInfoBuilder::injectMetadata(CollectionInfo *info)

View File

@ -39,5 +39,7 @@ 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::map<std::string, Item *> &list);
bool ImportBasicList(CollectionInfo *info, std::string file, std::vector<Item *> &list);
bool ImportDirectory(CollectionInfo *info, std::string mergedCollectionName); bool ImportDirectory(CollectionInfo *info, std::string mergedCollectionName);
void ImportRomDirectory(std::string path, CollectionInfo *info, std::map<std::string, Item *> includeFilter, std::map<std::string, Item *> excludeFilter);
}; };

View File

@ -45,19 +45,19 @@ Configuration::~Configuration()
void Configuration::initialize() void Configuration::initialize()
{ {
const char *environment = std::getenv("RETROFE_PATH"); const char *environment = std::getenv("RETROFE_PATH");
std::string environmentStr;
std::string home_load = std::getenv("HOME") + std::string("/.retrofe"); std::string home_load = std::getenv("HOME") + std::string("/.retrofe");
std::ifstream retrofe_path(home_load.c_str()); std::ifstream retrofe_path(home_load.c_str());
// Check Environment for path
if (environment != NULL) if (environment != NULL)
{ {
environmentStr = environment;
absolutePath = environment; absolutePath = environment;
} }
else if (retrofe_path.is_open()) // Or check for home based flat file works on linux/mac
else if (retrofe_path && std::getline( retrofe_path, absolutePath ))
{ {
std::getline( retrofe_path, absolutePath );
retrofe_path.close(); retrofe_path.close();
} }
// Or check executable for path
else else
{ {
#ifdef WIN32 #ifdef WIN32

View File

@ -67,6 +67,13 @@ bool Launcher::run(std::string collection, Item *collectionItem)
return false; return false;
} }
// Overwrite selectedItemsDirectory if already set in the file
if (collectionItem->filepath != "")
{
selectedItemsDirectory = collectionItem->filepath;
}
// It is ok to continue if the file could not be found. We could be launching a merged romset // It is ok to continue if the file could not be found. We could be launching a merged romset
findFile(selectedItemsPath, matchedExtension, selectedItemsDirectory, collectionItem->name, extensionstr); findFile(selectedItemsPath, matchedExtension, selectedItemsDirectory, collectionItem->name, extensionstr);
@ -119,7 +126,7 @@ std::string Launcher::replaceVariables(std::string str,
str = Utils::replace(str, "%ITEM_COLLECTION_NAME%", itemCollectionName); str = Utils::replace(str, "%ITEM_COLLECTION_NAME%", itemCollectionName);
str = Utils::replace(str, "%RETROFE_PATH%", Configuration::absolutePath); str = Utils::replace(str, "%RETROFE_PATH%", Configuration::absolutePath);
#ifdef WIN32 #ifdef WIN32
str = Utils::replace(str, "%RETROFE_EXEC_PATH%", Utils::combinePath(Configuration::absolutePath, "RetroFE.exe")); str = Utils::replace(str, "%RETROFE_EXEC_PATH%", Utils::combinePath(Configuration::absolutePath, "core", "RetroFE.exe"));
#else #else
str = Utils::replace(str, "%RETROFE_EXEC_PATH%", Utils::combinePath(Configuration::absolutePath, "RetroFE")); str = Utils::replace(str, "%RETROFE_EXEC_PATH%", Utils::combinePath(Configuration::absolutePath, "RetroFE"));
#endif #endif

View File

@ -485,7 +485,7 @@ void ScrollingList::update(float dt)
Component *c = components_.at(cindex); Component *c = components_.at(cindex);
if(c && (scrollRequested || scrollChanged)) if(c && readyToScroll && (scrollRequested || scrollChanged))
{ {
unsigned int nextI = 0; unsigned int nextI = 0;
if(currentScrollDirection_ == ScrollDirectionBack) if(currentScrollDirection_ == ScrollDirectionBack)

View File

@ -145,6 +145,18 @@ void Page::onNewItemSelected()
} }
void Page::highlightLoadArt()
{
selectedItem_ = activeMenu_->getSelectedItem();
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
{
(*it)->setNewItemSelected();
}
}
void Page::pushMenu(ScrollingList *s) void Page::pushMenu(ScrollingList *s)
{ {
menus_.push_back(s); menus_.push_back(s);

View File

@ -44,6 +44,7 @@ public:
virtual ~Page(); virtual ~Page();
void DeInitialize(); void DeInitialize();
virtual void onNewItemSelected(); virtual void onNewItemSelected();
void highlightLoadArt();
bool pushCollection(CollectionInfo *collection); bool pushCollection(CollectionInfo *collection);
bool popCollection(); bool popCollection();
void enterMenu(); void enterMenu();

View File

@ -378,36 +378,35 @@ void RetroFE::run()
} }
break; break;
case RETROFE_HIGHLIGHT_REQUEST: case RETROFE_HIGHLIGHT_MENU_IDLE:
currentPage_->highlightExit();
currentPage_->setScrolling(Page::ScrollDirectionIdle); currentPage_->setScrolling(Page::ScrollDirectionIdle);
if (currentPage_->isIdle())
{
state = RETROFE_HIGHLIGHT_REQUEST;
}
break;
case RETROFE_HIGHLIGHT_REQUEST:
currentPage_->setScrolling(Page::ScrollDirectionIdle);
currentPage_->highlightExit();
state = RETROFE_HIGHLIGHT_EXIT; state = RETROFE_HIGHLIGHT_EXIT;
break; break;
case RETROFE_HIGHLIGHT_EXIT: case RETROFE_HIGHLIGHT_EXIT:
if (processUserInput(currentPage_) == RETROFE_HIGHLIGHT_REQUEST) if (processUserInput(currentPage_) == RETROFE_HIGHLIGHT_REQUEST)
{ {
state = RETROFE_HIGHLIGHT_REQUEST; state = RETROFE_HIGHLIGHT_MENU_IDLE;
} }
else if ((currentPage_->isGraphicsIdle() && currentPage_->isMenuScrolling()) || else if (currentPage_->isIdle())
(currentPage_->isIdle()))
{ {
currentPage_->onNewItemSelected(); currentPage_->highlightLoadArt();
state = RETROFE_HIGHLIGHT_LOAD_ART; state = RETROFE_HIGHLIGHT_LOAD_ART;
} }
break; break;
case RETROFE_HIGHLIGHT_LOAD_ART: case RETROFE_HIGHLIGHT_LOAD_ART:
if (processUserInput(currentPage_) == RETROFE_HIGHLIGHT_REQUEST) currentPage_->highlightEnter();
{ state = RETROFE_HIGHLIGHT_ENTER;
state = RETROFE_HIGHLIGHT_REQUEST;
}
else if ((currentPage_->isGraphicsIdle() && currentPage_->isMenuScrolling()) ||
(currentPage_->isIdle()))
{
currentPage_->highlightEnter();
state = RETROFE_HIGHLIGHT_ENTER;
}
break; break;
case RETROFE_HIGHLIGHT_ENTER: case RETROFE_HIGHLIGHT_ENTER:
@ -415,7 +414,7 @@ void RetroFE::run()
{ {
state = RETROFE_HIGHLIGHT_REQUEST; state = RETROFE_HIGHLIGHT_REQUEST;
} }
else if (currentPage_->isGraphicsIdle()) else if (currentPage_->isIdle())
{ {
state = RETROFE_IDLE; state = RETROFE_IDLE;
} }
@ -860,10 +859,14 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
} }
} }
collection->sortItems();
bool menuSort = true; bool menuSort = true;
config_.getProperty("collections." + collectionName + ".list.menuSort", menuSort); config_.getProperty("collections." + collectionName + ".list.menuSort", menuSort);
if (menuSort)
{
collection->sortItems();
}
MenuParser mp; MenuParser mp;
mp.buildMenuItems(collection, menuSort); mp.buildMenuItems(collection, menuSort);

View File

@ -63,6 +63,7 @@ private:
RETROFE_HIGHLIGHT_EXIT, RETROFE_HIGHLIGHT_EXIT,
RETROFE_HIGHLIGHT_LOAD_ART, RETROFE_HIGHLIGHT_LOAD_ART,
RETROFE_HIGHLIGHT_ENTER, RETROFE_HIGHLIGHT_ENTER,
RETROFE_HIGHLIGHT_MENU_IDLE,
RETROFE_NEXT_PAGE_REQUEST, RETROFE_NEXT_PAGE_REQUEST,
RETROFE_NEXT_PAGE_MENU_EXIT, RETROFE_NEXT_PAGE_MENU_EXIT,
RETROFE_NEXT_PAGE_MENU_LOAD_ART, RETROFE_NEXT_PAGE_MENU_LOAD_ART,