1
0
Fork 0

src/Viewer/viewmgr.cxx: enable/disable video encoding menu items.

It doesn't look like menubar items can be enabled/disabled using <property>
or <expression>, so instead we write to the File menu's items tree
/sim/menubar/default/menu[]/name[]/enabled.

We also set /sim/video/encoding-path to '' or path of video file that we are
encoding to.
This commit is contained in:
Julian Smith 2021-12-10 16:56:27 +00:00
parent e3b619dd05
commit 3351a785be

View file

@ -175,9 +175,40 @@ static void videoEncodingPopup(const std::string& message, int delay)
globals->get_commands()->execute("show-message", args);
}
static void vidoEncodingUpdateStatus(const std::string& path)
{
fgSetString("/sim/video/encoding-path", path);
bool encoding = (path != "");
SGPropertyNode* node = fgGetNode("/sim/menubar/default");
/* Enable/disable menu items 'File/Video encode start' and 'File/Video
encode stop'. */
for (auto a: node->getChildren("menu"))
{
std::string name = a->getStringValue("name");
if (name == "file")
{
for (auto b: a->getChildren("item"))
{
std::string name = b->getStringValue("name");
if (name == "video-start")
{
b->setBoolValue("enabled", !encoding);
}
if (name == "video-stop")
{
b->setBoolValue("enabled", encoding);
}
}
break;
}
}
}
static void videoEncodingError(const std::string& message)
{
globals->get_props()->setIntValue("/sim/video/error", 1);
vidoEncodingUpdateStatus("");
videoEncodingPopup(message, 15);
}
@ -471,6 +502,8 @@ bool FGViewMgr::video_start(
videoEncodingError(e.what());
return false;
}
vidoEncodingUpdateStatus(path.str());
return true;
}
@ -479,6 +512,7 @@ void FGViewMgr::video_stop()
if (_video_encoder)
{
_video_encoder.reset();
vidoEncodingUpdateStatus("");
videoEncodingPopup("Video encoding stopped", 5);
}
else