Ejemplo n.º 1
0
        public TRK(Stream Data)
        {
            m_Reader = new FileReader(Data, false);
            string DataStr = "";

            string[] Elements;

            ASCIIEncoding Enc         = new ASCIIEncoding();
            string        MagicNumber = Enc.GetString(m_Reader.ReadBytes(4));

            if (!MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase) && !MagicNumber.Equals("TKDT", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new TRKException("Invalid TrackData header - TRK.cs");
            }

            if (MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase))
            {
                DataStr  = Enc.GetString(m_Reader.ReadBytes((int)m_Reader.ReadUInt32()));
                Elements = DataStr.Split(',');
            }
            else
            {
                Elements = Enc.GetString(m_Reader.ReadToEnd()).Split(',');
            }

            m_Version = int.Parse(Elements[1], NumberStyles.Integer);
            TrackName = Elements[2];

            if (!Elements[3].Equals("", StringComparison.InvariantCultureIgnoreCase))
            {
                SoundID = uint.Parse(Elements[3].Replace("0x", ""), NumberStyles.HexNumber);
            }
            else
            {
                SoundID = 0;
            }

            if (Elements[5].Equals("\r\n", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            if (!Elements[5].Equals("", StringComparison.InvariantCultureIgnoreCase))
            {
                Argument = (HITTrackArguments)Enum.Parse(typeof(HITTrackArguments), Elements[5]);
            }

            if (!Elements[7].Equals("", StringComparison.InvariantCultureIgnoreCase))
            {
                ControlGroup = (HITControlGroup)Enum.Parse(typeof(HITControlGroup), Elements[7]);
            }

            if (!Elements[(m_Version != 2) ? 11 : 12].Equals("", StringComparison.InvariantCultureIgnoreCase))
            {
                DuckingPriority = int.Parse(Elements[(m_Version != 2) ? 11 : 12], NumberStyles.Integer);
            }

            if (!Elements[(m_Version != 2) ? 12 : 13].Equals("", StringComparison.InvariantCultureIgnoreCase))
            {
                Looped = (int.Parse(Elements[(m_Version != 2) ? 12 : 13], NumberStyles.Integer) != 0) ? true : false;
            }

            if (!Elements[(m_Version != 2) ? 13 : 14].Equals("", StringComparison.InvariantCultureIgnoreCase))
            {
                Volume = int.Parse(Elements[(m_Version != 2) ? 13 : 14], NumberStyles.Integer);
            }

            m_Reader.Close();
        }
Ejemplo n.º 2
0
        public TRK(Stream Data)
        {
            m_Reader = new FileReader(Data, false);
            string DataStr = "";
            string[] Elements;

            ASCIIEncoding Enc = new ASCIIEncoding();
            string MagicNumber = Enc.GetString(m_Reader.ReadBytes(4));

            if (!MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase) && !MagicNumber.Equals("TKDT", StringComparison.InvariantCultureIgnoreCase))
                throw new HitException("Invalid TrackData header - TRK.cs");

            if (MagicNumber.Equals("2DKT", StringComparison.InvariantCultureIgnoreCase))
            {
                DataStr = Enc.GetString(m_Reader.ReadBytes((int)m_Reader.ReadUInt32()));
                Elements = DataStr.Split(',');
            }
            else
                Elements = Enc.GetString(m_Reader.ReadToEnd()).Split(',');

            m_Version = int.Parse(Elements[1], NumberStyles.Integer);
            TrackName = Elements[2];

            if (!Elements[3].Equals("", StringComparison.InvariantCultureIgnoreCase))
                SoundID = uint.Parse(Elements[3].Replace("0x", ""), NumberStyles.HexNumber);
            else
                SoundID = 0;

            if (Elements[5].Equals("\r\n", StringComparison.InvariantCultureIgnoreCase))
                return;

            if (!Elements[5].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Argument = (HITTrackArguments)Enum.Parse(typeof(HITTrackArguments), Elements[5]);

            if (!Elements[7].Equals("", StringComparison.InvariantCultureIgnoreCase))
                ControlGroup = (HITControlGroup)Enum.Parse(typeof(HITControlGroup), Elements[7]);

            if (!Elements[(m_Version != 2) ? 11 : 12].Equals("", StringComparison.InvariantCultureIgnoreCase))
                DuckingPriority = int.Parse(Elements[(m_Version != 2) ? 11 : 12], NumberStyles.Integer);

            if (!Elements[(m_Version != 2) ? 12 : 13].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Looped = (int.Parse(Elements[(m_Version != 2) ? 12 : 13], NumberStyles.Integer) != 0) ? true : false;

            if (!Elements[(m_Version != 2) ? 13 : 14].Equals("", StringComparison.InvariantCultureIgnoreCase))
                Volume = int.Parse(Elements[(m_Version != 2) ? 13 : 14], NumberStyles.Integer);

            m_Reader.Close();
        }