Esempio n. 1
0
        public void Play(string pack, string sound)
        {
            MusicEntry track = _appContext.ThemeMusicLibrary.LookupTrack(pack, sound);

            if (track == null)
            {
                track = _appContext.DefaultMusicLibrary.LookupTrack(pack, sound);
            }

            if (track != null)
            {
                GameLog.Client.Audio.DebugFormat("Play \"{0}\".", track.FileName);
                PlayFile(track.FileName);
            }
            else
            {
                GameLog.Client.GameData.WarnFormat("Soundplayer.cs: Could not locate track \"{0}\".", pack);
            }
        }
Esempio n. 2
0
        public MusicEntry LookupTrack(string packName, string trackName)
        {
            MusicPack pack;

            MusicPacks.TryGetValue(packName, out pack);

            if (pack != null)
            {
                MusicEntry track = null;
                pack.Dictionary.TryGetValue(trackName, out track);

                GameLog.Client.Audio.DebugFormat("trackName={0}, track.FileName={1}", trackName, track.FileName);

                return(track);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        public void Load(XmlElement xmlNode)
        {
            Name = xmlNode.GetAttribute("Name");
            Path = xmlNode.GetAttribute("Path");

            foreach (XmlElement track in xmlNode.GetElementsByTagName(TrackDefName))
            {
                var filename = track.InnerText.Trim();
                if (!string.IsNullOrEmpty(filename))
                {
                    // TODO: what sense does it have to have a different fading each track?
                    // shouldn't FadeTime better be part of the MusicPlayer settings?
                    //float fadeTime = 0f;
                    //if (track.HasAttribute("FadeTime"))
                    //{
                    //    var fadeTimeAttr = track.GetAttribute("FadeTime");
                    //    fadeTime = float.Parse(fadeTimeAttr, System.Globalization.CultureInfo.InvariantCulture);
                    //}

                    string trackName = track.GetAttribute("Name");
                    var    entry     = new MusicEntry(trackName, System.IO.Path.Combine(Path, filename));
                    _musicList.Add(entry);
                    if (!String.IsNullOrEmpty(trackName))
                    {
                        _musicDict.Add(trackName, entry);
                    }
                }
            }

            // TODO: load MusicPlayer.PlayMode from program settings? having different PlaybackModes for different MusicPacks (or races) doesn't make much sense.
            //if (xmlNode.HasAttribute("Selection"))
            //{
            //    string selMode = xmlNode.GetAttribute("Selection").ToUpperInvariant();
            //    if (selMode == "SEQUENTIAL")
            //        newPack.Selection = SelectionAlgo.Sequential;
            //}
        }