Beispiel #1
0
        void AddAllActivities()
        {
            var activityPath = Path.Combine(routePath, "Activities");

            if (Directory.Exists(activityPath))
            {
                foreach (string activity in Directory.GetFiles(activityPath, "*.act"))
                {
                    AddAdditionalFileAction.Invoke(activity, new ActivityLoader());
                }
            }

            var activityPathOr = Path.Combine(Path.Combine(routePath, "Activities"), "OpenRails");

            if (Directory.Exists(activityPathOr))
            {
                List <string> timetableFiles = new List <string>();
                timetableFiles.AddRange(Directory.GetFiles(activityPathOr, "*.timetable_or"));
                timetableFiles.AddRange(Directory.GetFiles(activityPathOr, "*.timetable-or"));
                timetableFiles.AddRange(Directory.GetFiles(activityPathOr, "*.timetablelist-or"));
                timetableFiles.AddRange(Directory.GetFiles(activityPathOr, "*.timetablelist-or"));
                foreach (string timetableFile in timetableFiles)
                {
                    AddAdditionalFileAction.Invoke(timetableFile, new TimetableLoader());
                }
            }
        }
Beispiel #2
0
        protected override void AddReferencedFiles()
        {
            routePath = Path.GetDirectoryName(loadedFile);
            basePath  = Path.GetDirectoryName(Path.GetDirectoryName(routePath));
            string loadingScreen = Path.Combine(routePath, TRK.Route.LoadingScreen);

            AddAdditionalFileAction.Invoke(loadingScreen, new AceLoader());
            string graphic = Path.Combine(routePath, TRK.Route.Thumbnail);

            AddAdditionalFileAction.Invoke(graphic, new AceLoader());

            AddAdditionalSMS(TRK.Route.DefaultCrossingSMS);
            AddAdditionalSMS(TRK.Route.DefaultCoalTowerSMS);
            AddAdditionalSMS(TRK.Route.DefaultDieselTowerSMS);
            AddAdditionalSMS(TRK.Route.DefaultSignalSMS);
            AddAdditionalSMS(TRK.Route.DefaultTurntableSMS);
            AddAdditionalSMS(TRK.Route.DefaultWaterTowerSMS);

            foreach (SeasonType season in Enum.GetValues(typeof(SeasonType)))
            {
                foreach (WeatherType weather in Enum.GetValues(typeof(WeatherType)))
                {
                    string environmentFile = TRK.Route.Environment.GetEnvironmentFileName(season, weather);
                    string envFileFull     = Path.Combine(Path.Combine(routePath, "ENVFILES"), environmentFile);
                    AddAdditionalFileAction.Invoke(envFileFull, new EnvironmentFileLoader());
                }
            }
        }
        protected override void AddReferencedFiles()
        {
            string routePath;
            string basePath;

            GetRouteAndBasePath(loadedFile, out routePath, out basePath);

            List <string> possiblePaths = new List <string>
            {
                Path.GetDirectoryName(loadedFile)
            };

            if (routePath != null)
            {
                possiblePaths.Add(Path.Combine(routePath, "SOUND"));
            }
            if (basePath != null)
            {
                possiblePaths.Add(Path.Combine(basePath, "SOUND"));
            }

            // Try to also load all sound files. This is tricky, beucase quit deep into the structure of a sms
            foreach (var group in sms.Tr_SMS.ScalabiltyGroups)
            {
                if (group.Streams == null)
                {
                    continue;
                }
                foreach (var stream in group.Streams)
                {
                    foreach (var trigger in stream.Triggers)
                    {
                        SoundPlayCommand playCommand = trigger.SoundCommand as SoundPlayCommand;
                        if (playCommand == null)
                        {
                            continue;
                        }
                        foreach (string file in playCommand.Files)
                        {
                            if (file == null)
                            {
                                Trace.TraceWarning("Missing well-defined file name in {0}\n", loadedFile);
                                continue;
                            }

                            //The file can be in multiple places
                            //Assume .wav file for now
                            var fullPath = Orts.Common.ORTSPaths.GetFileFromFolders(possiblePaths.ToArray(), file);
                            if (fullPath == null)
                            {
                                //apparently the file does not exist, but we want to make that known to the user, so we make a path anyway
                                fullPath = Path.Combine(possiblePaths[0], file);
                            }
                            AddAdditionalFileAction.Invoke(fullPath, new WavLoader());
                        }
                    }
                }
            }
        }
 protected override void AddDependentFiles()
 {
     foreach (string scriptfile in sigcfg.ScriptFiles)
     {
         Loader scriptLoader   = new SignalScriptLoader(sigcfg);
         string scriptfileFull = Path.Combine(sigcfg.ScriptPath, scriptfile);
         AddAdditionalFileAction.Invoke(scriptfileFull, scriptLoader);
     }
 }
Beispiel #5
0
        void AddAllWorldFiles()
        {
            var world = Path.Combine(routePath, "World");

            if (Directory.Exists(world))
            {
                foreach (string pat in Directory.GetFiles(world, "*.w"))
                {
                    AddAdditionalFileAction.Invoke(pat, new WorldFileLoader());
                }
            }
        }
Beispiel #6
0
        void AddAllPaths()
        {
            var paths = Path.Combine(routePath, "Paths");

            if (Directory.Exists(paths))
            {
                foreach (string pat in Directory.GetFiles(paths, "*.pat"))
                {
                    AddAdditionalFileAction.Invoke(pat, new PathLoader());
                }
            }
        }
Beispiel #7
0
        protected override void AddDependentFiles()
        {
            var baseFileWithDir = Path.Combine(Path.GetDirectoryName(loadedFile), Path.GetFileNameWithoutExtension(loadedFile));
            var sampleCount     = tFile.Terrain.Samples.SampleCount;

            AddAdditionalFileAction.Invoke(baseFileWithDir + "_y.raw", new TerrainAltitudeLoader(sampleCount));

            var f_raw_file = baseFileWithDir + "_f.raw";

            if (File.Exists(f_raw_file))
            {   // we need to check here if it exists, because we do not want an error popping up later
                AddAdditionalFileAction.Invoke(f_raw_file, new TerrainFlagsLoader(sampleCount));
            }
        }
Beispiel #8
0
        protected override void AddDependentFiles()
        {
            if (_routePath == null)
            { // we do not know which route needs to be loaded additionally
                return;
            }

            string routeTsectionDat = Path.Combine(_routePath, "tsection.dat");

            if (File.Exists(routeTsectionDat))
            {
                var tsectionLoader = new TsectionLoader(TSectionDat);
                AddAdditionalFileAction.Invoke(routeTsectionDat, tsectionLoader);
            }
        }
Beispiel #9
0
        protected override void AddDependentFiles()
        {
            string worldDirectory = Path.Combine(Path.GetDirectoryName(loadedFile), "WORLD");

            if (!Directory.Exists(worldDirectory))
            {
                return;
            }

            string[] worldSoundFiles = Directory.GetFiles(worldDirectory, "*.ws", SearchOption.TopDirectoryOnly);
            foreach (string soundFile in worldSoundFiles)
            {
                AddAdditionalFileAction.Invoke(soundFile, new WorldSoundLoader(tdbfile.TrackDB));
            }
        }
Beispiel #10
0
        void AddAdditionalSMS(string smsFileName)
        {
            if (smsFileName == null)
            {
                return;
            }
            string smsInRoute = Path.Combine(Path.Combine(routePath, "SOUND"), smsFileName);

            if (File.Exists(smsInRoute))
            {
                AddAdditionalFileAction.Invoke(smsInRoute, new SmsLoader());
            }
            else
            {
                string smsInBase = Path.Combine(Path.Combine(basePath, "SOUND"), smsFileName);
                AddAdditionalFileAction.Invoke(smsInBase, new SmsLoader());
            }
        }
Beispiel #11
0
        void AddMainFiles()
        {
            string globalTsectionDat = Path.Combine(Path.Combine(basePath, "Global"), "tsection.dat");

            AddAdditionalFileAction.Invoke(globalTsectionDat, new TsectionGlobalLoader(routePath));

            AddAdditionalFileAction.Invoke(Path.Combine(routePath, TRK.Route.FileName + ".tdb"), new TrackDataBaseLoader());
            AddAdditionalFileAction.Invoke(Path.Combine(routePath, TRK.Route.FileName + ".rdb"), new RoadDataBaseLoader());
            AddAdditionalFileAction.Invoke(Path.Combine(routePath, "carspawn.dat"), new CarSpawnLoader());
            string ORfilepath = System.IO.Path.Combine(routePath, "OpenRails");

            if (File.Exists(ORfilepath + @"\sigcfg.dat"))
            {
                AddAdditionalFileAction.Invoke(Path.Combine(ORfilepath, "sigcfg.dat"), new SignalConfigLoader());
            }
            else
            {
                AddAdditionalFileAction.Invoke(Path.Combine(routePath, "sigcfg.dat"), new SignalConfigLoader());
            }
        }
Beispiel #12
0
        void AddAllTiles()
        {
            var tiles = Path.Combine(routePath, "Tiles");

            if (Directory.Exists(tiles))
            {
                foreach (string tile in Directory.GetFiles(tiles, "*.t"))
                {
                    AddAdditionalFileAction.Invoke(tile, new TerrainLoader());
                }
            }

            var loTiles = Path.Combine(routePath, "Lo_Tiles");

            if (Directory.Exists(loTiles))
            {
                foreach (string tile in Directory.GetFiles(loTiles, "*.t"))
                {
                    AddAdditionalFileAction.Invoke(tile, new TerrainLoader());
                }
            }
        }