2002-11-07 16:27:47 +00:00
|
|
|
|
// new_gui.cxx: implementation of XML-configurable GUI support.
|
2010-09-30 17:58:01 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "new_gui.hxx"
|
|
|
|
|
|
2008-06-06 19:02:17 +00:00
|
|
|
|
#include <algorithm>
|
2008-06-02 21:07:35 +00:00
|
|
|
|
#include <iostream>
|
2008-06-06 19:02:17 +00:00
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <sys/types.h>
|
2002-11-07 16:27:47 +00:00
|
|
|
|
|
|
|
|
|
#include <plib/pu.h>
|
|
|
|
|
|
2003-04-13 21:25:46 +00:00
|
|
|
|
#include <simgear/compiler.h>
|
2003-09-24 17:20:55 +00:00
|
|
|
|
#include <simgear/structure/exception.hxx>
|
2008-07-31 12:04:32 +00:00
|
|
|
|
#include <simgear/props/props_io.hxx>
|
2010-10-24 00:09:06 +00:00
|
|
|
|
#include <simgear/misc/sg_dir.hxx>
|
2003-09-24 17:20:55 +00:00
|
|
|
|
|
2010-02-10 19:28:35 +00:00
|
|
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
2012-09-21 09:16:44 +00:00
|
|
|
|
#include <boost/foreach.hpp>
|
2010-02-10 19:28:35 +00:00
|
|
|
|
|
2018-02-27 10:10:12 +00:00
|
|
|
|
#include <Add-ons/AddonManager.hxx>
|
2002-11-07 16:27:47 +00:00
|
|
|
|
#include <Main/fg_props.hxx>
|
|
|
|
|
|
2011-10-01 09:05:01 +00:00
|
|
|
|
#if defined(SG_UNIX) && !defined(SG_MAC)
|
2011-10-01 07:50:34 +00:00
|
|
|
|
#include "GL/glx.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-11-19 22:04:35 +00:00
|
|
|
|
#include "FGPUIMenuBar.hxx"
|
2011-11-20 13:23:52 +00:00
|
|
|
|
|
|
|
|
|
#if defined(SG_MAC)
|
|
|
|
|
#include "FGCocoaMenuBar.hxx"
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-01-20 18:43:02 +00:00
|
|
|
|
#if defined(SG_WINDOWS)
|
|
|
|
|
#include "FGWindowsMenuBar.hxx"
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-11-19 20:46:17 +00:00
|
|
|
|
#include "FGPUIDialog.hxx"
|
2011-11-19 20:25:51 +00:00
|
|
|
|
#include "FGFontCache.hxx"
|
|
|
|
|
#include "FGColor.hxx"
|
2005-07-07 21:28:15 +00:00
|
|
|
|
|
2012-09-21 09:16:44 +00:00
|
|
|
|
// ignore the word Navaid here, it's a DataCache
|
|
|
|
|
#include <Navaids/NavDataCache.hxx>
|
|
|
|
|
|
2011-10-17 16:41:59 +00:00
|
|
|
|
using std::map;
|
|
|
|
|
using std::string;
|
2005-07-07 21:28:15 +00:00
|
|
|
|
|
2002-11-08 15:24:14 +00:00
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Implementation of NewGUI.
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
2005-07-07 21:28:15 +00:00
|
|
|
|
|
2011-11-20 13:23:52 +00:00
|
|
|
|
NewGUI::NewGUI () :
|
|
|
|
|
_active_dialog(0)
|
2002-11-08 15:24:14 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NewGUI::~NewGUI ()
|
|
|
|
|
{
|
2007-10-20 08:36:21 +00:00
|
|
|
|
for (_itt_t it = _colors.begin(); it != _colors.end(); ++it)
|
|
|
|
|
delete it->second;
|
2002-11-08 15:24:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
NewGUI::init ()
|
|
|
|
|
{
|
2014-01-15 22:00:09 +00:00
|
|
|
|
createMenuBarImplementation();
|
2013-10-06 16:34:53 +00:00
|
|
|
|
fgTie("/sim/menubar/visibility", this,
|
|
|
|
|
&NewGUI::getMenuBarVisible, &NewGUI::setMenuBarVisible);
|
|
|
|
|
|
2017-05-11 07:39:48 +00:00
|
|
|
|
fgTie("/sim/menubar/overlap-hide", this,
|
|
|
|
|
&NewGUI::getMenuBarOverlapHide, &NewGUI::setMenuBarOverlapHide);
|
|
|
|
|
|
2005-07-13 10:16:42 +00:00
|
|
|
|
setStyle();
|
2010-10-24 00:09:06 +00:00
|
|
|
|
SGPath p(globals->get_fg_root(), "gui/dialogs");
|
|
|
|
|
readDir(p);
|
2014-01-15 22:00:09 +00:00
|
|
|
|
|
|
|
|
|
SGPath aircraftDialogDir(string(fgGetString("/sim/aircraft-dir")), "gui/dialogs");
|
|
|
|
|
if (aircraftDialogDir.exists()) {
|
|
|
|
|
readDir(aircraftDialogDir);
|
|
|
|
|
}
|
2018-02-27 10:10:12 +00:00
|
|
|
|
|
|
|
|
|
// Read XML dialogs made available by registered add-ons
|
|
|
|
|
const auto& addonManager = flightgear::addons::AddonManager::instance();
|
|
|
|
|
for (const auto& addon: addonManager->registeredAddons()) {
|
|
|
|
|
SGPath addonDialogDir = addon->getBasePath() / "gui/dialogs";
|
|
|
|
|
|
|
|
|
|
if (addonDialogDir.exists()) {
|
|
|
|
|
readDir(addonDialogDir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-25 20:28:56 +00:00
|
|
|
|
// Fix for http://code.google.com/p/flightgear-bugs/issues/detail?id=947
|
|
|
|
|
fgGetNode("sim/menubar")->setAttribute(SGPropertyNode::PRESERVE, true);
|
2003-01-16 18:06:27 +00:00
|
|
|
|
_menubar->init();
|
2002-11-08 15:24:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-06 16:34:53 +00:00
|
|
|
|
void
|
|
|
|
|
NewGUI::shutdown()
|
|
|
|
|
{
|
2014-03-16 22:52:55 +00:00
|
|
|
|
DialogDict::iterator it = _active_dialogs.begin();
|
|
|
|
|
for (; it != _active_dialogs.end(); ++it) {
|
|
|
|
|
delete it->second;
|
|
|
|
|
}
|
|
|
|
|
_active_dialogs.clear();
|
|
|
|
|
|
2013-10-06 16:34:53 +00:00
|
|
|
|
fgUntie("/sim/menubar/visibility");
|
|
|
|
|
_menubar.reset();
|
|
|
|
|
_dialog_props.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-21 02:09:27 +00:00
|
|
|
|
void
|
|
|
|
|
NewGUI::reinit ()
|
2005-11-09 17:16:59 +00:00
|
|
|
|
{
|
|
|
|
|
reset(true);
|
2007-04-02 12:12:23 +00:00
|
|
|
|
fgSetBool("/sim/signals/reinit-gui", true);
|
2005-11-09 17:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
NewGUI::redraw ()
|
|
|
|
|
{
|
|
|
|
|
reset(false);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-15 22:00:09 +00:00
|
|
|
|
void
|
|
|
|
|
NewGUI::createMenuBarImplementation()
|
|
|
|
|
{
|
|
|
|
|
#if defined(SG_MAC)
|
|
|
|
|
if (fgGetBool("/sim/menubar/native", true)) {
|
|
|
|
|
_menubar.reset(new FGCocoaMenuBar);
|
|
|
|
|
}
|
2014-01-20 18:43:02 +00:00
|
|
|
|
#endif
|
|
|
|
|
#if defined(SG_WINDOWS)
|
|
|
|
|
if (fgGetBool("/sim/menubar/native", true)) {
|
|
|
|
|
// Windows-native menubar disabled for the moment, fall-through
|
|
|
|
|
// to PUI version
|
|
|
|
|
// _menubar.reset(new FGWindowsMenuBar);
|
|
|
|
|
}
|
2014-01-15 22:00:09 +00:00
|
|
|
|
#endif
|
|
|
|
|
if (!_menubar.get()) {
|
|
|
|
|
_menubar.reset(new FGPUIMenuBar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-09 17:16:59 +00:00
|
|
|
|
void
|
|
|
|
|
NewGUI::reset (bool reload)
|
2003-01-21 02:09:27 +00:00
|
|
|
|
{
|
2014-03-16 22:52:55 +00:00
|
|
|
|
DialogDict::iterator iter;
|
2012-09-21 09:16:44 +00:00
|
|
|
|
string_list openDialogs;
|
2005-07-07 21:28:15 +00:00
|
|
|
|
// close all open dialogs and remember them ...
|
2005-11-08 18:18:55 +00:00
|
|
|
|
for (iter = _active_dialogs.begin(); iter != _active_dialogs.end(); ++iter)
|
2012-09-21 09:16:44 +00:00
|
|
|
|
openDialogs.push_back(iter->first);
|
2005-11-08 18:18:55 +00:00
|
|
|
|
|
2012-09-21 09:16:44 +00:00
|
|
|
|
BOOST_FOREACH(string d, openDialogs)
|
|
|
|
|
closeDialog(d);
|
2005-07-07 21:28:15 +00:00
|
|
|
|
|
|
|
|
|
setStyle();
|
2005-11-09 17:16:59 +00:00
|
|
|
|
|
|
|
|
|
unbind();
|
|
|
|
|
|
|
|
|
|
if (reload) {
|
|
|
|
|
_dialog_props.clear();
|
2012-09-21 09:16:44 +00:00
|
|
|
|
_dialog_names.clear();
|
2005-11-09 17:16:59 +00:00
|
|
|
|
init();
|
|
|
|
|
} else {
|
2014-01-15 22:00:09 +00:00
|
|
|
|
createMenuBarImplementation();
|
2005-11-09 17:16:59 +00:00
|
|
|
|
_menubar->init();
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-21 02:09:27 +00:00
|
|
|
|
bind();
|
2005-07-07 21:28:15 +00:00
|
|
|
|
|
2005-11-09 17:16:59 +00:00
|
|
|
|
// open dialogs again
|
2012-09-21 09:16:44 +00:00
|
|
|
|
BOOST_FOREACH(string d, openDialogs)
|
|
|
|
|
showDialog(d);
|
2003-01-21 02:09:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-18 21:11:51 +00:00
|
|
|
|
void
|
|
|
|
|
NewGUI::bind ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
NewGUI::unbind ()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-08 15:24:14 +00:00
|
|
|
|
void
|
|
|
|
|
NewGUI::update (double delta_time_sec)
|
|
|
|
|
{
|
2013-02-08 19:39:41 +00:00
|
|
|
|
SG_UNUSED(delta_time_sec);
|
2004-05-14 17:16:35 +00:00
|
|
|
|
map<string,FGDialog *>::iterator iter = _active_dialogs.begin();
|
|
|
|
|
for(/**/; iter != _active_dialogs.end(); iter++)
|
|
|
|
|
iter->second->update();
|
2002-11-08 15:24:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-20 16:03:09 +00:00
|
|
|
|
bool
|
|
|
|
|
NewGUI::showDialog (const string &name)
|
2002-11-08 15:24:14 +00:00
|
|
|
|
{
|
2012-09-21 09:16:44 +00:00
|
|
|
|
// first, check if it's already shown
|
2018-08-07 16:33:57 +00:00
|
|
|
|
if (_active_dialogs.find(name) != _active_dialogs.end()){
|
|
|
|
|
_active_dialogs[name]->bringToFront();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2012-09-21 09:16:44 +00:00
|
|
|
|
|
|
|
|
|
// check we know about the dialog by name
|
|
|
|
|
if (_dialog_names.find(name) == _dialog_names.end()) {
|
2002-11-08 15:24:14 +00:00
|
|
|
|
SG_LOG(SG_GENERAL, SG_ALERT, "Dialog " << name << " not defined");
|
2003-01-20 16:03:09 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-09-21 09:16:44 +00:00
|
|
|
|
_active_dialogs[name] = new FGPUIDialog(getDialogProperties(name));
|
2018-08-07 16:33:57 +00:00
|
|
|
|
fgSetString("/sim/gui/dialogs/current-dialog", name);
|
|
|
|
|
|
|
|
|
|
// setActiveDialog(new FGPUIDialog(getDialogProperties(name)));
|
2012-09-21 09:16:44 +00:00
|
|
|
|
return true;
|
2003-01-20 16:03:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
NewGUI::closeActiveDialog ()
|
|
|
|
|
{
|
2003-12-08 02:05:10 +00:00
|
|
|
|
if (_active_dialog == 0)
|
2003-01-20 16:03:09 +00:00
|
|
|
|
return false;
|
2003-12-08 02:05:10 +00:00
|
|
|
|
|
|
|
|
|
// Kill any entries in _active_dialogs... Is there an STL
|
|
|
|
|
// algorithm to do (delete map entries by value, not key)? I hate
|
|
|
|
|
// the STL :) -Andy
|
|
|
|
|
map<string,FGDialog *>::iterator iter = _active_dialogs.begin();
|
2004-04-05 11:29:12 +00:00
|
|
|
|
for(/**/; iter != _active_dialogs.end(); iter++) {
|
|
|
|
|
if(iter->second == _active_dialog) {
|
2003-12-08 02:05:10 +00:00
|
|
|
|
_active_dialogs.erase(iter);
|
2004-04-05 11:29:12 +00:00
|
|
|
|
// iter is no longer valid
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-12-08 02:05:10 +00:00
|
|
|
|
|
|
|
|
|
delete _active_dialog;
|
|
|
|
|
_active_dialog = 0;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
NewGUI::closeDialog (const string& name)
|
|
|
|
|
{
|
|
|
|
|
if(_active_dialogs.find(name) != _active_dialogs.end()) {
|
|
|
|
|
if(_active_dialog == _active_dialogs[name])
|
|
|
|
|
_active_dialog = 0;
|
|
|
|
|
delete _active_dialogs[name];
|
|
|
|
|
_active_dialogs.erase(name);
|
2003-01-20 16:03:09 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2003-12-08 02:05:10 +00:00
|
|
|
|
return false; // dialog wasn't open...
|
2002-12-22 19:52:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-20 11:15:00 +00:00
|
|
|
|
SGPropertyNode_ptr
|
2006-04-28 09:59:31 +00:00
|
|
|
|
NewGUI::getDialogProperties (const string &name)
|
2005-10-20 11:15:00 +00:00
|
|
|
|
{
|
2012-09-21 09:16:44 +00:00
|
|
|
|
if (_dialog_names.find(name) == _dialog_names.end()) {
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_ALERT, "Dialog " << name << " not defined");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NameDialogDict::iterator it = _dialog_props.find(name);
|
|
|
|
|
if (it == _dialog_props.end()) {
|
|
|
|
|
// load the XML
|
|
|
|
|
SGPath path = _dialog_names[name];
|
|
|
|
|
SGPropertyNode_ptr props = new SGPropertyNode;
|
|
|
|
|
try {
|
2016-06-23 13:26:34 +00:00
|
|
|
|
readProperties(path, props);
|
2012-09-21 09:16:44 +00:00
|
|
|
|
} catch (const sg_exception &) {
|
|
|
|
|
SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog " << path);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it = _dialog_props.insert(it, std::make_pair(name, props));
|
|
|
|
|
}
|
2005-10-22 16:51:27 +00:00
|
|
|
|
|
2012-09-21 09:16:44 +00:00
|
|
|
|
return it->second;
|
2006-04-28 10:27:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FGDialog *
|
|
|
|
|
NewGUI::getDialog (const string &name)
|
|
|
|
|
{
|
|
|
|
|
if(_active_dialogs.find(name) != _active_dialogs.end())
|
|
|
|
|
return _active_dialogs[name];
|
|
|
|
|
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_DEBUG, "dialog '" << name << "' missing");
|
2005-10-22 16:51:27 +00:00
|
|
|
|
return 0;
|
2005-10-20 11:15:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-12-22 19:52:26 +00:00
|
|
|
|
void
|
2003-01-20 16:03:09 +00:00
|
|
|
|
NewGUI::setActiveDialog (FGDialog * dialog)
|
2002-12-22 19:52:26 +00:00
|
|
|
|
{
|
2018-08-07 16:33:57 +00:00
|
|
|
|
if (dialog){
|
|
|
|
|
fgSetString("/sim/gui/dialogs/current-dialog", dialog->getName());
|
|
|
|
|
}
|
2003-01-20 16:03:09 +00:00
|
|
|
|
_active_dialog = dialog;
|
2002-12-22 19:52:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-18 15:16:34 +00:00
|
|
|
|
FGDialog *
|
2003-01-20 16:03:09 +00:00
|
|
|
|
NewGUI::getActiveDialog ()
|
2002-12-22 19:52:26 +00:00
|
|
|
|
{
|
2003-01-20 16:03:09 +00:00
|
|
|
|
return _active_dialog;
|
2002-11-08 15:24:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-16 18:06:27 +00:00
|
|
|
|
FGMenuBar *
|
|
|
|
|
NewGUI::getMenuBar ()
|
|
|
|
|
{
|
2011-11-19 22:04:35 +00:00
|
|
|
|
return _menubar.get();
|
2003-01-16 18:06:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-18 21:11:51 +00:00
|
|
|
|
bool
|
|
|
|
|
NewGUI::getMenuBarVisible () const
|
|
|
|
|
{
|
|
|
|
|
return _menubar->isVisible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
NewGUI::setMenuBarVisible (bool visible)
|
|
|
|
|
{
|
|
|
|
|
if (visible)
|
|
|
|
|
_menubar->show();
|
|
|
|
|
else
|
|
|
|
|
_menubar->hide();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-11 07:39:48 +00:00
|
|
|
|
bool
|
|
|
|
|
NewGUI::getMenuBarOverlapHide() const
|
|
|
|
|
{
|
|
|
|
|
return _menubar->getHideIfOverlapsWindow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
NewGUI::setMenuBarOverlapHide(bool hide)
|
|
|
|
|
{
|
|
|
|
|
_menubar->setHideIfOverlapsWindow(hide);
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-08 02:05:10 +00:00
|
|
|
|
void
|
|
|
|
|
NewGUI::newDialog (SGPropertyNode* props)
|
|
|
|
|
{
|
|
|
|
|
const char* cname = props->getStringValue("name");
|
|
|
|
|
if(!cname) {
|
|
|
|
|
SG_LOG(SG_GENERAL, SG_ALERT, "New dialog has no <name> property");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-03-29 08:35:13 +00:00
|
|
|
|
string name = cname;
|
2012-09-21 09:16:44 +00:00
|
|
|
|
|
|
|
|
|
if(_active_dialogs.find(name) == _active_dialogs.end()) {
|
2005-03-29 08:35:13 +00:00
|
|
|
|
_dialog_props[name] = props;
|
2012-09-21 09:16:44 +00:00
|
|
|
|
// add a dummy path entry, so we believe the dialog exists
|
|
|
|
|
_dialog_names[name] = SGPath();
|
|
|
|
|
}
|
2003-12-08 02:05:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-08 15:24:14 +00:00
|
|
|
|
void
|
2010-10-24 00:09:06 +00:00
|
|
|
|
NewGUI::readDir (const SGPath& path)
|
2002-11-08 15:24:14 +00:00
|
|
|
|
{
|
2013-03-20 17:02:11 +00:00
|
|
|
|
simgear::Dir dir(path);
|
|
|
|
|
if( !dir.exists() )
|
|
|
|
|
{
|
2016-06-23 13:26:34 +00:00
|
|
|
|
SG_LOG(SG_INPUT, SG_INFO, "directory does not exist: " << path);
|
2013-03-20 17:02:11 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-24 08:27:09 +00:00
|
|
|
|
flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
|
|
|
|
|
flightgear::NavDataCache::Transaction txn(cache);
|
2010-10-24 00:09:06 +00:00
|
|
|
|
simgear::PathList xmls = dir.children(simgear::Dir::TYPE_FILE, ".xml");
|
|
|
|
|
|
2012-09-21 09:16:44 +00:00
|
|
|
|
BOOST_FOREACH(SGPath xmlPath, xmls) {
|
|
|
|
|
if (!cache->isCachedFileModified(xmlPath)) {
|
|
|
|
|
// cached, easy
|
2016-06-23 13:26:34 +00:00
|
|
|
|
string name = cache->readStringProperty(xmlPath.utf8Str());
|
2012-09-21 09:16:44 +00:00
|
|
|
|
_dialog_names[name] = xmlPath;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// we need to parse the actual XML
|
|
|
|
|
SGPropertyNode_ptr props = new SGPropertyNode;
|
2010-10-24 00:09:06 +00:00
|
|
|
|
try {
|
2016-06-23 13:26:34 +00:00
|
|
|
|
readProperties(xmlPath, props);
|
2010-10-24 00:09:06 +00:00
|
|
|
|
} catch (const sg_exception &) {
|
2012-09-21 09:16:44 +00:00
|
|
|
|
SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog " << xmlPath);
|
|
|
|
|
continue;
|
2010-10-24 00:09:06 +00:00
|
|
|
|
}
|
2012-09-21 09:16:44 +00:00
|
|
|
|
|
2010-10-24 00:09:06 +00:00
|
|
|
|
SGPropertyNode *nameprop = props->getNode("name");
|
|
|
|
|
if (!nameprop) {
|
2012-09-21 09:16:44 +00:00
|
|
|
|
SG_LOG(SG_INPUT, SG_WARN, "dialog " << xmlPath << " has no name; skipping.");
|
|
|
|
|
continue;
|
2010-10-24 00:09:06 +00:00
|
|
|
|
}
|
2012-09-21 09:16:44 +00:00
|
|
|
|
|
2010-10-24 00:09:06 +00:00
|
|
|
|
string name = nameprop->getStringValue();
|
2012-09-21 09:16:44 +00:00
|
|
|
|
_dialog_names[name] = xmlPath;
|
|
|
|
|
// update cached values
|
2013-11-18 15:40:14 +00:00
|
|
|
|
if (!cache->isReadOnly()) {
|
|
|
|
|
cache->stampCacheFile(xmlPath);
|
2016-06-23 13:26:34 +00:00
|
|
|
|
cache->writeStringProperty(xmlPath.utf8Str(), name);
|
2013-11-18 15:40:14 +00:00
|
|
|
|
}
|
2012-09-21 09:16:44 +00:00
|
|
|
|
} // of directory children iteration
|
2013-01-25 08:30:31 +00:00
|
|
|
|
|
|
|
|
|
txn.commit();
|
2012-09-21 09:16:44 +00:00
|
|
|
|
}
|
2005-07-07 21:28:15 +00:00
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Style handling.
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
NewGUI::setStyle (void)
|
|
|
|
|
{
|
2005-10-14 16:25:14 +00:00
|
|
|
|
_itt_t it;
|
|
|
|
|
for (it = _colors.begin(); it != _colors.end(); ++it)
|
|
|
|
|
delete it->second;
|
2005-07-13 10:16:42 +00:00
|
|
|
|
_colors.clear();
|
|
|
|
|
|
|
|
|
|
// set up the traditional colors as default
|
2005-07-18 09:18:24 +00:00
|
|
|
|
_colors["background"] = new FGColor(0.8f, 0.8f, 0.9f, 0.85f);
|
|
|
|
|
_colors["foreground"] = new FGColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
_colors["highlight"] = new FGColor(0.7f, 0.7f, 0.7f, 1.0f);
|
|
|
|
|
_colors["label"] = new FGColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
_colors["legend"] = new FGColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
_colors["misc"] = new FGColor(0.0f, 0.0f, 0.0f, 1.0f);
|
2005-11-09 17:16:59 +00:00
|
|
|
|
_colors["inputfield"] = new FGColor(0.8f, 0.7f, 0.7f, 1.0f);
|
2005-07-07 21:28:15 +00:00
|
|
|
|
|
|
|
|
|
//puSetDefaultStyle();
|
|
|
|
|
|
2006-03-09 23:04:41 +00:00
|
|
|
|
int which = fgGetInt("/sim/gui/current-style", 0);
|
2006-03-19 07:10:10 +00:00
|
|
|
|
SGPropertyNode *sim = globals->get_props()->getNode("sim/gui", true);
|
2006-03-09 23:04:41 +00:00
|
|
|
|
SGPropertyNode *n = sim->getChild("style", which);
|
2005-07-13 10:57:27 +00:00
|
|
|
|
if (!n)
|
2006-03-09 23:04:41 +00:00
|
|
|
|
n = sim->getChild("style", 0, true);
|
2017-10-15 19:49:40 +00:00
|
|
|
|
|
|
|
|
|
SGPropertyNode *selected_style = globals->get_props()->getNode("sim/gui/selected-style", true);
|
|
|
|
|
|
|
|
|
|
n->copy(selected_style);
|
|
|
|
|
|
|
|
|
|
//if (selected_style && n)
|
|
|
|
|
// n->alias(selected_style);
|
2005-07-13 10:57:27 +00:00
|
|
|
|
|
2006-02-04 13:06:47 +00:00
|
|
|
|
setupFont(n->getNode("fonts/gui", true));
|
2005-07-13 10:57:27 +00:00
|
|
|
|
n = n->getNode("colors", true);
|
2005-07-07 21:28:15 +00:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < n->nChildren(); i++) {
|
|
|
|
|
SGPropertyNode *child = n->getChild(i);
|
2005-07-18 09:18:24 +00:00
|
|
|
|
_colors[child->getName()] = new FGColor(child);
|
2005-07-07 21:28:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-18 09:18:24 +00:00
|
|
|
|
FGColor *c = _colors["background"];
|
|
|
|
|
puSetDefaultColourScheme(c->red(), c->green(), c->blue(), c->alpha());
|
2005-07-07 21:28:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2005-07-13 10:16:42 +00:00
|
|
|
|
NewGUI::setupFont (SGPropertyNode *node)
|
2005-07-07 21:28:15 +00:00
|
|
|
|
{
|
2016-01-01 20:33:17 +00:00
|
|
|
|
_font = FGFontCache::instance()->get(node);
|
2006-01-26 21:40:37 +00:00
|
|
|
|
puSetDefaultFonts(*_font, *_font);
|
|
|
|
|
return;
|
2005-07-07 21:28:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-11-07 16:27:47 +00:00
|
|
|
|
// end of new_gui.cxx
|