Use local game art ( image, marquee and video ) from romfolder/images if the gamelist didn't specify a path

This commit is contained in:
Tomas Jakobsson 2017-10-23 01:04:17 +02:00
parent 06d38db73b
commit cd2f2ee42b
4 changed files with 87 additions and 39 deletions

View file

@ -43,12 +43,32 @@ std::string FileData::getCleanName() const
return removeParenthesis(this->getDisplayName()); return removeParenthesis(this->getDisplayName());
} }
const std::string& FileData::getThumbnailPath() const const std::string FileData::getThumbnailPath() const
{ {
if(!metadata.get("thumbnail").empty()) std::string thumbnail = metadata.get("thumbnail");
return metadata.get("thumbnail");
else // no thumbnail, try image
return metadata.get("image"); if(thumbnail.empty())
{
thumbnail = metadata.get("image");
// no image, try to use local image
if(thumbnail.empty())
{
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(boost::filesystem::exists(path))
thumbnail = path;
}
}
}
}
return thumbnail;
} }
const std::string& FileData::getName() const std::string& FileData::getName()
@ -76,14 +96,63 @@ const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
} }
} }
const std::string& FileData::getVideoPath() const const std::string FileData::getVideoPath() const
{ {
return metadata.get("video"); std::string video = metadata.get("video");
// no video, try to use local video
if(video.empty())
{
std::string path = mEnvData->mStartPath + "/images/" + getDisplayName() + "-video.mp4";
if(boost::filesystem::exists(path))
video = path;
}
return video;
} }
const std::string& FileData::getMarqueePath() const const std::string FileData::getMarqueePath() const
{ {
return metadata.get("marquee"); std::string marquee = metadata.get("marquee");
// no marquee, try to use local marquee
if(marquee.empty())
{
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(boost::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(boost::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

View file

@ -43,9 +43,10 @@ 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& 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;
virtual const std::string getImagePath() const;
const std::vector<FileData*>& getChildrenListToDisplay(); const std::vector<FileData*>& getChildrenListToDisplay();
std::vector<FileData*> getFilesRecursive(unsigned int typeMask, bool displayedOnly = false) const; std::vector<FileData*> getFilesRecursive(unsigned int typeMask, bool displayedOnly = false) const;

View file

@ -194,7 +194,7 @@ void DetailedGameListView::updateInfoPanel()
//mDescription.setText(""); //mDescription.setText("");
fadingOut = true; fadingOut = true;
}else{ }else{
mImage.setImage(file->metadata.get("image")); mImage.setImage(file->getImagePath());
mDescription.setText(file->metadata.get("desc")); mDescription.setText(file->metadata.get("desc"));
mDescContainer.reset(); mDescContainer.reset();

View file

@ -240,37 +240,15 @@ void VideoGameListView::updateInfoPanel()
fadingOut = true; fadingOut = true;
}else{ }else{
std::string video_path; if (!mVideo->setVideo(file->getVideoPath()))
std::string marquee_path;
std::string thumbnail_path;
video_path = file->getVideoPath();
marquee_path = file->getMarqueePath();
thumbnail_path = file->getThumbnailPath();
if (!video_path.empty() && (video_path[0] == '~'))
{
video_path.erase(0, 1);
video_path.insert(0, getHomePath());
}
if (!marquee_path.empty() && (marquee_path[0] == '~'))
{
marquee_path.erase(0, 1);
marquee_path.insert(0, getHomePath());
}
if (!thumbnail_path.empty() && (thumbnail_path[0] == '~'))
{
thumbnail_path.erase(0, 1);
thumbnail_path.insert(0, getHomePath());
}
if (!mVideo->setVideo(video_path))
{ {
mVideo->setDefaultVideo(); mVideo->setDefaultVideo();
} }
mVideoPlaying = true; mVideoPlaying = true;
mVideo->setImage(thumbnail_path); mVideo->setImage(file->getThumbnailPath());
mMarquee.setImage(marquee_path); mMarquee.setImage(file->getMarqueePath());
mImage.setImage(thumbnail_path); mImage.setImage(file->getThumbnailPath());
mDescription.setText(file->metadata.get("desc")); mDescription.setText(file->metadata.get("desc"));
mDescContainer.reset(); mDescContainer.reset();