diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index a8a010d1c..9e59f9c88 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -40,8 +40,8 @@ FileData::~FileData() std::string FileData::getDisplayName() const { std::string stem = Utils::FileSystem::getStem(mPath); - if(mSystem && mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO)) - stem = MameNames::getInstance()->getRealName(stem); +// if(mSystem && mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO)) +// stem = MameNames::getInstance()->getRealName(stem); return stem; } @@ -51,35 +51,6 @@ std::string FileData::getCleanName() const return Utils::String::removeParenthesis(this->getDisplayName()); } -const std::string FileData::getThumbnailPath() const -{ - std::string thumbnail = metadata.get("thumbnail"); - - // no thumbnail, try image - if(thumbnail.empty()) - { - thumbnail = metadata.get("image"); - - // no image, try to use local image - if(thumbnail.empty() && Settings::getInstance()->getBool("LocalArt")) - { - const char* extList[2] = { ".png", ".jpg" }; - for(int i = 0; i < 2; i++) - { - if(thumbnail.empty()) - { - std::string path = mEnvData->mStartPath + "/images/" + getDisplayName() + "-image" + extList[i]; - if(Utils::FileSystem::exists(path)) - thumbnail = path; - } - } - } - } - - return thumbnail; -} - - const std::string& FileData::getName() { return metadata.get("name"); @@ -101,7 +72,155 @@ const bool FileData::getFavorite() return false; } -const std::vector& FileData::getChildrenListToDisplay() { +const std::string FileData::getMediaDirectory() const +{ + std::string mediaDirSetting = Settings::getInstance()->getString("MediaDirectory"); + std::string mediaDirPath = ""; + + if(mediaDirSetting == "") + { + mediaDirPath = Utils::FileSystem::getHomePath() + "/.emulationstation/downloaded_media/"; + } + else + { + mediaDirPath = mediaDirSetting; + + // Expand home symbol if the path starts with ~ + if(mediaDirPath[0] == '~') + { + mediaDirPath.erase(0, 1); + mediaDirPath.insert(0, Utils::FileSystem::getHomePath()); + } + + if(mediaDirPath.back() != '/') + { + mediaDirPath = mediaDirPath + "/"; + } + } + + return mediaDirPath; +} + +const std::string FileData::getThumbnailPath() const +{ + const char* extList[2] = { ".png", ".jpg" }; + std::string tempPath = getMediaDirectory() + mSystemName + "/thumbnails/" + getDisplayName(); + + // Look for media in the media directory + for(int i = 0; i < 2; i++) + { + std::string mediaPath = tempPath + extList[i]; + if(Utils::FileSystem::exists(mediaPath)) + return mediaPath; + } + + // No media found in the media directory, so look for local art as well (if configured to do so) + if(Settings::getInstance()->getBool("LocalArt")) + { + for(int i = 0; i < 2; i++) + { + std::string localMediaPath = mEnvData->mStartPath + "/images/" + getDisplayName() + "-thumbnail" + extList[i]; + if(Utils::FileSystem::exists(localMediaPath)) + return localMediaPath; + } + } + + return ""; +} + +const std::string FileData::getVideoPath() const +{ + const char* extList[5] = { ".avi", ".mkv", ".mov", ".mp4", ".wmv" }; + std::string tempPath = getMediaDirectory() + mSystemName + "/videos/" + getDisplayName(); + + // Look for media in the media directory + for(int i = 0; i < 5; i++) + { + std::string mediaPath = tempPath + extList[i]; + if(Utils::FileSystem::exists(mediaPath)) + return mediaPath; + } + + // No media found in the media directory, so look for local art as well (if configured to do so) + if(Settings::getInstance()->getBool("LocalArt")) + { + for(int i = 0; i < 5; i++) + { + std::string localMediaPath = mEnvData->mStartPath + "/images/" + getDisplayName() + "-video" + extList[i]; + if(Utils::FileSystem::exists(localMediaPath)) + return localMediaPath; + } + } + + return ""; +} + +const std::string FileData::getMarqueePath() const +{ + const char* extList[2] = { ".png", ".jpg" }; + std::string tempPath = getMediaDirectory() + mSystemName + "/marquees/" + getDisplayName(); + + // Look for media in the media directory + for(int i = 0; i < 2; i++) + { + std::string mediaPath = tempPath + extList[i]; + if(Utils::FileSystem::exists(mediaPath)) + return mediaPath; + } + + // No media found in the media directory, so look for local art as well (if configured to do so) + if(Settings::getInstance()->getBool("LocalArt")) + { + for(int i = 0; i < 2; i++) + { + std::string localMediaPath = mEnvData->mStartPath + "/images/" + getDisplayName() + "-marquee" + extList[i]; + if(Utils::FileSystem::exists(localMediaPath)) + return localMediaPath; + } + } + + return ""; +} + +const std::string FileData::getImagePath() const +{ + const char* extList[2] = { ".png", ".jpg" }; + + // Look for mix image (a combination of screenshot, 3D box and marquee) in the media directory + std::string tempPath = getMediaDirectory() + mSystemName + "/miximages/" + getDisplayName(); + for(int i = 0; i < 2; i++) + { + std::string mediaPath = tempPath + extList[i]; + if(Utils::FileSystem::exists(mediaPath)) + return mediaPath; + } + + // If no mix image exists, try normal screenshot + tempPath = getMediaDirectory() + mSystemName + "/screenshots/" + getDisplayName(); + + for(int i = 0; i < 2; i++) + { + std::string mediaPath = tempPath + extList[i]; + if(Utils::FileSystem::exists(mediaPath)) + return mediaPath; + } + + // No media found in the media directory, so look for local art as well (if configured to do so) + if(Settings::getInstance()->getBool("LocalArt")) + { + for(int i = 0; i < 2; i++) + { + std::string localMediaPath = mEnvData->mStartPath + "/images/" + getDisplayName() + "-image" + extList[i]; + if(Utils::FileSystem::exists(localMediaPath)) + return localMediaPath; + } + } + + return ""; +} + +const std::vector& FileData::getChildrenListToDisplay() +{ FileFilterIndex* idx = CollectionSystemManager::get()->getSystemToView(mSystem)->getIndex(); if (idx->isFiltered()) { @@ -121,65 +240,6 @@ const std::vector& FileData::getChildrenListToDisplay() { } } -const std::string FileData::getVideoPath() const -{ - std::string video = metadata.get("video"); - - // no video, try to use local video - if(video.empty() && Settings::getInstance()->getBool("LocalArt")) - { - std::string path = mEnvData->mStartPath + "/images/" + getDisplayName() + "-video.mp4"; - if(Utils::FileSystem::exists(path)) - video = path; - } - - return video; -} - -const std::string FileData::getMarqueePath() const -{ - std::string marquee = metadata.get("marquee"); - - // no marquee, try to use local marquee - if(marquee.empty() && Settings::getInstance()->getBool("LocalArt")) - { - const char* extList[2] = { ".png", ".jpg" }; - for(int i = 0; i < 2; i++) - { - if(marquee.empty()) - { - std::string path = mEnvData->mStartPath + "/images/" + getDisplayName() + "-marquee" + extList[i]; - if(Utils::FileSystem::exists(path)) - marquee = path; - } - } - } - - return marquee; -} - -const std::string FileData::getImagePath() const -{ - std::string image = metadata.get("image"); - - // no image, try to use local image - if(image.empty()) - { - const char* extList[2] = { ".png", ".jpg" }; - for(int i = 0; i < 2; i++) - { - if(image.empty()) - { - std::string path = mEnvData->mStartPath + "/images/" + getDisplayName() + "-image" + extList[i]; - if(Utils::FileSystem::exists(path)) - image = path; - } - } - } - - return image; -} - std::vector FileData::getFilesRecursive(unsigned int typeMask, bool displayedOnly) const { std::vector out; diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 80b376008..a96053165 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -46,6 +46,7 @@ public: inline const std::vector& getChildren() const { return mChildren; } inline SystemData* getSystem() const { return mSystem; } inline SystemEnvironmentData* getSystemEnvData() const { return mEnvData; } + virtual const std::string getMediaDirectory() const; virtual const std::string getThumbnailPath() const; virtual const std::string getVideoPath() const; virtual const std::string getMarqueePath() const; diff --git a/es-app/src/MetaData.cpp b/es-app/src/MetaData.cpp index 50d698e1e..f02207b80 100644 --- a/es-app/src/MetaData.cpp +++ b/es-app/src/MetaData.cpp @@ -9,10 +9,6 @@ MetaDataDecl gameDecls[] = { {"name", MD_STRING, "", false, "name", "enter game name"}, {"sortname", MD_STRING, "", false, "sortname", "enter game sort name"}, {"desc", MD_MULTILINE_STRING, "", false, "description", "enter description"}, - {"image", MD_PATH, "", false, "image", "enter path to image"}, - {"video", MD_PATH , "", false, "video", "enter path to video"}, - {"marquee", MD_PATH, "", false, "marquee", "enter path to marquee"}, - {"thumbnail", MD_PATH, "", false, "thumbnail", "enter path to thumbnail"}, {"rating", MD_RATING, "0.000000", false, "rating", "enter rating"}, {"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date"}, {"developer", MD_STRING, "unknown", false, "developer", "enter game developer"}, @@ -20,10 +16,13 @@ MetaDataDecl gameDecls[] = { {"genre", MD_STRING, "unknown", false, "genre", "enter game genre"}, {"players", MD_INT, "1", false, "players", "enter number of players"}, {"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on"}, + {"completed", MD_BOOL, "false", false, "completed", "enter completed off/on"}, {"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on" }, {"kidgame", MD_BOOL, "false", false, "kidgame", "enter kidgame off/on" }, + {"launcher", MD_STRING, "", false, "launcher", "enter launcher override"}, {"playcount", MD_INT, "0", false, "play count", "enter number of times played"}, {"lastplayed", MD_TIME, "0", true, "last played", "enter last played date"} + }; const std::vector gameMDD(gameDecls, gameDecls + sizeof(gameDecls) / sizeof(gameDecls[0])); @@ -31,10 +30,6 @@ MetaDataDecl folderDecls[] = { {"name", MD_STRING, "", false, "name", "enter game name"}, {"sortname", MD_STRING, "", false, "sortname", "enter game sort name"}, {"desc", MD_MULTILINE_STRING, "", false, "description", "enter description"}, - {"image", MD_PATH, "", false, "image", "enter path to image"}, - {"thumbnail", MD_PATH, "", false, "thumbnail", "enter path to thumbnail"}, - {"video", MD_PATH, "", false, "video", "enter path to video"}, - {"marquee", MD_PATH, "", false, "marquee", "enter path to marquee"}, {"rating", MD_RATING, "0.000000", false, "rating", "enter rating"}, {"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date"}, {"developer", MD_STRING, "unknown", false, "developer", "enter game developer"}, diff --git a/es-app/src/MetaData.h b/es-app/src/MetaData.h index 29154b4ee..65560c676 100644 --- a/es-app/src/MetaData.h +++ b/es-app/src/MetaData.h @@ -28,7 +28,7 @@ struct MetaDataDecl std::string key; MetaDataType type; std::string defaultValue; - bool isStatistic; //if true, ignore scraper values for this metadata + bool isStatistic; //if true, ignore values for this metadata std::string displayName; // displayed as this in editors std::string displayPrompt; // phrase displayed in editors when prompted to enter value (currently only for strings) }; diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index 144802b68..2e07b72a6 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -160,12 +160,17 @@ bool GridGameListView::input(InputConfig* config, Input input) const std::string GridGameListView::getImagePath(FileData* file) { ImageSource src = mGrid.getImageSource(); + FileData* returnFile; if (src == ImageSource::IMAGE) return file->getImagePath(); else if (src == ImageSource::MARQUEE) return file->getMarqueePath(); + // If no thumbnail was found, then use the image media type + if(file->getThumbnailPath() == ""); + return file->getImagePath(); + return file->getThumbnailPath(); } @@ -322,9 +327,9 @@ void GridGameListView::updateInfoPanel() // } // mVideoPlaying = true; - mVideo->setImage(file->getThumbnailPath()); +// mVideo->setImage(file->getThumbnailPath()); mMarquee.setImage(file->getMarqueePath()); - mImage.setImage(file->getImagePath()); +// mImage.setImage(file->getImagePath()); mDescription.setText(file->metadata.get("desc")); mDescContainer.reset(); diff --git a/es-app/src/views/gamelist/VideoGameListView.cpp b/es-app/src/views/gamelist/VideoGameListView.cpp index 9fa9482a3..420212f64 100644 --- a/es-app/src/views/gamelist/VideoGameListView.cpp +++ b/es-app/src/views/gamelist/VideoGameListView.cpp @@ -263,7 +263,8 @@ void VideoGameListView::updateInfoPanel() } mVideoPlaying = true; - mVideo->setImage(file->getThumbnailPath()); +// mVideo->setImage(file->getThumbnailPath()); + mVideo->setImage(file->getImagePath()); mThumbnail.setImage(file->getThumbnailPath()); mMarquee.setImage(file->getMarqueePath()); mImage.setImage(file->getImagePath()); diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 1eebc2e5d..da1ccb1a5 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -67,6 +67,7 @@ void Settings::setDefaults() mBoolMap["SplashScreenProgress"] = true; mStringMap["StartupSystem"] = ""; mBoolMap["DisableKidStartMenu"] = true; + mStringMap["MediaDirectory"] = ""; mBoolMap["VSync"] = true; @@ -96,7 +97,7 @@ void Settings::setDefaults() mStringMap["TransitionStyle"] = "fade"; mStringMap["ThemeSet"] = ""; mStringMap["ScreenSaverBehavior"] = "dim"; - mStringMap["Scraper"] = "TheGamesDB"; + mStringMap["Scraper"] = "ScreenScraper"; mStringMap["GamelistViewStyle"] = "automatic"; mStringMap["SaveGamelistsMode"] = "on exit";