]> git.mxchange.org Git - flightgear.git/blob - utils/fgadmin/src/main.cxx
Remove carrier wire and catapult configuration from the scenario file.
[flightgear.git] / utils / fgadmin / src / main.cxx
1 // main.cxx -- FlightGear Scenery/Aircraft Admin Tool
2 //
3 // Written by Curtis Olson, started February 2004.
4 //
5 // Copyright (c) 2004  Curtis L. Olson - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifdef HAVE_CONFIG_H
25 #  include <config.h>
26 #endif
27
28 #include <string>
29 #include <FL/Fl.H>
30 #include <FL/filename.H>
31
32 #include "fgadmin.h"
33
34 using std::string;
35
36 string def_install_source;
37 string def_scenery_dest;
38 bool silent = false;
39
40 /**
41  * --silent
42  * --install-source=<DIR>
43  * --scenery-dest=<DIR>
44  */
45 static int
46 parse_args( int, char** argv, int& i )
47 {
48     if (strcmp( argv[i], "--silent" ) == 0)
49     {
50         silent = true;
51         ++i;
52         return 1;
53     }
54     else if (strncmp( argv[i], "--install-source=", 17 ) == 0)
55     {
56         def_install_source.assign( &argv[i][17] );
57         ++i;
58         return 1;
59     }
60     else if (strncmp( argv[i], "--scenery-dest=", 15 ) == 0)
61     {
62         def_scenery_dest.assign( &argv[i][15] );
63         ++i;
64         return 1;
65     }
66
67     return 0;
68 }
69
70 int
71 main( int argc, char* argv[] )
72 {
73     int i = 0;
74     if (Fl::args( argc, argv, i, parse_args ) < argc)
75     {
76         Fl::fatal("Options are:\n --silent\n --install-source=<DIR>\n --scenery-dest=<DIR>\n%s", Fl::help );
77     }
78
79     if ( silent )
80     {
81         Fl_Preferences prefs( Fl_Preferences::USER, "flightgear.org", "fgadmin" );
82         char abs_name[ FL_PATH_MAX ];
83
84         fl_filename_absolute( abs_name, def_install_source.c_str() );
85         prefs.set( "install-source", abs_name );
86
87         fl_filename_absolute( abs_name, def_scenery_dest.c_str() );
88         prefs.set( "scenery-dest", abs_name );
89
90         return 0;
91     }
92
93     FGAdminUI ui;
94     ui.init();
95     ui.show();
96
97     return Fl::run();
98 }