Exemple #1
0
        private void ProcessRequest()
        {
            var    soundpack = SoundPack.Get(PackName);
            string soundPackPath;
            string collectionPath;
            var    file = (IsMusic ? soundpack.Music : soundpack.Sound).GetSound(RequestedFile, out collectionPath, out soundPackPath);

            if (file == null)
            {
                WriteError("File not found.");
                return;
            }
            WriteFile(soundPackPath + collectionPath + file.Path);
        }
Exemple #2
0
            public SoundCollection(XElement root, SoundPack parent)
            {
                this.parent = parent;
                Sounds      = new List <SoundObject>();
                Inherits    = root.Attribute("inheritFrom") != null;
                if (Inherits)
                {
                    SoundInherits = (root.Name == "MusicList" ? SoundPack.Get(root.Attribute("inheritFrom").Value).Music : SoundPack.Get(root.Attribute("inheritFrom").Value).Sound);
                }
                FolderPath = root.Attribute("folderPath")?.Value ?? String.Empty;

                var pathInformation = root.Attribute("pathInformation")?.Value;

                switch (pathInformation)
                {
                case "%allfiles%":
                    var files = Directory.GetFiles(parent.FolderLocation + FolderPath, "*", SearchOption.AllDirectories);
                    foreach (var file in files)
                    {
                        Sounds.Add(new SoundObject(file.Remove(0, file.IndexOf(FolderPath, StringComparison.InvariantCulture) + FolderPath.Length)));
                    }
                    break;
                }

                if (root.Name == "MusicList")
                {
                    foreach (var elem in root.XPathSelectElements("//Music"))
                    {
                        Sounds.Add(new SoundObject(elem));
                    }
                }
                else
                {
                    foreach (var elem in root.XPathSelectElements("//Sound"))
                    {
                        Sounds.Add(new SoundObject(elem));
                    }
                }
            }