1
0
Fork 0

src/Viewer/FGEventHandler.cxx: NewGUI::setStyle(): added code to rescan style files.

Changing style will reload style from filesystem, so one can edit styles and
see results without restarting fg.

Note that this duplicates initial populating of /gui/styles/ from
defaults.xml's <sim><gui>...</gui></sim> section, so it's a bit of a hack.
This commit is contained in:
Julian Smith 2019-08-19 12:14:36 +01:00
parent 43468727ad
commit 4ec80297bf

View file

@ -440,6 +440,23 @@ NewGUI::setStyle (void)
//puSetDefaultStyle();
if (1) {
// Re-read gui/style/*.xml files so that one can edit them and see the
// results without restarting flightgear.
SGPath p(globals->get_fg_root(), "gui/styles");
SGPropertyNode* sim_gui = globals->get_props()->getNode("sim/gui/", true);
simgear::Dir dir(p);
int i = 0;
for (SGPath xml: dir.children(simgear::Dir::TYPE_FILE, ".xml")) {
SGPropertyNode_ptr node = sim_gui->getChild("style", i, true);
node->removeAllChildren();
SG_LOG(SG_GENERAL, SG_WARN, "reading from " << xml << " into " << node->getPath());
readProperties(xml, node);
i += 1;
}
}
int which = fgGetInt("/sim/gui/current-style", 0);
SGPropertyNode *sim = globals->get_props()->getNode("sim/gui", true);
SGPropertyNode *n = sim->getChild("style", which);