diff --git a/es-app/src/guis/GuiScreensaverOptions.cpp b/es-app/src/guis/GuiScreensaverOptions.cpp index e9d2f068c..6537694e5 100644 --- a/es-app/src/guis/GuiScreensaverOptions.cpp +++ b/es-app/src/guis/GuiScreensaverOptions.cpp @@ -1,5 +1,6 @@ #include "guis/GuiScreensaverOptions.h" +#include "guis/GuiTextEditPopup.h" #include "views/ViewController.h" #include "Settings.h" #include "SystemData.h" @@ -67,3 +68,30 @@ std::vector GuiScreensaverOptions::getHelpPrompts() return prompts; } + +void GuiScreensaverOptions::addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr ed, std::string value) +{ + row.elements.clear(); + + auto lbl = std::make_shared(mWindow, Utils::String::toUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); + row.addElement(lbl, true); // label + + row.addElement(ed, true); + + auto spacer = std::make_shared(mWindow); + spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0); + row.addElement(spacer, false); + + auto bracket = std::make_shared(mWindow); + bracket->setImage(":/arrow.svg"); + bracket->setResize(Vector2f(0, lbl->getFont()->getLetterHeight())); + row.addElement(bracket, false); + + auto updateVal = [ed](const std::string& newVal) { ed->setValue(newVal); }; // ok callback (apply new value to ed) + row.makeAcceptInputHandler([this, label, ed, updateVal] { + mWindow->pushGui(new GuiTextEditPopup(mWindow, label, ed->getValue(), updateVal, false)); + }); + assert(ed); + addRow(row); + ed->setValue(value); +} diff --git a/es-app/src/guis/GuiScreensaverOptions.h b/es-app/src/guis/GuiScreensaverOptions.h index 6f61489f8..cabcff3c5 100644 --- a/es-app/src/guis/GuiScreensaverOptions.h +++ b/es-app/src/guis/GuiScreensaverOptions.h @@ -15,6 +15,7 @@ public: inline void addRow(const ComponentListRow& row) { mMenu.addRow(row); }; inline void addWithLabel(const std::string& label, const std::shared_ptr& comp) { mMenu.addWithLabel(label, comp); }; inline void addSaveFunc(const std::function& func) { mSaveFuncs.push_back(func); }; + void addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr ed, std::string value); bool input(InputConfig* config, Input input) override; std::vector getHelpPrompts() override; diff --git a/es-app/src/guis/GuiSlideshowScreensaverOptions.cpp b/es-app/src/guis/GuiSlideshowScreensaverOptions.cpp index e29b3e2e9..9f3c5b9db 100644 --- a/es-app/src/guis/GuiSlideshowScreensaverOptions.cpp +++ b/es-app/src/guis/GuiSlideshowScreensaverOptions.cpp @@ -80,31 +80,3 @@ void GuiSlideshowScreensaverOptions::addWithLabel(ComponentListRow row, const st addRow(row); } - -void GuiSlideshowScreensaverOptions::addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr ed, std::string value) -{ - row.elements.clear(); - - auto lbl = std::make_shared(mWindow, Utils::String::toUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF); - row.addElement(lbl, true); // label - - row.addElement(ed, true); - - auto spacer = std::make_shared(mWindow); - spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0); - row.addElement(spacer, false); - - auto bracket = std::make_shared(mWindow); - bracket->setImage(":/arrow.svg"); - bracket->setResize(Vector2f(0, lbl->getFont()->getLetterHeight())); - row.addElement(bracket, false); - - auto updateVal = [ed](const std::string& newVal) { ed->setValue(newVal); }; // ok callback (apply new value to ed) - row.makeAcceptInputHandler([this, label, ed, updateVal] { - mWindow->pushGui(new GuiTextEditPopup(mWindow, label, ed->getValue(), updateVal, false)); - }); - - assert(ed); - addRow(row); - ed->setValue(value); -} diff --git a/es-app/src/guis/GuiSlideshowScreensaverOptions.h b/es-app/src/guis/GuiSlideshowScreensaverOptions.h index 70705d0d2..4232a69ba 100644 --- a/es-app/src/guis/GuiSlideshowScreensaverOptions.h +++ b/es-app/src/guis/GuiSlideshowScreensaverOptions.h @@ -12,7 +12,6 @@ public: private: void addWithLabel(ComponentListRow row, const std::string label, std::shared_ptr component); - void addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr ed, std::string value); }; #endif // ES_APP_GUIS_GUI_SLIDESHOW_SCREENSAVER_OPTIONS_H diff --git a/es-app/src/guis/GuiVideoScreensaverOptions.cpp b/es-app/src/guis/GuiVideoScreensaverOptions.cpp index b7489b0ec..b491c2ff1 100644 --- a/es-app/src/guis/GuiVideoScreensaverOptions.cpp +++ b/es-app/src/guis/GuiVideoScreensaverOptions.cpp @@ -18,6 +18,11 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha PowerSaver::updateTimeouts(); }); + auto stretch_screensaver = std::make_shared(mWindow); + stretch_screensaver->setState(Settings::getInstance()->getBool("StretchVideoOnScreenSaver")); + addWithLabel("STRETCH VIDEO ON SCREENSAVER", stretch_screensaver); + addSaveFunc([stretch_screensaver] { Settings::getInstance()->setBool("StretchVideoOnScreenSaver", stretch_screensaver->getState()); }); + #ifdef _RPI_ auto ss_omx = std::make_shared(mWindow); ss_omx->setState(Settings::getInstance()->getBool("ScreenSaverOmxPlayer")); @@ -36,17 +41,49 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info); addSaveFunc([ss_info, this] { Settings::getInstance()->setString("ScreenSaverGameInfo", ss_info->getSelected()); }); +#ifdef _RPI_ + ComponentListRow row; + + // Set subtitle position + auto ss_omx_subs_align = std::make_shared< OptionListComponent >(mWindow, "GAME INFO ALIGNMENT", false); + std::vector align_mode; + align_mode.push_back("left"); + align_mode.push_back("center"); + for(auto it = align_mode.cbegin(); it != align_mode.cend(); it++) + ss_omx_subs_align->add(*it, *it, Settings::getInstance()->getString("SubtitleAlignment") == *it); + addWithLabel("GAME INFO ALIGNMENT", ss_omx_subs_align); + addSaveFunc([ss_omx_subs_align, this] { Settings::getInstance()->setString("SubtitleAlignment", ss_omx_subs_align->getSelected()); }); + + // Set font size + auto ss_omx_font_size = std::make_shared(mWindow, 1.f, 64.f, 1.f, "h"); + ss_omx_font_size->setValue((float)(Settings::getInstance()->getInt("SubtitleSize"))); + addWithLabel("GAME INFO FONT SIZE", ss_omx_font_size); + addSaveFunc([ss_omx_font_size] { + int subSize = (int)Math::round(ss_omx_font_size->getValue()); + Settings::getInstance()->setInt("SubtitleSize", subSize); + }); + + // Define subtitle font + auto ss_omx_font_file = std::make_shared(mWindow, "", Font::get(FONT_SIZE_SMALL), 0x777777FF); + addEditableTextComponent(row, "PATH TO FONT FILE", ss_omx_font_file, Settings::getInstance()->getString("SubtitleFont")); + addSaveFunc([ss_omx_font_file] { + Settings::getInstance()->setString("SubtitleFont", ss_omx_font_file->getValue()); + }); + + // Define subtitle italic font + auto ss_omx_italic_font_file = std::make_shared(mWindow, "", Font::get(FONT_SIZE_SMALL), 0x777777FF); + addEditableTextComponent(row, "PATH TO ITALIC FONT FILE", ss_omx_italic_font_file, Settings::getInstance()->getString("SubtitleItalicFont")); + addSaveFunc([ss_omx_italic_font_file] { + Settings::getInstance()->setString("SubtitleItalicFont", ss_omx_italic_font_file->getValue()); + }); +#endif + #ifndef _RPI_ auto captions_compatibility = std::make_shared(mWindow); captions_compatibility->setState(Settings::getInstance()->getBool("CaptionsCompatibility")); addWithLabel("USE COMPATIBLE LOW RESOLUTION FOR CAPTIONS", captions_compatibility); addSaveFunc([captions_compatibility] { Settings::getInstance()->setBool("CaptionsCompatibility", captions_compatibility->getState()); }); #endif - - auto stretch_screensaver = std::make_shared(mWindow); - stretch_screensaver->setState(Settings::getInstance()->getBool("StretchVideoOnScreenSaver")); - addWithLabel("STRETCH VIDEO ON SCREENSAVER", stretch_screensaver); - addSaveFunc([stretch_screensaver] { Settings::getInstance()->setBool("StretchVideoOnScreenSaver", stretch_screensaver->getState()); }); } GuiVideoScreensaverOptions::~GuiVideoScreensaverOptions() diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 13c09a84a..c51f653f0 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -117,6 +117,11 @@ void Settings::setDefaults() #ifdef _RPI_ // we're defaulting to OMX Player for full screen video on the Pi mBoolMap["ScreenSaverOmxPlayer"] = true; + // use OMX Player defaults + mStringMap["SubtitleFont"] = "/usr/share/fonts/truetype/freefont/FreeSans.ttf"; + mStringMap["SubtitleItalicFont"] = "/usr/share/fonts/truetype/freefont/FreeSansOblique.ttf"; + mIntMap["SubtitleSize"] = 55; + mStringMap["SubtitleAlignment"] = "left"; #else mBoolMap["ScreenSaverOmxPlayer"] = false; #endif diff --git a/es-core/src/components/VideoPlayerComponent.cpp b/es-core/src/components/VideoPlayerComponent.cpp index eeaba9177..0b0948e42 100644 --- a/es-core/src/components/VideoPlayerComponent.cpp +++ b/es-core/src/components/VideoPlayerComponent.cpp @@ -156,7 +156,7 @@ void VideoPlayerComponent::startVideo() // We need to specify the layer of 10000 or above to ensure the video is displayed on top // of our SDL display - const char* argv[] = { "", "--layer", "10010", "--loop", "--no-osd", "--aspect-mode", "letterbox", "--vol", "0", "-o", "both","--win", buf1, "--orientation", buf2, "", "", "", "", NULL }; + const char* argv[] = { "", "--layer", "10010", "--loop", "--no-osd", "--aspect-mode", "letterbox", "--vol", "0", "-o", "both","--win", buf1, "--orientation", buf2, "", "", "", "", "", "", "", "", "", "", "", NULL }; // check if we want to mute the audio if (!Settings::getInstance()->getBool("VideoAudio") || (float)VolumeControl::getInstance()->getVolume() == 0) @@ -187,6 +187,14 @@ void VideoPlayerComponent::startVideo() argv[15] = "--subtitles"; argv[16] = subtitlePath.c_str(); argv[17] = mPlayingVideoPath.c_str(); + argv[18] = "--font"; + argv[19] = Settings::getInstance()->getString("SubtitleFont").c_str(); + argv[20] = "--italic-font"; + argv[21] = Settings::getInstance()->getString("SubtitleItalicFont").c_str(); + argv[22] = "--font-size"; + argv[23] = std::to_string(Settings::getInstance()->getInt("SubtitleSize")).c_str(); + argv[24] = "--align"; + argv[25] = Settings::getInstance()->getString("SubtitleAlignment").c_str(); } else {