mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-22 14:25:39 +00:00
Added GIF animation support to GamelistView.
This commit is contained in:
parent
ed540359c5
commit
46fd4ce5cc
es-app/src/views
|
@ -16,6 +16,7 @@
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "components/BadgeComponent.h"
|
#include "components/BadgeComponent.h"
|
||||||
#include "components/DateTimeComponent.h"
|
#include "components/DateTimeComponent.h"
|
||||||
|
#include "components/GIFAnimComponent.h"
|
||||||
#include "components/LottieAnimComponent.h"
|
#include "components/LottieAnimComponent.h"
|
||||||
#include "components/RatingComponent.h"
|
#include "components/RatingComponent.h"
|
||||||
#include "components/ScrollableContainer.h"
|
#include "components/ScrollableContainer.h"
|
||||||
|
|
|
@ -67,18 +67,16 @@ void GamelistView::onFileChanged(FileData* file, bool reloadGamelist)
|
||||||
|
|
||||||
void GamelistView::onShow()
|
void GamelistView::onShow()
|
||||||
{
|
{
|
||||||
// Reset any Lottie animations.
|
// Reset any GIF and Lottie animations.
|
||||||
for (auto& animation : mLottieAnimComponents)
|
for (auto& animation : mLottieAnimComponents)
|
||||||
animation->resetFileAnimation();
|
animation->resetFileAnimation();
|
||||||
|
|
||||||
// Reset any Lottie animations.
|
for (auto& animation : mGIFAnimComponents)
|
||||||
if (mLegacyMode) {
|
animation->resetFileAnimation();
|
||||||
for (auto extra : mThemeExtras)
|
|
||||||
extra->resetFileAnimation();
|
|
||||||
}
|
|
||||||
|
|
||||||
mLastUpdated = nullptr;
|
mLastUpdated = nullptr;
|
||||||
GuiComponent::onShow();
|
GuiComponent::onShow();
|
||||||
|
|
||||||
if (mLegacyMode)
|
if (mLegacyMode)
|
||||||
legacyUpdateInfoPanel();
|
legacyUpdateInfoPanel();
|
||||||
else
|
else
|
||||||
|
@ -89,6 +87,9 @@ void GamelistView::onTransition()
|
||||||
{
|
{
|
||||||
for (auto& animation : mLottieAnimComponents)
|
for (auto& animation : mLottieAnimComponents)
|
||||||
animation->setPauseAnimation(true);
|
animation->setPauseAnimation(true);
|
||||||
|
|
||||||
|
for (auto& animation : mGIFAnimComponents)
|
||||||
|
animation->setPauseAnimation(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
|
@ -125,11 +126,32 @@ void GamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
if (mVideoComponents.back()->getThemeImageTypes().size() != 0)
|
if (mVideoComponents.back()->getThemeImageTypes().size() != 0)
|
||||||
mVideoComponents.back()->setScrollHide(true);
|
mVideoComponents.back()->setScrollHide(true);
|
||||||
}
|
}
|
||||||
else if (element.second.type == "animation") {
|
else if (element.second.type == "animation" && element.second.has("path")) {
|
||||||
mLottieAnimComponents.push_back(std::make_unique<LottieAnimComponent>());
|
const std::string extension {
|
||||||
mLottieAnimComponents.back()->setDefaultZIndex(35.0f);
|
Utils::FileSystem::getExtension(element.second.get<std::string>("path"))};
|
||||||
mLottieAnimComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
|
if (extension == ".json") {
|
||||||
addChild(mLottieAnimComponents.back().get());
|
mLottieAnimComponents.push_back(std::make_unique<LottieAnimComponent>());
|
||||||
|
mLottieAnimComponents.back()->setDefaultZIndex(35.0f);
|
||||||
|
mLottieAnimComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
|
||||||
|
addChild(mLottieAnimComponents.back().get());
|
||||||
|
}
|
||||||
|
else if (extension == ".gif") {
|
||||||
|
mGIFAnimComponents.push_back(std::make_unique<GIFAnimComponent>());
|
||||||
|
mGIFAnimComponents.back()->setDefaultZIndex(35.0f);
|
||||||
|
mGIFAnimComponents.back()->applyTheme(theme, "gamelist", element.first, ALL);
|
||||||
|
addChild(mGIFAnimComponents.back().get());
|
||||||
|
}
|
||||||
|
else if (extension == ".") {
|
||||||
|
LOG(LogWarning)
|
||||||
|
<< "GamelistView::onThemeChanged(): Invalid theme configuration, "
|
||||||
|
"animation file extension is missing";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG(LogWarning)
|
||||||
|
<< "GamelistView::onThemeChanged(): Invalid theme configuration, "
|
||||||
|
"animation file extension defined as \""
|
||||||
|
<< extension << "\"";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (element.second.type == "badges") {
|
else if (element.second.type == "badges") {
|
||||||
mBadgeComponents.push_back(std::make_unique<BadgeComponent>());
|
mBadgeComponents.push_back(std::make_unique<BadgeComponent>());
|
||||||
|
|
|
@ -101,6 +101,7 @@ private:
|
||||||
std::vector<std::unique_ptr<ImageComponent>> mImageComponents;
|
std::vector<std::unique_ptr<ImageComponent>> mImageComponents;
|
||||||
std::vector<std::unique_ptr<VideoFFmpegComponent>> mVideoComponents;
|
std::vector<std::unique_ptr<VideoFFmpegComponent>> mVideoComponents;
|
||||||
std::vector<std::unique_ptr<LottieAnimComponent>> mLottieAnimComponents;
|
std::vector<std::unique_ptr<LottieAnimComponent>> mLottieAnimComponents;
|
||||||
|
std::vector<std::unique_ptr<GIFAnimComponent>> mGIFAnimComponents;
|
||||||
std::vector<std::unique_ptr<BadgeComponent>> mBadgeComponents;
|
std::vector<std::unique_ptr<BadgeComponent>> mBadgeComponents;
|
||||||
std::vector<std::unique_ptr<RatingComponent>> mRatingComponents;
|
std::vector<std::unique_ptr<RatingComponent>> mRatingComponents;
|
||||||
std::vector<std::unique_ptr<ScrollableContainer>> mContainerComponents;
|
std::vector<std::unique_ptr<ScrollableContainer>> mContainerComponents;
|
||||||
|
|
Loading…
Reference in a new issue