2004-04-29 09:36:27 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
|
|
|
|
#include "menubar.hxx"
|
2012-04-21 18:17:42 +00:00
|
|
|
#include <Main/locale.hxx>
|
|
|
|
#include <Main/globals.hxx>
|
|
|
|
|
|
|
|
FGMenuBar::FGMenuBar()
|
|
|
|
{
|
|
|
|
// load locale's menu resources (default and current language)
|
|
|
|
globals->get_locale()->loadResource("menu");
|
|
|
|
}
|
2003-01-16 18:06:27 +00:00
|
|
|
|
|
|
|
FGMenuBar::~FGMenuBar ()
|
|
|
|
{
|
2003-01-20 16:02:26 +00:00
|
|
|
}
|
|
|
|
|
2017-02-26 21:59:05 +00:00
|
|
|
std::string
|
2012-04-21 18:17:42 +00:00
|
|
|
FGMenuBar::getLocalizedLabel(SGPropertyNode* node)
|
|
|
|
{
|
2020-09-08 13:01:39 +00:00
|
|
|
if (!node)
|
|
|
|
return {};
|
2012-04-21 18:17:42 +00:00
|
|
|
|
2020-09-08 13:01:39 +00:00
|
|
|
const char* name = node->getStringValue("name", 0);
|
|
|
|
const auto translated = globals->get_locale()->getLocalizedString(name, "menu");
|
2017-02-26 21:59:05 +00:00
|
|
|
if (!translated.empty())
|
2012-04-21 18:17:42 +00:00
|
|
|
return translated;
|
|
|
|
|
2014-07-30 21:53:16 +00:00
|
|
|
// return default with fallback to name
|
2020-09-08 13:01:39 +00:00
|
|
|
const char* l = node->getStringValue("label", name);
|
|
|
|
|
|
|
|
// this can occur if the menu item is missing a <name>
|
|
|
|
if (l == nullptr) {
|
|
|
|
SG_LOG(SG_GUI, SG_ALERT, "FGMenuBar::getLocalizedLabel: No <name> defined for:" << node->getPath());
|
|
|
|
return string{"<unnamed>"};
|
|
|
|
}
|
|
|
|
|
|
|
|
return string{l};
|
2012-04-21 18:17:42 +00:00
|
|
|
}
|
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
// end of menubar.cxx
|