mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 08:05:38 +00:00
Added checks for valid imageType property values to ImageComponent and VideoComponent.
This commit is contained in:
parent
9d2a9ed9d9
commit
0b34bd8991
|
@ -555,6 +555,32 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
imageTypes = Utils::String::replace(imageTypes, ",,", ",");
|
imageTypes = Utils::String::replace(imageTypes, ",,", ",");
|
||||||
mThemeImageTypes = Utils::String::delimitedStringToVector(imageTypes, ",");
|
mThemeImageTypes = Utils::String::delimitedStringToVector(imageTypes, ",");
|
||||||
|
|
||||||
|
if (mThemeImageTypes.empty()) {
|
||||||
|
LOG(LogError) << "ImageComponent: Invalid theme configuration, property <imageType> "
|
||||||
|
"contains no values";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::string& type : mThemeImageTypes) {
|
||||||
|
if (std::find(supportedImageTypes.cbegin(), supportedImageTypes.cend(), type) ==
|
||||||
|
supportedImageTypes.cend()) {
|
||||||
|
LOG(LogError)
|
||||||
|
<< "ImageComponent: Invalid theme configuration, property <imageType> "
|
||||||
|
"defined as \""
|
||||||
|
<< type << "\"";
|
||||||
|
mThemeImageTypes.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> sortedTypes {mThemeImageTypes};
|
||||||
|
std::stable_sort(sortedTypes.begin(), sortedTypes.end());
|
||||||
|
|
||||||
|
if (std::adjacent_find(sortedTypes.begin(), sortedTypes.end()) != sortedTypes.end()) {
|
||||||
|
LOG(LogError) << "ImageComponent: Invalid theme configuration, property <imageType> "
|
||||||
|
"contains duplicate values";
|
||||||
|
mThemeImageTypes.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("metadataElement") && elem->get<bool>("metadataElement"))
|
if (elem->has("metadataElement") && elem->get<bool>("metadataElement"))
|
||||||
|
|
|
@ -128,6 +128,10 @@ private:
|
||||||
|
|
||||||
std::string mDefaultPath;
|
std::string mDefaultPath;
|
||||||
|
|
||||||
|
static inline std::vector<std::string> supportedImageTypes {
|
||||||
|
"image", "miximage", "marquee", "screenshot", "titlescreen",
|
||||||
|
"cover", "backcover", "3dbox", "physicalmedia", "fanart"};
|
||||||
|
|
||||||
std::shared_ptr<TextureResource> mTexture;
|
std::shared_ptr<TextureResource> mTexture;
|
||||||
float mFadeOpacity;
|
float mFadeOpacity;
|
||||||
float mReflectionsFalloff;
|
float mReflectionsFalloff;
|
||||||
|
|
|
@ -206,6 +206,32 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
imageTypes = Utils::String::replace(imageTypes, ",,", ",");
|
imageTypes = Utils::String::replace(imageTypes, ",,", ",");
|
||||||
mThemeImageTypes = Utils::String::delimitedStringToVector(imageTypes, ",");
|
mThemeImageTypes = Utils::String::delimitedStringToVector(imageTypes, ",");
|
||||||
|
|
||||||
|
if (mThemeImageTypes.empty()) {
|
||||||
|
LOG(LogError) << "VideoComponent: Invalid theme configuration, property <imageType> "
|
||||||
|
"contains no values";
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::string& type : mThemeImageTypes) {
|
||||||
|
if (std::find(supportedImageTypes.cbegin(), supportedImageTypes.cend(), type) ==
|
||||||
|
supportedImageTypes.cend()) {
|
||||||
|
LOG(LogError)
|
||||||
|
<< "VideoComponent: Invalid theme configuration, property <imageType> "
|
||||||
|
"defined as \""
|
||||||
|
<< type << "\"";
|
||||||
|
mThemeImageTypes.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> sortedTypes {mThemeImageTypes};
|
||||||
|
std::stable_sort(sortedTypes.begin(), sortedTypes.end());
|
||||||
|
|
||||||
|
if (std::adjacent_find(sortedTypes.begin(), sortedTypes.end()) != sortedTypes.end()) {
|
||||||
|
LOG(LogError) << "VideoComponent: Invalid theme configuration, property <imageType> "
|
||||||
|
"contains duplicate values";
|
||||||
|
mThemeImageTypes.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("pillarboxes"))
|
if (elem->has("pillarboxes"))
|
||||||
|
|
|
@ -113,6 +113,10 @@ protected:
|
||||||
std::string mStaticImagePath;
|
std::string mStaticImagePath;
|
||||||
std::string mDefaultImagePath;
|
std::string mDefaultImagePath;
|
||||||
|
|
||||||
|
static inline std::vector<std::string> supportedImageTypes {
|
||||||
|
"image", "miximage", "marquee", "screenshot", "titlescreen",
|
||||||
|
"cover", "backcover", "3dbox", "physicalmedia", "fanart"};
|
||||||
|
|
||||||
std::string mVideoPath;
|
std::string mVideoPath;
|
||||||
unsigned mStartTime;
|
unsigned mStartTime;
|
||||||
std::atomic<bool> mIsPlaying;
|
std::atomic<bool> mIsPlaying;
|
||||||
|
|
Loading…
Reference in a new issue