#include <Main/globals.hxx>
#include <simgear/compiler.h>
+#include <simgear/misc/props.hxx>
#define DOTDOTSLASH "../"
#define SLASH "/"
for (i = 0; i < (int)node->nChildren(); i++) {
SGPropertyNode * child = node->getChild(i);
name = child->getName();
+ if ( node->getChild(name.c_str(), 1) != 0 ) {
+ iindex = child->getIndex();
+ sprintf(sindex, "[%d]", iindex);
+ name += sindex;
+ }
line = name;
names[ pi ] = new char[ strlen(line.c_str())+2 ] ;
strcpy ( names [ pi ], line.c_str() ) ;
if ( child->nChildren() > 0 ) {
- iindex = child->getIndex();
- sprintf(sindex, "%d", iindex);
dflag[ pi ] = 1 ;
files[ pi ] = new char[ strlen(line.c_str())+strlen(sindex)+4 ] ;
strcpy ( files [ pi ], line.c_str() ) ;
- if ( node->getChild(name, 1) != 0 ) {
- strcat ( files [ pi ], "[" ) ;
- strcat ( files [ pi ], sindex ) ;
- strcat ( files [ pi ], "]" ) ;
- }
strcat ( files [ pi ], "/" ) ;
values[ pi ] = new char[ 2 ] ;
} else {
dflag[ pi ] = 0 ;
- value = node->getStringValue ( name, "" );
+ value = node->getStringValue ( name.c_str(), "" );
values[ pi ] = new char[ strlen(value.c_str())+2 ] ;
strcpy ( values [pi], value.c_str() );
line += " = '" + value + "' " + "(";
- line += getValueTypeString( node->getNode( name ) );
+ line += getValueTypeString( node->getNode( name.c_str() ) );
line += ")";
files[ pi ] = new char[ strlen(line.c_str())+2 ] ;
strcpy ( files [ pi ], line.c_str() ) ;
++pi;
}
+ // truncate entries to 80 characters (plib pui limit)
+ for (i = 0; i < num_files; i++) {
+ if (strlen(files[i]) > 80) files[i][79] = '\0';
+ }
+
files [ num_files ] = NULL ;
+ // leave the . and .. alone...
+ int ii = ( strcmp(files [0], "." ) == 0 ) ? 2 : 0;
+
+ // Sort the entries. This is a simple N^2 extraction sort. More
+ // elaborate algorithms aren't necessary for the few dozen
+ // properties we're going to sort.
+ for(i=ii; i<num_files; i++) {
+ int j, min = i;
+ char df, *tmp;
+ for(j=i+1; j<num_files; j++)
+ if(strcmp(names[j], names[min]) < 0)
+ min = j;
+ if(i != min) {
+ tmp = names[min]; names[min] = names[i]; names[i] = tmp;
+ tmp = files[min]; files[min] = files[i]; files[i] = tmp;
+ tmp = values[min]; values[min] = values[i]; values[i] = tmp;
+ df = dflag[min]; dflag[min] = dflag[i]; dflag[i] = df;
+ }
+ }
+
// printf("files pointer=%i/%i\n", files, num_files);
proppath -> setLabel (startDir);
// if non-empty list, adjust the size of the slider...
if (num_files > 1) {
- if ((11.0f/(num_files-1)) < 1) {
- slider->setSliderFraction (11.0f/(num_files-1)) ;
+ if ((11.0f/(num_files)) < 1) {
+ slider->setSliderFraction (11.0f/(num_files)) ;
slider->reveal();
up_arrow->reveal();
down_arrow->reveal();
FG_FINALIZE_PUI_DIALOG( this );
}
+