From 7ab7dcc7c68ca6b0a5c615e6a6772633bf18e447 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 31 Jan 2021 19:53:55 +0100 Subject: [PATCH] Added 1-to-1 directory structure matching for game ROMs and media files. --- USERGUIDE.md | 10 ++++------ es-app/src/FileData.cpp | 25 ++++++++++++++++++++----- es-app/src/scrapers/Scraper.cpp | 8 +++++++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/USERGUIDE.md b/USERGUIDE.md index 88025e4a0..d1c5601ab 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -314,7 +314,7 @@ The platform name for the Commodore 64 is `c64`, so the following structure woul ~/ROMs/c64/Multidisk/Pirates/Pirates!.m3u ``` -It's highly recommended to create `.m3u` playlist files for multi-disk images as this automates (well it should) disk swapping in the emulator. It's then this .m3u file that should be selected for launching the game. +It's highly recommended to create `.m3u` playlist files for multi-disk images as this normally automates disk swapping in the emulator. It's then this .m3u file that should be selected for launching the game. The .m3u file simply contains a list of the game files, for example in the case of Last Ninja 2.m3u: @@ -323,8 +323,6 @@ LNINJA2A.D64 LNINJA2B.D64 ``` -It's recommended to have the exact same filename for the .m3u file as for the directory as the game media files will then be shared between the two. This saves some unnecessary scraping as well as some disk space. - It's of course also possible to skip this type of directory structure and put all the games in the root folder, but then there will be multiple entries for the same game which is not so tidy. Another approach would be to put all the files in the root folder and then hide the game files, showing only the .m3u playlist files. ES-DE is flexible so do whatever makes most sense for the situation. When setting up games in this fashion, it's recommended to scrape the directory in addition to the .m3u file as it looks nicer to see the metadata for the games also when browsing the folders. ES fully supports scraping folders, although some metadata is not included for folders for logical reasons. If you only scrape the folders and not the actual game files, it may look somehow ok when browsing, but when a game is part of a collection, the metadata will be missing there. This includes the **Last played** and **All games** collections for instance. Also note that while it's possible to mark a folder as a favorite, it will never be part of a collection, such as **Favorites**. @@ -606,11 +604,11 @@ The media files must correspond exactly to the game files. For example the follo ~/ROMs/c64/Multidisk/Last Ninja 2/Last Ninja 2.m3u ``` -Must have a corresponding filename for its media files in this fashion: +Must have corresponding filenames for its media files in this fashion: ``` -~/.emulationstation/downloaded_media/c64/screenshots/Last Ninja 2.jpg -~/.emulationstation/downloaded_media/c64/videos/Last Ninja 2.mp4 +~/.emulationstation/downloaded_media/c64/screenshots/Multidisk/Last Ninja 2/Last Ninja 2.jpg +~/.emulationstation/downloaded_media/c64/videos/Multidisk/Last Ninja 2/Last Ninja 2.mp4 ``` JPG and PNG file formats and file extensions are supported for images, and AVI, MKV, MOV, MP4 and WMV are supported for videos. diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index ef3f91c7f..9a6e7d6b4 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -209,11 +209,18 @@ const std::string FileData::getMediaDirectory() const std::string FileData::getMediafilePath(std::string subdirectory, std::string mediatype) const { - std::vector extList = { ".png", ".jpg" }; + const std::vector extList = { ".png", ".jpg" }; + std::string subFolders; + + // Extract possible subfolders from the path. + if (mEnvData->mStartPath != "") + subFolders = Utils::String::replace( + Utils::FileSystem::getParent(mPath), mEnvData->mStartPath, ""); + + const std::string tempPath = getMediaDirectory() + mSystemName + "/" + subdirectory + + subFolders + "/" + getDisplayName(); // Look for an image file in the media directory. - std::string tempPath = getMediaDirectory() + mSystemName + "/" + - subdirectory + "/" + getDisplayName(); for (int i = 0; i < extList.size(); i++) { std::string mediaPath = tempPath + extList[i]; if (Utils::FileSystem::exists(mediaPath)) @@ -282,8 +289,16 @@ const std::string FileData::getThumbnailPath() const const std::string FileData::getVideoPath() const { - std::vector extList = { ".avi", ".mkv", ".mov", ".mp4", ".wmv" }; - std::string tempPath = getMediaDirectory() + mSystemName + "/videos/" + getDisplayName(); + const std::vector extList = { ".avi", ".mkv", ".mov", ".mp4", ".wmv" }; + std::string subFolders; + + // Extract possible subfolders from the path. + if (mEnvData->mStartPath != "") + subFolders = Utils::String::replace( + Utils::FileSystem::getParent(mPath), mEnvData->mStartPath, ""); + + const std::string tempPath = + getMediaDirectory() + mSystemName + "/videos" + subFolders + "/" + getDisplayName(); // Look for media in the media directory. for (int i = 0; i < extList.size(); i++) { diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index b8c80b1b9..b1470b906 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -512,13 +512,19 @@ std::string getSaveAsPath(const ScraperSearchParams& params, { const std::string systemsubdirectory = params.system->getName(); const std::string name = Utils::FileSystem::getStem(params.game->getPath()); + std::string subFolders; + + // Extract possible subfolders from the path. + if (params.system->getSystemEnvData()->mStartPath != "") + subFolders = Utils::String::replace(Utils::FileSystem::getParent(params.game->getPath()), + params.system->getSystemEnvData()->mStartPath, ""); std::string path = FileData::getMediaDirectory(); if (!Utils::FileSystem::exists(path)) Utils::FileSystem::createDirectory(path); - path += systemsubdirectory + "/" + filetypeSubdirectory + "/"; + path += systemsubdirectory + "/" + filetypeSubdirectory + subFolders + "/"; if (!Utils::FileSystem::exists(path)) Utils::FileSystem::createDirectory(path);