Beispiel #1
0
 private void AutoLoad()
 {
     try
     {
         game.Canvas.Loading = true;
         string lasttrack;
         if (Program.args.Length > 0)
         {
             Settings.LastSelectedTrack = Program.args[0];
             lasttrack = Settings.LastSelectedTrack;
         }
         else
         {
             lasttrack = Settings.LastSelectedTrack;
             var trdr = Constants.TracksDirectory;
             if (!lasttrack.StartsWith(trdr))
             {
                 return;
             }
         }
         if (lasttrack.Contains("Crash Backup"))
         {
             if (!GameCanvas.ShowLoadCrashBackup(game.Canvas, lasttrack))
             {
                 game.Canvas.Loading = false; return;
             }
         }
         if (string.Equals(
                 Path.GetExtension(lasttrack),
                 ".trk",
                 StringComparison.InvariantCultureIgnoreCase))
         {
             var trackname = TrackIO.GetTrackName(lasttrack);
             lock (LoadSync)
             {
                 var track = TRKLoader.LoadTrack(lasttrack, trackname);
                 ChangeTrack(track);
             }
         }
         else if (string.Equals(
                      Path.GetExtension(lasttrack),
                      ".json",
                      StringComparison.InvariantCultureIgnoreCase))
         {
             var trackname = TrackIO.GetTrackName(lasttrack);
             lock (LoadSync)
             {
                 var track = JSONLoader.LoadTrack(lasttrack);
                 if (track.Name == Constants.DefaultTrackName ||
                     string.IsNullOrEmpty(track.Name))
                 {
                     track.Name = trackname;
                 }
                 ChangeTrack(track);
             }
         }
         else if (string.Equals(
                      Path.GetExtension(lasttrack),
                      ".sol",
                      StringComparison.InvariantCultureIgnoreCase))
         {
             var trackname = TrackIO.GetTrackName(lasttrack);
             var sol       = SOLLoader.LoadSol(lasttrack);
             if (sol.Count == 0)
             {
                 return;
             }
             lock (LoadSync)
             {
                 var track = SOLLoader.LoadTrack(sol[0]);
                 ChangeTrack(track);
             }
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine("Autoload failure: " + e.ToString());
     }
     finally
     {
         game.Canvas.Loading = false;
     }
 }