mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Added support for .webp, .svg and unanimated .gif files to the slideshow screensaver when using a custom image directory
Also changed the default slideshow custom image directory from slideshow/custom_images to screensavers/custom_slideshow and improved the menu entry for setting the custom directory. Changed the setting ScreensaverSlideshowImageDir to blank by default
This commit is contained in:
parent
e851f1205f
commit
9283ab71fa
|
@ -464,8 +464,14 @@ void Screensaver::generateVideoList()
|
||||||
|
|
||||||
void Screensaver::generateCustomImageList()
|
void Screensaver::generateCustomImageList()
|
||||||
{
|
{
|
||||||
std::string imageDir = Utils::FileSystem::expandHomePath(
|
std::string imageDir {Utils::FileSystem::expandHomePath(
|
||||||
Settings::getInstance()->getString("ScreensaverSlideshowImageDir"));
|
Settings::getInstance()->getString("ScreensaverSlideshowImageDir"))};
|
||||||
|
|
||||||
|
if (imageDir.empty())
|
||||||
|
imageDir = Utils::FileSystem::getAppDataDirectory()
|
||||||
|
.append("screensavers")
|
||||||
|
.append("custom_slideshow")
|
||||||
|
.string();
|
||||||
|
|
||||||
// This makes it possible to set the custom image directory relative to the ES-DE binary
|
// This makes it possible to set the custom image directory relative to the ES-DE binary
|
||||||
// directory or the ROM directory.
|
// directory or the ROM directory.
|
||||||
|
@ -473,19 +479,23 @@ void Screensaver::generateCustomImageList()
|
||||||
imageDir = Utils::String::replace(imageDir, "%ROMPATH%", FileData::getROMDirectory());
|
imageDir = Utils::String::replace(imageDir, "%ROMPATH%", FileData::getROMDirectory());
|
||||||
|
|
||||||
if (imageDir != "" && Utils::FileSystem::isDirectory(imageDir)) {
|
if (imageDir != "" && Utils::FileSystem::isDirectory(imageDir)) {
|
||||||
std::string imageFilter {".jpg, .JPG, .png, .PNG"};
|
const std::vector<std::string> extList {".jpg", ".JPG", ".png", ".PNG", ".gif",
|
||||||
Utils::FileSystem::StringList dirContent = Utils::FileSystem::getDirContent(
|
".GIF", ".webp", ".WEBP", ".svg", ".SVG"};
|
||||||
imageDir, Settings::getInstance()->getBool("ScreensaverSlideshowRecurse"));
|
|
||||||
|
Utils::FileSystem::StringList dirContent {Utils::FileSystem::getDirContent(
|
||||||
|
imageDir, Settings::getInstance()->getBool("ScreensaverSlideshowRecurse"))};
|
||||||
|
|
||||||
for (auto it = dirContent.begin(); it != dirContent.end(); ++it) {
|
for (auto it = dirContent.begin(); it != dirContent.end(); ++it) {
|
||||||
if (Utils::FileSystem::isRegularFile(*it)) {
|
if (Utils::FileSystem::isRegularFile(*it)) {
|
||||||
if (imageFilter.find(Utils::FileSystem::getExtension(*it)) != std::string::npos)
|
if (std::find(extList.cbegin(), extList.cend(),
|
||||||
|
Utils::FileSystem::getExtension(*it)) != extList.cend())
|
||||||
mImageCustomFiles.push_back(*it);
|
mImageCustomFiles.push_back(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG(LogWarning) << "Custom screensaver image directory '" << imageDir << "' does not exist";
|
LOG(LogWarning) << "Custom screensaver image directory \"" << imageDir
|
||||||
|
<< "\" does not exist";
|
||||||
}
|
}
|
||||||
|
|
||||||
mCustomFilesInventory.insert(mCustomFilesInventory.begin(), mImageCustomFiles.begin(),
|
mCustomFilesInventory.insert(mCustomFilesInventory.begin(), mImageCustomFiles.begin(),
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include "components/SliderComponent.h"
|
#include "components/SliderComponent.h"
|
||||||
#include "components/SwitchComponent.h"
|
#include "components/SwitchComponent.h"
|
||||||
#include "guis/GuiMsgBox.h"
|
#include "guis/GuiMsgBox.h"
|
||||||
|
#include "guis/GuiTextEditKeyboardPopup.h"
|
||||||
|
#include "guis/GuiTextEditPopup.h"
|
||||||
|
|
||||||
GuiScreensaverOptions::GuiScreensaverOptions(const std::string& title)
|
GuiScreensaverOptions::GuiScreensaverOptions(const std::string& title)
|
||||||
: GuiSettings {title}
|
: GuiSettings {title}
|
||||||
|
@ -196,20 +198,48 @@ void GuiScreensaverOptions::openSlideshowScreensaverOptions()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Custom image directory.
|
// Custom image directory.
|
||||||
|
ComponentListRow rowCustomImageDir;
|
||||||
auto screensaverSlideshowImageDir = std::make_shared<TextComponent>(
|
auto screensaverSlideshowImageDir = std::make_shared<TextComponent>(
|
||||||
"", Font::get(FONT_SIZE_SMALL), mMenuColorPrimary, ALIGN_RIGHT);
|
"CUSTOM IMAGE DIRECTORY", Font::get(FONT_SIZE_MEDIUM), mMenuColorPrimary);
|
||||||
s->addEditableTextComponent(
|
auto bracketCustomImageDir = std::make_shared<ImageComponent>();
|
||||||
"CUSTOM IMAGE DIRECTORY", screensaverSlideshowImageDir,
|
bracketCustomImageDir->setResize(
|
||||||
Settings::getInstance()->getString("ScreensaverSlideshowImageDir"),
|
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
||||||
Settings::getInstance()->getDefaultString("ScreensaverSlideshowImageDir"));
|
bracketCustomImageDir->setImage(":/graphics/arrow.svg");
|
||||||
s->addSaveFunc([screensaverSlideshowImageDir, s] {
|
bracketCustomImageDir->setColorShift(mMenuColorPrimary);
|
||||||
if (screensaverSlideshowImageDir->getValue() !=
|
rowCustomImageDir.addElement(screensaverSlideshowImageDir, true);
|
||||||
Settings::getInstance()->getString("ScreensaverSlideshowImageDir")) {
|
rowCustomImageDir.addElement(bracketCustomImageDir, false);
|
||||||
Settings::getInstance()->setString("ScreensaverSlideshowImageDir",
|
const std::string titleCustomImageDir {"CUSTOM IMAGE DIRECTORY"};
|
||||||
screensaverSlideshowImageDir->getValue());
|
const std::string defaultImageDirStaticText {"Default directory:"};
|
||||||
s->setNeedsSaving();
|
const std::string defaultImageDirText {Utils::FileSystem::getAppDataDirectory()
|
||||||
}
|
.append("screensavers")
|
||||||
});
|
.append("custom_slideshow")
|
||||||
|
.string()};
|
||||||
|
const std::string initValueMediaDir {
|
||||||
|
Settings::getInstance()->getString("ScreensaverSlideshowImageDir")};
|
||||||
|
const bool multiLineMediaDir {false};
|
||||||
|
auto updateValMediaDir = [this, s](const std::string& newVal) {
|
||||||
|
Settings::getInstance()->setString("ScreensaverSlideshowImageDir", newVal);
|
||||||
|
s->setNeedsSaving();
|
||||||
|
};
|
||||||
|
rowCustomImageDir.makeAcceptInputHandler(
|
||||||
|
[this, s, titleCustomImageDir, defaultImageDirStaticText, defaultImageDirText,
|
||||||
|
initValueMediaDir, updateValMediaDir, multiLineMediaDir] {
|
||||||
|
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
|
||||||
|
mWindow->pushGui(new GuiTextEditKeyboardPopup(
|
||||||
|
getHelpStyle(), s->getMenu().getPosition().y, titleCustomImageDir,
|
||||||
|
Settings::getInstance()->getString("ScreensaverSlideshowImageDir"),
|
||||||
|
updateValMediaDir, multiLineMediaDir, "SAVE", "SAVE CHANGES?",
|
||||||
|
defaultImageDirStaticText, defaultImageDirText, "load default directory"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mWindow->pushGui(new GuiTextEditPopup(
|
||||||
|
getHelpStyle(), titleCustomImageDir,
|
||||||
|
Settings::getInstance()->getString("ScreensaverSlideshowImageDir"),
|
||||||
|
updateValMediaDir, multiLineMediaDir, "SAVE", "SAVE CHANGES?",
|
||||||
|
defaultImageDirStaticText, defaultImageDirText, "load default directory"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
s->addRow(rowCustomImageDir);
|
||||||
|
|
||||||
s->setSize(mSize);
|
s->setSize(mSize);
|
||||||
mWindow->pushGui(s);
|
mWindow->pushGui(s);
|
||||||
|
|
|
@ -202,8 +202,7 @@ void Settings::setDefaults()
|
||||||
mBoolMap["ScreensaverSlideshowScanlines"] = {false, false};
|
mBoolMap["ScreensaverSlideshowScanlines"] = {false, false};
|
||||||
mBoolMap["ScreensaverSlideshowCustomImages"] = {false, false};
|
mBoolMap["ScreensaverSlideshowCustomImages"] = {false, false};
|
||||||
mBoolMap["ScreensaverSlideshowRecurse"] = {false, false};
|
mBoolMap["ScreensaverSlideshowRecurse"] = {false, false};
|
||||||
mStringMap["ScreensaverSlideshowImageDir"] = {"~/.emulationstation/slideshow/custom_images",
|
mStringMap["ScreensaverSlideshowImageDir"] = {"", ""};
|
||||||
"~/.emulationstation/slideshow/custom_images"};
|
|
||||||
|
|
||||||
// UI settings -> screensaver settings -> video screensaver settings.
|
// UI settings -> screensaver settings -> video screensaver settings.
|
||||||
mIntMap["ScreensaverSwapVideoTimeout"] = {0, 0};
|
mIntMap["ScreensaverSwapVideoTimeout"] = {0, 0};
|
||||||
|
|
Loading…
Reference in a new issue