Add 'set-scenery-paths' command.
This commit is contained in:
parent
56ca1fe93b
commit
c7f2992904
3 changed files with 44 additions and 2 deletions
|
@ -1407,6 +1407,41 @@ do_profiler_stop(const SGPropertyNode *arg)
|
|||
}
|
||||
|
||||
|
||||
static bool
|
||||
do_set_scenery_paths(const SGPropertyNode* arg)
|
||||
{
|
||||
SGPropertyNode* sim = fgGetNode("/sim", true);
|
||||
sim->removeChildren("fg-scenery");
|
||||
|
||||
globals->clear_fg_scenery();
|
||||
|
||||
std::string terrasyncPath(fgGetString("/sim/terrasync/scenery-dir"));
|
||||
bool seenTerrasyncPath = false;
|
||||
|
||||
simgear::PropertyList paths = arg->getChildren("path");
|
||||
for (size_t i = 0; i < paths.size(); ++i) {
|
||||
std::string s = paths[i]->getStringValue();
|
||||
if (s == terrasyncPath) {
|
||||
seenTerrasyncPath = true;
|
||||
}
|
||||
|
||||
globals->append_fg_scenery(s);
|
||||
}
|
||||
|
||||
if (fgGetBool("/sim/terrasync/enabled") && !seenTerrasyncPath) {
|
||||
globals->append_fg_scenery(terrasyncPath);
|
||||
}
|
||||
|
||||
if (paths.empty()) {
|
||||
// no scenery paths set *at all*, use the data in FG_ROOT
|
||||
SGPath root(globals->get_fg_root());
|
||||
root.append("Scenery");
|
||||
globals->append_fg_scenery(root.str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Command setup.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1481,7 +1516,8 @@ static struct {
|
|||
{ "print-visible-scene", do_print_visible_scene_info },
|
||||
{ "reload-shaders", do_reload_shaders },
|
||||
{ "reload-materials", do_materials_reload },
|
||||
|
||||
{ "set-scenery-paths", do_set_scenery_paths },
|
||||
|
||||
{ "profiler-start", do_profiler_start },
|
||||
{ "profiler-stop", do_profiler_stop },
|
||||
|
||||
|
|
|
@ -339,7 +339,6 @@ SGPath FGGlobals::find_data_dir(const std::string& pathSuffix) const
|
|||
|
||||
void FGGlobals::append_fg_scenery (const std::string &paths)
|
||||
{
|
||||
// fg_scenery.clear();
|
||||
SGPropertyNode* sim = fgGetNode("/sim", true);
|
||||
|
||||
// find first unused fg-scenery property in /sim
|
||||
|
@ -395,6 +394,11 @@ void FGGlobals::append_fg_scenery (const std::string &paths)
|
|||
} // of path list iteration
|
||||
}
|
||||
|
||||
void FGGlobals::clear_fg_scenery()
|
||||
{
|
||||
fg_scenery.clear();
|
||||
}
|
||||
|
||||
void FGGlobals::append_aircraft_path(const std::string& path)
|
||||
{
|
||||
SGPath dirPath(path);
|
||||
|
|
|
@ -219,6 +219,8 @@ public:
|
|||
inline const string_list &get_fg_scenery () const { return fg_scenery; }
|
||||
void append_fg_scenery (const std::string &scenery);
|
||||
|
||||
void clear_fg_scenery();
|
||||
|
||||
const string_list& get_aircraft_paths() const { return fg_aircraft_dirs; }
|
||||
void append_aircraft_path(const std::string& path);
|
||||
void append_aircraft_paths(const std::string& path);
|
||||
|
|
Loading…
Add table
Reference in a new issue