mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Rewrote media handling to look for images and videos in a configurable media directory (by matching the ROM names) instead of being configured per game as XML tags
This commit is contained in:
parent
7686f87d5d
commit
fbec408dfa
|
@ -40,8 +40,8 @@ FileData::~FileData()
|
||||||
std::string FileData::getDisplayName() const
|
std::string FileData::getDisplayName() const
|
||||||
{
|
{
|
||||||
std::string stem = Utils::FileSystem::getStem(mPath);
|
std::string stem = Utils::FileSystem::getStem(mPath);
|
||||||
if(mSystem && mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO))
|
// if(mSystem && mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO))
|
||||||
stem = MameNames::getInstance()->getRealName(stem);
|
// stem = MameNames::getInstance()->getRealName(stem);
|
||||||
|
|
||||||
return stem;
|
return stem;
|
||||||
}
|
}
|
||||||
|
@ -51,35 +51,6 @@ std::string FileData::getCleanName() const
|
||||||
return Utils::String::removeParenthesis(this->getDisplayName());
|
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()
|
const std::string& FileData::getName()
|
||||||
{
|
{
|
||||||
return metadata.get("name");
|
return metadata.get("name");
|
||||||
|
@ -101,7 +72,155 @@ const bool FileData::getFavorite()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<FileData*>& 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*>& FileData::getChildrenListToDisplay()
|
||||||
|
{
|
||||||
|
|
||||||
FileFilterIndex* idx = CollectionSystemManager::get()->getSystemToView(mSystem)->getIndex();
|
FileFilterIndex* idx = CollectionSystemManager::get()->getSystemToView(mSystem)->getIndex();
|
||||||
if (idx->isFiltered()) {
|
if (idx->isFiltered()) {
|
||||||
|
@ -121,65 +240,6 @@ const std::vector<FileData*>& 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*> FileData::getFilesRecursive(unsigned int typeMask, bool displayedOnly) const
|
std::vector<FileData*> FileData::getFilesRecursive(unsigned int typeMask, bool displayedOnly) const
|
||||||
{
|
{
|
||||||
std::vector<FileData*> out;
|
std::vector<FileData*> out;
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
inline const std::vector<FileData*>& getChildren() const { return mChildren; }
|
inline const std::vector<FileData*>& getChildren() const { return mChildren; }
|
||||||
inline SystemData* getSystem() const { return mSystem; }
|
inline SystemData* getSystem() const { return mSystem; }
|
||||||
inline SystemEnvironmentData* getSystemEnvData() const { return mEnvData; }
|
inline SystemEnvironmentData* getSystemEnvData() const { return mEnvData; }
|
||||||
|
virtual const std::string getMediaDirectory() const;
|
||||||
virtual const std::string getThumbnailPath() const;
|
virtual const std::string getThumbnailPath() const;
|
||||||
virtual const std::string getVideoPath() const;
|
virtual const std::string getVideoPath() const;
|
||||||
virtual const std::string getMarqueePath() const;
|
virtual const std::string getMarqueePath() const;
|
||||||
|
|
|
@ -9,10 +9,6 @@ MetaDataDecl gameDecls[] = {
|
||||||
{"name", MD_STRING, "", false, "name", "enter game name"},
|
{"name", MD_STRING, "", false, "name", "enter game name"},
|
||||||
{"sortname", MD_STRING, "", false, "sortname", "enter game sort name"},
|
{"sortname", MD_STRING, "", false, "sortname", "enter game sort name"},
|
||||||
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description"},
|
{"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"},
|
{"rating", MD_RATING, "0.000000", false, "rating", "enter rating"},
|
||||||
{"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date"},
|
{"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date"},
|
||||||
{"developer", MD_STRING, "unknown", false, "developer", "enter game developer"},
|
{"developer", MD_STRING, "unknown", false, "developer", "enter game developer"},
|
||||||
|
@ -20,10 +16,13 @@ MetaDataDecl gameDecls[] = {
|
||||||
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre"},
|
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre"},
|
||||||
{"players", MD_INT, "1", false, "players", "enter number of players"},
|
{"players", MD_INT, "1", false, "players", "enter number of players"},
|
||||||
{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on"},
|
{"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" },
|
{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on" },
|
||||||
{"kidgame", MD_BOOL, "false", false, "kidgame", "enter kidgame 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"},
|
{"playcount", MD_INT, "0", false, "play count", "enter number of times played"},
|
||||||
{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date"}
|
{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date"}
|
||||||
|
|
||||||
};
|
};
|
||||||
const std::vector<MetaDataDecl> gameMDD(gameDecls, gameDecls + sizeof(gameDecls) / sizeof(gameDecls[0]));
|
const std::vector<MetaDataDecl> gameMDD(gameDecls, gameDecls + sizeof(gameDecls) / sizeof(gameDecls[0]));
|
||||||
|
|
||||||
|
@ -31,10 +30,6 @@ MetaDataDecl folderDecls[] = {
|
||||||
{"name", MD_STRING, "", false, "name", "enter game name"},
|
{"name", MD_STRING, "", false, "name", "enter game name"},
|
||||||
{"sortname", MD_STRING, "", false, "sortname", "enter game sort name"},
|
{"sortname", MD_STRING, "", false, "sortname", "enter game sort name"},
|
||||||
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description"},
|
{"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"},
|
{"rating", MD_RATING, "0.000000", false, "rating", "enter rating"},
|
||||||
{"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date"},
|
{"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date"},
|
||||||
{"developer", MD_STRING, "unknown", false, "developer", "enter game developer"},
|
{"developer", MD_STRING, "unknown", false, "developer", "enter game developer"},
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct MetaDataDecl
|
||||||
std::string key;
|
std::string key;
|
||||||
MetaDataType type;
|
MetaDataType type;
|
||||||
std::string defaultValue;
|
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 displayName; // displayed as this in editors
|
||||||
std::string displayPrompt; // phrase displayed in editors when prompted to enter value (currently only for strings)
|
std::string displayPrompt; // phrase displayed in editors when prompted to enter value (currently only for strings)
|
||||||
};
|
};
|
||||||
|
|
|
@ -160,12 +160,17 @@ bool GridGameListView::input(InputConfig* config, Input input)
|
||||||
const std::string GridGameListView::getImagePath(FileData* file)
|
const std::string GridGameListView::getImagePath(FileData* file)
|
||||||
{
|
{
|
||||||
ImageSource src = mGrid.getImageSource();
|
ImageSource src = mGrid.getImageSource();
|
||||||
|
FileData* returnFile;
|
||||||
|
|
||||||
if (src == ImageSource::IMAGE)
|
if (src == ImageSource::IMAGE)
|
||||||
return file->getImagePath();
|
return file->getImagePath();
|
||||||
else if (src == ImageSource::MARQUEE)
|
else if (src == ImageSource::MARQUEE)
|
||||||
return file->getMarqueePath();
|
return file->getMarqueePath();
|
||||||
|
|
||||||
|
// If no thumbnail was found, then use the image media type
|
||||||
|
if(file->getThumbnailPath() == "");
|
||||||
|
return file->getImagePath();
|
||||||
|
|
||||||
return file->getThumbnailPath();
|
return file->getThumbnailPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,9 +327,9 @@ void GridGameListView::updateInfoPanel()
|
||||||
// }
|
// }
|
||||||
// mVideoPlaying = true;
|
// mVideoPlaying = true;
|
||||||
|
|
||||||
mVideo->setImage(file->getThumbnailPath());
|
// mVideo->setImage(file->getThumbnailPath());
|
||||||
mMarquee.setImage(file->getMarqueePath());
|
mMarquee.setImage(file->getMarqueePath());
|
||||||
mImage.setImage(file->getImagePath());
|
// mImage.setImage(file->getImagePath());
|
||||||
|
|
||||||
mDescription.setText(file->metadata.get("desc"));
|
mDescription.setText(file->metadata.get("desc"));
|
||||||
mDescContainer.reset();
|
mDescContainer.reset();
|
||||||
|
|
|
@ -263,7 +263,8 @@ void VideoGameListView::updateInfoPanel()
|
||||||
}
|
}
|
||||||
mVideoPlaying = true;
|
mVideoPlaying = true;
|
||||||
|
|
||||||
mVideo->setImage(file->getThumbnailPath());
|
// mVideo->setImage(file->getThumbnailPath());
|
||||||
|
mVideo->setImage(file->getImagePath());
|
||||||
mThumbnail.setImage(file->getThumbnailPath());
|
mThumbnail.setImage(file->getThumbnailPath());
|
||||||
mMarquee.setImage(file->getMarqueePath());
|
mMarquee.setImage(file->getMarqueePath());
|
||||||
mImage.setImage(file->getImagePath());
|
mImage.setImage(file->getImagePath());
|
||||||
|
|
|
@ -67,6 +67,7 @@ void Settings::setDefaults()
|
||||||
mBoolMap["SplashScreenProgress"] = true;
|
mBoolMap["SplashScreenProgress"] = true;
|
||||||
mStringMap["StartupSystem"] = "";
|
mStringMap["StartupSystem"] = "";
|
||||||
mBoolMap["DisableKidStartMenu"] = true;
|
mBoolMap["DisableKidStartMenu"] = true;
|
||||||
|
mStringMap["MediaDirectory"] = "";
|
||||||
|
|
||||||
mBoolMap["VSync"] = true;
|
mBoolMap["VSync"] = true;
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ void Settings::setDefaults()
|
||||||
mStringMap["TransitionStyle"] = "fade";
|
mStringMap["TransitionStyle"] = "fade";
|
||||||
mStringMap["ThemeSet"] = "";
|
mStringMap["ThemeSet"] = "";
|
||||||
mStringMap["ScreenSaverBehavior"] = "dim";
|
mStringMap["ScreenSaverBehavior"] = "dim";
|
||||||
mStringMap["Scraper"] = "TheGamesDB";
|
mStringMap["Scraper"] = "ScreenScraper";
|
||||||
mStringMap["GamelistViewStyle"] = "automatic";
|
mStringMap["GamelistViewStyle"] = "automatic";
|
||||||
mStringMap["SaveGamelistsMode"] = "on exit";
|
mStringMap["SaveGamelistsMode"] = "on exit";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue