示例#1
0
 protected Activity(string filePath, Folder folder, Route route)
 {
     if (filePath == null)
     {
         Name = catalog.GetString("- Explore Route -");
     }
     else if (File.Exists(filePath))
     {
         var showInList = true;
         try
         {
             var actFile = new ActivityFile(filePath);
             var srvFile = new ServiceFile(System.IO.Path.Combine(System.IO.Path.Combine(route.Path, "SERVICES"), actFile.Tr_Activity.Tr_Activity_File.Player_Service_Definition.Name + ".srv"));
             // ITR activities are excluded.
             showInList  = actFile.Tr_Activity.Tr_Activity_Header.Mode != ActivityMode.IntroductoryTrainRide;
             Name        = actFile.Tr_Activity.Tr_Activity_Header.Name.Trim();
             Description = actFile.Tr_Activity.Tr_Activity_Header.Description;
             Briefing    = actFile.Tr_Activity.Tr_Activity_Header.Briefing;
             StartTime   = actFile.Tr_Activity.Tr_Activity_Header.StartTime;
             Season      = actFile.Tr_Activity.Tr_Activity_Header.Season;
             Weather     = actFile.Tr_Activity.Tr_Activity_Header.Weather;
             Difficulty  = actFile.Tr_Activity.Tr_Activity_Header.Difficulty;
             Duration    = actFile.Tr_Activity.Tr_Activity_Header.Duration;
             Consist     = new Consist(System.IO.Path.Combine(System.IO.Path.Combine(System.IO.Path.Combine(folder.Path, "TRAINS"), "CONSISTS"), srvFile.Train_Config + ".con"), folder);
             Path        = new Path(System.IO.Path.Combine(System.IO.Path.Combine(route.Path, "PATHS"), srvFile.PathID + ".pat"));
             if (!Path.IsPlayerPath)
             {
                 // Not nice to throw an error now. Error was originally thrown by new Path(...);
                 throw new InvalidDataException("Not a player path");
             }
         }
         catch
         {
             Name = "<" + catalog.GetString("load error:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (!showInList)
         {
             throw new InvalidDataException(catalog.GetStringFmt("Activity '{0}' is excluded.", filePath));
         }
         if (string.IsNullOrEmpty(Name))
         {
             Name = "<" + catalog.GetString("unnamed:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
         }
         if (string.IsNullOrEmpty(Description))
         {
             Description = null;
         }
         if (string.IsNullOrEmpty(Briefing))
         {
             Briefing = null;
         }
     }
     else
     {
         Name = "<" + catalog.GetString("missing:") + " " + System.IO.Path.GetFileNameWithoutExtension(filePath) + ">";
     }
     FilePath = filePath;
 }
示例#2
0
        public static Consist GetConsist(Folder folder, string name, bool reverseConsist)
        {
            Consist consist   = null;
            var     directory = System.IO.Path.Combine(System.IO.Path.Combine(folder.Path, "TRAINS"), "CONSISTS");
            var     file      = System.IO.Path.Combine(directory, System.IO.Path.ChangeExtension(name, "con"));

            try
            {
                consist = new Consist(file, folder, reverseConsist);
            }
            catch { }

            return(consist);
        }