Пример #1
0
        public TrackInfo GetTrack(string trackType)
        {
            if (mTrackCache.ContainsKey(trackType))
            {
                return(mTrackCache[trackType]);
            }
            var tagArray1 = DataArrayUtl.FindTagArray(DataArrayUtl.FindTagArray(mData, "tracks"), trackType);
            var tagStr    = DataArrayUtl.FindTagStr(tagArray1, "file");
            var track     = new TrackInfo {
                TrackType = trackType
            };
            var tagInt = DataArrayUtl.FindTagInt(tagArray1, "enabled");

            switch (tagInt)
            {
            case 0:
            case 1:
                track.Enabled = tagInt == 1;
                if (tagStr == "")
                {
                    return(track);
                }
                track.InitFromFile(tagStr, trackType);
                switch (track.NumChannels > 0 ? track.NumChannels : DataArrayUtl.FindTagInt(tagArray1, "channels"))
                {
                case 1:
                    track.PanLeft = DataArrayUtl.FindTagFloat(tagArray1, "pan");
                    track.VolLeft = DataArrayUtl.FindTagFloat(tagArray1, "vol");
                    break;

                case 2:
                    var tagArray2 = DataArrayUtl.FindTagArray(tagArray1, "pan");
                    track.PanLeft  = DataArrayUtl.GetFloat(tagArray2, 1U);
                    track.PanRight = DataArrayUtl.GetFloat(tagArray2, 2U);
                    var tagArray3 = DataArrayUtl.FindTagArray(tagArray1, "vol");
                    track.VolLeft  = DataArrayUtl.GetFloat(tagArray3, 1U);
                    track.VolRight = DataArrayUtl.GetFloat(tagArray3, 2U);
                    break;
                }
                if (!track.IsValid())
                {
                    return(track);
                }
                if (track.NumChannels != DataArrayUtl.FindTagInt(tagArray1, "channels"))
                {
                    track.SetDefaultPan();
                    track.SetDefaultVol();
                    SetTrack(track);
                }
                mTrackCache[trackType] = track;
                return(track);

            default:
                throw new MagmaException("Invalid value for 'enabled' on track " + trackType);
            }
        }
Пример #2
0
        protected void SetLanguage(string strTag, bool nValue)
        {
            var tagArray = DataArrayUtl.FindTagArray(mData, "languages");

            if (DataArrayUtl.FindTagInt(tagArray, strTag) != 0 == nValue)
            {
                return;
            }
            DataArrayUtl.SetTagInt(tagArray, strTag, nValue ? 1 : 0);
            OnChangeToUnsavedData();
        }
Пример #3
0
        protected void SetGamedataInt(string strTag, int nValue)
        {
            var tagArray = DataArrayUtl.FindTagArray(mData, "gamedata");

            if (DataArrayUtl.FindTagInt(tagArray, strTag) == nValue)
            {
                return;
            }
            DataArrayUtl.SetTagInt(tagArray, strTag, nValue);
            OnChangeToUnsavedData();
        }
Пример #4
0
 protected int GetMetadataInt(string strTag)
 {
     return(DataArrayUtl.FindTagInt(DataArrayUtl.FindTagArray(mData, "metadata"), strTag));
 }
Пример #5
0
 protected bool GetLanguage(string strTag)
 {
     return(DataArrayUtl.FindTagInt(DataArrayUtl.FindTagArray(mData, "languages"), strTag) != 0);
 }