diff --git a/es-core/src/components/primary/CarouselComponent.h b/es-core/src/components/primary/CarouselComponent.h index 00a81eed9..1ee2d3b9d 100644 --- a/es-core/src/components/primary/CarouselComponent.h +++ b/es-core/src/components/primary/CarouselComponent.h @@ -61,10 +61,10 @@ public: Entry& getEntry(int index) { return mEntries.at(index); } void onDemandTextureLoad() override; const CarouselType getType() { return mType; } - const std::string& getDefaultCarouselImage() const { return mDefaultImage; } - const std::string& getDefaultCarouselFolderImage() const { return mDefaultFolderImage; } - void setDefaultImage(std::string defaultImage) { mDefaultImage = defaultImage; } - void setDefaultFolderImage(std::string defaultImage) { mDefaultFolderImage = defaultImage; } + const std::string& getDefaultCarouselImage() const { return mDefaultImagePath; } + const std::string& getDefaultCarouselFolderImage() const { return mDefaultFolderImagePath; } + void setDefaultImage(std::string defaultImage) { mDefaultImagePath = defaultImage; } + void setDefaultFolderImage(std::string defaultImage) { mDefaultFolderImagePath = defaultImage; } bool isScrolling() const override { return List::isScrolling(); } const LetterCase getLetterCase() const override { return mLetterCase; } const LetterCase getLetterCaseAutoCollections() const override @@ -144,8 +144,9 @@ private: CarouselType mType; std::vector mImageTypes; - std::string mDefaultImage; - std::string mDefaultFolderImage; + std::string mDefaultImagePath; + std::string mDefaultFolderImagePath; + std::shared_ptr mDefaultImage; float mMaxItemCount; int mItemsBeforeCenter; int mItemsAfterCenter; @@ -319,27 +320,29 @@ void CarouselComponent::addEntry(Entry& entry, const std::shared_ptr(false, dynamic); - defaultImage->setLinearInterpolation(mLinearInterpolation); - defaultImage->setMipmapping(true); - defaultImage->setMaxSize( - glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f))); - defaultImage->setImage(entry.data.defaultImagePath); - defaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL); - if (mImageBrightness != 0.0) - defaultImage->setBrightness(mImageBrightness); - if (mImageSaturation != 1.0) - defaultImage->setSaturation(mImageSaturation); - if (mImageColorShift != 0xFFFFFFFF) - defaultImage->setColorShift(mImageColorShift); - if (mImageColorShiftEnd != mImageColorShift) - defaultImage->setColorShiftEnd(mImageColorShiftEnd); - if (!mImageColorGradientHorizontal) - defaultImage->setColorGradientHorizontal(false); - defaultImage->setRotateByTargetSize(true); + if (mDefaultImage.get() == nullptr || !mGamelistView) { + mDefaultImage = std::make_shared(false, dynamic); + mDefaultImage->setLinearInterpolation(mLinearInterpolation); + mDefaultImage->setMipmapping(true); + mDefaultImage->setMaxSize( + glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f))); + mDefaultImage->setImage(entry.data.defaultImagePath); + mDefaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL); + if (mImageBrightness != 0.0) + mDefaultImage->setBrightness(mImageBrightness); + if (mImageSaturation != 1.0) + mDefaultImage->setSaturation(mImageSaturation); + if (mImageColorShift != 0xFFFFFFFF) + mDefaultImage->setColorShift(mImageColorShift); + if (mImageColorShiftEnd != mImageColorShift) + mDefaultImage->setColorShiftEnd(mImageColorShiftEnd); + if (!mImageColorGradientHorizontal) + mDefaultImage->setColorGradientHorizontal(false); + mDefaultImage->setRotateByTargetSize(true); + } // For the gamelist view the default image is applied in onDemandTextureLoad(). if (!mGamelistView) - entry.data.item = defaultImage; + entry.data.item = mDefaultImage; } else if (!mGamelistView) { entry.data.imagePath = ""; diff --git a/es-core/src/components/primary/GridComponent.h b/es-core/src/components/primary/GridComponent.h index 0fe3b2302..4272bac69 100644 --- a/es-core/src/components/primary/GridComponent.h +++ b/es-core/src/components/primary/GridComponent.h @@ -71,10 +71,10 @@ public: { return mLetterCaseSystemNameSuffix; } - const std::string& getDefaultGridImage() const { return mDefaultImage; } - const std::string& getDefaultGridFolderImage() const { return mDefaultFolderImage; } - void setDefaultImage(std::string defaultImage) { mDefaultImage = defaultImage; } - void setDefaultFolderImage(std::string defaultImage) { mDefaultFolderImage = defaultImage; } + const std::string& getDefaultGridImage() const { return mDefaultImagePath; } + const std::string& getDefaultGridFolderImage() const { return mDefaultFolderImagePath; } + void setDefaultImage(std::string defaultImage) { mDefaultImagePath = defaultImage; } + void setDefaultFolderImage(std::string defaultImage) { mDefaultFolderImagePath = defaultImage; } bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; void render(const glm::mat4& parentTrans) override; @@ -145,8 +145,9 @@ private: float mVerticalMargin; std::vector mImageTypes; - std::string mDefaultImage; - std::string mDefaultFolderImage; + std::string mDefaultImagePath; + std::string mDefaultFolderImagePath; + std::shared_ptr mDefaultImage; glm::vec2 mItemSize; float mItemScale; glm::vec2 mItemSpacing; @@ -309,33 +310,36 @@ void GridComponent::addEntry(Entry& entry, const std::shared_ptr& ResourceManager::getInstance().fileExists(entry.data.defaultImagePath)) { if (!mGamelistView) entry.data.imagePath = ""; - auto defaultImage = std::make_shared(false, dynamic); - defaultImage->setLinearInterpolation(true); - defaultImage->setMipmapping(true); - if (mImagefit == ImageFit::CONTAIN) - defaultImage->setMaxSize(mItemSize * mImageRelativeScale); - else if (mImagefit == ImageFit::FILL) - defaultImage->setResize(mItemSize * mImageRelativeScale); - else if (mImagefit == ImageFit::COVER) - defaultImage->setCroppedSize(mItemSize * mImageRelativeScale); - defaultImage->setImage(entry.data.defaultImagePath); - defaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL); - if (mImageBrightness != 0.0) - defaultImage->setBrightness(mImageBrightness); - if (mImageSaturation != 1.0) - defaultImage->setSaturation(mImageSaturation); - if (mImageColor != 0xFFFFFFFF) - defaultImage->setColorShift(mImageColor); - if (mImageColorEnd != mImageColor) { - defaultImage->setColorShiftEnd(mImageColorEnd); - if (!mImageColorGradientHorizontal) - defaultImage->setColorGradientHorizontal(false); + + if (mDefaultImage.get() == nullptr || !mGamelistView) { + mDefaultImage = std::make_shared(false, dynamic); + mDefaultImage->setLinearInterpolation(true); + mDefaultImage->setMipmapping(true); + if (mImagefit == ImageFit::CONTAIN) + mDefaultImage->setMaxSize(mItemSize * mImageRelativeScale); + else if (mImagefit == ImageFit::FILL) + mDefaultImage->setResize(mItemSize * mImageRelativeScale); + else if (mImagefit == ImageFit::COVER) + mDefaultImage->setCroppedSize(mItemSize * mImageRelativeScale); + mDefaultImage->setImage(entry.data.defaultImagePath); + mDefaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL); + if (mImageBrightness != 0.0) + mDefaultImage->setBrightness(mImageBrightness); + if (mImageSaturation != 1.0) + mDefaultImage->setSaturation(mImageSaturation); + if (mImageColor != 0xFFFFFFFF) + mDefaultImage->setColorShift(mImageColor); + if (mImageColorEnd != mImageColor) { + mDefaultImage->setColorShiftEnd(mImageColorEnd); + if (!mImageColorGradientHorizontal) + mDefaultImage->setColorGradientHorizontal(false); + } + mDefaultImage->setOrigin(0.5f, 0.5f); + mDefaultImage->setRotateByTargetSize(true); } - defaultImage->setOrigin(0.5f, 0.5f); - defaultImage->setRotateByTargetSize(true); // For the gamelist view the default image is applied in onDemandTextureLoad(). if (!mGamelistView) - entry.data.item = defaultImage; + entry.data.item = mDefaultImage; } else if (!mGamelistView) { entry.data.imagePath = "";