mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
Merge pull request #569 from danovision/subtitle-font-settings
Add Game Info Font Settings to OMX Player
This commit is contained in:
commit
6defa8ef1c
|
@ -1,5 +1,6 @@
|
||||||
#include "guis/GuiScreensaverOptions.h"
|
#include "guis/GuiScreensaverOptions.h"
|
||||||
|
|
||||||
|
#include "guis/GuiTextEditPopup.h"
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
|
@ -67,3 +68,30 @@ std::vector<HelpPrompt> GuiScreensaverOptions::getHelpPrompts()
|
||||||
|
|
||||||
return prompts;
|
return prompts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiScreensaverOptions::addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr<GuiComponent> ed, std::string value)
|
||||||
|
{
|
||||||
|
row.elements.clear();
|
||||||
|
|
||||||
|
auto lbl = std::make_shared<TextComponent>(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<GuiComponent>(mWindow);
|
||||||
|
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0);
|
||||||
|
row.addElement(spacer, false);
|
||||||
|
|
||||||
|
auto bracket = std::make_shared<ImageComponent>(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);
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ public:
|
||||||
inline void addRow(const ComponentListRow& row) { mMenu.addRow(row); };
|
inline void addRow(const ComponentListRow& row) { mMenu.addRow(row); };
|
||||||
inline void addWithLabel(const std::string& label, const std::shared_ptr<GuiComponent>& comp) { mMenu.addWithLabel(label, comp); };
|
inline void addWithLabel(const std::string& label, const std::shared_ptr<GuiComponent>& comp) { mMenu.addWithLabel(label, comp); };
|
||||||
inline void addSaveFunc(const std::function<void()>& func) { mSaveFuncs.push_back(func); };
|
inline void addSaveFunc(const std::function<void()>& func) { mSaveFuncs.push_back(func); };
|
||||||
|
void addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr<GuiComponent> ed, std::string value);
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
std::vector<HelpPrompt> getHelpPrompts() override;
|
std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
|
|
|
@ -80,31 +80,3 @@ void GuiSlideshowScreensaverOptions::addWithLabel(ComponentListRow row, const st
|
||||||
|
|
||||||
addRow(row);
|
addRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiSlideshowScreensaverOptions::addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr<GuiComponent> ed, std::string value)
|
|
||||||
{
|
|
||||||
row.elements.clear();
|
|
||||||
|
|
||||||
auto lbl = std::make_shared<TextComponent>(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<GuiComponent>(mWindow);
|
|
||||||
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0);
|
|
||||||
row.addElement(spacer, false);
|
|
||||||
|
|
||||||
auto bracket = std::make_shared<ImageComponent>(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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addWithLabel(ComponentListRow row, const std::string label, std::shared_ptr<GuiComponent> component);
|
void addWithLabel(ComponentListRow row, const std::string label, std::shared_ptr<GuiComponent> component);
|
||||||
void addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr<GuiComponent> ed, std::string value);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_GUIS_GUI_SLIDESHOW_SCREENSAVER_OPTIONS_H
|
#endif // ES_APP_GUIS_GUI_SLIDESHOW_SCREENSAVER_OPTIONS_H
|
||||||
|
|
|
@ -18,6 +18,11 @@ GuiVideoScreensaverOptions::GuiVideoScreensaverOptions(Window* window, const cha
|
||||||
PowerSaver::updateTimeouts();
|
PowerSaver::updateTimeouts();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
auto stretch_screensaver = std::make_shared<SwitchComponent>(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_
|
#ifdef _RPI_
|
||||||
auto ss_omx = std::make_shared<SwitchComponent>(mWindow);
|
auto ss_omx = std::make_shared<SwitchComponent>(mWindow);
|
||||||
ss_omx->setState(Settings::getInstance()->getBool("ScreenSaverOmxPlayer"));
|
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);
|
addWithLabel("SHOW GAME INFO ON SCREENSAVER", ss_info);
|
||||||
addSaveFunc([ss_info, this] { Settings::getInstance()->setString("ScreenSaverGameInfo", ss_info->getSelected()); });
|
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<std::string> >(mWindow, "GAME INFO ALIGNMENT", false);
|
||||||
|
std::vector<std::string> 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<SliderComponent>(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<TextComponent>(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<TextComponent>(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_
|
#ifndef _RPI_
|
||||||
auto captions_compatibility = std::make_shared<SwitchComponent>(mWindow);
|
auto captions_compatibility = std::make_shared<SwitchComponent>(mWindow);
|
||||||
captions_compatibility->setState(Settings::getInstance()->getBool("CaptionsCompatibility"));
|
captions_compatibility->setState(Settings::getInstance()->getBool("CaptionsCompatibility"));
|
||||||
addWithLabel("USE COMPATIBLE LOW RESOLUTION FOR CAPTIONS", captions_compatibility);
|
addWithLabel("USE COMPATIBLE LOW RESOLUTION FOR CAPTIONS", captions_compatibility);
|
||||||
addSaveFunc([captions_compatibility] { Settings::getInstance()->setBool("CaptionsCompatibility", captions_compatibility->getState()); });
|
addSaveFunc([captions_compatibility] { Settings::getInstance()->setBool("CaptionsCompatibility", captions_compatibility->getState()); });
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto stretch_screensaver = std::make_shared<SwitchComponent>(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()
|
GuiVideoScreensaverOptions::~GuiVideoScreensaverOptions()
|
||||||
|
|
|
@ -117,6 +117,11 @@ void Settings::setDefaults()
|
||||||
#ifdef _RPI_
|
#ifdef _RPI_
|
||||||
// we're defaulting to OMX Player for full screen video on the Pi
|
// we're defaulting to OMX Player for full screen video on the Pi
|
||||||
mBoolMap["ScreenSaverOmxPlayer"] = true;
|
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
|
#else
|
||||||
mBoolMap["ScreenSaverOmxPlayer"] = false;
|
mBoolMap["ScreenSaverOmxPlayer"] = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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
|
// We need to specify the layer of 10000 or above to ensure the video is displayed on top
|
||||||
// of our SDL display
|
// 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
|
// check if we want to mute the audio
|
||||||
if (!Settings::getInstance()->getBool("VideoAudio") || (float)VolumeControl::getInstance()->getVolume() == 0)
|
if (!Settings::getInstance()->getBool("VideoAudio") || (float)VolumeControl::getInstance()->getVolume() == 0)
|
||||||
|
@ -187,6 +187,14 @@ void VideoPlayerComponent::startVideo()
|
||||||
argv[15] = "--subtitles";
|
argv[15] = "--subtitles";
|
||||||
argv[16] = subtitlePath.c_str();
|
argv[16] = subtitlePath.c_str();
|
||||||
argv[17] = mPlayingVideoPath.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
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue