Ampere K. Hardraade wrote:
On October 20, 2004 10:05 pm, Boris Koenig wrote:
Personally, I'd hence still prefer getting everything and being able
to tell FlightGear what maturity level I require for all aircraft
minimally.
I'm sure your method of showing maturity of aircrafts will come in handy, but
we *really* have to drop that download size.
Well, everybody who wants to give it a try can now do so easily: I've
made a quick stab at it this morning, because I was messing around with
the corresponding files anyway.
After applying the attached patches (based on latest CVS) you should
have a new option available within your version that should also
show up using fgfs --help, the syntax is:
fgfs --min-maturity={level} --show-aircraft
whereas "level" can be anything between
"pre-alpha","alpha","pre-beta","beta" and "done"
Of course running something like
fgfs --min-maturity=alpha --show-aircraft
should not return any aircraft right now, as none of the
current aircraft definition files in your base-package is using the
required
<maturity></maturity>
tag - but you can easily give it a try by adding something like
<maturity>alpha</maturity>
to abitrary aircraft ($FG_ROOT/data/Aircraft/.../*-set.xml) files.
The tag should be placed as a sub-tag within <sim> - so directly behind
the <description> tag would be just fine and straight-forward.
Essentially, this is a quick hack, but actually it could already turn
out to be useful:
At least as soon as most aircraft have been classified based on their
development status - that way one could easily modify preferences.xml in
the base package to make --show-aircraft use only "beta" or "done"
aircraft by default.
Everything can still be easily overriden - using either said new option
or directly by using the property node "/sim/aircraft-maturity-level"
Also, I would not mind extending the whole thing a bit to provide some
more information, possibly directly within fgrund was has been discussed
before - that way one could also provide a detailed description within
the aircraft selection dialog.
---------
Boris
--- preferences.xml.orig Fri Oct 22 09:20:52 2004
+++ preferences.xml.new Fri Oct 22 09:10:41 2004
@@ -292,6 +292,9 @@
<enabled type="bool">true</enabled>
<!-- <scenario>aircraft_demo</scenario> -->
</ai>
+
+ <!--to provide a default value that shows ALL aircraft regardless of development
status-->
+ <aircraft-min-maturity>all</aircraft-min-maturity>
</sim>
--- options.cxx.orig Fri Oct 22 10:05:12 2004
+++ options.cxx Fri Oct 22 09:43:11 2004
@@ -1333,6 +1333,7 @@
{"nav2", true, OPTION_FUNC, "", false, "", fgOptNAV2 },
{"adf", true, OPTION_FUNC, "", false, "", fgOptADF },
{"dme", true, OPTION_FUNC, "", false, "", fgOptDME },
+ {"min-maturity", true, OPTION_STRING,
"/sim/aircraft-min-maturity", false, "all", 0 },
{0}
};
@@ -1683,9 +1684,29 @@
#endif
}
+//CHANGED: a simple function to return an integer depending on the position
+//of the maturity string within the array in order to determine the hierarchy.
+unsigned int getNumMaturity(const char * str)
+{
+//a simple char array to hold supported maturity levels (vectors would be overkill)
;-)
+//changes should also be reflected in $FG_ROOT/data/options.xml &
+//$FG_ROOT/data/Translations/string-default.xml
+
+const char levels[6][10]= { "pre-alpha","alpha","pre-beta","beta","done",0};
+
+
+for (int i=0; i<(sizeof(levels)/sizeof(levels[0])-1);i++)
+ if (strcmp(str,levels[i])==0)
+ return i;
+
+return 0;
+};
+
+
static void fgSearchAircraft(const SGPath &path, string_list &aircraft,
bool recursive)
-{
+{
+
ulDirEnt* dire;
ulDir *dirp = ulOpenDir(path.str().c_str());
if (dirp == NULL) {
@@ -1720,28 +1741,60 @@
}
SGPropertyNode *desc = NULL;
+ //allow for specification of an additional <maturity> tag within the xml file
+ SGPropertyNode *maturity = NULL;
+
SGPropertyNode *node = root.getNode("sim");
if (node) {
desc = node->getNode("description");
+ // if a maturity tag is found, read it in
+ if (node->hasValue("maturity"))
+ maturity = node->getNode("maturity");
}
char cstr[96];
+ //additionally display maturity information where it is available
+ char maturity_level[12]="";
+ strcpy(maturity_level,(maturity) ? maturity->getStringValue() : "" );
+
if (strlen(dire->d_name) <= 27) {
- snprintf(cstr, 96, " %-27s %s", dire->d_name,
- (desc) ? desc->getStringValue() : "" );
+ snprintf(cstr, 96, " %-27s %s %s", dire->d_name,
+ (desc) ? desc->getStringValue() : "",
+ maturity_level );
} else {
- snprintf(cstr, 96, " %-27s\n%32c%s", dire->d_name, ' ',
- (desc) ? desc->getStringValue() : "" );
+ snprintf(cstr, 96, " %-27s\n%32c%s %s", dire->d_name, ' ',
+ (desc) ? desc->getStringValue() : "",
+ maturity_level );
}
- aircraft.push_back(cstr);
- }
+ //CHANGED: read out property tree value in order to obtain selected maturity
level
+ SGPropertyNode * required_maturity = fgGetNode
("/sim/aircraft-min-maturity", true);
+
+ //CHANGED: if the node holds the value "all", then there wasn't any maturity
level specified,
+ //so we simply go ahead and output ALL aircraft
+ if (strcmp(required_maturity->getStringValue(),"all")==0) {
+ aircraft.push_back(cstr);
+ }
+ else
+ {
+ // CHANGED:if the node doesn't hold "all" as its value, then we are supposed
to
+ // show only aircraft meeting specific maturity (development status)
requirements:
+
+ if (node->hasValue("maturity")) {
+ //Compare (minimally) required maturity level with actual aircraft maturity:
+ if ( getNumMaturity(maturity->getStringValue() ) >=
+ getNumMaturity(required_maturity->getStringValue() ) )
+ aircraft.push_back(cstr); }
+
+ }
+
+
+ }
}
ulCloseDir(dirp);
}
-
/*
* Search in the current directory, and in on directory deeper
--- strings-default.xml.orig Fri Oct 22 09:22:23 2004
+++ strings-default.xml Fri Oct 22 09:05:14 2004
@@ -126,6 +126,7 @@
<aircraft-options>Aircraft</aircraft-options>
<aircraft-desc>Select an aircraft profile as defined by a top level
<name>-set.xml</aircraft-desc>
<show-aircraft-desc>Print a list of the currently available aircraft
types</show-aircraft-desc>
+ <min-aircraft-maturity>Allows you to define a minimum maturity level (=development
status) for all aircraft that are shown</min-aircraft-maturity>
<!-- Flight Dynamics Model options -->
<fdm-options>Flight Model</fdm-options>
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d