Example #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);
            }
        }
Example #2
0
        protected void SetGamedataString(string strTag, string strValue)
        {
            var tagArray = DataArrayUtl.FindTagArray(mData, "gamedata");

            if (DataArrayUtl.FindTagStr(tagArray, strTag).ToString(CultureInfo.InvariantCulture) == strValue)
            {
                return;
            }
            DataArrayUtl.SetTagStr(tagArray, strTag, strValue);
            OnChangeToUnsavedData();
        }
Example #3
0
        protected void SetMetadataString(string strTag, string strValue)
        {
            var tagArray = DataArrayUtl.FindTagArray(mData, "metadata");

            if (DataArrayUtl.FindTagStr(tagArray, strTag) == strValue)
            {
                return;
            }
            DataArrayUtl.SetTagStr(tagArray, strTag, strValue);
            OnChangeToUnsavedData();
        }
Example #4
0
 protected string GetMetadataString(string strTag)
 {
     return(DataArrayUtl.FindTagStr(DataArrayUtl.FindTagArray(mData, "metadata"), strTag));
 }
Example #5
0
        protected bool PatchPreviousProjectVersions()
        {
            var flag = false;

            if (GetProjectVersion() < 3)
            {
                return(false);
            }
            switch (GetProjectVersion())
            {
            case 3:
                DataArrayUtl.InsertTagStrAtEnd(mData, "destination_file", GetDefaultDestination());
                flag = true;
                break;

            case 4:
                DataArrayUtl.InsertTagIntAtEnd(DataArrayUtl.FindTagArray(mData, "metadata"), "has_album", 1);
                if (TrackNumber == 0)
                {
                    TrackNumber = 1;
                }
                flag = true;
                break;
            }
            if (GetProjectVersion() < 20)
            {
                var tagArray1 = DataArrayUtl.FindTagArray(mData, "gamedata");
                DataArrayUtl.InsertTagIntAtEnd(tagArray1, "rank_keys", 1);
                DataArrayUtl.InsertTagIntAtEnd(tagArray1, "rank_pro_keys", 1);
                var tagArray2 = DataArrayUtl.FindTagArray(mData, "dry_vox");
                var tagStr    = DataArrayUtl.FindTagStr(tagArray2, "file");
                DataArrayUtl.InsertTagStrAtEnd(DataArrayUtl.InsertTagArrayAtEnd(tagArray2, "part0"), "file", tagStr);
                DataArrayUtl.InsertTagStrAtEnd(DataArrayUtl.InsertTagArrayAtEnd(tagArray2, "part1"), "file", "");
                DataArrayUtl.InsertTagStrAtEnd(DataArrayUtl.InsertTagArrayAtEnd(tagArray2, "part2"), "file", "");
                DataArrayUtl.RemoveTagArray(tagArray2, "file");
                DataArrayUtl.InsertTagIntAtEnd(tagArray1, "vocal_parts", tagStr.Length > 0 ? 1 : 0);
                var data = DataArrayUtl.InsertTagArrayAtEnd(DataArrayUtl.FindTagArray(mData, "tracks"), "keys");
                DataArrayUtl.InsertTagIntAtEnd(data, "enabled", 0);
                DataArrayUtl.InsertTagIntAtEnd(data, "channels", 0);
                DataArrayUtl.InsertTagArrayAtEnd(data, "pan");
                DataArrayUtl.InsertTagArrayAtEnd(data, "vol");
                DataArrayUtl.InsertTagStrAtEnd(data, "file", "");
                flag = true;
            }
            if (GetProjectVersion() < 21)
            {
                DataArrayUtl.InsertTagStrAtEnd(DataArrayUtl.FindTagArray(mData, "midi"), "autogen_theme", "");
                flag = true;
            }
            if (GetProjectVersion() < 22)
            {
                var tagArray = DataArrayUtl.FindTagArray(mData, "languages");
                DataArrayUtl.InsertTagIntAtEnd(tagArray, "german", 0);
                DataArrayUtl.InsertTagIntAtEnd(tagArray, "japanese", 0);
                flag = true;
            }
            if (GetProjectVersion() < 23)
            {
                DataArrayUtl.AddTagFloatAtEnd(DataArrayUtl.FindTagArray(mData, "gamedata"), "guide_pitch_volume", -3f);
                flag = true;
            }
            if (GetProjectVersion() < 24)
            {
                var tagArray1 = DataArrayUtl.FindTagArray(mData, "dry_vox");
                var tagArray2 = DataArrayUtl.FindTagArray(tagArray1, "part0");
                var tagArray3 = DataArrayUtl.FindTagArray(tagArray1, "part1");
                var tagArray4 = DataArrayUtl.FindTagArray(tagArray1, "part2");
                var tagStr1   = DataArrayUtl.FindTagStr(tagArray2, "file");
                var tagStr2   = DataArrayUtl.FindTagStr(tagArray3, "file");
                var tagStr3   = DataArrayUtl.FindTagStr(tagArray4, "file");
                DataArrayUtl.InsertTagIntAtEnd(tagArray2, "enabled", tagStr1.Length > 0 ? 1 : 0);
                DataArrayUtl.InsertTagIntAtEnd(tagArray3, "enabled", tagStr2.Length > 0 ? 1 : 0);
                DataArrayUtl.InsertTagIntAtEnd(tagArray4, "enabled", tagStr3.Length > 0 ? 1 : 0);
                flag = true;
            }
            return(flag || GetProjectVersion() == 24);
        }