@@ -249,8 +249,8 @@ public class TRPFile
249249 //public RenderProcess RenderProcess; // TODO: Pass this along in function calls
250250
251251 /// <summary>
252- /// Creates a TRPFile instance from a track profile file (XML or STF) or canned.
253- /// (Precedence is XML [.XML], STF [.DAT], default [canned]).
252+ /// Creates a List< TRPFile></TRPFile> instance from a set of track profile file(s)
253+ /// (XML or STF) or canned. ( Precedence is XML [.XML], STF [.DAT], default [canned]).
254254 /// </summary>
255255 /// <param name="viewer">Viewer.</param>
256256 /// <param name="routePath">Path to route.</param>
@@ -263,14 +263,36 @@ public static void CreateTrackProfile(Viewer viewer, string routePath, out List<
263263
264264 if ( Directory . Exists ( path ) )
265265 {
266+ // The file called "TrProfile" should be used as the default track profile, if present
267+ string xmlDefault = path + @"\TrProfile.xml" ;
268+ string stfDefault = path + @"\TrProfile.stf" ;
269+
270+ if ( File . Exists ( xmlDefault ) )
271+ {
272+ trpFiles . Add ( new TRPFile ( viewer , xmlDefault ) ) ;
273+ profileNames . Add ( Path . GetFileNameWithoutExtension ( xmlDefault ) ) ;
274+ }
275+ else if ( File . Exists ( stfDefault ) )
276+ {
277+ trpFiles . Add ( new TRPFile ( viewer , stfDefault ) ) ;
278+ profileNames . Add ( Path . GetFileNameWithoutExtension ( stfDefault ) ) ;
279+ }
280+ else // Add the canned (Kuju) track profile if no default is given
281+ trpFiles . Add ( new TRPFile ( viewer , "" ) ) ;
282+
266283 // Get all .xml/.stf files that start with "TrProfile"
267284 string [ ] xmlProfiles = Directory . GetFiles ( path , "TrProfile*.xml" ) ;
268285 string [ ] stfProfiles = Directory . GetFiles ( path , "TrProfile*.stf" ) ;
269286
270287 foreach ( string xmlProfile in xmlProfiles )
271288 {
272- trpFiles . Add ( new TRPFile ( viewer , xmlProfile ) ) ;
273- profileNames . Add ( Path . GetFileNameWithoutExtension ( xmlProfile ) ) ;
289+ string xmlName = Path . GetFileNameWithoutExtension ( xmlProfile ) ;
290+ // Don't try to add the default track profile twice
291+ if ( ! profileNames . Contains ( xmlName ) )
292+ {
293+ trpFiles . Add ( new TRPFile ( viewer , xmlProfile ) ) ;
294+ profileNames . Add ( xmlName ) ;
295+ }
274296 }
275297 foreach ( string stfProfile in stfProfiles )
276298 {
@@ -284,7 +306,7 @@ public static void CreateTrackProfile(Viewer viewer, string routePath, out List<
284306 }
285307 }
286308
287- // Add default profile only if no other profiles were added
309+ // Add canned profile if no profiles were found
288310 if ( trpFiles . Count <= 0 )
289311 trpFiles . Add ( new TRPFile ( viewer , "" ) ) ;
290312
0 commit comments