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());
                        }
                    }
                }
            }
        }
Exemple #2
0
 public SoundPlayCommand[] CreateVoices()
 {
     SoundPlayCommand[] voices = new SoundPlayCommand[Voices.Count];
     for (int i = 0; i < voices.Length; i++)
     {
         voices[i] = new SoundPlayCommand(Voices[i].Content);
     }
     return(voices);
 }
Exemple #3
0
            private static string ToVoiceId(SoundPlayCommand cmd)
            {
                string snd   = cmd.Sound;
                int    index = snd.IndexOf('_');

                if (index != -1)
                {
                    return(snd.Substring(0, index).ToLower());
                }
                return(string.Empty);
            }
Exemple #4
0
 private static int CompareVoiceIds(SoundPlayCommand a, SoundPlayCommand b)
 {
     return(string.Compare(ToVoiceId(a), ToVoiceId(b)));
 }